/* ==========================================================================
   Formulários de Registro — Chlorum Solutions
   Sistema de design. Arquivo único, sem dependências externas.

   Convenção: seletores de classe única e planos. O ritmo vertical vem da
   regra `.stack > * + *`, nunca de margens por seção — assim as margens não
   se anulam entre si.
   ========================================================================== */

/* --- 1. Tokens ---------------------------------------------------------- */

:root {
  /* Cores oficiais */
  --ink:      #0a192f;
  --brand:    #003988;

  /* Derivadas */
  --paper:    #f4f7fb;
  --surface:  #ffffff;
  --line:     #dbe3ee;
  --mute:     #556680;
  --alert:    #c2410c;

  --brand-soft: #e6ecf6;
  --brand-deep: #002a66;
  --alert-soft: #fbeae2;
  --ink-soft:   #16294a;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --t-eyebrow: 0.72rem;
  --t-small:   0.8125rem;
  --t-base:    0.9375rem;
  --t-lead:    1.125rem;
  --t-title:   1.5rem;

  --r: 3px;
  --wrap: 72rem;
}

/* --- 2. Reset ----------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* Coluna flex de altura mínima igual à da janela: o <main> absorve a folga
   e empurra o rodapé para a base em telas curtas. */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-base);
  line-height: 1.5;
}

/* dvh desconta a barra de endereço no celular, onde 100vh estoura. */
@supports (min-height: 100dvh) {
  body { min-height: 100dvh; }
}

img { max-width: 100%; display: block; }

a { color: var(--brand); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* --- 3. Primitivas de layout -------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.stack > * + * { margin-top: 1.25rem; }
.stack-tight > * + * { margin-top: 0.625rem; }

.row {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(12, 1fr);
}

.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-8  { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* --- 4. Barra superior --------------------------------------------------- */

.topbar {
  background: var(--ink);
  border-bottom: 1px solid #06101f;
}

.topbar__in {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.5rem;
  flex-wrap: wrap;
}

/* A logo cresce dentro da altura que a barra já tinha: 36px de logo mais os
   0.5rem de respiro somam 52px, abaixo do min-height de 3.5rem do .topbar__in,
   então a faixa não engorda. */
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0;
  text-decoration: none;
}

.topbar__brand img { height: 29px; width: auto; }

/* Qual app é este. Vem depois de um filete para ler como "Chlorum > Troca de
   Células". Caixa alta para não se confundir com os links do menu, que são caixa
   normal; o tracking fica curto de propósito — espaçado demais viraria eco do
   "SOLUTIONS" da logo, que é fino e largo logo ao lado. */
.topbar__app {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  padding-right: 1.1rem;
  border-right: 1px solid #2a3d5c;
}

.topbar__nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 0.15rem;
  flex: 1 1 auto;
  flex-wrap: wrap;
  /* O primeiro link já traz o padding próprio. Sem descontá-lo, o filete ficaria
     colado no nome do app e longe demais do menu. */
  margin-left: -0.5rem;
}

/* A aba atual é marcada por um filete na borda inferior da barra, não por
   um preenchimento: azul sobre azul-marinho embaralha as duas cores, e
   --brand fica reservado ao que se aciona e ao estado dentro da faixa.

   O padding horizontal é curto de propósito: são oito itens mais a marca e o
   usuário na mesma linha, e cada 0.1rem aqui vale 26px na largura total. */
.topbar__link {
  position: relative;
  display: flex;
  align-items: center;
  color: #a9bad4;
  text-decoration: none;
  font-size: var(--t-small);
  padding: 0.4rem 0.5rem;
  white-space: nowrap;
}

.topbar__link::after {
  content: "";
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 0;
  height: 2px;
  background: transparent;
}

