:root {
  --fundo: #101114;
  --cartao: #191a1e;
  --elev: #222328;
  --linha: #2c2d33;
  --texto: #f2f0ea;
  --apoio: #a3a29c;
  --am: #ffc21a;
  --am-txt: #1a1400;
  --ok: #6fd09a;
  --alerta: #f5b83d;
  --ruim: #ff6b5e;
  --azul: #7cb7ff;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); overflow-x: hidden; }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--am); }
[hidden] { display: none !important; }

.topo {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: rgba(16,17,20,.94);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--linha);
}
.topo h1 { flex: 1; margin: 0; font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icone-btn { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--elev); font-size: 28px; line-height: 1; }
.chip-sync { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--linha); background: var(--cartao); font-size: 13px; color: var(--apoio); }
.chip-sync.ok { color: var(--ok); } .chip-sync.pend { color: var(--alerta); } .chip-sync.off { color: var(--apoio); }

.main { padding: 14px 14px calc(env(safe-area-inset-bottom) + 96px); max-width: 760px; margin: 0 auto; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); background: #15161a; border-top: 1px solid var(--linha);
}
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center;
  text-decoration: none; color: var(--apoio); font-size: 12px; border-radius: 12px; }
.nav a .ni { font-size: 20px; line-height: 1; }
.nav a.ativo { color: var(--am); background: rgba(255,194,26,.08); }

h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--apoio); margin: 22px 2px 8px; font-weight: 700; }
.cartao { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--r); padding: 14px; }
.cartao + .cartao { margin-top: 10px; }
.apoio { color: var(--apoio); font-size: 14px; }
.peq { font-size: 13px; }

.acoes-grandes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acao { display: flex; flex-direction: column; gap: 4px; min-height: 92px; padding: 14px; border-radius: var(--r); border: 1px solid var(--linha);
  background: var(--cartao); text-decoration: none; color: var(--texto); text-align: left; }
.acao b { font-size: 17px; } .acao span { font-size: 13px; color: var(--apoio); }
.acao .ic { font-size: 22px; color: var(--am); }
.acao.principal { grid-column: 1 / -1; background: var(--am); color: var(--am-txt); border-color: var(--am); min-height: 76px; }
.acao.principal span, .acao.principal .ic { color: var(--am-txt); }

.numeros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numeros div { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--r); padding: 10px; }
.numeros b { display: block; font-size: 26px; } .numeros span { font-size: 12px; color: var(--apoio); }

.lista { list-style: none; margin: 0; padding: 0; background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--r); overflow: hidden; }
.lista li + li { border-top: 1px solid var(--linha); }
.lista a, .lista .item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; min-height: 60px; text-decoration: none; color: var(--texto); }
.lista .cresce { flex: 1; min-width: 0; }
.lista .l1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista .l2 { font-size: 13px; color: var(--apoio); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vazio { padding: 22px 14px; text-align: center; color: var(--apoio); }

.selo { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.s-aberta { color: var(--azul); } .s-andamento { color: var(--alerta); } .s-aguardando { color: var(--ruim); } .s-concluida { color: var(--ok); }
.s-tipo { color: var(--apoio); }

.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--elev); flex: none; display: grid; place-items: center; color: var(--apoio); }
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.peca-card { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--r); overflow: hidden; text-decoration: none; color: var(--texto); display: flex; flex-direction: column; }
.peca-card img, .peca-card .semfoto { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--elev); display: grid; place-items: center; color: var(--apoio); }
.peca-card div.txt { padding: 8px 10px 10px; }
.peca-card b { display: block; font-size: 14px; line-height: 1.25; max-height: 2.5em; overflow: hidden; }
.peca-card small { color: var(--apoio); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.busca { display: flex; gap: 8px; margin-bottom: 10px; }
.busca input { flex: 1; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: none; }
.chips button { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--linha); background: var(--cartao); font-size: 14px; color: var(--apoio); }
.chips button.ativo { background: var(--am); color: var(--am-txt); border-color: var(--am); font-weight: 600; }

label { display: block; font-size: 13px; color: var(--apoio); margin: 12px 2px 5px; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--linha); background: var(--elev); font-size: 16px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--am); outline-offset: 0; border-color: transparent; }
.lado { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.lado3 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0 10px; }
.lado3 > :first-child { grid-column: 1 / -1; }
@media (min-width: 560px) { .lado3 { grid-template-columns: minmax(0,1.3fr) minmax(0,1fr) minmax(0,1fr); } .lado3 > :first-child { grid-column: auto; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--linha); background: var(--elev); font-weight: 600; text-decoration: none; color: var(--texto); cursor: pointer; }
.btn.prim { background: var(--am); border-color: var(--am); color: var(--am-txt); }
.btn.perigo { color: var(--ruim); border-color: rgba(255,107,94,.4); background: transparent; }
.btn.bloco { width: 100%; }
.btn.peq { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.botoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.botoes .btn { flex: 1 1 140px; }
.fixo-base { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 76px); padding: 10px 0 0; background: linear-gradient(transparent, var(--fundo) 30%); }

.item-peca { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--linha); }
.item-peca:first-child { border-top: 0; }
.item-peca .qtd { width: 70px; text-align: center; }
.foto-grande { width: 100%; max-height: 60vh; object-fit: contain; border-radius: var(--r); background: #000; display: block; }
.aviso { padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(245,184,61,.4); color: var(--alerta); background: rgba(245,184,61,.06); font-size: 14px; }
.aviso.ok { color: var(--ok); border-color: rgba(111,208,154,.4); background: rgba(111,208,154,.06); }

.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.modal-caixa { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--cartao); border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(env(safe-area-inset-bottom) + 16px); border: 1px solid var(--linha); }
.modal-caixa h3 { margin: 0 0 10px; font-size: 18px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 40; background: var(--texto); color: #111;
  padding: 12px 16px; border-radius: 12px; font-weight: 600; max-width: 92vw; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.carregando { display: inline-block; width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: gira .8s linear infinite; vertical-align: -3px; }
@keyframes gira { to { transform: rotate(360deg); } }

.login { max-width: 420px; margin: 8vh auto 0; }
.login .logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 12px; }
.login h1 { text-align: center; margin: 0 0 4px; }

/* ---------- folha da OS (PDF) ---------- */
.folha { background: #fff; color: #111; border-radius: 8px; padding: 22px; font-size: 13px; line-height: 1.45; }
.folha h1 { font-size: 20px; margin: 0; }
.folha .cab { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 12px; }
.folha table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.folha th, .folha td { border: 1px solid #bbb; padding: 6px 8px; text-align: left; vertical-align: top; }
.folha th { background: #f1f1f1; font-weight: 600; width: 32%; }
.folha .tab-pecas th { width: auto; }
.folha h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 4px; }
.folha .txt { white-space: pre-wrap; border: 1px solid #bbb; padding: 8px; min-height: 40px; }
.folha .assin { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 50px; text-align: center; }
.folha .assin div { border-top: 1px solid #111; padding-top: 4px; }
.folha .rodape { margin-top: 18px; font-size: 11px; color: #666; text-align: center; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .topo, .nav, .nao-imprime, .toast, .modal { display: none !important; }
  .main { padding: 0; max-width: none; }
  .folha { border-radius: 0; padding: 0; }
}
@media (min-width: 700px) {
  .acoes-grandes { grid-template-columns: repeat(3, 1fr); }
  .acao.principal { grid-column: auto; }
}
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; }
.modal-caixa .lista .item { width: 100%; }
