/* Visual do CT — "tatame e faixa".
   Uma família (Archivo): larga e pesada nos títulos/números, normal no texto.
   O título de cada tela é uma faixa na cor da equipe; a ponta preta guarda a ação da tela.
   Cores da equipe chegam em tempo de execução por --primary / --secondary (comum.js › aplicarMarca). */

:root {
  /* tema claro: lona e papel */
  --bg: #e9ece6;
  --surface: #fbfcfa;
  --surface-2: #f0f2ee;
  --line: #d3d8d1;
  --text: #14191b;
  --muted: #545d64;
  --primary: #1f5e52; /* verde tatame, até o professor escolher as cores da equipe */
  --on-primary: #ffffff;
  --primary-ink: #1f5e52;
  --secondary: #c9a227;
  --bjj: #2f5f9e;
  --success: #1d7a46;
  --danger: #b42323;
  --warn: #8a5a00;
  --ring: #1f5e52;
  --preta: #000000;

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-campo: 10px;
  --r-bloco: 16px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --tap: 48px;
  --rapido: 140ms;
  --suave: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1416;
    --surface: #171e21;
    --surface-2: #1f282c;
    --line: #2b353a;
    --text: #e9eeea;
    --muted: #9aa5aa;
    --primary-ink: #7fc3b2;
    --bjj: #8db4ea;
    --success: #5cc98b;
    --danger: #f08a8a;
    --warn: #e6b450;
    --ring: #7fc3b2;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  font-stretch: 100%;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--s-4) + env(safe-area-inset-top)) var(--s-4) calc(104px + env(safe-area-inset-bottom));
}
a { color: var(--primary-ink); text-underline-offset: 3px; }
img, video { max-width: 100%; }
code { font-size: .85em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

h1, h2, h3, .stat, .valor { margin: 0; font-stretch: 118%; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 6vw, 2.2rem); font-weight: 800; line-height: 1.05; }
h2 { font-size: 1.05rem; font-weight: 700; margin: var(--s-6) 0 var(--s-3); }
h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.25; }
p { margin: var(--s-2) 0 0; }
.muted { color: var(--muted); font-size: .94rem; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; font-weight: 600; color: var(--primary-ink); }
.eyebrow svg.i { width: 18px; height: 18px; }
.texto-longo { white-space: pre-wrap; }
.err { color: var(--danger); min-height: 1.5em; margin: var(--s-2) 0 0; font-weight: 600; }

svg.i { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- a faixa: título de cada tela ---------- */
.page-head { margin: 0 calc(var(--s-4) * -1) var(--s-5); }
.faixa-titulo {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 76px;
  overflow: hidden; /* a ponta entra deslizando; sem isso o celular alarga a página */
  background-color: var(--primary);
  /* costura da faixa: linhas no comprimento */
  background-image: repeating-linear-gradient(180deg, transparent 0 9px, color-mix(in srgb, var(--on-primary) 14%, transparent) 9px 10px);
  color: var(--on-primary);
}
.faixa-titulo h1 { flex: 1; align-self: center; padding: var(--s-4) var(--s-4); min-width: 0; overflow-wrap: break-word; hyphens: auto; }
.ponta {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 64px;
  padding: var(--s-3) var(--s-4);
  background: var(--preta);
  color: #fff;
  border-left: 3px solid var(--bg);
  animation: amarrar 420ms var(--suave) both;
}
@keyframes amarrar { from { transform: translateX(24px); opacity: 0; } }
.ponta .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .4); }
.ponta .btn.primary { background: #fff; color: #000; border-color: #fff; }
.ponta input { background: #111; color: #fff; border-color: rgba(255, 255, 255, .35); width: 9.5em !important; min-height: 42px; padding: 6px 8px; font-size: .9rem; color-scheme: dark; }
.page-head .sub { margin: var(--s-3) var(--s-4) 0; }
@media (min-width: 720px) {
  .page-head { margin-left: 0; margin-right: 0; }
  .faixa-titulo { border-radius: 6px; overflow: hidden; }
  .faixa-titulo h1 { padding-left: var(--s-5); }
  .page-head .sub { margin-left: 0; }
}

/* ---------- blocos ---------- */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-bloco);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
}
a.card { color: inherit; text-decoration: none; transition: border-color var(--rapido) var(--suave); }
a.card:hover { border-color: var(--primary-ink); }
.card > h3 + .muted { margin-top: var(--s-1); }
details.card > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: var(--s-2); min-height: 32px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform var(--rapido) var(--suave); }
details.card[open] > summary::after { transform: rotate(225deg); }
details.card[open] > summary { margin-bottom: var(--s-3); }
details > summary.btn { list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }

