:root {
  --bg: #0f0f13;
  --bg2: #17171f;
  --bg3: #1e1e28;
  --surface: #23232f;
  --surface2: #2a2a38;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #5c5c78;
  --accent: #4f8ef7;
  --accent2: #2d5fc4;
  --green: #22c98a;
  --green2: #156a4a;
  --amber: #f5a623;
  --red: #e05252;
  --sidebar-w: 220px;
  --radius: 10px;
  --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── LAYOUT ───────────────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent);
}
.brand-sub {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: none;
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: all 0.15s;
  width: 100%;
}
.nav-btn:hover { background: var(--surface); color: var(--text); }
.nav-btn.active { background: var(--surface2); color: var(--text); font-weight: 500; }
.nav-btn svg { flex-shrink: 0; }

.sidebar-lote {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}
.lote-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.sidebar-lote select {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}
.btn-novo-lote {
  width: 100%;
  margin-top: 6px;
  padding: 7px;
  background: none;
  border: 1px dashed var(--border2);
  color: var(--text2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-novo-lote:hover { border-color: var(--accent); color: var(--accent); }

/* ── MAIN ─────────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
}

.tab-section { display: none; }
.tab-section.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 { font-size: 20px; font-weight: 600; }

.lote-ativo-badge {
  font-size: 12px;
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  color: var(--text2);
}

/* ── STATS ────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
}
.stat-card.accent { border-color: rgba(79,142,247,0.3); background: rgba(79,142,247,0.07); }
.stat-val { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-card.accent .stat-val { color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ── CARD ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── IMPORT ───────────────────────────────────────────────────────────────── */
.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 700px) { .import-grid { grid-template-columns: 1fr; } }

.drop-zone {
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text2);
  font-size: 13px;
  transition: all 0.2s;
}
.drop-zone:hover { border-color: var(--accent); color: var(--accent); background: rgba(79,142,247,0.04); }
.drop-zone svg { opacity: 0.5; }
.drop-zone:hover svg { opacity: 1; }

.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text2);
}
.file-item .badge-tipo {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
}
.badge-nf { background: rgba(34,201,138,0.15); color: var(--green); }
.badge-et { background: rgba(79,142,247,0.15); color: var(--accent); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.btn-rm { background: none; border: none; color: var(--text3); cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; }
.btn-rm:hover { color: var(--red); }

.import-actions { margin-top: 1.5rem; display: flex; gap: 10px; }

.import-log {
  margin-top: 1.5rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  max-height: 300px;
  overflow-y: auto;
}
.log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.log-item:last-child { border-bottom: none; }
.log-ok { color: var(--green); }
.log-err { color: var(--red); }
.log-arquivo { color: var(--text2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── PEDIDOS LIST ─────────────────────────────────────────────────────────── */
.pedidos-filtros { display: flex; gap: 10px; }
.input-busca {
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 280px;
}
.input-busca:focus { outline: none; border-color: var(--accent); }
.pedidos-filtros select {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}

.pedido-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.pedido-row:hover { border-color: var(--border2); }
.pedido-nome { font-weight: 500; font-size: 14px; }
.pedido-num { font-size: 11px; color: var(--text2); font-family: monospace; margin-top: 2px; }
.pedido-prod { font-size: 12px; color: var(--text2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rastreio-txt { font-size: 12px; font-family: monospace; color: var(--text2); }

.status-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.s-pendente { background: rgba(255,255,255,0.07); color: var(--text2); }
.s-separado { background: rgba(245,166,35,0.15); color: var(--amber); }
.s-expedido { background: rgba(34,201,138,0.15); color: var(--green); }
.s-pronto { background: rgba(79,142,247,0.15); color: var(--accent); }
.s-problema { background: rgba(224,82,82,0.15); color: var(--red); }

.completude-dots { display: flex; gap: 4px; align-items: center; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-ok { background: var(--green); }
.dot-no { background: var(--border2); }
.dot-label { font-size: 10px; color: var(--text3); }

/* ── SEPARAÇÃO ────────────────────────────────────────────────────────────── */
.sep-container { max-width: 600px; }
.sep-label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.8px; }
.sep-row { display: flex; gap: 10px; margin-bottom: 1.5rem; }
.inp-sep {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  font-family: monospace;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius);
  letter-spacing: 1px;
}
.inp-sep:focus { outline: none; border-color: var(--accent); }
.sep-input-box { margin-bottom: 1rem; }

.sep-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sep-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sep-card-nome { font-size: 18px; font-weight: 700; }
.sep-card-body { padding: 1.25rem; }

/* grid de informações da separação */
.sep-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.sep-info-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.sep-info-full { grid-column: 1 / -1; }
.sep-info-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.sep-info-val {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.sep-info-mono { font-family: monospace; letter-spacing: 0.5px; }
.sep-rastreio-big {
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--accent);
}

.produto-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(34,201,138,0.08);
  border: 1px solid rgba(34,201,138,0.2);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.prod-icon { font-size: 20px; }
.prod-desc { font-size: 14px; font-weight: 500; color: var(--green); flex: 1; }
.prod-qtd { font-size: 12px; color: var(--green); }

.sep-info-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.sep-info-row:last-child { border-bottom: none; }
.sep-info-label { color: var(--text2); }
.sep-info-val { font-family: monospace; }

.sep-actions { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px; 
  padding: 1.25rem; 
  border-top: 1px solid var(--border); 
}

/* botões de ação da separação */
.btn-sep {
  flex: 1;
  justify-content: center;
  padding: 12px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
  transition: all 0.2s;
}
.btn-sep:hover { border-color: var(--green); color: var(--green); background: rgba(34,201,138,0.1); }
.btn-sep.btn-sep-active, .btn-sep:active { background: rgba(34,201,138,0.15); border-color: var(--green); color: var(--green); }

.btn-sep-blue { border-color: var(--border2); }
.btn-sep-blue:hover { border-color: var(--accent); color: var(--accent); background: rgba(79,142,247,0.1); }
.btn-sep-blue.btn-sep-active { background: rgba(79,142,247,0.15); border-color: var(--accent); color: var(--accent); }

.btn-sep-red { border-color: var(--border2); }
.btn-sep-red:hover { border-color: var(--red); color: var(--red); background: rgba(224,82,82,0.1); }
.btn-sep-red.btn-sep-active { background: rgba(224,82,82,0.15); border-color: var(--red); color: var(--red); }

/* ── BOTÕES ───────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface2); border-color: var(--border2); }
.btn-primary { background: var(--accent2); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-green { background: var(--green2); border-color: var(--green); color: #fff; }
.btn-green:hover { background: var(--green); }
.btn-danger { background: rgba(224,82,82,0.15); border-color: var(--red); color: var(--red); }

/* ── MISC ─────────────────────────────────────────────────────────────────── */
.empty-msg { color: var(--text3); font-size: 13px; text-align: center; padding: 2rem 0; }
.alert-info {
  background: rgba(79,142,247,0.1);
  border: 1px solid rgba(79,142,247,0.3);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 1rem;
}
.alert-err {
  background: rgba(224,82,82,0.1);
  border: 1px solid rgba(224,82,82,0.3);
  color: var(--red);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ── MODAL ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 380px;
  max-width: 90vw;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 1rem; }
.field-label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 6px; }
.inp-modal {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 1rem;
}
.inp-modal:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── DASH RECENTES ────────────────────────────────────────────────────────── */
.recente-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.recente-item:last-child { border-bottom: none; }
