:root {
  --azul-rail: #16305c;
  --azul-rail-hover: #21437a;
  --azul-primario: #2f6fdb;
  --azul-primario-hover: #2557b8;
  --azul-claro: #eaf1fd;
  --fundo-painel: #f5f6f8;
  --fundo-app: #ffffff;
  --texto: #1f2937;
  --texto-secundario: #6b7280;
  --borda: #e5e7eb;
  --verde: #16a34a;
  --amarelo: #d97706;
  --vermelho: #dc2626;
  --raio: 10px;
  --sombra: 0 2px 10px rgba(22, 48, 92, 0.12);
  --sombra-alta: 0 18px 44px rgba(15, 32, 62, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--texto);
  background: var(--fundo-app);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Ícones (sprite <symbol>/<use>) ---------- */

.ico {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-sm { width: 16px; height: 16px; }

/* ---------- Layout do app (rail + painel + área principal) ---------- */

.app {
  display: grid;
  grid-template-columns: 68px 310px 1fr;
  height: 100vh;
}

.rail {
  background: var(--azul-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 14px;
  gap: 4px;
}

.rail-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 14px;
}

.rail-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a8c2ea;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.rail-icon:hover { background: var(--azul-rail-hover); color: #fff; }
.rail-icon.ativo { background: var(--azul-rail-hover); color: #fff; }

.rail-icon.primaria {
  background: #fff;
  color: var(--azul-primario);
  border-radius: 50%;
  margin: 10px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.rail-icon.primaria:hover { background: var(--azul-claro); color: var(--azul-primario-hover); }

.rail-spacer { flex: 1; }

.painel {
  background: var(--fundo-painel);
  border-right: 1px solid var(--borda);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.painel-abas {
  display: flex;
  border-bottom: 1px solid var(--borda);
  background: #fff;
}

.painel-aba {
  flex: 1;
  padding: 15px 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--texto-secundario);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.painel-aba.ativa { color: var(--azul-primario); border-bottom-color: var(--azul-primario); }

.painel-busca { padding: 12px; position: relative; }

.painel-busca-ico {
  position: absolute;
  left: 23px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--texto-secundario);
  width: 18px;
  height: 18px;
}

.painel-busca input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

.painel-busca input:focus,
.campo input:focus,
.campo select:focus {
  outline: 2px solid var(--azul-primario);
  outline-offset: -1px;
  border-color: transparent;
}

.painel-lista { overflow-y: auto; flex: 1; }

.painel-dica {
  margin: 0;
  padding: 10px 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--texto-secundario);
  border-top: 1px solid var(--borda);
  background: #fff;
}

.card-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--borda);
  background: var(--fundo-painel);
}

.card-item[draggable="true"] { cursor: grab; }
.card-item[draggable="true"]:hover { background: #fff; }
.card-item.arrastando { opacity: 0.45; }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.card-item-texto { min-width: 0; }
.card-item strong { display: block; font-size: 14px; }

.card-item span {
  display: block;
  font-size: 12px;
  color: var(--texto-secundario);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lista-vazia {
  padding: 28px 18px;
  text-align: center;
  color: var(--texto-secundario);
  font-size: 13px;
  line-height: 1.6;
}

.area-principal { position: relative; overflow: hidden; }

#vista-mapa, #vista-kanban-wrap { position: absolute; inset: 0; }
#vista-mapa[hidden] { display: none; }

.mapa { width: 100%; height: 100%; }

.mapa-topo {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  z-index: 500;
  pointer-events: none;
}

.mapa-topo > * { pointer-events: auto; }

.mapa-data {
  background: #fff;
  padding: 9px 15px;
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.mapa-data .ico { width: 18px; height: 18px; color: var(--texto-secundario); }

.botao-flutuante {
  background: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  cursor: pointer;
  color: var(--texto);
  display: flex;
  align-items: center;
  justify-content: center;
}

.botao-flutuante:hover { background: var(--azul-claro); color: var(--azul-primario); }

/* ---------- Barra do quadro (data + alerta de rodízio) ---------- */

#vista-kanban-wrap { display: flex; flex-direction: column; }
#vista-kanban-wrap[hidden] { display: none; }

.quadro-topo {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--borda);
  background: #fff;
  flex-shrink: 0;
}

.quadro-data {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  font-weight: 600;
  font-size: 14px;
}

.quadro-data .ico { width: 18px; height: 18px; color: var(--texto-secundario); }
.quadro-data input { border: none; font-family: inherit; font-size: 14px; font-weight: 600; color: inherit; }
.quadro-data input:focus { outline: none; }

.quadro-rodizio { font-size: 13px; flex: 1; min-width: 0; }

.rodizio-alerta {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.rodizio-ok {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.rodizio-neutro { color: var(--texto-secundario); }

.aviso-rodizio {
  margin: 0;
  padding: 8px 14px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
  border-bottom: 1px solid #fecaca;
}

.aviso-previa {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--azul-primario);
  line-height: 1.5;
  min-height: 18px;
}

/* ---------- Blocos de configuração ---------- */

.bloco-config {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--borda);
}

.bloco-config:last-child { border-bottom: none; }
.bloco-config-texto { flex: 1; }

.bloco-config h4 {
  margin: 0 0 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bloco-config h4 .ico { width: 18px; height: 18px; color: var(--azul-primario); }
.bloco-config p { margin: 0; font-size: 12.5px; color: var(--texto-secundario); line-height: 1.6; }

/* ---------- Kanban ---------- */

.kanban {
  display: flex;
  gap: 14px;
  padding: 16px;
  overflow-x: auto;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

.kanban-coluna {
  background: var(--fundo-painel);
  border: 1px solid var(--borda);
  border-radius: 12px;
  width: 288px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.kanban-coluna.pool { background: #eef2f7; }
.kanban-coluna.alvo { border-color: var(--azul-primario); background: var(--azul-claro); }

.kanban-coluna-topo {
  padding: 12px 14px;
  border-bottom: 1px solid var(--borda);
  display: flex;
  align-items: center;
  gap: 10px;
}

.kanban-coluna-topo .avatar { width: 32px; height: 32px; font-size: 12px; }
.kanban-coluna-nome { font-weight: 700; font-size: 14px; flex: 1; min-width: 0; }

.kanban-coluna-nome span {
  display: block;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--texto-secundario);
  margin-top: 2px;
}

.etiqueta-status {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #4b5563;
  white-space: nowrap;
}

.etiqueta-status.sem_rota { background: #e5e7eb; color: #4b5563; }
.etiqueta-status.planejada { background: #fef3c7; color: #92400e; }
.etiqueta-status.em_rota { background: #dbeafe; color: #1e40af; }
.etiqueta-status.concluida { background: #dcfce7; color: #166534; }

.kanban-cards {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 90px;
}

.kanban-card {
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 9px;
  padding: 10px 11px;
  cursor: grab;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.kanban-card:hover { border-color: #c9d4e5; }
.kanban-card.arrastando { opacity: 0.4; }
.kanban-card.concluida { background: #f8fafc; }
.kanban-card.concluida .kanban-card-texto strong { text-decoration: line-through; color: var(--texto-secundario); }

.kanban-card-alca {
  color: #cbd5e1;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 5px;
  display: flex;
}

.kanban-card-alca:hover { color: var(--vermelho); background: #fef2f2; }
.kanban-card-alca .ico { width: 16px; height: 16px; }

.kanban-card-texto { min-width: 0; flex: 1; }
.kanban-card-texto strong { display: block; font-size: 13px; }

.kanban-card-texto span {
  display: block;
  font-size: 11.5px;
  color: var(--texto-secundario);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-ordem {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--azul-claro);
  color: var(--azul-primario);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kanban-coluna-vazia {
  padding: 20px 12px;
  text-align: center;
  font-size: 12px;
  color: #9aa4b2;
  border: 1.5px dashed var(--borda);
  border-radius: 9px;
  line-height: 1.5;
}

/* ---------- Login ---------- */

.tela-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--azul-rail), #0d1f3d);
}

.card-login {
  background: #fff;
  border-radius: 14px;
  padding: 36px 34px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--sombra-alta);
}

.card-login h1 { font-size: 20px; margin: 0 0 4px; }
.card-login p { color: var(--texto-secundario); font-size: 13px; margin: 0 0 24px; }

.campo { margin-bottom: 16px; flex: 1; }

.campo label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.campo-ajuda { font-weight: 400; color: var(--texto-secundario); font-size: 12px; }

.campo input,
.campo select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

.linha-campos { display: flex; gap: 12px; }

.btn-primario {
  width: 100%;
  padding: 11px;
  background: var(--azul-primario);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn-primario:hover { background: var(--azul-primario-hover); }
.btn-primario:disabled { background: #b6c6e3; cursor: not-allowed; }
.btn-auto { width: auto; padding: 10px 20px; }

.btn-secundario {
  padding: 10px 18px;
  background: #fff;
  color: var(--texto);
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn-secundario:hover { background: var(--fundo-painel); }

.erro-login {
  color: var(--vermelho);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

/* ---------- Modais ---------- */

.modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--sombra-alta);
  width: min(460px, calc(100vw - 32px));
  color: var(--texto);
}

.modal-largo { width: min(920px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(15, 23, 42, 0.5); }

.modal-corpo { display: flex; flex-direction: column; max-height: min(86vh, 760px); }

.modal-topo {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--borda);
}

.modal-topo h3 { margin: 0; font-size: 17px; }
.modal-topo p { margin: 4px 0 0; font-size: 12.5px; opacity: 0.85; }
.modal-topo > div:first-child { flex: 1; }

.modal-topo-azul {
  background: var(--azul-primario);
  color: #fff;
  border-bottom: none;
  align-items: center;
}

.modal-limite { font-weight: 400; font-size: 12px; opacity: 0.8; }

.botao-icone {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--texto-secundario);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-self: flex-start;
}

.botao-icone:hover { background: var(--fundo-painel); color: var(--texto); }
.botao-icone.claro { color: rgba(255, 255, 255, 0.85); }
.botao-icone.claro:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.modal-conteudo { padding: 20px; overflow-y: auto; flex: 1; }

.modal-rodape {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--borda);
  background: var(--fundo-painel);
  border-radius: 0 0 14px 14px;
}

.rodape-erro { flex: 1; color: var(--vermelho); font-size: 13px; }

/* ---------- Wizard de importação ---------- */

.passos { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }

.passo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  padding-right: 8px;
}

.passo span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
}

.passo.ativo { color: #fff; }
.passo.ativo span { background: #fff; color: var(--azul-primario); border-color: #fff; }
.passo.concluido span { background: rgba(255, 255, 255, 0.3); color: #fff; }

.passo-painel { display: none; }
.passo-painel.ativo { display: block; }

.area-drop {
  border: 2px dashed #c7d3e6;
  border-radius: 12px;
  padding: 36px 20px;
  text-align: center;
  background: #fbfcfe;
}

.area-drop.sobre { border-color: var(--azul-primario); background: var(--azul-claro); }

.opcoes-import {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 300px;
  margin: 0 auto;
  background: var(--azul-primario);
  border-radius: 10px;
  overflow: hidden;
  padding: 4px;
}

.opcao-import {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  background: transparent;
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 7px;
  font-family: inherit;
}

.opcao-import:hover { background: rgba(255, 255, 255, 0.16); }

.area-drop-nota { margin: 18px 0 0; font-size: 13px; color: var(--texto-secundario); }
.area-drop-nota.ok { color: var(--verde); font-weight: 600; }

.dica-rodape {
  margin: 16px 0 0;
  padding: 12px 14px;
  background: var(--azul-claro);
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #29456e;
}

.secao-nota { margin: 0 0 16px; font-size: 13px; color: var(--texto-secundario); line-height: 1.6; }

.resumo-arquivo {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--fundo-painel);
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 18px;
}

.resumo-arquivo b { display: block; font-size: 11px; color: var(--texto-secundario); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }

.tabela-rolagem { overflow: auto; max-height: 260px; border: 1px solid var(--borda); border-radius: 9px; }
.tabela-rolagem.alta { max-height: 360px; }

.tabela-previa { border-collapse: collapse; font-size: 12.5px; width: 100%; }

.tabela-previa th,
.tabela-previa td {
  border-bottom: 1px solid var(--borda);
  border-right: 1px solid var(--borda);
  padding: 7px 10px;
  text-align: left;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabela-previa th {
  background: var(--fundo-painel);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.tabela-previa tr.linha-cabecalho td { background: var(--azul-claro); font-weight: 700; }

.grade-mapeamento { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grade-mapeamento .campo { margin-bottom: 0; }

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

.marcar-todos { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.revisao-contagem { font-size: 13px; color: var(--texto-secundario); }

@media (max-width: 900px) {
  .app { grid-template-columns: 60px 1fr; }
  .painel { display: none; }
  .grade-mapeamento { grid-template-columns: 1fr; }
}