.row { display: flex; gap: var(--s-2); align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.row > .fit { flex: 0 0 auto; }
.between { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.acoes { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; align-items: center; flex: 0 1 auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-bottom: var(--s-3); }
.grid-2 > .card { margin: 0; }
.grid-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
.grid-stats > .card { margin: 0; min-width: 0; }
/* valores em reais nos cartões de resumo: cabem em meia tela de celular */
.grid-stats .valor, .grid-stats .stat[style] { font-size: clamp(1rem, 4.6vw, 1.7rem) !important; font-stretch: 100%; white-space: nowrap; }
.cols-2 { display: grid; gap: 0 var(--s-4); }
.cols-2 > * { min-width: 0; }

/* números */
.stat { font-size: 2.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat small { font-size: 1rem; font-weight: 600; font-stretch: 100%; color: var(--muted); margin-left: 4px; }
.stat-label { display: block; margin-top: var(--s-2); font-size: .9rem; color: var(--muted); line-height: 1.3; }
.valor { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.valor.pos { color: var(--success); }
.valor.neg { color: var(--danger); }

/* bloco de destaque: faixa atual do aluno */
.card.today { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.card.today .muted, .card.today .eyebrow, .card.today .stat small, .card.today .stat-label { color: inherit; opacity: .85; }
.card.today .belt { border-color: color-mix(in srgb, var(--on-primary) 35%, transparent); }

.tecnica-dia { border-left: 6px solid var(--preta); }
.indicacao { border: 2px solid var(--secondary); background: color-mix(in srgb, var(--secondary) 8%, var(--surface)); }
.indicacao .eyebrow { color: var(--text); }
.consent { border: 2px solid var(--primary-ink); }
.consent ul { margin: var(--s-2) 0 0; padding-left: 1.2em; color: var(--muted); font-size: .94rem; }

/* ---------- formulários ---------- */
label { display: block; font-size: .9rem; font-weight: 600; color: var(--muted); margin: var(--s-4) 0 6px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-campo);
  padding: 10px 12px;
  transition: border-color var(--rapido) var(--suave);
}
select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 18px top 50%, right 13px top 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input[type="date"], input[type="time"], input[type="month"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="search"] { -webkit-appearance: none; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--muted) 60%, var(--line)); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; border-color: transparent; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s-3); }
.fields-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 var(--s-3); }
.fields-2 > *, .fields-3 > * { min-width: 0; }
.check-linha { display: flex; gap: var(--s-3); align-items: flex-start; color: var(--text); font-weight: 500; font-size: .98rem; margin-top: var(--s-4); cursor: pointer; }
.check-linha input, .chamada input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; flex: 0 0 auto; margin: 1px 0 0; accent-color: var(--primary); }
.cores { display: flex; gap: var(--s-3); }
.cores input[type="color"] { width: 64px; height: 48px; padding: 4px; flex: 0 0 auto; cursor: pointer; }
.previa-escudo { width: 72px; height: 72px; object-fit: contain; border: 1.5px dashed var(--line); border-radius: var(--r-campo); background: var(--surface-2); display: block; }

.mes-ref { display: flex; align-items: center; gap: var(--s-3); margin: calc(var(--s-2) * -1) 0 var(--s-4); }
.mes-ref label { margin: 0; }
.mes-ref input { width: auto; min-width: 12em; }

/* busca e filtros da lista de alunos */
.filtros { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); margin-bottom: var(--s-2); }
.filtros input[type="search"] { grid-column: 1 / -1; }
.busca { margin-bottom: var(--s-3); }

