/* Lethor Vision 1.0. Paleta e tipografia da marca Lethor (Inter, base escura).
   Cores de estado têm sempre texto e símbolo junto: nunca só a cor. */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial"); size-adjust: 107%; ascent-override: 90%; descent-override: 22.4%;
}

:root {
  --bg: #040A14; --bg-deep: #061326; --navy: #15253F; --card: #0A1729; --line: #1C3152;
  --text: #EDF1F5; --muted: #93A1B4; --accent: #34C5FD; --blue: #1686FE; --blue-deep: #095CFD;
  --attention: #FFB84D;
  --ok: #0E7A43; --ok-strong: #12A150; --bad: #C3261F; --excess: #E06C00; --unknown: #3B4350; --info: #1686FE;
  --radius-l: 22px; --radius-m: 14px; --radius-s: 10px;
  --tap: 64px;
  --font: "Inter", "Inter Fallback", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 18px; line-height: 1.4; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
a { color: var(--accent); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 20px; max-width: 640px; width: 100%; margin: 0 auto; }
.screen.wide { max-width: 1200px; }
.screen.full { max-width: none; padding: 0; gap: 0; }
.row { display: flex; gap: 12px; align-items: center; }
.row > .grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: var(--bg-deep); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--text); }
.brand b { font-weight: 800; letter-spacing: 0.14em; font-size: 17px; }
.brand span { color: var(--accent); font-weight: 600; font-size: 17px; }
.topbar .who { margin-left: auto; text-align: right; font-size: 14px; color: var(--muted); line-height: 1.25; min-width: 0; max-width: 45%; }
.topbar .who strong, .topbar .who .emp { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who strong { color: var(--text); font-weight: 600; }
.topbar .who .conn { justify-content: flex-end; }
@media (max-width: 560px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar .who .emp, .topbar > strong { display: none; }
  .topbar .who .conn span:last-child { display: none; }
  .topbar .who { display: flex; align-items: center; gap: 8px; }
  .demo-flag { font-size: 11px; padding: 2px 7px; }
}
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ok-strong); flex-shrink: 0; }
.dot.off { background: var(--bad); } .dot.warn { background: var(--attention); }
.demo-flag { background: var(--attention); color: #121212; font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 99px; }

/* ---------- headings ---------- */
h1 { font-size: 30px; line-height: 1.15; margin: 4px 0; font-weight: 750; letter-spacing: -0.01em; }
h2 { font-size: 22px; margin: 0; font-weight: 700; }
.lead { color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap); border-radius: var(--radius-m); border: 0; padding: 0 20px; display: inline-flex;
  align-items: center; justify-content: center; gap: 10px; font-weight: 750; font-size: 21px; cursor: pointer;
  background: var(--navy); color: var(--text); text-decoration: none; transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--blue); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.light { background: var(--text); color: #0A1729; }
.btn.danger { background: var(--bad); }
.btn.big { min-height: 76px; font-size: 24px; }
.btn.small { min-height: 48px; font-size: 17px; padding: 0 14px; }
.btn.wide { width: 100%; }
.btn svg { flex-shrink: 0; }
.icon-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }

