:root {
  --brand: #45597c;
  --paper: #f4f5f7;
  --ink: #1c1f26;
  --ok: #1f8a4c;
  --err: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

h1 {
  font-size: 1.4rem;
  color: var(--brand);
  margin-bottom: 0.25rem;
}

.hint {
  color: #666;
  margin-top: 0;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

label {
  font-size: 0.9rem;
  color: #444;
}

input[type="number"],
input[type="text"] {
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  width: 8rem;
}

/* Campos empilhados (label em cima do input) alinhados em colunas — usado
   nos cards de configuracao (lote, opcoes de PDF) em vez de rotular
   inline, que embaralha quando tem varios campos na mesma linha. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field > label,
.field__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.field input {
  width: 100%;
}

/* Campo que precisa da largura toda do card (ex: radios de formato, que nao
   cabem espremidos numa coluna estreita ao lado de outro campo). */
.field--wide {
  grid-column: 1 / -1;
}

.btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn--ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.result {
  min-height: 1.2rem;
  font-size: 0.95rem;
  margin: 0;
}

.result.ok { color: var(--ok); }
.result.error { color: var(--err); }

#one-code-output {
  width: 11rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  background: #f0f1f3;
}

.format-choice {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  min-height: 2.25rem;
}

.format-choice label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.table-wrap {
  max-height: 60vh;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #eee;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

th {
  position: sticky;
  top: 0;
  background: #fff;
  font-family: system-ui, sans-serif;
}

#scan-wrap {
  margin-top: 0.75rem;
}

#scan-video {
  width: 100%;
  max-width: 360px;
  border-radius: 8px;
  background: #000;
  display: block;
  margin-bottom: 0.6rem;
}