/* ---------- botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-4);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-campo);
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--rapido) var(--suave), border-color var(--rapido) var(--suave), transform 80ms var(--suave);
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 35%, var(--line)); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.ok { color: var(--success); }
.btn.ok[aria-pressed="true"] { background: color-mix(in srgb, var(--success) 12%, var(--surface)); border-color: color-mix(in srgb, var(--success) 45%, var(--line)); }
.btn.whats { background: #1f8f4e; border-color: #1f8f4e; color: #fff; }
.btn.whats:hover { background: #18733f; }
.btn.full { display: flex; width: 100%; margin-top: var(--s-4); }
.btn.sm { min-height: 40px; padding: 0 var(--s-3); font-size: .9rem; }
.btn.icon { width: var(--tap); padding: 0; flex: 0 0 auto; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }
.acoes .btn { min-height: 40px; padding: 0 var(--s-3); font-size: .9rem; }
.acoes .btn.icon { width: 40px; padding: 0; }

/* abas */
.tabs { display: grid; gap: 4px; padding: 4px; margin-bottom: var(--s-4); background: var(--surface-2); border-radius: 12px; }
.tabs .btn { border: 0; background: transparent; color: var(--muted); min-height: 42px; font-size: .95rem; }
.tabs .btn[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 -3px 0 var(--primary); }

/* selos */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tag.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.tag.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.tag.info { color: var(--bjj); border-color: color-mix(in srgb, var(--bjj) 40%, transparent); background: color-mix(in srgb, var(--bjj) 10%, var(--surface)); }

/* ---------- listas ---------- */
ul.list, .chamada { list-style: none; margin: 0; padding: 0; }
ul.list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
ul.list li > :first-child { flex: 1 1 180px; }
ul.list li:first-child { padding-top: 0; }
ul.list li:last-child { border-bottom: 0; padding-bottom: 0; }
ul.list li > :first-child { min-width: 0; }
.empty { color: var(--muted); justify-content: center !important; text-align: center; padding: var(--s-5) 0 !important; }
.inativo { opacity: .55; }
.aluno-linha { display: flex; align-items: center; gap: var(--s-3); text-decoration: none; color: inherit; min-width: 0; flex: 1; }
.aluno-linha b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aluno-linha .muted { font-size: .85rem; display: block; }
@media (max-width: 560px) {
  #lista li { flex-wrap: wrap; row-gap: var(--s-2); }
  #lista .aluno-linha { flex-basis: 100%; }
  #lista .acoes { justify-content: flex-start; padding-left: calc(56px + var(--s-3)); }
  #lista .acoes:empty { display: none; }
}

/* chamada */
.chamada li { border-bottom: 1px solid var(--line); }
.chamada li:last-child { border-bottom: 0; }
.chamada label { display: flex; align-items: center; gap: var(--s-3); margin: 0; padding: var(--s-3) var(--s-1); color: var(--text); font-weight: 500; font-size: 1rem; cursor: pointer; border-radius: 8px; }
.chamada label:hover { background: var(--surface-2); }
.chamada .belt.sm { margin-left: auto; }

