:root {
  --cor-primaria: #650c0d;
  --cor-escura: #000000;
  --bg: #f4f6f8;
  --card: #ffffff;
  --texto: #1a1a1a;
  --borda: #dde3e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--texto);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cor-primaria);
  color: white;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 1.2rem; margin: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 60px;
}

.panel {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.panel h2 {
  font-size: 1rem;
  margin: 0 0 12px 0;
  color: var(--cor-escura);
}

.hidden { display: none; }

label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: #555;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--borda);
  border-radius: 8px;
  margin-top: 4px;
  background: white;
  font-family: inherit;
}

.dica {
  font-size: 0.85rem;
  color: #666;
  margin: 4px 0 12px;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-row input { flex: 1; }

.btn {
  border: 1px solid var(--borda);
  background: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.btn.primary {
  background: var(--cor-primaria);
  color: white;
  border-color: var(--cor-primaria);
}

.btn.primary:active { background: var(--cor-escura); }

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

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: white;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  animation: girar 0.7s linear infinite;
}

.spinner.hidden { display: none; }

.btn:not(.primary) .spinner {
  border-color: rgba(0, 0, 0, 0.2);
  border-top-color: var(--cor-primaria);
}

@keyframes girar {
  to { transform: rotate(360deg); }
}

.btn-imprimir { width: 100%; margin-top: 12px; font-weight: bold; }

.lista-resultados, .lista-fila {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-card {
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.item-info { flex: 1; }
.item-info .cod { font-weight: bold; }
.item-info .desc { font-size: 0.9rem; color: #555; }

.item-card input.copias {
  width: 50px;
  padding: 8px;
  text-align: center;
  border: 1px solid var(--borda);
  border-radius: 6px;
}

.item-card .remover {
  background: none;
  border: none;
  color: #c0392b;
  font-size: 1.2rem;
  cursor: pointer;
}

.form-ficha {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}

.form-ficha textarea {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--borda);
  border-radius: 8px;
  margin-top: 4px;
  background: white;
  font-family: inherit;
  resize: vertical;
}

.grid-2, .grid-3 {
  display: grid;
  gap: 8px;
}

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.item-info .cliente { font-size: 0.9rem; color: #555; }

.vazio { color: #888; font-size: 0.9rem; }

.status {
  text-align: center;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.status.ok { color: #1e7e34; }
.status.erro { color: #c0392b; }

#printArea { display: none; }

@media print {
  .topbar, #configPanel, main { display: none !important; }
  #printArea { display: block; }

  .label-print {
    box-sizing: border-box;
    padding: 4mm;
    page-break-after: always;
    display: flex;
    flex-direction: column;
    gap: 2.2mm;
    font-family: Arial, sans-serif;
  }
  .label-print .lp-cabecalho { display: flex; justify-content: space-between; align-items: flex-start; gap: 3mm; border-bottom: 0.3mm solid #000; padding-bottom: 1.5mm; }
  .label-print .lp-empresa-topo { display: flex; flex-direction: column; align-items: flex-start; flex-shrink: 0; }
  .label-print .lp-marca { display: flex; align-items: center; gap: 2mm; }
  .label-print .lp-logo { height: 8mm; width: auto; display: block; }
  .label-print .lp-empresa { font-size: 4.5mm; font-weight: bold; }
  .label-print .lp-pedido-header { display: flex; flex-direction: column; align-items: flex-end; text-align: right; min-width: 0; width: 65%; }
  .label-print .lp-pedido-label { font-size: 2.6mm; color: #333; text-transform: uppercase; letter-spacing: 0.3px; }
  .label-print .lp-pedido-numero { font-size: 6mm; font-weight: 800; line-height: 1.05; word-break: break-all; }
  .label-print .lp-pedido-header svg { display: block; width: 100%; height: auto; margin-top: 0.8mm; }
  .label-print .lp-pedido-sub { font-size: 2.6mm; color: #333; margin-top: 0.8mm; }
  .label-print .lp-cliente { font-size: 3.2mm; line-height: 1.3; border-bottom: 0.3mm solid #000; padding-bottom: 1.5mm; }
  .label-print .lp-cliente div:first-child { font-weight: bold; }
  .label-print .lp-linha { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 4mm; border-bottom: 0.3mm solid #000; padding-bottom: 1.5mm; }
  .label-print .lp-descricao-linha { grid-template-columns: 1fr; }
  .label-print .lp-label { font-size: 2.6mm; color: #333; }
  .label-print .lp-valor { font-size: 3.4mm; font-weight: bold; margin: 0.5mm 0 1mm; }
  .label-print svg { display: block; max-width: 100%; height: auto; margin-top: 0.5mm; }
  .label-print .lp-observacao { font-size: 3mm; }
}