.topbar__link:hover { color: #fff; }
.topbar__link:hover::after { background: #2a3d5c; }

.topbar__link.is-active { color: #fff; font-weight: 500; }
.topbar__link.is-active::after { background: #fff; }

/* Separa as rotas de administração das rotas de operação. */
.topbar__sep {
  align-self: center;
  width: 1px;
  height: 1.1rem;
  margin: 0 0.35rem;
  background: #2a3d5c;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: var(--t-small);
  color: #a9bad4;
  margin-left: auto;
}

.topbar__who { color: #fff; font-weight: 500; }
.topbar__role {
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  color: #a9bad4;
}

.topbar__out {
  color: #a9bad4;
  text-decoration: none;
  font-size: var(--t-small);
  padding: 0.3rem 0.7rem;
  border: 1px solid #2a3d5c;
  border-radius: var(--r);
}

.topbar__out:hover { color: #fff; border-color: #4d6a9c; background: var(--ink-soft); }

/* --- 5. Cabeçalho de página ---------------------------------------------- */

.page { flex: 1 0 auto; padding: 1.75rem 0 3rem; }

.eyebrow {
  font-size: var(--t-eyebrow);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 0 0 0.3rem;
}

.title {
  font-size: var(--t-title);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
}

/* --- 6. Painel ----------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.panel__body { padding: 1.25rem; }
.panel__body.is-flush { padding: 0; }

.panel__head {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-small);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mute);
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.5rem 0;
}

/* --- 7. Formulários ------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: 0.3rem; }

.label {
  font-size: var(--t-eyebrow);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}

.input {
  width: 100%;
  font-family: inherit;
  font-size: var(--t-base);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.5rem 0.65rem;
  min-height: 2.4rem;
}

/* Valores medidos leem-se como um instrumento, não como texto corrido. */
.input[type="number"], .input[type="date"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.input:hover { border-color: #bccadd; }

.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.input:disabled {
  background: var(--paper);
  color: var(--mute);
  cursor: not-allowed;
}

.input[readonly] { background: var(--paper); color: var(--mute); }

textarea.input { min-height: 4.5rem; resize: vertical; }

/* Linha viva sob um campo: "posição 57 · ocupada por CEL-0231". Ocupada usa
   --alert porque é exatamente o que vai barrar a gravação. */
.hint {
  font-size: var(--t-eyebrow);
  color: var(--mute);
  min-height: 1.1rem;
}

.hint.is-busy { color: var(--alert); font-weight: 500; }

/* Valor que o formulário mostra mas não deixa editar — a origem de uma troca é
   deduzida, não digitada. Ocupa a mesma altura de um .input para a linha não
   dançar ao lado dos campos de verdade. */
.readout {
  font-size: var(--t-base);
  color: var(--ink);
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 0.5rem 0.65rem;
  min-height: 2.4rem;
  display: flex;
  align-items: center;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5l3.5 3.5 3.5-3.5' fill='none' stroke='%23556680' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 12px;
  padding-right: 2rem;
}

/* --- 8. Botões ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: var(--t-small);
  font-weight: 500;
  line-height: 1;
  padding: 0.6rem 1rem;
  min-height: 2.4rem;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: none;
  color: var(--brand);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-deep); }

.btn-ghost { border-color: var(--line); color: var(--brand); background: var(--surface); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }

.btn-danger { border-color: var(--line); color: var(--alert); background: var(--surface); }
.btn-danger:hover:not(:disabled) { border-color: var(--alert); background: var(--alert-soft); }

.btn-sm { font-size: var(--t-eyebrow); padding: 0.35rem 0.6rem; min-height: 1.9rem; }
.btn-wide { width: 100%; }

.btn-row { display: flex; gap: 0.5rem; }

/* --- 9. Mensagens -------------------------------------------------------- */

.flash {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--r);
  background: var(--surface);
  font-size: var(--t-small);
}

.flash::before { font-weight: 700; }
.flash-success { border-left-color: var(--brand); }
.flash-success::before { content: "✓"; color: var(--brand); }
.flash-danger { border-left-color: var(--alert); }
.flash-danger::before { content: "!"; color: var(--alert); }

/* --- 10. Tabelas --------------------------------------------------------- */

.table-scroll { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
}

.table th {
  background: var(--ink);
  color: #fff;
  font-size: var(--t-eyebrow);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
}

.table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:hover td { background: var(--paper); }
.table tbody tr:last-child td { border-bottom: 0; }

/* Colunas tipadas: o dado manda no alinhamento e na face tipográfica. */
.c-id, .c-time { color: var(--mute); }
.c-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.c-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
/* Observações chegam a frases inteiras. Quebram em vez de esticar a tabela. */
.c-obs { max-width: 18rem; min-width: 9rem; color: var(--mute); }

.c-value { font-weight: 700; }
.c-value .u { font-weight: 400; color: var(--mute); }
.c-act { width: 1%; white-space: nowrap; }

.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--mute);
  font-size: var(--t-small);
}

.tag-pill {
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
}

.badge {
  display: inline-block;
  font-size: var(--t-eyebrow);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: var(--r);
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--mute);
}

.badge-admin { background: var(--brand); border-color: var(--brand); color: #fff; }

/* --- 11. Paginação ------------------------------------------------------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--line);
  font-size: var(--t-small);
  flex-wrap: wrap;
}

.pager__count { color: var(--mute); }

.pager__count b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink);
}

.pager__nav { display: flex; align-items: center; gap: 0.5rem; }

.pager__at {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-eyebrow);
  color: var(--mute);
  padding: 0 0.25rem;
}

/* Extremos ficam desativados no lugar, nunca escondidos: o controle não
   deve mudar de posição entre uma página e outra. */
.pager span.btn[aria-disabled="true"] {
  opacity: 0.4;
  color: var(--mute);
  cursor: default;
}

/* --- 12. Crédito de desenvolvimento -------------------------------------- */

/* Aparece em todas as telas, então é uma linha só e discreta: rótulo e
   marca lado a lado, não um bloco centralizado. */
/* Sem margem superior: o <main> já ocupa a folga, e uma margem aqui somaria
   à altura da janela e criaria barra de rolagem em toda tela curta. */
.credit {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0.85rem 1.25rem 1.25rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.credit__label {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
}

/* Crédito de autoria, não uma marca do produto: fica legível para quem procurar
   e recua para quem está usando o sistema. Recupera a cor cheia no hover. */
.credit__logo {
  width: 62px;
  height: auto;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.credit:hover .credit__logo { opacity: 1; }

/* Variante para dentro de um cartão: vira o rodapé do próprio painel. */
.credit--inset {
  max-width: none;
  margin-top: 0;
  padding: 0.85rem 1.25rem;
}

/* --- 13. Login ----------------------------------------------------------- */

.auth {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--ink);
}

.auth__card { width: 100%; max-width: 22rem; }

.auth__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.auth__brand img { height: 34px; width: auto; }

.auth__foot {
  margin-top: 1.25rem;
  text-align: center;
  font-size: var(--t-eyebrow);
  color: #6d7f9c;
}

/* --- 14. Ajuda ----------------------------------------------------------- */

/* Índice de âncoras: atalho para quem já sabe o que procura, sem virar uma
   segunda navegação concorrendo com a barra do topo. */
.help-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.help-index a {
  font-size: var(--t-small);
  color: var(--brand);
  text-decoration: none;
}

.help-index a:hover { text-decoration: underline; }

/* Os primeiros passos são uma ordem, não uma lista de opções: o numeral fica
   visível o bastante para se ler como sequência. */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: passo; }

.steps > li {
  counter-increment: passo;
  position: relative;
  padding-left: 2.25rem;
  min-height: 1.6rem;
}

.steps > li + li { margin-top: 0.9rem; }

.steps > li::before {
  content: counter(passo);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-nota {
  border-left: 2px solid var(--brand);
  background: var(--paper);
  padding: 0.7rem 0.9rem;
  border-radius: 0 var(--r) var(--r) 0;
}

/* --- 15. Trilho de formulários ------------------------------------------- */
/*
   A navegação deste app é a lista de folhas, e ela é fixa: cinco itens que não
   mudam. Por isso saiu do topo e virou um trilho vertical — assim a faixa
   superior fica só com a marca e o usuário, e a largura toda da janela sobra
   para a grade, que é o que realmente precisa de espaço.

   Recolhido, o item é reconhecido pelos quatro últimos dígitos do código
   (1671, 1672…): é como a operação já chama as folhas, e cabe em 3.25rem.
*/

.shell { flex: 1 0 auto; display: flex; align-items: stretch; }

/* min-width: 0 impede que a tabela larga estufe o flex e empurre o trilho
   para fora da tela — o overflow tem que ficar dentro do .table-scroll. */
.shell__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.rail {
  flex: 0 0 auto;
  width: 15rem;
  background: var(--ink);
  border-right: 1px solid #06101f;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: width 0.16s ease;
}

.rail-fechada .rail { width: 3.25rem; }

.rail__toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.5rem 0.9rem;
  background: none;
  border: 0;
  color: #a9bad4;
  font-family: inherit;
  font-size: var(--t-eyebrow);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.rail__toggle:hover { color: #fff; }

/* Três traços desenhados em fundo, não um glifo: um caractere herdaria a
   métrica da fonte e nunca cairia no mesmo eixo dos códigos abaixo. */
.rail__burger {
  flex: 0 0 auto;
  width: 1.45rem;
  height: 2px;
  background: currentColor;
  position: relative;
}

.rail__burger::before,
.rail__burger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
}

.rail__burger::before { top: -5px; }
.rail__burger::after { top: 5px; }

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

.rail__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.9rem;
  color: #a9bad4;
  text-decoration: none;
  white-space: nowrap;
}

.rail__link:hover { color: #fff; background: #12203a; }

/* Filete à esquerda, espelhando o filete inferior da aba ativa no topbar do
   Troca de Células: mesma gramática de estado, girada 90°. */
.rail__link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: transparent;
}

.rail__link.is-active { color: #fff; background: #12203a; }
.rail__link.is-active::before { background: #fff; }

.rail__code {
  flex: 0 0 auto;
  width: 1.45rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-eyebrow);
  font-weight: 600;
  text-align: center;
}

.rail__code--glyph { font-family: inherit; font-size: 0.95rem; }

.rail__text { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }

.rail__cod {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: #6d7f9c;
}

.rail__tit {
  font-size: var(--t-small);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail__sep {
  display: block;
  height: 1px;
  margin: 0 0.9rem;
  background: #2a3d5c;
}

/* Recolhido: só o código. `visibility` em vez de `display` para o texto não
   reflowar o item enquanto a largura anima. */
.rail-fechada .rail__text,
.rail-fechada .rail__toggle-text {
  display: none;
}

.rail__veu { display: none; }

/* O trilho é permanente em tela larga, então este botão não existe lá — ele só
   aparece quando o trilho vira gaveta e leva o próprio botão para fora da tela. */
.rail-abrir {
  display: none;
  align-items: center;
  padding: 0.5rem 0.25rem;
  background: none;
  border: 0;
  color: #a9bad4;
  cursor: pointer;
}

.rail-abrir:hover { color: #fff; }

/* --- 16. Folha de preenchimento ------------------------------------------ */

/* A grade é larga por natureza — trinta e uma colunas na folha de salmoura.
   Nessas telas a coluna de conteúdo abandona o limite de 72rem. */
.wrap--largo { max-width: none; }

.barra-folha {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
}

.datanav { display: flex; align-items: center; gap: 0.35rem; }
.datanav__data { width: auto; min-width: 9.5rem; }

.barra-folha__resp { font-size: var(--t-small); color: var(--mute); }

.barra-folha__estado {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.badge-fechado { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Alternador de dois estados. Um par de links encostados lê-se como um só
   controle, e não como dois botões que fazem coisas diferentes. */
.segmento {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.segmento__op {
  padding: 0.35rem 0.75rem;
  font-size: var(--t-eyebrow);
  font-weight: 500;
  color: var(--brand);
  background: var(--surface);
  text-decoration: none;
}

.segmento__op + .segmento__op { border-left: 1px solid var(--line); }
.segmento__op:hover { background: var(--brand-soft); }
.segmento__op.is-active { background: var(--brand); color: #fff; }

/* Navegação de horário do modo por horário. */
.horanav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.horanav__atual {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-lead);
  font-weight: 700;
  min-width: 4.5rem;
  text-align: center;
}

.horanav__todos { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: 0.5rem; }

.horanav__op {
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--mute);
  text-decoration: none;
}

.horanav__op:hover { border-color: var(--brand); color: var(--brand); }
.horanav__op.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn.is-off { opacity: 0.35; pointer-events: none; }

/* Campo do modo por horário: rótulo à esquerda, controle e unidade à direita.
   Trinta campos empilhados só ficam legíveis se o rótulo tiver uma coluna
   própria e o valor sempre cair no mesmo eixo. */
.field--linha {
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
}

.field--linha:last-child { border-bottom: 0; }

.field--linha > .label {
  flex: 1 1 auto;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--t-small);
  color: var(--ink);
}

.field__num {
  display: inline-block;
  min-width: 1.5rem;
  font-family: var(--font-mono);
  color: var(--mute);
}

.field__tag {
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  color: var(--mute);
}

.field__controle { flex: 0 0 auto; display: flex; align-items: center; gap: 0.5rem; }

.field__unid {
  min-width: 3rem;
  font-size: var(--t-eyebrow);
  color: var(--mute);
}

.subsecao {
  margin: 0.9rem 0 0.2rem;
  font-size: var(--t-eyebrow);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}

/* Célula: um .input enxuto o bastante para caber trinta na largura da tela. */
.cel {
  width: 100%;
  min-width: 4.5rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-small);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 0.3rem 0.35rem;
}

.field--linha .cel { min-width: 8rem; border-color: var(--line); }

.cel--num { text-align: right; }
.cel--op { min-width: 3.5rem; text-transform: uppercase; }
.cel--opcao { font-family: inherit; padding-right: 0.2rem; }

.cel:hover:not(:disabled) { border-color: var(--line); }

.cel:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
  position: relative;
  z-index: 1;
}

.cel:disabled { background: var(--paper); color: var(--mute); cursor: not-allowed; }

/* Estados do salvamento automático, pintados pelo app.js. */
.cel.is-salvo { background: #eef6ee; }
.cel.is-erro { border-color: var(--alert); background: var(--alert-soft); }

/* Remove os esporins do input[type=number]: numa grade eles roubam a largura
   útil da célula e disparam com o scroll do mouse. */
.cel--num::-webkit-outer-spin-button,
.cel--num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cel--num { -moz-appearance: textfield; appearance: textfield; }

/* --- 17. Folha completa (grade horária) --------------------------------- */

.grade-scroll {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  max-height: 78vh;
  overflow: auto;
}

.grade {
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--t-small);
}

.grade th, .grade td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
}

.grade thead th {
  position: sticky;
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  font-size: var(--t-eyebrow);
  text-align: center;
  padding: 0.35rem 0.4rem;
  border-right-color: #2a3d5c;
  border-bottom-color: #2a3d5c;
  z-index: 2;
}

/* Cada faixa gruda na altura acumulada das faixas acima dela. As alturas são
   fixas de propósito: `sticky` precisa de um `top` resolvido, e um cabeçalho
   de cinco faixas não pode depender do conteúdo para saber onde parar. */
.grade thead tr:nth-child(1) th { top: 0;      height: 1.9rem; }
.grade thead tr:nth-child(2) th { top: 1.9rem; height: 1.9rem; }
.grade thead tr:nth-child(3) th { top: 3.8rem; height: 9.5rem; }
.grade thead tr:nth-child(4) th { top: 13.3rem; height: 1.7rem; }
.grade thead tr:nth-child(5) th { top: 15rem;  height: 1.5rem; }

.grade__g1 { letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.grade__g2 { background: var(--ink-soft); font-size: 0.68rem; }

/* Rótulo de coluna na vertical: é o que permite trinta e uma colunas de
   parâmetro caberem numa tela, e é como o papel já faz. */
.grade__rot { vertical-align: bottom; padding: 0.4rem 0.1rem; }

.grade__rot > span {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 9rem;
  margin: 0 auto;
  font-weight: 400;
  text-align: left;
  white-space: normal;
  line-height: 1.15;
}

.grade__tag, .grade__unid {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  background: var(--ink-soft);
  color: #a9bad4;
  white-space: nowrap;
}

.grade__unid { color: #fff; }

/* Horário e OP acompanham a rolagem horizontal: sem eles à vista, a linha
   trinta colunas adentro deixa de ter identidade. */
.grade__fix {
  position: sticky;
  z-index: 3;
  background: var(--surface);
}

.grade__fix--h { left: 0; width: 3.9rem; }
.grade__fix--op { left: 3.9rem; width: 4.5rem; }

.grade thead .grade__fix { z-index: 4; background: var(--ink); }

.grade tbody .grade__fix--h {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.grade tbody tr:hover td, .grade tbody tr:hover .grade__fix { background: #f7fafd; }
.grade tbody td:focus-within { background: var(--brand-soft); }

/* A folha completa é consulta: a célula fica travada, mas o valor lançado
   precisa continuar legível de longe — inclusive no Safari, que esmaece
   controles desabilitados por conta própria. */
.grade--leitura .cel:disabled {
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  opacity: 1;
  background: var(--paper);
  cursor: default;
}

/* --- 18. Checklist de turno ---------------------------------------------- */

.check {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
  background: var(--surface);
}

.check th, .check td {
  border: 1px solid var(--line);
  padding: 0.3rem 0.5rem;
  vertical-align: middle;
}

.check thead th {
  background: var(--ink);
  color: #fff;
  font-size: var(--t-eyebrow);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
}

.check__secao th {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: var(--t-eyebrow);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}

.check__num {
  width: 2.4rem;
  text-align: center;
  font-family: var(--font-mono);
  color: var(--mute);
}

.check__item { font-weight: 400; text-align: left; }
.check__item.is-cont { color: var(--mute); font-style: italic; }
.check__unid { width: 4rem; text-align: center; font-family: var(--font-mono); color: var(--mute); }
.check__turno { width: 11rem; text-align: center; }

/* A janela do turno é a informação de apoio: fica numa segunda linha, mais
   fraca, para o "1º / 2º / 3º" continuar sendo o que se lê de relance. */
.check__faixa {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: #a9bad4;
}

/* Par sim/não como no papel — o operador procura os parênteses, não um menu. */
.simnao {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--t-small);
}

.simnao__op { display: inline-flex; align-items: center; gap: 0.25rem; cursor: pointer; }

.simnao__limpa {
  border: 0;
  background: none;
  color: var(--mute);
  font-size: var(--t-base);
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
}

.simnao__limpa:hover { color: var(--alert); }

/* Mesmos recibos de salvamento das células, aplicados ao par inteiro. */
.simnao.is-salvo { background: #eef6ee; border-radius: 2px; }
.simnao.is-erro { outline: 1px solid var(--alert); background: var(--alert-soft); }

.assin {
  display: grid;
  grid-template-columns: 12rem 1fr 1fr;
  gap: 1rem;
  align-items: end;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.assin:last-child { border-bottom: 0; }
.assin__turno { font-size: var(--t-small); font-weight: 500; padding-bottom: 0.55rem; }

/* --- 19. Impressão -------------------------------------------------------- */
/*
   A folha impressa é o documento de arquivo, então ela imita o PDF original:
   mesmo cabeçalho, mesma grade, mesmas assinaturas. Fora da impressão a mesma
   marcação serve de pré-visualização na tela.
*/

.impressao { background: var(--paper); }

.impressao__barra {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.folha {
  background: #fff;
  margin: 1rem auto;
  padding: 1rem;
  max-width: 100%;
  overflow-x: auto;
  color: #000;
}

.folha__cab { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
.folha__cab th, .folha__cab td { border: 1px solid #000; padding: 0.2rem 0.4rem; }
.folha__cab th { text-align: left; width: 11rem; }

.folha__marca { width: 12rem; text-align: center; vertical-align: middle; }
.folha__marca img { height: 30px; width: auto; margin: 0 auto; }

.folha__tipo { text-align: center; font-weight: 700; }
.folha__rot { font-weight: 700; width: 4rem; }
.folha__titulo { text-align: center; vertical-align: middle; }
.folha__val { text-align: center; width: 9rem; }

.folha__data { font-size: 0.75rem; margin: 0.5rem 0; }

.pgrade { width: 100%; border-collapse: collapse; font-size: 0.6rem; }

.pgrade th, .pgrade td {
  border: 1px solid #000;
  padding: 0.15rem 0.2rem;
  text-align: center;
}

.pgrade thead th { font-weight: 700; }
.pgrade__g1, .pgrade__g2 { text-transform: uppercase; }
.pgrade__g2 { font-size: 0.55rem; }
.pgrade__h { width: 2.6rem; font-weight: 700; }
.pgrade__op { width: 2.6rem; }
.pgrade__tag { font-size: 0.52rem; font-weight: 400; }
.pgrade__tag em { color: #333; font-style: normal; }

.pgrade__rot { vertical-align: bottom; height: 8.5rem; }

.pgrade__rot > span {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin: 0 auto;
  font-weight: 400;
  text-align: left;
  white-space: normal;
  line-height: 1.1;
  max-height: 8.2rem;
}

.pgrade tbody td { height: 1.4rem; }

.pgrade__secao th {
  text-align: left;
  text-transform: uppercase;
  background: #e8e8e8;
  font-size: 0.62rem;
}

.pgrade--check { font-size: 0.66rem; }
.pgrade--check td, .pgrade--check th { text-align: left; }
.pcheck__num { width: 1.6rem; text-align: center !important; }
.pcheck__unid { width: 3rem; text-align: center !important; }
.pcheck__val { width: 8.5rem; text-align: center !important; white-space: nowrap; }

/* Largura fixa para o parêntese não fechar sobre o vazio quando não há X. */
.pcheck__x {
  display: inline-block;
  width: 0.7rem;
  text-align: center;
  font-weight: 700;
}
.pcheck__resp { font-weight: 400; font-size: 0.6rem; }

.assinaturas { margin-top: 1.2rem; font-size: 0.72rem; }
.assinaturas__linha { display: flex; align-items: baseline; gap: 0.5rem; margin: 1.1rem 0; }
.assinaturas__rot { white-space: nowrap; }

.assinaturas__campo {
  flex: 1 1 0;
  border-bottom: 1px solid #000;
  min-height: 1rem;
  padding: 0 0.3rem;
}

@media print {
  /* Só a folha vai para o papel. */
  .topbar, .rail, .rail__veu, .credit, .impressao__barra, .btn-row, .flash { display: none !important; }

  html, body { background: #fff !important; }

  .impressao { background: #fff; }
  .folha { margin: 0; padding: 0; overflow: visible; max-width: none; }

  /* A grade não pode ser partida no meio de uma linha. */
  .pgrade tr, .pgrade thead { break-inside: avoid; }
  .pgrade thead { display: table-header-group; }
  .assinaturas { break-inside: avoid; }

  a[href]::after { content: none !important; }
}

/* --- 20. Responsivo ------------------------------------------------------ */

@media (max-width: 900px) {
  .col-3, .col-4, .col-5, .col-6, .col-8 { grid-column: span 12; }

  /* Abaixo desta largura o trilho deixa de dividir a linha com o conteúdo e
     vira gaveta por cima dele: numa tela estreita, 15rem de menu permanente
     custariam metade da folha. */
  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: 15rem;
    transform: translateX(0);
    transition: transform 0.16s ease;
    overflow-y: auto;
  }

  .rail-fechada .rail { width: 15rem; transform: translateX(-100%); }
  .rail-fechada .rail__text, .rail-fechada .rail__toggle-text { display: flex; }
  .rail-fechada .rail__text { flex-direction: column; }

  .rail__veu {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(10, 25, 47, 0.45);
  }

  .rail-fechada .rail__veu { display: none; }

  /* O botão de abrir some junto com a gaveta; quem a reabre é o da topbar. */
  .rail-abrir { display: inline-flex; }
}

@media (max-width: 640px) {
  :root { --t-title: 1.25rem; }

  .topbar__in { gap: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .topbar__user { width: 100%; margin-left: 0; }

  /* Marca e nome do app dividem a largura do celular sem empurrar a navegação
     para fora da tela. */
  .topbar__brand { gap: 0.6rem; }
  .topbar__brand img { height: 26px; }
  .topbar__app { font-size: 0.75rem; letter-spacing: 0.06em; padding-right: 0.8rem; }

  /* A tabela vira cartões empilhados: rolagem horizontal não pode ser a
     única forma de ler os dados num tablet de chão de fábrica. */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; }

  .table-stack tr {
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: 0.75rem;
    background: var(--surface);
  }

  .table-stack td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.75rem;
  }

  .table-stack td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: var(--t-eyebrow);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mute);
    text-align: left;
  }

  .table-stack td:last-child { border-bottom: 0; }
  .table-stack .c-act { width: auto; }
  .pager { justify-content: center; }

  /* Rótulo e controle deixam de dividir a linha: o rótulo de um parâmetro de
     processo é longo demais para caber ao lado do campo no celular. */
  .field--linha { flex-direction: column; align-items: stretch; gap: 0.3rem; }
  .field--linha > .label { flex: none; }
  .field__controle { justify-content: space-between; }
  .field--linha .cel { min-width: 0; flex: 1 1 auto; }

  .assin { grid-template-columns: 1fr; gap: 0.5rem; }
  .assin__turno { padding-bottom: 0; }
}

/* --- 21. Movimento ------------------------------------------------------- */

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