:root {
  --ac-orange:   #E26546;
  --ac-cream:    #F4F3EE;
  --ac-stone:    #B1ADA1;
  --ac-graphite: #30302E;
  --ac-ink:      #1A1918;

  --bg: var(--ac-cream); --bg-elev: #FFFFFF; --bg-sunk: #ECEAE2;
  --fg: var(--ac-ink); --fg-muted: var(--ac-graphite); --fg-soft: var(--ac-stone);
  --border: rgba(26,25,24,0.10); --border-2: rgba(26,25,24,0.16);
  --accent: var(--ac-orange);
  --success: #4F7A5A; --warning: #D6A24E; --danger: #C0432D;

  --font-sans: "Fira Sans", system-ui, sans-serif;
  --font-serif: "Libre Baskerville", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --r-2: 4px; --r-3: 8px; --r-4: 12px; --r-5: 18px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(26,25,24,.06), 0 1px 1px rgba(26,25,24,.04);
  --shadow-md: 0 4px 14px rgba(26,25,24,.08), 0 1px 2px rgba(26,25,24,.04);
  --shadow-lg: 0 18px 48px rgba(26,25,24,.16), 0 3px 8px rgba(26,25,24,.06);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --tr-widest: 0.22em;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--fg);
  background-color: var(--bg);
  line-height: 1.6;
}

/* A grade fica numa camada propria. Mascarar o body apagaria o conteudo junto. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 40%, transparent 100%);
          mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 40%, transparent 100%);
}

h1 { font-family: var(--font-sans); font-size: 1.9rem; font-weight: 600; margin: .1rem 0 1.4rem; letter-spacing: -.01em; }
h2 { font-family: var(--font-sans); font-size: 1.15rem; font-weight: 600; margin: 2.2rem 0 .8rem; }
h1 i, h2 i, .marca-nome i { font-family: var(--font-serif); font-style: italic; font-weight: 400; }

.eyebrow { font-family: var(--font-sans); font-size: .7rem; text-transform: uppercase;
  letter-spacing: var(--tr-widest); color: var(--fg-soft); margin: 0 0 .3rem; }

.pill { display: inline-block; font-family: var(--font-sans); font-size: .62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: var(--tr-widest); color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--r-pill); padding: .22rem .6rem .18rem; }

/* ---------- topo ---------- */
.topo { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.5rem;
  padding: .85rem 1.6rem; background: rgba(244,243,238,.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: .6rem; }
.marca-nome { font-family: var(--font-sans); font-weight: 500; }
.abas { display: flex; gap: .3rem; margin-left: auto; }
.aba { font-family: var(--font-sans); font-size: .9rem; background: none; border: 1px solid transparent;
  border-radius: var(--r-pill); padding: .35rem .95rem; cursor: pointer; color: var(--fg-muted); }
.aba:hover { background: var(--bg-sunk); }
.aba.ativa { background: var(--ac-ink); color: var(--ac-cream); }
.usuario { display: flex; align-items: center; gap: .8rem; margin-left: auto;
  font-size: .85rem; color: var(--fg-muted); }

main { max-width: 1100px; margin: 0 auto; padding: 2.2rem 1.6rem 5rem; }
.tela[hidden] { display: none; }
.voltar { margin-bottom: .8rem; }

/* ---------- cartoes ---------- */
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.cartao { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-4);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: box-shadow .18s var(--ease), transform .18s var(--ease); }
.cartao:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cartao h3 { font-family: var(--font-sans); font-size: 1.02rem; margin: 0 0 .3rem; }
.cartao .meta { font-size: .82rem; color: var(--fg-muted); }

.resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem;
  margin-bottom: 1rem; }
.metrica { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-3);
  padding: .8rem .9rem; }
.metrica .n { font-family: var(--font-sans); font-size: 1.5rem; font-weight: 600; display: block; }
.metrica .r { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-soft); }
.metrica.alerta .n { color: var(--danger); }

/* ---------- linhas ---------- */
.linhas { display: flex; flex-direction: column; gap: .4rem; }
.linha { display: flex; align-items: center; gap: .9rem; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--r-3); padding: .7rem .95rem;
  cursor: pointer; transition: border-color .15s var(--ease); }
.linha:hover { border-color: var(--border-2); }
.linha .principal { flex: 1; min-width: 0; }
.linha .nome { font-weight: 500; }
.linha .sub { font-size: .8rem; color: var(--fg-muted); }
.linha .direita { text-align: right; font-size: .82rem; color: var(--fg-muted); white-space: nowrap; }

