:root {
  --topo: #000000; --fundo: #0f0f11; --painel: #1a1a1c; --painel2: #232227; --linha: #35343a;
  --texto: #ffffff; --suave: #a1a1aa; --laranja: #f39f41; --laranja2: #f39f41; --escuro: #111111;
  --ok: #3fb96b; --nok: #ef5f52;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--laranja2); }
h1 { font-size: 1.6rem; font-weight: 800; color: var(--laranja); margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0; }
.carregar { text-align: center; color: var(--suave); padding: 3rem 1rem; }
.oculto { display: none !important; }

/* topo */
.topo { background: var(--topo); border-bottom: 3px solid var(--laranja); position: sticky; top: 0; z-index: 5; }
.topo-in { max-width: 1200px; margin: 0 auto; padding: .55rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; }
.marca { font-size: 1.25rem; font-weight: 400; color: var(--laranja); text-decoration: none; margin-right: auto; }
.marca b { color: var(--texto); font-weight: 800; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; }
.nav a { color: var(--texto); text-decoration: none; padding: .4rem .75rem; border-radius: 10px; font-size: .95rem; font-weight: 500; }
.nav a:hover { background: var(--painel2); }
.nav a.ativo { background: var(--laranja); color: var(--escuro); font-weight: 700; }
button.sair { background: transparent; border-color: var(--nok); color: var(--nok); font-weight: 600; border-radius: 10px; }
button.sair:hover { border-color: var(--nok); background: #2a1513; }
.quem { color: var(--suave); font-size: .85rem; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }

/* controlos */
button, .botao { font: inherit; border: 1px solid var(--linha); background: var(--painel2); color: var(--texto); padding: .45rem .8rem; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .botao:hover { border-color: var(--laranja); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.principal { background: var(--laranja); border-color: var(--laranja); color: var(--escuro); font-weight: 700; }
button.perigo { border-color: var(--nok); color: #ffb3ae; }
button.peq { padding: .25rem .5rem; font-size: .85rem; }
button.b-ok { border-color: var(--ok); color: #9be3b6; min-width: 4rem; font-weight: 600; }
button.b-nok { border-color: var(--nok); color: #ffb3ae; min-width: 4rem; font-weight: 600; }
input, select, textarea { font: inherit; background: #ffffff; color: var(--escuro); border: 1px solid #c9c9cf; border-radius: 10px; padding: .5rem .65rem; max-width: 100%; }
input::placeholder, textarea::placeholder { color: #9a9aa2; }
input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: var(--laranja); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--laranja); outline-offset: 1px; }
textarea { width: 100%; min-height: 3.2rem; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--suave); margin-bottom: .2rem; }
.campo { margin-bottom: .8rem; }
.campo input, .campo select { width: 100%; }
.barra { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.barra .campo { margin: 0; }
.barra .campo input, .barra .campo select { width: auto; }
.cresce { flex: 1 1 12rem; }
.cresce input { width: 100% !important; }
.abas { display: flex; gap: .4rem; flex-wrap: wrap; }
.abas button { border-radius: 999px; padding: .45rem 1rem; }
.abas button.ativo { background: var(--laranja); border-color: var(--laranja); color: var(--escuro); font-weight: 700; }
.nota { color: var(--suave); font-size: .88rem; }
.erro { color: #ffb3ae; margin: .5rem 0; min-height: 1.2rem; }

/* painéis */
.painel { background: var(--painel); border: 1px solid var(--linha); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }
.login { max-width: 360px; margin: 12vh auto 0; }
.login h1 { text-align: center; font-weight: 400; }
.login h1 b { color: var(--texto); font-weight: 800; }
.login button { width: 100%; margin-top: .4rem; }

/* grelha de máquinas */
.grelha { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.maq { display: block; background: var(--painel); border: 1px solid var(--linha); border-radius: 14px; padding: .8rem .9rem; color: var(--texto); text-decoration: none; }
.maq:hover { border-color: var(--laranja); }
.maq.pend { border-left: 5px solid var(--laranja); }
.maq.tem-nok { border-left: 5px solid var(--nok); }
.maq .cod { font-weight: 800; font-size: 1.15rem; display: flex; justify-content: space-between; align-items: center; }
.maq .num { color: var(--suave); font-size: .85rem; margin-top: .35rem; }
.prog { height: 8px; background: #2c2b30; border-radius: 4px; overflow: hidden; margin-top: .45rem; }
.prog span { display: block; height: 100%; background: var(--laranja); }
.prog.completo span { background: var(--ok); }
.selo { font-size: .72rem; padding: .1rem .4rem; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.selo.nok { background: var(--nok); color: #fff; }
.selo.ok { background: var(--ok); color: #0d1a12; }
.selo.fM { border-color: var(--laranja); color: var(--laranja); }
.selo.f { background: var(--painel2); border: 1px solid var(--linha); color: var(--suave); }
.resumo { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; color: var(--suave); margin-bottom: 1rem; font-size: .92rem; }
.resumo b { color: var(--laranja); font-weight: 800; }
.resumo b.v-nok { color: var(--nok); }

/* checklist */
.area-cab { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.area-cab h2 { flex: 1 1 auto; }
.area-cab .codigo { color: var(--laranja); font-weight: 700; }
.tarefa { border-top: 1px solid var(--linha); padding: .65rem 0; display: grid; grid-template-columns: 1fr auto; gap: .5rem .8rem; align-items: center; }
.tarefa .txt .c { color: var(--suave); font-size: .82rem; margin-right: .4rem; }
.tarefa .acoes { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.tarefa .feito { grid-column: 1 / -1; font-size: .86rem; color: var(--suave); }
.tarefa .feito .obs { color: var(--texto); display: block; margin-top: .15rem; }
.tarefa.e-ok { box-shadow: inset 3px 0 0 var(--ok); padding-left: .6rem; }
.tarefa.e-nok { box-shadow: inset 3px 0 0 var(--nok); padding-left: .6rem; }
.tarefa .form-nok { grid-column: 1 / -1; display: flex; flex-direction: column; gap: .4rem; }
.tarefa .form-nok .linha { display: flex; gap: .4rem; flex-wrap: wrap; }
details.painel > summary { cursor: pointer; color: var(--suave); }
.lista-simples { margin: .6rem 0 0; padding: 0; list-style: none; }
.lista-simples li { padding: .3rem 0; border-top: 1px solid var(--linha); display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }

/* administração */
.adm-tarefa { display: flex; gap: .4rem; align-items: center; border-top: 1px solid var(--linha); padding: .45rem 0; flex-wrap: wrap; }
.adm-tarefa .c { color: var(--suave); font-size: .82rem; width: 3.6rem; flex: none; }
.adm-tarefa input { flex: 1 1 16rem; }
.adm-novo { display: flex; gap: .4rem; margin-top: .6rem; flex-wrap: wrap; }
.adm-novo input { flex: 1 1 16rem; }
.rolar { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { border-bottom: 1px solid var(--linha); padding: .4rem .5rem; text-align: left; vertical-align: top; }
th { color: var(--suave); font-weight: 600; white-space: nowrap; background: var(--painel); position: sticky; top: 0; }
table.freq td, table.freq th { text-align: center; padding: .2rem; }
table.freq td:first-child, table.freq th:first-child { text-align: left; font-weight: 700; position: sticky; left: 0; background: var(--painel); }
table.freq select { padding: .15rem .1rem; font-size: .85rem; border-radius: 6px; }
select.fM { background: var(--laranja); border-color: var(--laranja); color: var(--escuro); font-weight: 700; }
td.c-ok { color: #9be3b6; font-weight: 600; } td.c-nok { color: #ffb3ae; font-weight: 600; }
.inativo td { opacity: .55; }

.lista-maq { display: flex; flex-wrap: wrap; gap: .5rem; }
.item-maq { display: inline-flex; align-items: center; gap: .5rem; background: var(--painel2); border: 1px solid var(--linha); border-radius: 10px; padding: .3rem .4rem .3rem .7rem; font-weight: 700; }
.item-maq a { color: var(--texto); text-decoration: none; }
.item-maq.inativa { opacity: .6; }
.folha { display: none; }

#toast { font-weight: 500; position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--painel2); border: 1px solid var(--laranja); color: var(--texto); padding: .6rem 1rem; border-radius: 8px; max-width: 92vw; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
#toast.ver { opacity: 1; }
#toast.mau { border-color: var(--nok); }

@media (max-width: 560px) {
  .tarefa { grid-template-columns: 1fr; }
  .tarefa .acoes { justify-content: flex-start; }
  .grelha { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; color: #000; }
  .topo, .barra, .acoes, #toast, button { display: none !important; }
  .painel { border-color: #999; background: #fff; break-inside: avoid; }
  body.com-folha main > * { display: none !important; }
  body.com-folha main > .folha { display: block !important; }
  body.com-folha main { max-width: none; padding: 0; }
  .folha { font: 10pt/1.3 Arial, Helvetica, sans-serif; color: #000; }
  .folha-cab { display: flex; align-items: center; gap: 6mm; border-bottom: 1.2mm solid #000; padding-bottom: 4mm; margin-bottom: 5mm; }
  .folha-maq { flex: 1 1 auto; }
  .folha-cod { font-size: 34pt; font-weight: 800; line-height: 1; }
  .folha-grupo { font-size: 12pt; color: #333; margin-top: 2mm; }
  .folha-info { display: flex; flex-direction: column; text-align: right; font-size: 10.5pt; }
  .folha-info b { font-size: 11.5pt; }
  .folha-qr { display: flex; flex-direction: column; align-items: center; font-size: 7.5pt; }
  .folha-qr svg { width: 30mm; height: 30mm; border: .3mm solid #000; }
  .folha-tab { width: 100%; border-collapse: collapse; font-size: 9pt; }
  .folha-tab th, .folha-tab td { border: .2mm solid #555; padding: 1.2mm 1.6mm; text-align: left; vertical-align: middle; color: #000; background: #fff; position: static; }
  .folha-tab th { background: #e6e6e6; font-weight: 700; white-space: nowrap; }
  .folha-tab thead { display: table-header-group; }
  .folha-tab tr { break-inside: avoid; }
  .folha-tab tr.folha-area td { background: #f1f1f1; font-weight: 700; break-after: avoid; }
  .folha-tab td.cx, .folha-tab th:nth-child(3), .folha-tab th:nth-child(4) { text-align: center; width: 11mm; }
  .folha-tab td:first-child { white-space: nowrap; width: 13mm; }
  .folha-tab td:nth-child(5) { width: 42mm; }
  .folha-tab td:nth-child(6) { width: 32mm; font-size: 8pt; }
  .caixa { display: inline-block; width: 4.2mm; height: 4.2mm; border: .3mm solid #000; line-height: 3.8mm; font-weight: 800; font-size: 9pt; text-align: center; }
  .folha-fim { display: flex; justify-content: space-between; gap: 6mm; margin-top: 9mm; font-size: 9.5pt; break-inside: avoid; }
}