/* home tiles */
.tile { flex: 1; min-height: 150px; border-radius: var(--radius-l); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; text-decoration: none; color: var(--text); border: 0; cursor: pointer; padding: 18px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.tile.primary { background: linear-gradient(160deg, var(--blue) 0%, var(--blue-deep) 100%); box-shadow: none; }
.tile strong { font-size: 30px; font-weight: 800; letter-spacing: 0.02em; }
.tile span { font-size: 18px; color: inherit; opacity: .85; }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 16px; }
.input, select.input, textarea.input {
  min-height: 58px; border-radius: var(--radius-s); border: 2px solid var(--line); background: var(--bg-deep);
  padding: 0 16px; font-size: 20px; width: 100%;
}
textarea.input { padding: 12px 16px; min-height: 96px; }
.input:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.error-text { color: #FF8A80; font-weight: 600; }
.card { background: var(--card); border-radius: var(--radius-m); padding: 18px; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- camera ---------- */
.cam { position: relative; background: #000; overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam.fill { flex: 1; min-height: 0; }
.cam .frame { position: absolute; inset: 14% 10%; border: 4px solid rgba(255,255,255,.85); border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(4,10,20,.35); transition: border-color .2s; pointer-events: none; }
.cam .frame.code { inset: 30% 8%; }
.cam .frame.busy { border-color: var(--info); }
.cam .frame.present { border-color: var(--accent); }
.cam .hint { position: absolute; left: 12px; right: 12px; bottom: 14px; text-align: center; font-size: 20px; font-weight: 650;
  background: rgba(4,10,20,.72); padding: 10px 12px; border-radius: 12px; }
.cam .badge { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 8px; font-size: 16px;
  font-weight: 650; background: rgba(4,10,20,.75); padding: 8px 12px; border-radius: 99px; }
.cam .badge .dot { background: var(--info); }
.cam .badge.paused .dot { background: var(--attention); }
.cam .cam-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; }
.cam .cam-msg { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center;
  justify-content: center; text-align: center; padding: 24px; background: var(--bg-deep); }
.scanline { position: absolute; left: 10%; right: 10%; height: 3px; background: var(--accent); top: 50%; opacity: .9;
  animation: scan 1.8s ease-in-out infinite alternate; pointer-events: none; }
@keyframes scan { from { top: 32%; } to { top: 66%; } }
@media (prefers-reduced-motion: reduce) { .scanline { animation: none; } }

/* ---------- conference screen ---------- */
.conf { height: 100dvh; display: flex; flex-direction: column; background: #0B0F16; }
.conf-head { padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-deep); }
.count { display: flex; align-items: baseline; gap: 8px; }
.count b { font-size: 48px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.count span { color: var(--muted); font-size: 20px; }
.progress { height: 12px; border-radius: 6px; background: var(--navy); overflow: hidden; }
.progress > div { height: 100%; background: var(--ok-strong); width: 0; transition: width .3s ease; }
.last { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-deep); min-height: 72px; }
.last .thumb, .thumb { width: 52px; height: 52px; border-radius: 10px; background: var(--navy); object-fit: cover; flex-shrink: 0; }
.last .txt { flex: 1; min-width: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 14px; font-weight: 700; }
.chip.ok { background: var(--ok); } .chip.bad { background: var(--bad); } .chip.excess { background: var(--excess); color: #121212; }
.chip.unknown { background: var(--unknown); } .chip.info { background: var(--navy); }
.conf-actions { display: flex; gap: 12px; padding: 12px 16px 16px; background: var(--bg-deep); }
.conf-actions .btn { flex: 1; }

/* full-screen result overlay */
.result { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; padding: 32px 22px 24px;
  gap: 18px; color: #fff; animation: pop .16s ease-out; overflow-y: auto; }
@keyframes pop { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.result.ok { background: var(--ok); align-items: center; justify-content: center; text-align: center; }
.result.bad { background: var(--bad); }
.result.excess { background: var(--excess); color: #121212; }
.result.unknown { background: #2A3039; }
.result.info { background: var(--navy); }
.result .big-word { font-size: clamp(34px, 10.5vw, 52px); font-weight: 850; letter-spacing: .01em; line-height: 1.05; overflow-wrap: anywhere; min-width: 0; }
.result .row { align-items: flex-start; }
.result .prod { font-size: 24px; font-weight: 650; }
.result .sym { width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; }
.result .box { background: #fff; color: #121212; border-radius: var(--radius-m); padding: 18px; display: flex; gap: 14px; align-items: center; font-size: 22px; }
.result .box b { font-weight: 850; }
.result .pair { display: flex; gap: 12px; }
.result .pair > div { flex: 1; border-radius: var(--radius-m); padding: 14px; display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.22); color: inherit; box-shadow: none; font-weight: 650; }
.result .pair .n { font-size: 46px; font-weight: 850; line-height: 1; }
.cand { display: flex; gap: 12px; align-items: center; background: #fff; color: #121212; border: 0; border-radius: var(--radius-m);
  padding: 10px; min-height: 76px; text-align: left; font-size: 19px; font-weight: 650; cursor: pointer; width: 100%; }
.cand img, .cand .thumb { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; background: #DDE3EA; }

/* ---------- summary tiles ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { border-radius: var(--radius-m); padding: 14px; display: flex; flex-direction: column; gap: 2px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.stat b { font-size: 40px; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.stat.excess { background: var(--excess); color: #121212; box-shadow: none; }
.stat.bad { background: var(--bad); box-shadow: none; } .stat.unknown { background: var(--unknown); box-shadow: none; }
.stat.ok { background: var(--ok); box-shadow: none; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.item .grow { flex: 1; min-width: 0; }
.item .qty { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
button.item { border: 0; text-align: left; cursor: pointer; width: 100%; color: inherit; font: inherit; }

/* ---------- photo capture ---------- */
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 10px; border-radius: 5px; background: var(--navy); }
.steps span.done { background: var(--ok-strong); } .steps span.now { background: var(--text); }
.shutter-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; background: var(--bg-deep); }
.shutter { width: 92px; height: 92px; border-radius: 50%; border: 6px solid #fff; background: transparent; display: flex;
  align-items: center; justify-content: center; cursor: pointer; }
.shutter span { width: 70px; height: 70px; border-radius: 50%; background: #fff; }
.shutter:disabled { opacity: .4; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius-m); overflow: hidden; background: var(--card); border: 0; padding: 0; cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .lbl { position: absolute; left: 8px; bottom: 8px; background: #fff; color: #121212; font-weight: 750; font-size: 15px; padding: 2px 8px; border-radius: 8px; }
.photo.bad { outline: 4px solid var(--excess); }
.photo .warn { position: absolute; left: 6px; right: 6px; top: 6px; background: var(--excess); color: #121212; font-weight: 750; font-size: 14px; padding: 6px; border-radius: 8px; text-align: center; }
.face-illus { width: 120px; height: 120px; }

/* ---------- toast / dialog ---------- */
.toast { position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 90;
  max-width: 560px; margin: 0 auto; background: var(--text); color: #0A1729; border-radius: var(--radius-m);
  padding: 14px 16px; font-weight: 650; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.err { background: #FFDAD6; }
.dialog-back { position: fixed; inset: 0; z-index: 80; background: rgba(4,10,20,.78); display: flex; align-items: flex-end; justify-content: center; }
.dialog { background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 14px; max-height: 92dvh; overflow-y: auto; }
@media (min-width: 700px) { .dialog-back { align-items: center; } .dialog { border-radius: 22px; } }
.banner { padding: 10px 16px; font-weight: 650; text-align: center; }
.banner.off { background: var(--bad); }
.banner.demo { background: var(--attention); color: #121212; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.tab { min-height: 46px; padding: 0 14px; border-radius: 99px; border: 0; background: var(--card); color: var(--muted); font-weight: 650; cursor: pointer; white-space: nowrap; font-size: 16px; }
.tab.on { background: var(--blue); color: #fff; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--bg-deep); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* ---------- station (fixed camera / conveyor) ---------- */
.station { height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: auto 1fr auto; background: #0B0F16; }
.station header { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--bg-deep); }
.station header .health { margin-left: auto; display: flex; gap: 8px; }
.station .cam { margin: 14px; border-radius: 18px; }
.station .side { display: flex; flex-direction: column; gap: 12px; padding: 14px 14px 14px 0; min-height: 0; }
.station .now { border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; justify-content: center; background: var(--card); }
.station .now.ok { background: var(--ok); } .station .now.bad { background: var(--bad); } .station .now.excess { background: var(--excess); color: #121212; }
.station .now.unknown { background: var(--unknown); }
.station .now .w { font-size: 40px; font-weight: 850; line-height: 1.05; }
.station .now .p { font-size: 22px; font-weight: 650; }
.station .divert { align-self: flex-start; background: #fff; color: #121212; font-weight: 750; padding: 6px 12px; border-radius: 10px; }
.station footer { grid-column: 1 / -1; display: flex; gap: 8px; padding: 0 14px 14px; overflow-x: auto; }
.station footer .ev { min-width: 120px; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 15px; }
@media (max-width: 900px) { .station { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; height: auto; min-height: 100dvh; } .station .cam { height: 50vh; } .station .side { padding: 0 14px; } }

@media (min-width: 900px) { .screen { padding: 28px; } }
.result .row > .big-word:first-child:not(:only-child) { flex-shrink: 0; overflow-wrap: normal; white-space: nowrap; }
.photo .icon-btn { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; background: rgba(4,10,20,.72); }

/* consulta */
.grid2 > .tile { min-height: 132px; }
.grid2 > .tile strong { font-size: 22px; }
.grid2 > .tile span { font-size: 15px; text-align: center; }
.consult-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #0B0F16; border-radius: var(--radius-m); }
.consult-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.consult-thumb { flex: 0 0 72px; height: 72px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--navy); cursor: pointer; }
.consult-thumb.on { border-color: var(--accent); }
.consult-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); border: 2px dashed var(--line); background: transparent; font-weight: 650; }