.tag { display: inline-block; font-size: .68rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: .08em; border-radius: var(--r-pill); padding: .16rem .55rem; }
.tag.ok { background: rgba(79,122,90,.14); color: var(--success); }
.tag.aviso { background: rgba(214,162,78,.18); color: #8a6410; }
.tag.erro { background: rgba(192,67,45,.13); color: var(--danger); }
.tag.neutra { background: var(--bg-sunk); color: var(--fg-muted); }

/* ---------- matriz de frequencia ---------- */
.rolagem { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-3);
  background: var(--bg-elev); }
table { border-collapse: collapse; width: 100%; font-size: .82rem; }
th, td { padding: .45rem .6rem; text-align: center; border-bottom: 1px solid var(--border); }
th { font-family: var(--font-sans); font-weight: 500; font-size: .72rem; color: var(--fg-muted);
  position: sticky; top: 0; background: var(--bg-elev); white-space: nowrap; }
td.aluno, th.aluno { text-align: left; white-space: nowrap; position: sticky; left: 0;
  background: var(--bg-elev); font-weight: 500; }
.m { display: inline-block; min-width: 2.4rem; border-radius: var(--r-2); padding: .1rem .3rem;
  font-family: var(--font-mono); font-size: .72rem; }
.m.P { background: rgba(79,122,90,.16); color: var(--success); }
.m.Pn { background: rgba(214,162,78,.2); color: #8a6410; }
.m.F { background: rgba(192,67,45,.12); color: var(--danger); }
.m.FJ { background: var(--bg-sunk); color: var(--fg-muted); }
.m.vazio { color: var(--fg-soft); }

/* ---------- formularios e botoes ---------- */
.btn { font-family: var(--font-sans); font-size: .9rem; font-weight: 500; background: var(--ac-ink);
  color: var(--ac-cream); border: none; border-radius: var(--r-pill); padding: .55rem 1.3rem;
  cursor: pointer; transition: opacity .15s; }
.btn:hover { opacity: .87; }
.btn.acento { background: var(--accent); }
.btn.secundario { background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border-2); }
.btn-texto { background: none; border: none; color: var(--fg-muted); font-size: .85rem;
  cursor: pointer; padding: .2rem; font-family: var(--font-body); }
.btn-texto:hover { color: var(--accent); }

