/* ==========================================================
   RONDA — app do operador
   Uso em campo: alvos grandes, contraste alto,
   ações na zona do polegar, tema escuro automático.
   ========================================================== */
html, body { height: 100%; }
body { background: var(--paper); overscroll-behavior-y: none; }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Barra superior ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background: #1B2A36; color: #fff;
}
.top .ttl { flex: 1; min-width: 0; }
.top .ttl b { display: block; font-family: var(--cond); font-size: 20px; letter-spacing: .01em; line-height: 1.1; }
.top .ttl span { display: block; font-size: 12.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; display: grid; place-items: center;
  background: rgba(255,255,255,.08); color: inherit; flex: none;
}
.iconbtn:active { background: rgba(255,255,255,.18); }
.iconbtn svg { width: 22px; height: 22px; }

.net { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 99px; background: rgba(255,255,255,.1); white-space: nowrap; }
.net i { width: 8px; height: 8px; border-radius: 50%; background: #4ADE80; box-shadow: 0 0 0 3px rgba(74,222,128,.2); }
.net.off i { background: #F87171; box-shadow: 0 0 0 3px rgba(248,113,113,.2); }
.net.sync i { background: var(--amber); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }

/* ---------- Faixa de progresso (uma marca por equipamento) ---------- */
.strip { display: flex; gap: 3px; padding: 10px 14px 0; }
.strip i { flex: 1; height: 7px; border-radius: 2px; background: var(--idle); min-width: 3px; transition: background .2s; }
.strip i.ok { background: var(--ok); }
.strip i.anomalia { background: var(--bad); }
.strip i.justificado { background: var(--just); }
.strip i.cur { outline: 2px solid var(--amber); outline-offset: 1px; }

/* ---------- Corpo ---------- */
.body { flex: 1; padding: 16px 14px calc(120px + env(safe-area-inset-bottom, 0px)); }
.body.no-bar { padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
h1, h2, h3 { margin: 0; line-height: 1.15; }

.card { background: var(--surface); border-radius: var(--r-md); padding: 16px; box-shadow: var(--shadow-1); }
.block { margin-top: 18px; }
.block > .bh { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 2px 8px; }
.block > .bh h3 { font-size: 15px; font-weight: 700; }
.block > .bh small { color: var(--muted); font-size: 13px; }

/* ---------- Entrada ---------- */
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 6px 6px; }
.brand svg { width: 44px; height: 44px; flex: none; }
.brand b { font-family: var(--cond); font-size: 32px; line-height: 1; display: block; }
.brand span { color: var(--muted); font-size: 14px; }

.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin: 0 2px 6px; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; min-height: 54px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--surface); border: 2px solid var(--line); font-size: 18px; outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--amber); }
.textarea { min-height: 92px; resize: vertical; font-size: 16px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.input.big { font-size: 26px; font-weight: 600; letter-spacing: .04em; }

.turnos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.turnos button {
  border: 2px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 10px 6px 8px;
  display: grid; justify-items: center; gap: 2px; min-height: 70px;
}
.turnos button b { font-family: var(--cond); font-size: 30px; line-height: 1; }
.turnos button small { font-size: 12px; color: var(--muted); }
.turnos button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.turnos button[aria-pressed="true"] small { color: inherit; opacity: .7; }
.turnos button .now { font-size: 10.5px; font-weight: 700; color: var(--amber); }

/* Plaqueta da rota */
.route-plate { margin-top: 14px; padding: 16px 22px 18px; display: flex; align-items: center; gap: 14px; }
.route-plate label { flex: none; font-family: var(--cond); font-weight: 700; font-size: 22px; line-height: 1; opacity: .75; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.route-plate input {
  flex: 1; min-width: 0; width: 100%; border: 0; background: rgba(0,0,0,.08); border-radius: 6px;
  font-family: var(--cond); font-weight: 700; font-size: 58px; line-height: 1; padding: 4px 12px; color: var(--plate-ink);
  text-shadow: 0 1px 0 rgba(255,255,255,.5); box-shadow: inset 0 2px 3px rgba(0,0,0,.18); outline: none;
}
.route-plate input::placeholder { color: rgba(27,42,54,.35); }
.route-plate input:focus { box-shadow: inset 0 2px 3px rgba(0,0,0,.18), 0 0 0 3px var(--amber); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 20px; border-radius: var(--r-sm); border: 2px solid transparent;
  font-weight: 700; font-size: 17px; text-decoration: none; transition: transform .06s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.primary { background: var(--amber); color: #3D2B00; box-shadow: inset 0 -3px 0 rgba(0,0,0,.14); }
.btn.primary:hover { background: var(--amber-hi); }
.btn.danger { background: var(--bad); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.btn.just { background: var(--just); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.block-w { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Barra de ação fixa (zona do polegar) */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.actionbar .in { max-width: 532px; margin: 0 auto; display: flex; gap: 10px; }
.actionbar .btn { flex: 1; white-space: nowrap; font-size: 16px; padding: 0 14px; min-width: 0; }
.actionbar .btn.narrow { flex: 0 0 auto; }

/* ---------- Avisos ---------- */
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); font-size: 14.5px; margin-top: 12px; }
.note svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.note.warn { background: var(--amber-soft); color: var(--ink); }
.note.bad { background: var(--bad-soft); }
.note.info { background: var(--surface); box-shadow: var(--shadow-1); }
.note.ok { background: var(--ok-soft); }
.note .btn { min-height: 40px; font-size: 14px; padding: 0 14px; margin-top: 8px; }

/* ---------- Visão da rota ---------- */
.who { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.who .nm { font-weight: 700; font-size: 17px; }
.who .meta { color: var(--muted); font-size: 13.5px; }
.who .tb { grid-row: span 2; font-family: var(--cond); font-weight: 700; font-size: 15px; background: var(--ink); color: var(--paper); border-radius: 8px; padding: 6px 10px; text-align: center; line-height: 1.05; }
.who .tb b { display: block; font-size: 28px; }

.tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.tally div { background: var(--surface); border-radius: 10px; padding: 8px 6px; text-align: center; box-shadow: var(--shadow-1); }
.tally b { display: block; font-family: var(--cond); font-size: 28px; line-height: 1; }
.tally small { font-size: 11.5px; color: var(--muted); }
.tally .k-ok b { color: var(--ok); } .tally .k-bad b { color: var(--bad); } .tally .k-just b { color: var(--just); }

.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-1); overflow: hidden; }
.items li + li { border-top: 1px solid var(--line-2); }
.items button { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; background: none; border: 0; min-height: 64px; }
.items button:active { background: var(--surface-2); }
.items .n { font-family: var(--cond); font-weight: 600; color: var(--muted); font-size: 16px; text-align: right; }
.items .c { font-family: var(--cond); font-weight: 700; font-size: 21px; line-height: 1; display: block; }
.items .d { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 99px; white-space: nowrap; }
.st.ok { background: var(--ok-soft); color: var(--ok); }
.st.anomalia { background: var(--bad-soft); color: var(--bad); }
.st.justificado { background: var(--just-soft); color: var(--just); }
.st.pend { background: var(--surface-2); color: var(--muted); }
.st svg { width: 14px; height: 14px; }

/* ---------- Tela do equipamento ---------- */
.eq-plate { padding: 20px 26px 18px; }
.eq-plate .top-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.eq-plate .pos { font-family: var(--cond); font-weight: 700; font-size: 15px; opacity: .7; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.eq-plate .tipo { font-family: var(--cond); font-weight: 700; font-size: 14px; padding: 3px 9px; border-radius: 5px; background: var(--plate-ink); color: var(--plate-1); }
.eq-plate .code { font-size: clamp(60px, 19vw, 92px); display: block; word-break: break-all; }
.eq-plate .desc { font-weight: 600; font-size: 15.5px; margin-top: 8px; line-height: 1.3; }

.confirm { display: flex; gap: 8px; align-items: stretch; }
.confirm .input { font-family: var(--cond); font-weight: 700; font-size: 26px; letter-spacing: .04em; text-transform: uppercase; }
.confirm .iconbtn { width: 56px; height: auto; background: var(--ink); color: var(--paper); border-radius: var(--r-sm); }
.confirm.matched .input:not([disabled]) { border-color: var(--ok); background: var(--ok-soft); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
.hint.err { color: var(--bad); font-weight: 600; }
.hint.good { color: var(--ok); font-weight: 600; }

.q { background: var(--surface); border-radius: var(--r-md); padding: 14px; box-shadow: var(--shadow-1); }
.q + .q { margin-top: 10px; }
.q p { margin: 0 0 10px; font-weight: 600; font-size: 16.5px; }
.q p small { font-weight: 500; color: var(--muted); font-size: 13px; }
.sn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sn button { min-height: 58px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface-2); font-weight: 700; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.sn button svg { width: 22px; height: 22px; }
.sn button[data-v="S"][aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.sn button[data-v="N"][aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.numq { display: flex; align-items: center; gap: 10px; }
.numq .input { font-size: 24px; font-weight: 700; max-width: 180px; }
.numq em { font-style: normal; font-weight: 600; color: var(--muted); }
.q.fora { box-shadow: 0 0 0 2px var(--bad), var(--shadow-1); }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos .ph button { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.photos .ph button svg { width: 16px; height: 16px; }
.photos .add { aspect-ratio: 1; border-radius: var(--r-sm); border: 2px dashed var(--ink-2); background: transparent; display: grid; place-items: center; align-content: center; gap: 4px; font-weight: 700; font-size: 13.5px; color: var(--ink-2); }
.photos .add svg { width: 30px; height: 30px; }
.photos .add.req { border-color: var(--amber); background: var(--amber-soft); color: var(--ink); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); padding: 14px; border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.switch b { font-size: 16px; }
.switch small { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.tog { position: relative; width: 58px; height: 34px; flex: none; }
.tog input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.tog span { position: absolute; inset: 0; border-radius: 99px; background: var(--idle); transition: background .15s; }
.tog span::after { content: ''; position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.tog input:checked + span { background: var(--amber); }
.tog input:checked + span::after { transform: translateX(24px); }
.tog input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: 2px; }
.os-num { margin-top: 10px; }

.verdict { margin-top: 16px; padding: 12px 14px; border-radius: var(--r-sm); font-weight: 700; display: flex; align-items: center; gap: 10px; }
.verdict svg { width: 22px; height: 22px; flex: none; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.anomalia { background: var(--bad-soft); color: var(--bad); }
.verdict.wait { background: var(--surface-2); color: var(--muted); }

/* ---------- Painel inferior (sheet) ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(10, 18, 24, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.sheet { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--paper); border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom, 0px)); animation: rise .22s cubic-bezier(.2,.8,.2,1); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--idle); margin: 4px auto 14px; }
.sheet h2 { font-family: var(--cond); font-size: 26px; }
.sheet .sub { color: var(--muted); margin: 4px 0 12px; font-size: 14.5px; }
.sheet .acts { display: flex; gap: 10px; margin-top: 16px; }
.sheet .acts .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }

.motivos { display: grid; gap: 8px; }
.motivos label { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--surface); border: 2px solid var(--line); font-weight: 600; font-size: 15.5px; cursor: pointer; }
.motivos input { width: 22px; height: 22px; accent-color: var(--just); flex: none; }
.motivos label:has(input:checked) { border-color: var(--just); background: var(--just-soft); }

/* Leitor de código */
.scan { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.scan video { flex: 1; width: 100%; object-fit: cover; }
.scan .frame { position: absolute; left: 12%; right: 12%; top: 32%; height: 22%; border: 3px solid var(--amber); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.scan .bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: center; }
.scan p { position: absolute; top: calc(18% + env(safe-area-inset-top, 0px)); left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; }

/* ---------- Final ---------- */
.done { text-align: center; padding: 36px 8px 8px; }
.done .seal { width: 112px; height: 112px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; box-shadow: 0 0 0 10px var(--ok-soft); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.done .seal svg { width: 60px; height: 60px; }
.done h1 { font-family: var(--cond); font-size: 34px; }
.done p { color: var(--muted); max-width: 34ch; margin: 8px auto 0; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); z-index: 70; background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 28px); text-align: center; box-shadow: var(--shadow-2); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); color: #fff; }

.foot { text-align: center; padding: 22px 0 8px; color: var(--muted); font-size: 13px; }
.foot a { color: var(--ink-2); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; min-height: 60vh; color: var(--muted); gap: 10px; }

/* ---------- Ficha do equipamento (QR) ---------- */
.ficha-st { background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow-1); border-left: 6px solid var(--idle); }
.ficha-st.ok { border-left-color: var(--ok); } .ficha-st.anomalia { border-left-color: var(--bad); } .ficha-st.justificado { border-left-color: var(--just); }
.ficha-st small { display: block; color: var(--muted); font-size: 12.5px; }
.ficha-st b { display: block; font-family: var(--cond); font-size: 30px; line-height: 1.05; }
.ficha-st.ok b { color: var(--ok); } .ficha-st.anomalia b { color: var(--bad); } .ficha-st.justificado b { color: var(--just); }
.ficha-st span { color: var(--ink-2); font-size: 14px; }
.ficha-pend { display: flex; gap: 10px; align-items: center; margin-top: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bad-soft); font-weight: 600; font-size: 14px; }
.ficha-pend svg { width: 18px; height: 18px; color: var(--bad); flex: none; }
.ficha-pend.media { background: var(--amber-soft); } .ficha-pend.media svg { color: #9A6B00; }
.hist { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.hist li { display: grid; grid-template-columns: 10px 52px 1fr auto; gap: 10px; align-items: center; padding: 11px 14px; font-size: 14px; }
.hist li + li { border-top: 1px solid var(--line-2); }
.hist b { font-family: var(--cond); font-size: 19px; }
.hist span:not(.st):not(.dot) { color: var(--muted); }
.hist .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--idle); }
.hist .dot.ok { background: var(--ok); } .hist .dot.anomalia { background: var(--bad); } .hist .dot.justificado { background: var(--just); }
.ficha-rotas { display: grid; gap: 8px; }
.ficha-rota { display: grid; grid-template-columns: 54px 1fr 22px; gap: 12px; align-items: center; text-align: left; border: 0; width: 100%; padding: 12px 14px; }
.ficha-rota .n { font-family: var(--cond); font-weight: 700; font-size: 30px; background: var(--ink); color: var(--paper); border-radius: 8px; text-align: center; line-height: 1.4; }
.ficha-rota b { display: block; font-size: 15.5px; }
.ficha-rota small { color: var(--muted); font-size: 13px; }
.ficha-rota svg { width: 22px; height: 22px; color: var(--muted); }
.ficha-ativa { font-size: 15px; }

/* ---------- O.S. na rota ---------- */
.osv { border-left: 6px solid var(--amber); }
.osv-h { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.osv-h svg { width: 26px; height: 26px; color: #9A6B00; flex: none; background: var(--amber-soft); border-radius: 8px; padding: 4px; }
.osv-h b { display: block; font-size: 16px; }
.osv-h small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.osv p { margin: 6px 0 10px; }
.sn button[data-v="ok"][aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.sn button[data-v="reincidente"][aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.os-aberta { display: flex; gap: 12px; align-items: flex-start; background: var(--amber-soft); border-radius: var(--r-md); padding: 12px 14px; }
.os-aberta > svg { width: 22px; height: 22px; color: #9A6B00; flex: none; margin-top: 2px; }
.os-aberta > div { flex: 1; min-width: 0; }
.os-aberta b { display: block; font-size: 15px; }
.os-aberta small { display: block; color: var(--ink-2); font-size: 12.5px; margin-top: 6px; }
.os-l { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 14px; }
.mini { border: 0; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 13px; padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
