/* ScanPro - estilo
   Prioridade: legibilidade sob luz de supermercado, alvos grandes de toque,
   contraste alto. Uma cor de ação forte, resto neutro e disciplinado. */

:root {
  --bg:        #0f1720;
  --surface:   #172230;
  --surface-2: #1f2d3d;
  --line:      #2b3a4d;
  --text:      #eef3f8;
  --text-dim:  #9fb0c3;
  --brand:     #14a06b;   /* verde-mercado, alta visibilidade */
  --brand-ink: #ffffff;
  --info:      #2b7de0;
  --warn:      #e0a02b;
  --danger:    #e0524d;
  --radius:    12px;
  --tap:       52px;      /* altura mínima de toque */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar img { width: 34px; height: 34px; object-fit: contain; }
.topbar h1 { font-size: 1rem; font-weight: 700; margin: 0; letter-spacing: .3px; }
.topbar small { color: var(--text-dim); font-weight: 500; }

.container { max-width: 720px; margin: 0 auto; padding: 16px; }

label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text-dim); }

select, button {
  font-family: inherit;
  font-size: 1rem;
  min-height: var(--tap);
  border-radius: var(--radius);
  width: 100%;
}

select {
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='12' viewBox='0 0 16 12'%3E%3Cpath fill='%239fb0c3' d='M8 12 0 0h16z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

button {
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--brand);
  margin-top: 12px;
  transition: filter .15s ease, transform .05s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.info  { background: var(--info); }
button.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }

button:focus-visible, select:focus-visible, .prop-row:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

#reader {
  margin-top: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  position: relative;
}
#reader video {
  width: 100%;
  display: block;
  max-height: 42vh;      /* não ocupa a tela toda */
  object-fit: cover;
  cursor: pointer;
}
/* Dica de toque para focar */
#reader::after {
  content: "Toque para focar · aproxime o código";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  text-align: center;
  font-size: .8rem;
  color: #fff;
  background: rgba(0,0,0,.45);
  padding: 6px 0;
  pointer-events: none;
}

.card {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.card .meta { color: var(--text-dim); font-size: .92rem; margin-bottom: 12px; }
.card .meta b { color: var(--text); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions button { margin-top: 0; }
.actions .full { grid-column: 1 / -1; }

.table-wrap {
  margin-top: 14px;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
tbody tr:nth-child(odd) { background: rgba(255,255,255,.02); }
th { color: var(--text-dim); font-weight: 600; width: 52%; }

/* Modais */
.modal {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px; z-index: 20;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); width: 100%; max-width: 560px;
  max-height: 86vh; overflow: hidden; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.modal-head img { width: 26px; height: 26px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-body img { width: 100%; border-radius: 8px; }
.btn-x {
  width: auto; min-height: auto; background: none; color: var(--text-dim);
  font-size: 1.4rem; line-height: 1; padding: 4px 8px; margin: 0;
}

/* Proporcionais — cada item vira um cartão empilhado (bom no celular) */
.prop-list { display: flex; flex-direction: column; gap: 10px; }

.prop-card {
  width: 100%;
  text-align: left;
  min-height: auto;
  margin: 0;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
}
.prop-card:hover { filter: brightness(1.08); }
.prop-card:active { transform: translateY(1px); }

.prop-desc {
  font-weight: 700;
  font-size: 1rem;
  color: var(--brand);
  margin-bottom: 6px;
  line-height: 1.25;
}
.prop-ids {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  color: var(--text-dim); font-size: .88rem; margin-bottom: 10px;
}
.prop-ids b { color: var(--text); font-weight: 600; }

.prop-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.prop-stats span { display: flex; flex-direction: column; gap: 2px; }
.prop-stats i { font-style: normal; color: var(--text-dim); font-size: .78rem; }
.prop-stats b { font-size: 1.05rem; font-weight: 700; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-left: 4px solid var(--warn);
  border-radius: 10px; padding: 12px 16px;
  max-width: calc(100vw - 24px);   /* nunca estoura a tela */
  width: max-content;              /* cresce conforme o texto */
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40;
  display: flex; align-items: center; gap: 10px;
}
.toast #toast-msg { white-space: nowrap; }  /* mensagem em linha única */
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast img { width: 22px; height: 22px; flex-shrink: 0; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Busca manual por código digitado */
.manual-search { display:flex; gap:8px; margin-top:10px; }
.manual-search input {
  flex:1; min-height:var(--tap); padding:0 14px; font-size:1rem;
  background:var(--surface-2); color:var(--text);
  border:1px solid var(--line); border-radius:var(--radius);
}
.manual-search input:disabled { opacity:.45; }
.manual-search button { width:auto; margin-top:0; padding:0 20px; }

/* Portão de PIN */
.pin-gate {
  position:fixed; inset:0; z-index:60; background:var(--bg);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.pin-box {
  background:var(--surface); border:1px solid var(--line); border-radius:16px;
  padding:28px; width:100%; max-width:320px; text-align:center;
}
.pin-box img { width:84px; height:auto; margin-bottom:8px; }
.pin-box h2 { margin:.2rem 0; font-size:1.2rem; }
.pin-box p { color:var(--text-dim); font-size:.9rem; margin-top:0; }
.pin-box input {
  width:100%; min-height:var(--tap); margin-top:12px; padding:0 14px;
  font-size:1.4rem; text-align:center; letter-spacing:.3em;
  background:var(--surface-2); color:var(--text);
  border:1px solid var(--line); border-radius:var(--radius);
}
.pin-error { color:var(--danger, #e0524d); margin-top:10px; font-size:.9rem; }
