:root {
  --bg: #14171c;
  --panel: #1d222a;
  --panel-2: #262d38;
  --border: #333c48;
  --text: #e7ebf0;
  --muted: #93a0b0;
  --accent: #e8792c;
  --accent-2: #f0a058;
  --ok: #4caf76;
  --warn: #d9a441;
  --danger: #e0574f;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.3px;
}

header h1 span { color: var(--accent); }

nav {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

nav button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

nav button.active {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}

.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}

textarea { resize: vertical; min-height: 60px; }

.field { margin-bottom: 12px; }

button.btn {
  background: var(--accent);
  color: #1a1204;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button.btn.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.btn.danger {
  background: var(--danger);
  color: #fff;
}

button.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Tabelas com muitas colunas (ex: Histórico) rolam na horizontal em vez de
   estourar a largura do card e quebrar o layout da página em telas menores. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 900px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 500; }

tr:hover td { background: var(--panel-2); }

.processos-lista .linha {
  display: grid;
  grid-template-columns: 40px 2fr 1fr 1fr 1fr 1fr 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.processos-header {
  display: grid;
  grid-template-columns: 40px 2fr 1fr 1fr 1fr 1fr 32px;
  gap: 8px;
  padding: 0 0 6px 2px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
}

.notas-tecnicas {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 14px;
}

.notas-tecnicas .nota-item {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.notas-tecnicas .nota-item:last-child { border-bottom: none; }

.notas-tecnicas .nota-label {
  flex: 0 0 120px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding-top: 1px;
}

.notas-tecnicas .nota-valor { flex: 1; }

.t-linha-msg {
  display: inline-block;
  margin-left: 10px;
  font-size: 11px;
}

.t-linha-msg.aviso-inline { color: var(--ok); }
.t-linha-msg.erro-inline { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge.rascunho { background: #3a3f4a; color: var(--muted); }
.badge.enviado { background: #3d3620; color: var(--warn); }
.badge.aprovado { background: #1f3a2a; color: var(--ok); }
.badge.recusado { background: #3a2323; color: var(--danger); }

.badge.manual { background: #23303a; color: #7fb7d8; }
.badge.ia { background: #2f2440; color: #c69bf0; }
.badge.historico { background: #2e2e1a; color: #cbc36a; }

.similares-painel {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-2);
}

.similares-painel .similares-titulo {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.similares-painel .linha-similar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.similares-painel .linha-similar:last-child { border-bottom: none; }

.similares-painel .linha-similar .peca-nome {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.similares-painel .linha-similar .peca-preco {
  color: var(--accent-2);
  white-space: nowrap;
}

.total-box {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  margin-top: 12px;
  font-size: 14px;
}

.total-box b { color: var(--accent-2); }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}

.dropzone.drag { border-color: var(--accent); color: var(--text); }

.aviso {
  background: #2a2410;
  border: 1px solid #55461a;
  color: var(--warn);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.erro {
  background: #2f1616;
  border: 1px solid #5a2626;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

.filtros {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.muted { color: var(--muted); font-size: 12px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
}

.modal-header h3 { margin: 0; }

.detalhe-secao { margin-top: 16px; }
.detalhe-secao h4 { margin: 0 0 8px 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.detalhe-linha { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detalhe-linha:last-child { border-bottom: none; }
.detalhe-linha .label { color: var(--muted); }
.detalhe-total { font-weight: 600; font-size: 15px; }