input[type="search"], input[type="text"], input[type="email"], input[type="password"], select {
  font-family: var(--font-body); font-size: .92rem; width: 100%; padding: .55rem .8rem;
  border: 1px solid var(--border-2); border-radius: var(--r-3); background: var(--bg-elev);
  color: var(--fg); margin-bottom: 1rem; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { font-family: var(--font-sans); font-size: .78rem; font-weight: 500; display: block;
  margin-bottom: .25rem; color: var(--fg-muted); }

.nota { font-size: .78rem; color: var(--fg-soft); margin-top: .6rem; }
.vazio-estado { color: var(--fg-soft); font-style: italic; padding: 1.2rem 0; }

/* ---------- upload ---------- */
.solta { border: 2px dashed var(--border-2); border-radius: var(--r-4); padding: 1.4rem;
  text-align: center; background: var(--bg-sunk); margin-bottom: 1rem; }
.solta.sobre { border-color: var(--accent); background: rgba(226,101,70,.06); }
.solta p { margin: .3rem 0; font-size: .85rem; color: var(--fg-muted); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(26,25,24,.42);
  display: flex; align-items: flex-start; justify-content: center; padding: 3rem 1rem; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-caixa { position: relative; background: var(--bg-elev); border-radius: var(--r-5);
  box-shadow: var(--shadow-lg); width: min(760px, 100%); padding: 1.8rem 1.9rem 2rem; }
.fechar { position: absolute; top: .7rem; right: .9rem; background: none; border: none;
  font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--fg-soft); }

/* ---------- barras de metrica ---------- */
.barras { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.2rem; }
.barra-linha { display: grid; grid-template-columns: minmax(120px, 1.2fr) 3fr auto;
  gap: .8rem; align-items: center; font-size: .85rem; }
.barra-rotulo { color: var(--fg-muted); }
.barra-trilho { height: 10px; background: var(--bg-sunk); border-radius: var(--r-pill);
  overflow: hidden; }
.barra-preenche { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.barra-valor { color: var(--fg-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.saiu td { opacity: .62; }
tr.saiu td.aluno { opacity: 1; color: var(--fg-muted); }

/* ---------- filtros ---------- */
.filtros { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end;
  margin: 1.2rem 0 .6rem; }
.filtros > div { flex: 0 0 auto; }
.filtros .cresce { flex: 1 1 200px; }
.filtros input, .filtros select { margin-bottom: 0; }
.filtros select, .filtros input[type="date"] { min-width: 9rem; }

/* ---------- aviso de sigilo ---------- */
.aviso-sigilo { border-left: 3px solid var(--warning); background: rgba(214,162,78,.09);
  padding: .9rem 1.1rem; border-radius: 0 var(--r-3) var(--r-3) 0; margin: 1rem 0 1.2rem; }
.aviso-sigilo p { margin: 0 0 .5rem; font-size: .88rem; }
.aviso-sigilo p:last-child { margin-bottom: 0; }
.checa { display: flex; gap: .6rem; align-items: flex-start; font-size: .88rem;
  color: var(--fg); font-family: var(--font-body); font-weight: 400; margin-bottom: 1.2rem; }
.checa input { margin-top: .25rem; flex: 0 0 auto; }
.acoes { display: flex; gap: .6rem; flex-wrap: wrap; }
.revelado { margin-top: 1.2rem; padding: 1rem 1.1rem; background: var(--bg-sunk);
  border-radius: var(--r-3); }
.revelado .rotulo { font-family: var(--font-sans); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--fg-soft); margin: 0 0 .2rem; }
.revelado p { margin: 0 0 .8rem; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center;
  justify-content: center; background: var(--bg); padding: 1.5rem; }
.login[hidden] { display: none; }
.card-login { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-5);
  box-shadow: var(--shadow-lg); padding: 2.2rem 2rem; width: min(380px, 100%); }
.card-login h1 { font-size: 1.5rem; margin: .7rem 0 1.5rem; }
.card-login .btn { width: 100%; }
.erro { color: var(--danger); font-size: .84rem; margin: 0 0 .8rem; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--ac-ink); color: var(--ac-cream); padding: .65rem 1.2rem;
  border-radius: var(--r-pill); font-size: .88rem; box-shadow: var(--shadow-lg); }
.toast[hidden] { display: none; }
.toast.erro-toast { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .topo { gap: .8rem; padding: .7rem 1rem; }
  .abas, .usuario { margin-left: 0; }
  main { padding: 1.4rem 1rem 4rem; }
  h1 { font-size: 1.45rem; }
  .modal { padding: 1rem .6rem; }
  .modal-caixa { padding: 1.4rem 1.1rem 1.6rem; }
}

/* ---------- quadro de notas: composicao visivel ---------- */
th.grupo { border-left: 2px solid var(--border-2); border-right: 2px solid var(--border-2);
  padding-bottom: .2rem; }
th.grupo .sub-cab { display: block; font-size: .58rem; font-weight: 400; text-transform: none;
  letter-spacing: 0; color: var(--fg-soft); margin-top: .1rem; }
th.parte, td.parte { font-size: .72rem; color: var(--fg-muted); background: var(--bg-sunk); }
td.parte { font-family: var(--font-mono); }
.m sup { font-size: .6em; margin-left: 1px; }

/* ---------- origem da aluna no modulo ---------- */
.linha-alerta { border-color: var(--danger); }
.sub.citacao { font-style: italic; color: var(--fg-soft); margin-top: .2rem; }

/* ---------- nota abre a ficha da aluna ---------- */
.ficha-link { text-decoration: none; border-bottom: 1px dotted var(--fg-soft); }
.ficha-link:hover .m { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- coluna Ficha: botao visivel, nao numero sublinhado ---------- */
td.col-ficha, th.col-ficha { white-space: nowrap; text-align: center;
  border-right: 2px solid var(--border-2); }
.btn-ficha { display: inline-block; font-family: var(--font-sans); font-size: .68rem;
  font-weight: 600; letter-spacing: .04em; text-decoration: none;
  color: var(--fg-muted); background: var(--bg-sunk);
  border: 1px solid var(--border-2); border-radius: var(--r-pill);
  padding: .16rem .5rem; margin: 0 .1rem; transition: all .15s var(--ease); }
.btn-ficha:hover { background: var(--ac-ink); color: var(--ac-cream); border-color: var(--ac-ink); }

/* ---------- formulario de decisao ---------- */
.linha-campos { display: flex; gap: .8rem; margin: .3rem 0 1rem; }
.linha-campos span { flex: 1; }
.linha-campos input { width: 100%; }
#form-decisao label { display: block; font-family: var(--font-sans); font-size: .8rem;
  font-weight: 600; margin: 1rem 0 .25rem; }
#form-decisao textarea { width: 100%; font-family: var(--font-body); font-size: .92rem;
  padding: .55rem .8rem; border: 1px solid var(--border-2); border-radius: var(--r-3);
  background: var(--bg-elev); resize: vertical; }
.erro-inline { color: var(--danger); font-size: .85rem; margin: .6rem 0 0; }
