:root {
  --fundo: #f5f5f2; --sup: #ffffff; --sup2: #f9f9f7; --tinta: #101010; --tinta2: #4f4e4a; --suave: #86847e;
  --linha: #e3e2dc; --linha2: #cfcec7; --navy: #0d366b; --azul: #2a78d6; --azul-claro: #e6f0fc;
  --verde: #0ca30c; --verde-txt: #006300; --verde-claro: #e9f6e9; --ambar: #b97700; --ambar-claro: #fdf3dc;
  --verm: #c0392b; --verm-claro: #fbeceb; --raio: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--fundo); color: var(--tinta); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--azul); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- estrutura */
.shell { display: grid; grid-template-columns: 212px 1fr; min-height: 100vh; }
.lado { background: var(--navy); color: #fff; padding: 22px 12px 18px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.marca { font-weight: 700; letter-spacing: .12em; font-size: 11px; text-transform: uppercase; opacity: .7; padding: 0 10px; }
.marca b { display: block; font-size: 19px; letter-spacing: 0; text-transform: none; opacity: 1; margin: 2px 0 16px; color: #fff; }
.lado a { color: #dbe6f5; padding: 9px 10px; border-radius: 6px; display: flex; gap: 10px; align-items: center; }
.lado a:hover { background: rgba(255,255,255,.08); }
.lado a.at { background: #fff; color: var(--navy); font-weight: 600; }
.lado a svg { width: 17px; height: 17px; flex: none; }
.lado .fim { margin-top: auto; font-size: 12px; color: #b9cae3; padding: 10px; border-top: 1px solid rgba(255,255,255,.14); }
.lado .fim b { color: #fff; display: block; font-size: 13px; }
.lado .fim button { background: none; border: 0; color: #dbe6f5; padding: 4px 0; cursor: pointer; text-decoration: underline; margin-right: 10px; }
.main { padding: 22px 26px 60px; min-width: 0; }
.topo { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.topo h1 { font-size: 22px; margin-right: auto; }
.topo .sub { color: var(--suave); font-size: 13px; }
.cartao { background: var(--sup); border: 1px solid var(--linha); border-radius: var(--raio); }
.cartao > h2 { font-size: 15px; padding: 13px 16px 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cartao > h2 .esp { margin-left: auto; }
.pad { padding: 12px 16px 16px; }
.grade { display: grid; gap: 14px; }
.rolar { overflow-x: auto; }

/* ---------- controles */
.bt { border: 1px solid var(--linha2); background: var(--sup); border-radius: 6px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.bt:hover { border-color: var(--tinta2); }
.bt.pri { background: var(--navy); border-color: var(--navy); color: #fff; }
.bt.pri:hover { background: #0a2a54; }
.bt.peq { padding: 3px 8px; font-size: 12px; }
.bt.per { color: var(--verm); }
.bt:disabled { opacity: .45; cursor: default; }
.campo { display: grid; gap: 4px; font-size: 13px; color: var(--tinta2); }
.campo input, .campo select, .campo textarea, .sel, .inp { border: 1px solid var(--linha2); border-radius: 6px; padding: 7px 9px; background: var(--sup); min-width: 0; }
.inp:focus, .sel:focus, .campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--azul); outline-offset: -1px; }
.seg { display: inline-flex; border: 1px solid var(--linha2); border-radius: 7px; overflow: hidden; background: var(--sup); }
.seg button { border: 0; background: none; padding: 7px 13px; cursor: pointer; border-right: 1px solid var(--linha2); }
.seg button:last-child { border-right: 0; }
.seg button.at { background: var(--navy); color: #fff; }
.linha-f { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- indicadores e tabelas */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--sup); border: 1px solid var(--linha); border-radius: var(--raio); padding: 13px 15px; }
.kpi .r { font-size: 12.5px; color: var(--tinta2); }
.kpi .v { font-size: 28px; font-weight: 600; line-height: 1.15; }
.kpi .s { font-size: 12px; color: var(--suave); }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--suave); padding: 8px 10px; border-bottom: 1px solid var(--linha2); white-space: nowrap; background: var(--sup); position: sticky; top: 0; }
.t td { padding: 7px 10px; border-bottom: 1px solid var(--linha); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tr.cli { cursor: pointer; }
.t tr.cli:hover td { background: var(--sup2); }
.t tr.sub td { background: var(--sup2); font-weight: 600; }
.t tr.tot td { font-weight: 600; border-top: 1px solid var(--linha2); }
.t .z { color: #b9b8b1; }
.t td.ok { color: var(--verde-txt); text-align: right; }
.barra { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: #e9e8e3; min-width: 90px; }
.barra i { display: block; height: 100%; }
.barra .c { background: var(--verde); } .barra .a { background: var(--azul); margin-left: 2px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 20px; background: #eeede8; color: var(--tinta2); white-space: nowrap; }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--suave); }
.tag.conc { background: var(--verde-claro); color: var(--verde-txt); } .tag.conc::before { background: var(--verde); }
.tag.arm { background: var(--azul-claro); color: #174f95; } .tag.arm::before { background: var(--azul); }
.tag.pa, .tag.pc { background: var(--ambar-claro); color: #7a4f00; } .tag.pa::before, .tag.pc::before { background: #eda100; }
.tag.atras { background: var(--verm-claro); color: var(--verm); } .tag.atras::before { background: var(--verm); }
.tag.pend::before { background: none; box-shadow: inset 0 0 0 1.5px var(--suave); }
.leg { color: var(--suave); font-size: 12.5px; }
.vazio { padding: 28px; text-align: center; color: var(--suave); }

/* ---------- mestre / detalhe */
.md { display: grid; grid-template-columns: 290px 1fr; gap: 14px; align-items: start; }
.lista { display: grid; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.lista .it { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--linha); cursor: pointer; }
.lista .it:last-child { border-bottom: 0; }
.lista .it:hover { background: var(--sup2); }
.lista .it.at { background: var(--azul-claro); box-shadow: inset 3px 0 0 var(--azul); }
.lista .it .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lista .it .ct { color: var(--suave); font-size: 12.5px; font-variant-numeric: tabular-nums; flex: none; }
.lista .it .pr { width: 20px; color: var(--suave); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.pega { cursor: grab; color: var(--linha2); user-select: none; padding: 0 2px; }
.arr { opacity: .35; }
.alvo-cima td, .it.alvo-cima { box-shadow: inset 0 2px 0 var(--azul); }

/* ---------- programação */
.quadro { display: grid; gap: 1px; background: var(--linha); border: 1px solid var(--linha); border-radius: var(--raio); overflow: hidden; min-width: 900px; }
.quadro > div { background: var(--sup); padding: 7px 8px; min-width: 0; }
.quadro .cab { background: var(--sup2); font-size: 12.5px; }
.quadro .cab b { font-size: 14px; }
.quadro .cab .acoes { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }
.quadro .cab.sab { background: #efeee9; }
.quadro .fm { font-size: 12.5px; font-weight: 600; display: flex; gap: 7px; align-items: flex-start; }
.quadro .fm i { width: 9px; height: 9px; border-radius: 2px; flex: none; margin-top: 4px; }
.quadro .fm span { display: block; font-weight: 400; color: var(--suave); }
.cel { min-height: 46px; display: flex; flex-direction: column; gap: 3px; }
.cel.sobre { outline: 2px dashed var(--azul); outline-offset: -3px; background: var(--azul-claro) !important; }
.cel .cap { margin-top: auto; font-size: 11px; color: var(--suave); font-variant-numeric: tabular-nums; }
.cel .cap.estouro { color: var(--verm); font-weight: 600; }
.cel.inat { background: #f3f2ee !important; }
.chip { border: 1px solid var(--linha2); border-left: 3px solid var(--navy); border-radius: 5px; padding: 3px 7px; font-size: 12px; background: var(--sup); cursor: grab; line-height: 1.3; min-width: 0; }
.chip .l1 { display: flex; flex-wrap: wrap; column-gap: 6px; align-items: baseline; }
.chip .id { min-width: 0; }
.chip .id::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--azul); margin-right: 5px; }
.chip.narm .id::before { background: none; box-shadow: inset 0 0 0 1.5px var(--suave); }
.chip b { font-weight: 600; }
.chip .ob { font-size: 11px; color: var(--navy); font-weight: 600; }
.chip .md { color: var(--suave); font-size: 11.5px; white-space: nowrap; }
.chip .l2 { color: var(--suave); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.sug { border-style: dashed; border-left-color: var(--suave); background: var(--sup2); }
.chip.incomp { border-left-color: var(--verm); }
.chip.arr { opacity: .4; }
.col-arm { display: flex; flex-direction: column; gap: 3px; min-height: 120px; }
.col-arm .gob { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--suave); margin-top: 5px; }
.resumo-prog { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.painel-pecas { position: sticky; top: 12px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.painel-pecas .rol { overflow-y: auto; padding: 8px; display: grid; gap: 3px; align-content: start; }
.livre { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.pop { position: absolute; z-index: 40; background: var(--sup); border: 1px solid var(--linha2); border-radius: var(--raio); box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 12px 14px; width: 270px; font-size: 13px; }
.pop h3 { font-size: 15px; margin-bottom: 6px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 10px; }
.pop dt { color: var(--suave); } .pop dd { margin: 0; }

/* ---------- modal, login, avisos */
.fundo { position: fixed; inset: 0; background: rgba(16,16,16,.42); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--sup); border-radius: 10px; width: min(620px, 100%); max-height: 92vh; overflow: auto; padding: 20px 22px; }
.modal h2 { font-size: 18px; margin-bottom: 14px; }
.modal .form { display: grid; gap: 12px; }
.modal .dupla { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .pe { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.marcas { display: flex; flex-wrap: wrap; gap: 6px; }
.marcas label { border: 1px solid var(--linha2); border-radius: 20px; padding: 3px 10px; cursor: pointer; font-size: 13px; color: var(--tinta); }
.marcas input { display: none; }
.marcas label:has(input:checked) { background: var(--navy); border-color: var(--navy); color: #fff; }
.entrar { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--navy); }
.entrar form { background: var(--sup); border-radius: 12px; padding: 28px; width: min(380px, 100%); display: grid; gap: 14px; }
.entrar h1 { font-size: 22px; }
.entrar .erro { color: var(--verm); font-size: 13px; min-height: 18px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 80; }
.toast { background: #1d1d1b; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.erro { background: var(--verm); }
.solta { border: 2px dashed var(--linha2); border-radius: var(--raio); padding: 34px; text-align: center; background: var(--sup); }
.solta.sobre { border-color: var(--azul); background: var(--azul-claro); }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } .md, .livre { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .lado { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .lado .marca, .lado .fim { width: 100%; } .marca b { margin-bottom: 6px; }
  .main { padding: 16px 12px 50px; } .kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- dias sem produção, peças fora da programação */
.quadro .cab.off { background: #ecebe6; color: var(--suave); }
.traco { color: var(--linha2); font-size: 18px; text-align: center; margin: auto; }
.bt.fant { border-color: transparent; background: none; color: var(--suave); padding-left: 4px; padding-right: 4px; }
.bt.fant:hover { color: var(--verm); border-color: var(--linha2); }
.retiradas { padding: 9px 12px; margin-bottom: 10px; min-height: 0; border-style: dashed; }
.retiradas .chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px; margin-top: 8px; }
.tag.fora { background: #eeede8; color: var(--tinta2); } .tag.fora::before { background: var(--tinta2); }

/* ---------- folha de exportação (PDF pela impressão do navegador); estilo do cronograma do sistema Fachinello */
#folha { display: none; }
@media print {
  html, body { background: #fff !important; height: auto; }
  body > *:not(#folha) { display: none !important; }
  #folha { display: block; color: #26313b; font-family: Arial, Helvetica, sans-serif; line-height: 1.3; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .fo-topo { display: flex; align-items: center; gap: 2em; padding-bottom: .9em; border-bottom: .22em solid #af2634; margin-bottom: 1.1em; }
  .fo-topo img { height: 4.2em; width: auto; }
  .fo-tit { flex: 1; text-align: center; }
  .fo-tit b { display: block; font-size: 1.95em; letter-spacing: .02em; }
  .fo-tit span { display: block; font-size: 1.2em; font-weight: 700; color: #af2634; margin-top: .25em; }
  .fo-info { text-align: right; color: #65717b; font-size: .85em; white-space: nowrap; }
  .fo-tab { width: 100%; border-collapse: collapse; table-layout: fixed; margin-bottom: 1.4em; border: .5pt solid #d7dee3; }
  .fo-tab thead { display: table-header-group; }
  .fo-tab th { background: #26313b; color: #fff; font-weight: 700; text-align: center; padding: .65em .5em; border-bottom: .24em solid #af2634; border-right: .5pt solid #4a5661; }
  .fo-tab th.off { background: #65717b; }
  .fo-tab th small { display: block; font-weight: 400; font-size: .78em; opacity: .9; }
  .fo-tab th.fo-forma { width: 13%; text-align: left; }
  .fo-tab td { padding: .55em .6em; border: .5pt solid #d7dee3; vertical-align: top; overflow-wrap: anywhere; }
  .fo-tab td:nth-child(odd) { background: #f5f7f8; }
  .fo-tab td.fo-forma { background: #eaeff2; }
  .fo-tab td.fo-forma b { display: block; }
  .fo-tab td.fo-forma span { color: #65717b; font-size: .88em; }
  .fo-tab tr { break-inside: avoid; }
  .fo-tab td em { display: block; text-align: center; font-style: normal; color: #65717b; }
  .fo-g + .fo-g { margin-top: .35em; padding-top: .35em; border-top: .5pt dotted #b9c3ca; }
  .fo-g i { font-style: normal; font-weight: 700; color: #af2634; font-size: .86em; }
  .fo-g u { text-decoration: none; color: #65717b; }
  .fo-g span { color: #65717b; white-space: nowrap; }
  .fo-g.sug { font-style: italic; color: #65717b; }
  .fo-g.sug b { font-weight: 600; }
  .fo-tot td { background: #eaeff2 !important; text-align: center; border-top: .12em solid #26313b; }
  .fo-tot td.fo-forma { text-align: left; }
  .fo-pe { color: #65717b; font-size: .82em; border-top: .5pt solid #d7dee3; padding-top: .6em; }
  /* listas (pendências): uma seção por obra, linhas zebradas */
  .fo-pag + .fo-pag { break-before: page; }
  .fo-sec { font-size: 1.3em; margin: 1.4em 0 .4em; padding-bottom: .25em; border-bottom: .12em solid #26313b; break-after: avoid; }
  .fo-sub { font-size: 1.1em; margin: .2em 0 .5em; break-after: avoid; }
  .fo-res { color: #65717b; margin-bottom: .7em; break-after: avoid; }
  .fo-res b { color: #26313b; }
  .fo-lista { table-layout: auto; }
  .fo-lista th { text-align: left; padding: .5em .6em; }
  .fo-lista td { padding: .32em .6em; vertical-align: middle; overflow-wrap: normal; }
  .fo-lista th.n, .fo-lista td.n { text-align: right; white-space: nowrap; }
  .fo-lista td:nth-child(odd) { background: none; }
  .fo-lista tbody tr:nth-child(even) td { background: #f5f7f8; }
  .fo-lista .fo-tot td { text-align: left; font-weight: 700; }
  .fo-lista .fo-tot td.n { text-align: right; }
  .fo-lista .fo-tot b { font-weight: inherit; }
}