/* ---------- faixa (desenho) ---------- */
.belt {
  display: flex;
  height: 30px;
  border-radius: 4px;
  overflow: hidden;
  margin: var(--s-3) 0;
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
}
.belt .body { flex: 1; background-image: repeating-linear-gradient(180deg, transparent 0 5px, rgba(0, 0, 0, .12) 5px 6px); }
.belt .tip { width: 32%; background: var(--preta); display: flex; align-items: center; gap: 6px; padding-left: 12px; }
.belt.preta .tip { background: #b3191d; }
.belt .tip i { width: 6px; height: 100%; background: #f4f4f0; }
.belt.sm { height: 14px; width: 56px; margin: 0; flex: 0 0 auto; border-radius: 3px; }
.belt.sm .body { background-image: none; }
.belt.sm .tip { gap: 2px; padding-left: 4px; }
.belt.sm .tip i { width: 2px; }

/* ---------- mídia das aulas e foto do reconhecimento ---------- */
.midias { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-2); margin-top: var(--s-3); }
.midia { position: relative; margin: 0; border-radius: 12px; overflow: hidden; background: var(--preta); aspect-ratio: 4 / 3; }
.midia img, .midia video { display: block; width: 100%; height: 100%; object-fit: cover; }
.midia video { object-fit: contain; }
.midia .btn { position: absolute; top: 6px; right: 6px; min-height: 36px; width: 36px; background: rgba(0, 0, 0, .6); color: #fff; border: 0; }
#envio:not(:empty) { margin-top: var(--s-2); font-weight: 600; }

.foto-facial { position: relative; margin-top: var(--s-3); border-radius: 12px; overflow: hidden; background: var(--preta); }
.foto-facial img { display: block; width: 100%; height: auto; }
.foto-facial .caixa { position: absolute; border: 3px solid #39d47a; border-radius: 6px; }
.foto-facial .caixa.desconhecido { border-color: #ff6b6b; border-style: dashed; }
.foto-facial .caixa span { position: absolute; left: -3px; top: 100%; background: #39d47a; color: #04110a; font-size: .75rem; font-weight: 700; padding: 1px 6px; border-radius: 0 0 6px 6px; white-space: nowrap; }
.foto-facial .caixa.desconhecido span { background: #ff6b6b; color: #000; }

/* gráfico de frequência do aluno */
.barras { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s-2); align-items: end; height: 160px; margin-top: var(--s-5); }
.barras > div { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.barras .barra { width: 100%; min-height: 4px; background: var(--primary); border-radius: 4px 4px 0 0; position: relative; }
.barras .barra span { position: absolute; top: -1.5em; left: 0; right: 0; text-align: center; font-weight: 700; font-size: .85rem; color: var(--text); }
.barras small { color: var(--muted); font-size: .8rem; }

/* ---------- marca do CT ---------- */
.marca { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.marca .escudo { width: 44px; height: 44px; object-fit: contain; flex: 0 0 auto; }
.marca b { display: block; font-stretch: 118%; font-weight: 800; font-size: 1.1rem; line-height: 1.15; }
.marca .muted { font-size: .85rem; display: block; }

/* ---------- entrada (login, setup, convite) ---------- */
.auth-hero { padding: var(--s-7) 0 var(--s-5); max-width: 440px; }
.auth-hero .logo { width: 64px; height: 64px; border-radius: 14px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; margin-bottom: var(--s-5); }
.auth-hero .logo svg.i { width: 34px; height: 34px; }
.auth-hero h1 { font-size: clamp(2.2rem, 9vw, 3.2rem); }
.auth-hero .marca .escudo { width: 76px; height: 76px; }
.auth-hero .marca b { font-size: 1.5rem; }
.auth-hero + .card { border-top: 6px solid var(--preta); }

/* ---------- navegação ---------- */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav[hidden] { display: none; }
nav .nav-marca { display: none; }
nav a {
  flex: 1; max-width: 140px; min-width: 0; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 62px; padding: 8px 0;
  color: var(--muted); text-decoration: none;
  font-size: .74rem; font-weight: 700; font-stretch: 80%; /* versão estreita da Archivo: 6 itens cabem em 360 px */
  transition: color var(--rapido) var(--suave);
}
nav a svg.i { width: 24px; height: 24px; }
nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav a[aria-current="page"] { color: var(--text); }
nav a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 4px; background: var(--primary); border-radius: 0 0 4px 4px; }
nav a:focus-visible { outline: 2px solid var(--ring); outline-offset: -4px; border-radius: 10px; }

/* computador: menu na lateral, conteúdo em duas colunas */
@media (min-width: 980px) {
  body.painel main, body.aluno main { max-width: 1120px; margin-left: 248px; padding: var(--s-6) var(--s-6) var(--s-7); }
  nav {
    top: 0; right: auto; width: 232px;
    flex-direction: column; justify-content: flex-start; gap: 2px;
    padding: var(--s-5) var(--s-3);
    border-top: 0; border-right: 1px solid var(--line);
  }
  nav .nav-marca { display: block; padding: 0 var(--s-2) var(--s-5); }
  nav .nav-marca .marca { margin: 0; }
  nav .nav-marca .logo-nav { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--primary); color: var(--on-primary); }
  nav a { flex: 0 0 auto; max-width: none; flex-direction: row; justify-content: flex-start; gap: var(--s-3); min-height: 46px; padding: 0 var(--s-3); border-radius: 10px; font-size: .95rem; }
  nav a:hover { background: var(--surface-2); color: var(--text); }
  nav a[aria-current="page"] { background: var(--surface-2); }
  nav a[aria-current="page"]::before { top: 10px; bottom: 10px; left: 0; right: auto; width: 4px; height: auto; border-radius: 0 4px 4px 0; }
  main > .marca { display: none; } /* a marca já está no topo do menu lateral */
  .cols-2 { grid-template-columns: 1fr 1fr; align-items: start; }
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
  .filtros { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .filtros input[type="search"] { grid-column: auto; }
}
@media (min-width: 560px) and (max-width: 979px) {
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation: none !important; }
}
