:root {
  --verde-escuro: #2F5158;
  --verde-claro: #F0FAD8;
  --verde-limao: #B8E342;
  --ok: #2E8B3D;
  --ok-bg: #E4F5E6;
  --bad: #C62828;
  --bad-bg: #FDE7E7;
  --warn: #B26A00;
  --warn-bg: #FFF3D1;
  --texto: #1d2b2e;
  --suave: #5d7276;
  --borda: #cfe0a8;
  --branco: #fff;
  --raio: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--texto);
  background: var(--verde-claro);
  font-size: 15px;
}
h1, h2, h3 { margin: 0 0 .6rem; color: var(--verde-escuro); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
.hidden { display: none !important; }
.muted { color: var(--suave); }
.mono { font-family: Consolas, "Courier New", monospace; }

/* header */
.topbar {
  background: var(--verde-escuro);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.25rem;
  height: 56px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: .85rem; text-decoration: none; white-space: nowrap; }
.brand img { height: 28px; width: auto; display: block; }
.brand-sep { width: 2px; height: 24px; background: var(--verde-limao); border-radius: 2px; }
.brand-name { color: var(--verde-limao); font-weight: 700; letter-spacing: .14em; font-size: .85rem; }
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a {
  color: #dfeee0; text-decoration: none; padding: .45rem .9rem; border-radius: 8px; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.1); }
.topbar { border-bottom: 3px solid var(--verde-limao); }
.nav a.active { background: var(--verde-limao); color: var(--verde-escuro); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.userbox small { color: #b9d2bf; display: block; line-height: 1.1; }

main { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }

/* components */
.card {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(47,81,88,.05);
}
.notice {
  background: #fff;
  border-left: 4px solid var(--verde-limao);
  padding: .6rem .9rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  color: var(--verde-escuro);
  font-size: .9rem;
}
label { display: block; font-size: .8rem; font-weight: 600; color: var(--verde-escuro); margin-bottom: .25rem; }
input, select, textarea {
  width: 100%;
  padding: .55rem .65rem;
  border: 1px solid #b9c9b0;
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--texto);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde-limao); border-color: var(--verde-escuro); }
textarea { resize: vertical; min-height: 56px; }
.field { margin-bottom: .75rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
@media (max-width: 860px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .nav a { padding: .4rem .55rem; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--verde-escuro); color: #fff; border: 0; border-radius: 8px;
  padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.lime { background: var(--verde-limao); color: var(--verde-escuro); }
.btn.ghost { background: transparent; color: var(--verde-escuro); border: 1px solid var(--verde-escuro); }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.big { padding: .9rem 1.6rem; font-size: 1.05rem; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.chip { background: var(--verde-claro); color: var(--verde-escuro); border: 1px solid var(--borda);
  border-radius: 999px; padding: .15rem .65rem; font-size: .8rem; font-weight: 600; }
.chip.off { background: #eee; color: #888; text-decoration: line-through; }

.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.off { background: #eee; color: #777; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; background: var(--verde-claro); color: var(--verde-escuro); padding: .55rem .7rem; font-size: .8rem; white-space: nowrap; }
td { padding: .55rem .7rem; border-bottom: 1px solid #e8efdb; vertical-align: middle; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f4fbdf; }
td.c, th.c { text-align: center; }
.cmp td.s { text-align: center; font-weight: 700; width: 70px; }
.cmp tr.st-ok td.s { color: var(--ok); }
.cmp tr.st-divergente { background: var(--bad-bg); }
.cmp tr.st-divergente td.s { color: var(--bad); }
.cmp tr.st-ausente, .cmp tr.st-invalido { background: var(--warn-bg); }
.cmp tr.st-ausente td.s, .cmp tr.st-invalido td.s { color: var(--warn); }
.cmp tr.st-nao_aplicavel { color: #999; }

/* summary cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.7rem; color: var(--verde-escuro); }
.stat.ok b { color: var(--ok); } .stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); }
.stat span { font-size: .8rem; color: var(--suave); font-weight: 600; }

/* inspection */
.labelcols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .labelcols { grid-template-columns: 1fr; } }
.labelbox { border: 2px solid var(--borda); border-radius: var(--raio); padding: .9rem 1rem .3rem; background: #fcfef6; }
.labelbox h3 small { color: var(--suave); font-weight: 500; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
@media (max-width: 860px) { .photos { grid-template-columns: 1fr; } }
.photo { border: 2px dashed #b9c9b0; border-radius: var(--raio); padding: .6rem; text-align: center; min-height: 150px; }
.photo img { max-width: 100%; max-height: 150px; border-radius: 6px; display: block; margin: .4rem auto; }
.photo input { font-size: .8rem; }

.banner {
  border-radius: var(--raio); padding: 1.2rem 1.5rem; display: flex; align-items: center; gap: 1.2rem; margin-bottom: 1rem;
}
.banner .ic { font-size: 3rem; font-weight: 800; line-height: 1; }
.banner .tt { font-size: 1.9rem; font-weight: 800; letter-spacing: .03em; }
.banner.ok { background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok); }
.banner.bad { background: var(--bad-bg); color: var(--bad); border: 2px solid var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 2px solid var(--warn); }

/* modal */
.backdrop { position: fixed; inset: 0; background: rgba(20,40,44,.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 2rem 1rem; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; padding: 1.3rem 1.5rem; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal.sm { max-width: 460px; }
.modal-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .8rem; }
.modal-head h2 { margin: 0; flex: 1; }
.x { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--suave); line-height: 1; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem 1rem; margin-bottom: 1rem; }
.meta div small { display: block; color: var(--suave); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.thumbs figure { margin: 0; border: 1px solid var(--borda); border-radius: 8px; overflow: hidden; background: #fafafa; }
.thumbs img { width: 100%; height: 140px; object-fit: cover; display: block; cursor: zoom-in; }
.thumbs figcaption { padding: .3rem .5rem; font-size: .75rem; color: var(--suave); }
.checks { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .8rem; }
.checks label { display: flex; align-items: center; gap: .4rem; font-weight: 500; margin: 0; }
.checks input { width: auto; }
pre.raw { background: #f2f6ea; padding: .5rem .7rem; border-radius: 6px; overflow-x: auto; margin: .2rem 0 .8rem; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--verde-escuro); padding: 1rem; }
.login-card { background: #fff; border-top: 6px solid var(--verde-limao); border-radius: 14px; padding: 2rem 2rem 1.5rem; width: 100%; max-width: 390px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.login-logo { display: block; width: 190px; max-width: 70%; height: auto; margin: .3rem auto 1rem; }
.login-title { text-align: center; color: var(--verde-escuro); font-weight: 700; letter-spacing: .3em; font-size: .85rem; padding-bottom: .7rem; margin-bottom: .8rem; border-bottom: 3px solid var(--verde-limao); width: 70%; margin-left: auto; margin-right: auto; }
.login-card p { text-align: center; margin: 0 0 1.4rem; }
.err { color: var(--bad); font-size: .88rem; min-height: 1.2rem; margin-bottom: .5rem; }

#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 99; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--verde-escuro); color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: 360px; }
.toast.err { background: var(--bad); }
.pager { display: flex; align-items: center; gap: .6rem; justify-content: flex-end; margin-top: .8rem; }
.empty { text-align: center; padding: 2rem; color: var(--suave); }

/* ---- bancada (V0.2) ---- */
.bench-head { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; padding: .7rem 1rem; }
.bench-head small { display: block; color: var(--suave); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.bench-head b { color: var(--verde-escuro); }
.sess { display: flex; gap: .8rem; font-weight: 800; font-size: 1.05rem; }
.sess .ok { color: var(--ok); } .sess .bad { color: var(--bad); } .sess .warn { color: var(--warn); }
label.inl { display: flex; align-items: center; gap: .35rem; font-weight: 500; margin: 0; font-size: .85rem; }
label.inl input { width: auto; }
.steps { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.step { flex: 1; min-width: 170px; background: #fff; border: 2px solid var(--borda); border-radius: 10px; padding: .55rem .8rem; font-weight: 600; color: var(--suave); display: flex; gap: .6rem; align-items: center; }
.step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--borda); color: var(--verde-escuro); display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.step.active { border-color: var(--verde-limao); color: var(--verde-escuro); }
.step.active .n { background: var(--verde-limao); }
.step.done { color: var(--ok); }
.step.done .n { background: var(--ok); color: #fff; }
.bench-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .bench-grid { grid-template-columns: 1fr; } }
.cam-box { position: relative; background: #0f1c1f; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; border: 3px solid var(--verde-escuro); }
.cam-box video { width: 100%; height: 100%; object-fit: contain; display: block; background: #0f1c1f; }
.guide { position: absolute; inset: 14% 18%; border: 3px dashed rgba(184, 227, 66, .85); border-radius: 10px; pointer-events: none; }
.cam-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1.5rem; color: #fff; background: rgba(15, 28, 31, .94); line-height: 1.5; }
.cam-box.flash::after { content: ''; position: absolute; inset: 0; background: #fff; animation: fl .22s ease-out forwards; }
@keyframes fl { from { opacity: .9; } to { opacity: 0; } }
.cam-tools { display: flex; gap: .6rem; align-items: center; margin: .7rem 0; flex-wrap: wrap; }
.cam-tools select { width: auto; max-width: 280px; }
.lab-col .labelbox { margin-bottom: .9rem; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.thumb { border: 2px dashed #b9c9b0; border-radius: 8px; min-height: 90px; display: flex; align-items: center; justify-content: center; margin-bottom: .8rem; position: relative; background: #fff; overflow: hidden; }
.thumb.active { border: 2px solid var(--verde-limao); box-shadow: 0 0 0 3px rgba(184, 227, 66, .35); }
.thumb img { width: 100%; max-height: 150px; object-fit: cover; cursor: zoom-in; display: block; }
.thumb .refazer { position: absolute; right: 6px; bottom: 6px; background: var(--verde-escuro); }
.thumb-empty { color: var(--suave); font-size: .85rem; padding: 1rem; }
.banner.big { padding: 2rem 2.2rem; }
.banner.big .ic { font-size: 5rem; }
.banner.big .tt { font-size: 3.2rem; }

[hidden] { display: none !important; }

/* ---- leitor de código de barras (V0.3) ---- */
.notice.ok { border-left-color: var(--ok); background: var(--ok-bg); }
.notice.warn { border-left-color: var(--warn); background: var(--warn-bg); color: #5a3a00; }
.tag { display: inline-block; margin-left: .4rem; padding: .1rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: #eee; color: #777; vertical-align: middle; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.wait { background: var(--verde-limao); color: var(--verde-escuro); animation: pulso 1.2s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: .55; } }
.labelbox h3[data-alvo] { cursor: pointer; }
.labelbox.alvo { border-color: var(--verde-limao); box-shadow: 0 0 0 3px rgba(184, 227, 66, .4); }

/* ---- leitura automática da foto (V0.3.1) ---- */
.dica { font-size: .82rem; color: #6b4300; background: var(--warn-bg); border-radius: 6px; padding: .4rem .6rem; margin: .1rem 0 .7rem; line-height: 1.35; }
.cam-col .notice { margin-bottom: .7rem; }
