/* Portal de Escala 5x2 */
:root {
  --fundo: #f4f6f4;
  --superficie: #ffffff;
  --texto: #1d2a22;
  --texto-suave: #5c6b62;
  --borda: #dbe3dd;
  --primaria: #1f7a45;
  --primaria-escura: #165c34;
  --primaria-clara: #e3f2e8;
  --erro: #b42318;
  --erro-fundo: #fdecea;
  --alerta: #9a5b00;
  --alerta-fundo: #fff4e0;
  --info-fundo: #e9f1fb;
  --info: #1d4f91;
  --folga: #eceff1;
  --raio: 8px;
  --sombra: 0 1px 2px rgba(16, 40, 24, .06), 0 2px 8px rgba(16, 40, 24, .05);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fundo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--primaria); }
h1 { font-size: 1.45rem; margin: 0; }
h1 small { font-size: .9rem; color: var(--texto-suave); font-weight: 400; margin-left: .4rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
code { background: #eef1ef; padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }

/* Topo e menu */
.topo { background: var(--primaria-escura); color: #fff; position: sticky; top: 0; z-index: 20; }
.topo-in { max-width: 1500px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .55rem 16px; }
.marca { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; }
.marca small { display: block; font-size: .78rem; opacity: .8; }
.marca-icone {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 9px;
  background: #fff; color: var(--primaria-escura); font-weight: 800; font-size: .85rem; letter-spacing: -.5px;
}
.menu { display: flex; flex-wrap: wrap; gap: .15rem; margin-left: auto; align-items: center; }
.menu a { color: #fff; text-decoration: none; padding: .45rem .7rem; border-radius: 6px; opacity: .88; }
.menu a:hover { background: rgba(255,255,255,.12); opacity: 1; }
.menu a.ativo { background: rgba(255,255,255,.2); opacity: 1; font-weight: 600; }
.menu-usuario { margin-left: .6rem; font-size: .85rem; opacity: .85; }
.menu-usuario a { padding: 0; text-decoration: underline; }
.menu-botao { display: none; margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; font-size: 1.2rem; border-radius: 6px; padding: .2rem .6rem; cursor: pointer; }
@media (max-width: 1260px) {
  .menu-botao { display: block; }
  .menu { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--primaria-escura); flex-direction: column; align-items: stretch; padding: .5rem 16px 1rem; }
  .menu.aberto { display: flex; }
  .menu-usuario { margin: .5rem 0 0; }
}

.conteudo { max-width: 1500px; margin: 0 auto; padding: 1.2rem 16px 2rem; }
.rodape { text-align: center; color: var(--texto-suave); font-size: .8rem; padding: 1rem; }

/* Barra de título */
.barra-titulo { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1rem; margin-bottom: 1rem; }
.navega-mes { display: flex; align-items: center; gap: .5rem; }
.acoes { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }

/* Botões */
.botao {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 6px;
  border: 1px solid var(--borda); background: var(--superficie); color: var(--texto); font: inherit;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.botao:hover { border-color: #b9c7bd; background: #f8faf8; }
.botao-primario { background: var(--primaria); border-color: var(--primaria); color: #fff; font-weight: 600; }
.botao-primario:hover { background: var(--primaria-escura); border-color: var(--primaria-escura); }
.botao-icone { width: 36px; height: 36px; justify-content: center; padding: 0; font-size: 1.3rem; }
.botao-largo { width: 100%; justify-content: center; }
.botao-link { background: none; border: 0; padding: 0; color: var(--primaria); font: inherit; cursor: pointer; text-decoration: underline; }
.perigo { color: var(--erro); }
.selo { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; font-size: .75rem; font-weight: 700; color: #fff; }
.selo-erro { background: var(--erro); }
.selo-aviso { background: #d98a00; }

/* Avisos */
.aviso { padding: .7rem 1rem; border-radius: var(--raio); margin-bottom: 1rem; border: 1px solid transparent; }
.aviso-ok { background: var(--primaria-clara); border-color: #b9dfc6; color: #134d2b; }
.aviso-erro { background: var(--erro-fundo); border-color: #f5c2bd; color: var(--erro); }
.aviso-alerta { background: var(--alerta-fundo); border-color: #f3d29b; color: #6b4000; }
.aviso-info { background: var(--info-fundo); border-color: #c5d8f2; color: var(--info); }
.dica { color: var(--texto-suave); font-size: .9rem; }
.vazio { color: var(--texto-suave); text-align: center; padding: 1.5rem; }

/* Painéis e formulários */
.painel { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.1rem 1.2rem; margin: 1.2rem 0; box-shadow: var(--sombra); }
.formulario { display: flex; flex-direction: column; gap: .8rem; max-width: 900px; }
.formulario fieldset { border: 1px solid var(--borda); border-radius: var(--raio); padding: .8rem 1rem 1rem; display: flex; flex-direction: column; gap: .8rem; }
.formulario legend { font-weight: 700; padding: 0 .3rem; }
.formulario .botao-primario { align-self: flex-start; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; font-weight: 600; color: #34443a; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--texto); background: #fff; border: 1px solid #c8d3cb; border-radius: 6px; padding: .45rem .6rem; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd4b1; border-color: var(--primaria); }
input[type="color"] { padding: 2px; width: 44px; height: 34px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primaria); }
.grade-campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; }
.grade-campos .largo { grid-column: span 2; }
@media (max-width: 520px) { .grade-campos .largo { grid-column: auto; } }
.form-acoes { display: flex; gap: .5rem; justify-content: flex-end; margin: .8rem 0; }
.filtro select, .filtro input { padding: .45rem .6rem; }
.filtro-linha { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1rem 0 .6rem; }
.linha-form { display: flex; gap: .4rem; }
.linha-form input { width: 160px; }

/* Tabelas de cadastro */
.tabela-rolagem { overflow-x: auto; background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); }
.tabela { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabela th, .tabela td { padding: .55rem .7rem; border-bottom: 1px solid #edf1ee; text-align: left; vertical-align: middle; }
.tabela thead th { background: #f6f8f6; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: var(--texto-suave); }
.tabela tr.inativo td { color: #98a39c; }
.tabela-edicao input:not([type="checkbox"]):not([type="color"]) { width: 100%; min-width: 120px; }
.tabela-edicao input.num { width: 70px; min-width: 70px; }
.tabela-edicao input.sigla { width: 60px; min-width: 60px; text-transform: uppercase; }
.tabela-edicao input[type="time"] { min-width: 100px; }
.acoes-linha { white-space: nowrap; }
.etiqueta { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: color-mix(in srgb, var(--cor) 14%, #fff); color: color-mix(in srgb, var(--cor) 80%, #000); border: 1px solid color-mix(in srgb, var(--cor) 30%, #fff); }

/* Legenda da escala */
.legenda { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; color: var(--texto-suave); margin-bottom: .3rem; }
.legenda span { display: inline-flex; align-items: center; gap: .3rem; }
.leg { display: inline-grid; place-items: center; min-width: 30px; height: 22px; border-radius: 4px; font-size: .72rem; }

/* Grade da escala */
.setor-bloco { margin: 1.3rem 0; }
.setor-titulo { display: flex; align-items: baseline; flex-wrap: wrap; gap: .5rem; }
.setor-titulo small { font-weight: 400; font-size: .82rem; color: var(--texto-suave); }
.bolinha { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--cor); flex: none; align-self: center; }
.grade-rolagem { overflow-x: auto; background: var(--superficie); border: 1px solid var(--borda); border-top: 3px solid var(--cor); border-radius: var(--raio); box-shadow: var(--sombra); }
.grade { border-collapse: separate; border-spacing: 0; font-size: .8rem; min-width: 100%; }
.grade th, .grade td { border-bottom: 1px solid #edf1ee; border-right: 1px solid #f1f4f2; text-align: center; padding: 0; }
.grade .col-nome {
  position: sticky; left: 0; z-index: 2; background: var(--superficie); text-align: left; padding: .35rem .6rem;
  min-width: 180px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; border-right: 1px solid var(--borda);
}
.grade .col-nome a { color: var(--texto); text-decoration: none; }
.grade .col-nome a:hover { text-decoration: underline; }
.grade thead th { background: #f6f8f6; font-weight: 600; padding: .25rem 0; position: sticky; top: 0; }
.grade thead .col-nome { z-index: 3; background: #f6f8f6; }
.grade .dia { min-width: 34px; line-height: 1.1; }
.grade .dia small { display: block; font-weight: 400; font-size: .68rem; color: var(--texto-suave); }
.grade .dia.dom, .grade .dia.fer { background: #fff1e6; color: #8a3d00; }
.grade .dia.sab { background: #f3f0fb; }
.grade .seg { border-left: 2px solid #d5ddd7; }
.grade .tot { min-width: 48px; padding: 0 .4rem; color: var(--texto-suave); font-variant-numeric: tabular-nums; }
.cel { height: 30px; font-weight: 600; font-size: .74rem; white-space: nowrap; }
.cel.editavel { cursor: pointer; }
.cel.editavel:hover { outline: 2px solid var(--primaria); outline-offset: -2px; }
.c-trab { background: color-mix(in srgb, var(--cor, #1f7a45) 16%, #fff); color: color-mix(in srgb, var(--cor, #1f7a45) 75%, #000); }
.c-folga { background: var(--folga); color: #7a868d; }
.c-fer { background: #ffe9d6; color: #8a3d00; }
.c-aus { background: #e8eefc; color: #2d4f8f; }
.c-vazio { background: repeating-linear-gradient(45deg, #fff, #fff 4px, #f6f7f6 4px, #f6f7f6 8px); }
.c-conflito { box-shadow: inset 0 0 0 2px var(--erro); }
.cel.manual { position: relative; }
.cel.manual::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: #d98a00; }
.leg.c-trab { --cor: #1f7a45; }
.cobertura td, .cobertura th { background: #f6f8f6; font-weight: 700; padding: .3rem 0; font-variant-numeric: tabular-nums; }
.cobertura th.col-nome { font-weight: 600; font-size: .75rem; color: var(--texto-suave); }
.cobertura small { font-weight: 400; color: var(--texto-suave); font-size: .66rem; }
.cobertura td.baixo { background: var(--erro-fundo); color: var(--erro); }

/* Popover de edição */
.popover {
  position: absolute; z-index: 50; background: #fff; border: 1px solid var(--borda); border-radius: var(--raio);
  box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: .5rem; width: 230px;
}
.popover h4 { margin: .1rem .3rem .4rem; font-size: .82rem; color: var(--texto-suave); font-weight: 600; }
.popover button { display: flex; width: 100%; gap: .5rem; align-items: center; text-align: left; background: none; border: 0; border-radius: 5px; padding: .4rem .45rem; font: inherit; font-size: .85rem; cursor: pointer; color: var(--texto); }
.popover button:hover, .popover button:focus { background: var(--primaria-clara); outline: none; }
.popover button b { display: inline-grid; place-items: center; min-width: 30px; height: 22px; border-radius: 4px; font-size: .72rem; }
.popover .sep { border-top: 1px solid var(--borda); margin: .3rem 0; }
.popover .erro { color: var(--erro); font-size: .8rem; padding: .3rem; }

/* Alertas */
.lista-alertas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; max-height: 520px; overflow-y: auto; }
.lista-alertas li { display: flex; gap: .7rem; align-items: baseline; padding: .45rem .6rem; border-radius: 6px; font-size: .9rem; }
.lista-alertas .nivel { flex: none; font-size: .7rem; font-weight: 700; text-transform: uppercase; padding: .1rem .4rem; border-radius: 4px; min-width: 76px; text-align: center; }
.alerta-erro { background: var(--erro-fundo); } .alerta-erro .nivel { background: var(--erro); color: #fff; }
.alerta-aviso { background: var(--alerta-fundo); } .alerta-aviso .nivel { background: #d98a00; color: #fff; }
.alerta-info { background: var(--info-fundo); } .alerta-info .nivel { background: var(--info); color: #fff; }
.tudo-ok { color: var(--primaria); font-weight: 600; }

/* Diálogo */
.dialogo { border: 0; border-radius: 12px; padding: 1.3rem 1.4rem; max-width: 520px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.dialogo::backdrop { background: rgba(10, 30, 18, .45); }
.dialogo ul { padding-left: 1.2rem; }
.dialogo-acoes { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.dialogo-perigo { border-top: 1px solid var(--borda); margin-top: 1rem; padding-top: .8rem; font-size: .85rem; }

/* Início */
.cartoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: .9rem 1rem; display: flex; flex-direction: column; box-shadow: var(--sombra); color: var(--texto-suave); text-decoration: none; }
.cartao-num { font-size: 2rem; font-weight: 800; color: var(--texto); line-height: 1.1; }
.cartao-link:hover { border-color: var(--primaria); }
.cartao-erro .cartao-num { color: var(--erro); }
.setores-dia { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.setor-dia { background: var(--superficie); border: 1px solid var(--borda); border-top: 3px solid var(--cor); border-radius: var(--raio); padding: .8rem 1rem; box-shadow: var(--sombra); }
.setor-dia h2 { display: flex; align-items: center; gap: .5rem; font-size: 1rem; }
.setor-dia h3 { font-size: .75rem; text-transform: uppercase; color: var(--texto-suave); margin: .6rem 0 .2rem; }
.setor-dia ul { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.setor-dia li { padding: .15rem 0; }
.setor-dia li small { color: var(--texto-suave); }
.contagem { margin-left: auto; font-size: .85rem; font-weight: 700; background: var(--primaria-clara); color: var(--primaria-escura); padding: .1rem .5rem; border-radius: 999px; }
.contagem.baixo { background: var(--erro-fundo); color: var(--erro); }
.passos ol { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .35rem; }
.passos li.feito { color: var(--texto-suave); text-decoration: line-through; }
.lista-simples { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .3rem; }
.historico { font-size: .88rem; }

/* Login e instalação */
.pagina-auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #e6f2ea, #f4f6f4 60%); }
.auth-caixa { background: #fff; width: 100%; max-width: 400px; padding: 1.6rem; border-radius: 14px; box-shadow: 0 10px 40px rgba(16, 60, 34, .12); }
.auth-larga { max-width: 760px; }
.auth-marca { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.2rem; }
.auth-marca .marca-icone { background: var(--primaria); color: #fff; width: 48px; height: 48px; font-size: 1rem; }
.auth-marca h1 { font-size: 1.3rem; }
.auth-marca p { margin: 0; color: var(--texto-suave); }
.auth-caixa .formulario { max-width: none; }

/* Coringas, horas por semana e links da grade */
.tag-coringa { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; background: #d98a00; color: #fff; font-size: .65rem; font-weight: 800; vertical-align: 1px; }
.c-apoio { box-shadow: inset 0 -4px 0 var(--alvo, #d98a00); }
.linha-apoio .col-nome { color: var(--texto-suave); font-weight: 400; font-style: italic; }
.c-fora { background: #fafbfa; }
.grade .tot.sem { min-width: 54px; font-size: .74rem; }
.grade th.tot small { display: block; font-weight: 400; font-size: .64rem; }
.grade td.excesso { background: var(--erro-fundo); color: var(--erro); font-weight: 700; }
.setor-link { margin-left: auto; font-size: .85rem; font-weight: 600; }
.centro { text-align: center !important; }
.dias-check { display: flex !important; flex-direction: row !important; flex-wrap: wrap; gap: .4rem 1.2rem !important; }

/* Mapa de cobertura */
.mapa-rolagem { border-top: 3px solid var(--cor); }
.mapa { border-collapse: separate; border-spacing: 0; font-size: .72rem; min-width: 100%; }
.mapa th, .mapa td { text-align: center; padding: 0; height: 30px; border-bottom: 1px solid #fff; }
.mapa thead th.hora { font-weight: 600; color: var(--texto-suave); text-align: left; padding-left: 3px; border-left: 1px solid var(--borda); background: #f6f8f6; }
.mapa .col-nome { position: sticky; left: 0; background: var(--superficie); z-index: 2; text-align: left; padding: 0 .6rem; min-width: 110px; white-space: nowrap; font-weight: 600; border-right: 1px solid var(--borda); }
.mapa .col-nome small { color: #8a3d00; font-weight: 400; }
.mapa td { min-width: 22px; font-weight: 700; }
.mapa td.hora-ini { border-left: 1px solid rgba(0,0,0,.08); }
.mapa-falta { background: #e5484d; color: #fff; }
.mapa-ok { background: #c9ecd3; color: #165c34; }
.mapa-sobra { background: #2f9e57; color: #fff; }
.mapa-livre { background: #eef1ef; color: #7a868d; }
.mapa-vazio { background: #fafbfa; }
.mapa-fechado { background: repeating-linear-gradient(45deg, #f4f6f4, #f4f6f4 6px, #eceff1 6px, #eceff1 12px); color: var(--texto-suave); font-weight: 600; }
.leg.mapa-falta, .leg.mapa-ok, .leg.mapa-sobra, .leg.mapa-livre { font-weight: 700; }
.dias-turnos { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .4rem 1.2rem; }
.dias-turnos h3 small { color: var(--texto-suave); font-weight: 400; }
.lista-turnos { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.lista-turnos li { padding: .15rem 0; }
.lista-turnos small { display: block; color: var(--texto-suave); padding-left: 2.1rem; }
.lista-turnos b { display: inline-block; min-width: 2rem; color: var(--primaria-escura); }

/* Dimensionamento */
.texto-erro { color: var(--erro); font-weight: 700; }
.texto-alerta { color: var(--alerta); font-weight: 700; }
.texto-ok { color: var(--primaria); font-weight: 600; }
.linha-total td { font-weight: 700; background: #f6f8f6; }

/* Impressão */
.pagina-impressao { background: #fff; }
.barra-impressao { display: flex; gap: 1rem; align-items: center; padding: 1rem 16px; border-bottom: 1px solid var(--borda); }
.folha { padding: 16px; }
.folha-topo { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; font-size: .95rem; }
.grade-impressa { width: 100%; font-size: .72rem; border: 1px solid #999; }
.grade-impressa th, .grade-impressa td { border: 1px solid #bbb; }
.grade-impressa .col-nome { position: static; min-width: 0; max-width: none; }
.grade-impressa .cel { height: 22px; }
.grade-impressa .dom { background: #fff1e6; }
.grade-impressa .c-trab { background: #fff; color: #000; }
.folha-rodape { font-size: .75rem; margin-top: .5rem; display: flex; flex-direction: column; gap: .3rem; }
.folha-rodape span { margin-right: .9rem; }
.assinatura { margin-top: 1.4rem; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  .nao-imprimir { display: none !important; }
  .folha { padding: 0; break-after: page; }
  .folha:last-child { break-after: auto; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
