:root {
  --azul: #1d4e89;
  --azul-claro: #2f6fb8;
  --ambar: #ba7517;
  --verde: #1d9e75;
  --vermelho: #c0392b;
  --bg: #0f1623;
  --surface: #1a2332;
  --surface-2: #232f42;
  --linha: #2d3a4f;
  --txt: #eef2f8;
  --txt-2: #9fb0c7;
  --raio: 12px;
  --sombra: 0 4px 16px rgba(0,0,0,.25);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef1f6; --surface: #ffffff; --surface-2: #f3f6fb;
    --linha: #dde3ec; --txt: #16202e; --txt-2: #5e6b7e; --sombra: 0 2px 10px rgba(20,40,80,.08);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--txt); line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--azul-claro); }
h1,h2,h3 { font-weight: 600; line-height: 1.25; }

/* ===== Layout base ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--azul); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  box-shadow: var(--sombra);
}
.topbar .titulo { font-size: 17px; font-weight: 600; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; opacity: .85; font-weight: 400; }
.icon-btn { background: rgba(255,255,255,.15); border: 0; color: #fff; width: 38px; height: 38px;
  border-radius: 10px; font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:active { transform: scale(.94); }

.layout { display: flex; min-height: 100vh; }
.nav {
  width: 230px; background: var(--surface); border-right: 1px solid var(--linha);
  padding: 12px 8px; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0;
}
.nav a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  color: var(--txt); text-decoration: none; font-size: 15px; margin-bottom: 2px; }
.nav a.ativo { background: var(--azul); color: #fff; }
.nav a:not(.ativo):active { background: var(--surface-2); }
.nav .ic { width: 22px; text-align: center; }
.conteudo { flex: 1; min-width: 0; }
.container { max-width: 1000px; margin: 0 auto; padding: 16px; }

.menu-btn { display: none; }
.nav-backdrop { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: grid; }
  .nav {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
    transform: translateX(-100%); transition: transform .22s ease; width: 260px;
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .nav.aberta { transform: translateX(0); box-shadow: var(--sombra); }
  .nav-backdrop.aberta { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
}

/* ===== Componentes ===== */
.card { background: var(--surface); border: 1px solid var(--linha); border-radius: var(--raio);
  box-shadow: var(--sombra); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { text-align: left; }
.stat .num { font-size: 30px; font-weight: 700; }
.stat .lbl { color: var(--txt-2); font-size: 13px; }
.stat.alerta .num { color: var(--vermelho); }

label { display: block; font-size: 13px; color: var(--txt-2); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--linha); border-radius: 10px;
  background: var(--surface-2); color: var(--txt); font-size: 16px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-claro); border-color: var(--azul-claro); }
textarea { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border: 0; border-radius: 10px; background: var(--azul); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.full { width: 100%; }
.btn.sec { background: var(--surface-2); color: var(--txt); border: 1px solid var(--linha); }
.btn.verde { background: var(--verde); }
.btn.vermelho { background: var(--vermelho); }
.btn.ambar { background: var(--ambar); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 8px 12px; font-size: 13px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.b-recebida, .b-notificada { background: rgba(186,117,23,.18); color: var(--ambar); }
.b-retirada { background: rgba(29,158,117,.18); color: var(--verde); }
.b-devolvida { background: rgba(192,57,43,.18); color: var(--vermelho); }
.b-perfil { background: var(--surface-2); color: var(--txt-2); border: 1px solid var(--linha); }

.lista-item { display: flex; gap: 12px; align-items: center; padding: 12px;
  border: 1px solid var(--linha); border-radius: 12px; margin-bottom: 10px; background: var(--surface);
  cursor: pointer; }
.lista-item:active { background: var(--surface-2); }
.thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: var(--surface-2);
  flex-shrink: 0; display: grid; place-items: center; color: var(--txt-2); font-size: 22px; }
.lista-item .info { flex: 1; min-width: 0; }
.lista-item .info .t { font-weight: 600; }
.lista-item .info .s { color: var(--txt-2); font-size: 13px; }
.lista-item .info .pin-mini b { color: var(--azul-claro); letter-spacing: 1px; font-family: ui-monospace, monospace; }

.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th, .tabela td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--linha); }
.tabela th { color: var(--txt-2); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.scroll-x { overflow-x: auto; }

.muted { color: var(--txt-2); }
.center { text-align: center; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.pill-pin { font-family: ui-monospace, monospace; font-size: 26px; letter-spacing: 4px;
  font-weight: 700; color: var(--azul-claro); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, var(--azul) 0%, var(--bg) 60%); }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--sombra);
  padding: 28px 24px; width: 100%; max-width: 380px; }
.login-card .logo { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 14px; display: block; }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 100;
  background: var(--surface-2); color: var(--txt); border: 1px solid var(--linha);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--sombra); max-width: 90%; font-size: 14px; }
.toast.erro { border-color: var(--vermelho); color: var(--vermelho); }
.toast.ok { border-color: var(--verde); color: var(--verde); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60;
  display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--sombra);
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; padding: 20px; }
.modal h3 { margin-top: 0; }

canvas.assinatura { width: 100%; height: 160px; border: 1px dashed var(--linha);
  border-radius: 10px; background: var(--surface-2); touch-action: none; }
img.preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px;
  background: var(--surface-2); margin-top: 8px; }
.foto-grande { width: 100%; border-radius: 12px; background: var(--surface-2); }

/* passos do formulário */
.passo { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; margin: 20px 0 6px; }
.passo-n { width: 23px; height: 23px; border-radius: 50%; background: var(--azul); color: #fff;
  font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }

/* captura de foto */
.captor { margin-top: 6px; }
.captor-acoes { display: flex; gap: 10px; flex-wrap: wrap; }
.captor-acoes .btn { flex: 1; min-width: 150px; padding: 14px; }
.captor-prev { width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px;
  background: var(--surface-2); }

/* câmera ao vivo */
.cam-overlay { position: fixed; inset: 0; z-index: 200; background: #000;
  display: flex; flex-direction: column; }
.cam-video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.cam-barra { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); background: #000; }
.cam-shot { width: 66px; height: 66px; border-radius: 50%; border: 5px solid #fff;
  background: #fff; cursor: pointer; flex-shrink: 0; }
.cam-shot:active { transform: scale(.93); }

.banner { background: var(--surface-2); border: 1px solid var(--linha); border-left: 4px solid var(--ambar);
  border-radius: 0 10px 10px 0; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.empty { text-align: center; color: var(--txt-2); padding: 40px 16px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--linha); border-top-color: var(--azul-claro);
  border-radius: 50%; animation: gira .8s linear infinite; margin: 40px auto; }
@keyframes gira { to { transform: rotate(360deg); } }
