/* =============================================================================
   Fretes · Grupo TREMED — design system v2
   Direção: "logística de precisão" — sidebar verde-petróleo com rota pontilhada,
   conteúdo em papel claro, números em mono, âmbar só pra destacar o vencedor.
   ========================================================================== */

:root {
  --tinta: #0d2f30;
  --tinta-2: #124240;
  --tinta-3: #1a5a55;
  --papel: #f2f3ef;
  --card: #ffffff;
  --texto: #16302c;
  --suave: #63736d;
  --linha: #e4e6df;
  --verde: #0e7a5f;
  --verde-escuro: #0a5c48;
  --verde-claro: #e2f1ea;
  --ambar: #d98e2b;
  --ambar-claro: #fdf3e3;
  --erro: #b3372e;
  --erro-claro: #fbeae8;
  --sombra: 0 1px 2px rgba(13, 47, 48, .05), 0 8px 24px -12px rgba(13, 47, 48, .18);
  --sombra-alta: 0 2px 4px rgba(13, 47, 48, .07), 0 20px 44px -16px rgba(13, 47, 48, .28);
  --fonte-display: "Bricolage Grotesque", "Segoe UI", sans-serif;
  --fonte-corpo: "Instrument Sans", "Segoe UI", sans-serif;
  --fonte-mono: "Spline Sans Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--fonte-corpo);
  background: var(--papel);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------------------------------------------------------------- sidebar */
.lateral {
  position: fixed; inset: 0 auto 0 0; width: 228px;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(26, 90, 85, .55) 0%, transparent 60%),
    linear-gradient(168deg, var(--tinta) 0%, #0a2425 100%);
  color: #e8efe9;
  display: flex; flex-direction: column;
  padding: 26px 0 18px;
  overflow: hidden;
  z-index: 10;
}
.lateral::after { /* rota pontilhada atravessando a lateral */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='228' height='900' viewBox='0 0 228 900'%3E%3Cpath d='M -20 640 C 90 600 40 520 130 470 S 260 360 190 300 S 60 220 150 150' fill='none' stroke='%23378a7c' stroke-opacity='.35' stroke-width='1.6' stroke-dasharray='2 7' stroke-linecap='round'/%3E%3Ccircle cx='150' cy='150' r='3.5' fill='%23d98e2b' fill-opacity='.85'/%3E%3Ccircle cx='-20' cy='640' r='3' fill='%23378a7c' fill-opacity='.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: bottom left;
}
.logo { padding: 0 24px 26px; position: relative; z-index: 1; }
.logo .marca {
  font-family: var(--fonte-display); font-weight: 700; font-size: 21px;
  letter-spacing: .01em; color: #fff; display: flex; align-items: baseline; gap: 7px;
}
.logo .marca small {
  font-family: var(--fonte-mono); font-size: 10.5px; font-weight: 600;
  color: var(--ambar); letter-spacing: .18em; text-transform: uppercase;
}
.logo .tag { font-size: 11.5px; color: #9db4ab; margin-top: 2px; }

.menu { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; position: relative; z-index: 1; }
.menu a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 9px;
  color: #c3d2c9; text-decoration: none; font-size: 14px; font-weight: 500;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.menu a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.menu a:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.menu a.ativo {
  background: rgba(255, 255, 255, .1); color: #fff;
  box-shadow: inset 3px 0 0 var(--ambar);
}
.lateral .rodape {
  margin-top: auto; padding: 0 24px; position: relative; z-index: 1;
  font-size: 11px; color: #7e948a; line-height: 1.5;
}

/* --------------------------------------------------------------- conteúdo */
.conteudo { margin-left: 228px; padding: 34px 44px 64px; max-width: 1180px; }
.topo { margin-bottom: 26px; }
.topo h1 {
  font-family: var(--fonte-display); font-weight: 700; font-size: 30px;
  letter-spacing: -.015em; margin: 0 0 4px;
}
.topo .sub { color: var(--suave); font-size: 14.5px; margin: 0; }

/* stagger de entrada */
@keyframes surgir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.surgir { animation: surgir .5s cubic-bezier(.22, .8, .36, 1) both; }
.surgir:nth-child(2) { animation-delay: .06s; }
.surgir:nth-child(3) { animation-delay: .12s; }
.surgir:nth-child(4) { animation-delay: .18s; }
.surgir:nth-child(5) { animation-delay: .24s; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--card); border: 1px solid var(--linha); border-radius: 14px;
  box-shadow: var(--sombra); padding: 24px;
}
.card h2 {
  font-family: var(--fonte-display); font-size: 17px; font-weight: 600;
  margin: 0 0 16px; letter-spacing: -.01em;
}
.grade-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 18px 20px 16px; }
.kpi .rotulo {
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--suave); margin-bottom: 8px;
}
.kpi .valor {
  font-family: var(--fonte-mono); font-size: 24px; font-weight: 600;
  letter-spacing: -.02em; line-height: 1.1;
}
.kpi .extra { font-size: 12px; color: var(--suave); margin-top: 5px; }
.kpi.destaque { background: linear-gradient(150deg, var(--tinta) 0%, var(--tinta-2) 100%); border: none; color: #fff; }
.kpi.destaque .rotulo { color: #a9c0b6; }
.kpi.destaque .extra { color: #9db4ab; }
.kpi.destaque .valor { color: #fff; }

.grade-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; align-items: start; }

/* ----------------------------------------------------------------- gráfico */
.grafico { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.grafico .coluna { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.grafico .barra {
  width: 100%; max-width: 34px; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--tinta-3), var(--tinta-2));
  transition: transform .18s ease, filter .18s ease;
  transform-origin: bottom; animation: crescer .7s cubic-bezier(.22, .8, .36, 1) both;
}
@keyframes crescer { from { transform: scaleY(0); } }
.grafico .coluna:hover .barra { filter: brightness(1.25); }
.grafico .coluna.max .barra { background: linear-gradient(180deg, #e9a94f, var(--ambar)); }
.grafico .mes {
  font-family: var(--fonte-mono); font-size: 9.5px; color: var(--suave);
  white-space: nowrap; overflow: hidden; max-width: 100%;
}

/* barras horizontais (ranking de gasto) */
.ranking-gasto { display: flex; flex-direction: column; gap: 12px; }
.ranking-gasto .item .linha1 { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; gap: 8px; }
.ranking-gasto .item .nome { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-gasto .item .num { font-family: var(--fonte-mono); font-size: 12px; color: var(--suave); flex: none; }
.ranking-gasto .trilho { height: 7px; background: var(--papel); border-radius: 4px; overflow: hidden; }
.ranking-gasto .preenchido {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--tinta-3), var(--verde));
}
.ranking-gasto .item.inativa .preenchido { background: #c9d2cb; }
.ranking-gasto .item.inativa .nome { color: var(--suave); }

/* ------------------------------------------------------------------- form */
.cotacao-layout > * { min-width: 0; } /* deixa as colunas do grid encolherem (evita overflow) */
.volume-linha input, .form-grade input, .form-grade select { min-width: 0; }
.form-grade { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.campo { display: flex; flex-direction: column; gap: 5px; }
.campo.linha-toda { grid-column: 1 / -1; }
.campo label { font-size: 12.5px; font-weight: 600; color: var(--texto); }
.campo .dica-campo { font-size: 11.5px; color: var(--suave); }
.campo input, .campo select {
  font-family: var(--fonte-corpo); font-size: 14.5px; color: var(--texto);
  padding: 10px 12px; border: 1.5px solid var(--linha); border-radius: 9px;
  background: #fff; outline: none; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.campo input:focus, .campo select:focus {
  border-color: var(--verde); box-shadow: 0 0 0 3px rgba(14, 122, 95, .14);
}
.chip-cidade {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; color: var(--verde-escuro);
  background: var(--verde-claro); border-radius: 20px; padding: 3px 10px;
  animation: surgir .3s ease both;
}
.chip-cidade:empty { display: none; }

/* seletor segmentado (remetente) */
.segmentos { display: inline-flex; background: var(--papel); border: 1.5px solid var(--linha); border-radius: 10px; padding: 3px; gap: 3px; }
.segmentos button {
  font-family: var(--fonte-corpo); font-size: 13.5px; font-weight: 600;
  border: none; background: transparent; color: var(--suave);
  padding: 7px 18px; border-radius: 7px; cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.segmentos button.ativo { background: #fff; color: var(--tinta); box-shadow: 0 1px 4px rgba(13, 47, 48, .14); }

/* volumes (linhas dinâmicas) */
.volumes-tabela { display: flex; flex-direction: column; gap: 8px; }
.volume-linha { display: grid; grid-template-columns: 70px 1fr 1fr 1fr 34px; gap: 8px; align-items: center; }
.volume-linha input { padding: 8px 10px; font-size: 13.5px; font-family: var(--fonte-mono); }
.volume-cab { display: grid; grid-template-columns: 70px 1fr 1fr 1fr 34px; gap: 8px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--suave); }
.btn-remover {
  border: none; background: transparent; color: var(--suave); cursor: pointer;
  font-size: 16px; border-radius: 7px; height: 34px;
  transition: background .15s ease, color .15s ease;
}
.btn-remover:hover { background: var(--erro-claro); color: var(--erro); }

/* ---------------------------------------------------------------- botões */
.btn {
  font-family: var(--fonte-corpo); font-size: 14.5px; font-weight: 600;
  border: none; border-radius: 10px; padding: 12px 22px; cursor: pointer;
  background: var(--verde); color: #fff;
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
  box-shadow: 0 6px 16px -8px rgba(14, 122, 95, .55);
}
.btn:hover { background: var(--verde-escuro); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-ghost {
  background: transparent; color: var(--verde-escuro); box-shadow: none;
  border: 1.5px solid var(--linha);
}
.btn-ghost:hover { background: var(--verde-claro); border-color: var(--verde); }
.btn-mini { font-size: 12.5px; padding: 6px 12px; border-radius: 8px; box-shadow: none; }
.btn-link {
  background: none; border: none; color: var(--verde-escuro); font-size: 12.5px;
  font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline;
  text-underline-offset: 3px;
}

/* ------------------------------------------------------- resumo da carga */
.resumo-fixo { position: sticky; top: 28px; }
.resumo-fixo .linha-resumo {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; border-bottom: 1px dashed var(--linha); font-size: 13.5px;
}
.resumo-fixo .linha-resumo:last-of-type { border-bottom: none; }
.resumo-fixo .linha-resumo .v { font-family: var(--fonte-mono); font-weight: 600; font-size: 14px; }
.resumo-fixo .linha-resumo.forte { font-size: 14.5px; }
.resumo-fixo .linha-resumo.forte .v { color: var(--verde-escuro); font-size: 16px; }
.nota-cubado {
  font-size: 11.5px; color: var(--suave); background: var(--papel);
  border-radius: 8px; padding: 8px 10px; margin-top: 10px; line-height: 1.45;
}

/* -------------------------------------------------------------- resultados */
.rota-cab {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
  font-family: var(--fonte-mono); font-size: 13px; font-weight: 600;
}
.rota-cab .ponto { flex: none; }
.rota-cab .tracejado {
  flex: 1; height: 2px; position: relative;
  background-image: linear-gradient(90deg, var(--suave) 33%, transparent 0);
  background-size: 9px 2px; opacity: .5;
}
.rota-cab .tracejado::after {
  content: ""; position: absolute; top: -4px; left: 0; width: 10px; height: 10px;
  border-radius: 50%; background: var(--ambar);
  animation: viajar 2.6s ease-in-out infinite;
}
@keyframes viajar { 0% { left: 0; } 50% { left: calc(100% - 10px); } 100% { left: 0; } }

.vencedor {
  border: 1.5px solid var(--ambar); background: linear-gradient(160deg, #fffdf8, var(--ambar-claro));
  border-radius: 14px; padding: 20px 24px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  box-shadow: var(--sombra-alta); animation: surgir .45s ease both;
}
.vencedor .selo {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  background: var(--ambar); color: #fff; border-radius: 20px; padding: 4px 12px;
}
.vencedor .nome-t { font-family: var(--fonte-display); font-weight: 700; font-size: 19px; }
.vencedor .preco { font-family: var(--fonte-mono); font-weight: 600; font-size: 28px; color: var(--tinta); margin-left: auto; }
.vencedor .detalhe { font-size: 13px; color: var(--suave); }

.linha-resultado {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--linha); border-radius: 12px;
  padding: 14px 20px; margin-bottom: 8px;
  animation: surgir .45s ease both;
}
.linha-resultado .nome-t { font-weight: 600; font-size: 14.5px; min-width: 170px; }
.linha-resultado .preco { font-family: var(--fonte-mono); font-weight: 600; font-size: 16px; margin-left: auto; }
.linha-resultado .detalhe { font-size: 12.5px; color: var(--suave); }
.linha-resultado.apagada { opacity: .75; background: transparent; box-shadow: none; }

.selo-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; border-radius: 20px; padding: 4px 11px;
}
.selo-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.selo-ok { background: var(--verde-claro); color: var(--verde-escuro); }
.selo-pendente { background: var(--ambar-claro); color: #96601a; }
.selo-erro { background: var(--erro-claro); color: var(--erro); }
.selo-neutro { background: var(--papel); color: var(--suave); }

/* skeleton */
@keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.esqueleto {
  border-radius: 12px; height: 58px; margin-bottom: 8px;
  background: linear-gradient(90deg, #eceee8 25%, #f7f8f4 50%, #eceee8 75%);
  background-size: 200% 100%; animation: brilho 1.4s linear infinite;
}

/* ---------------------------------------------------------------- tabelas */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--suave); padding: 10px 14px;
  border-bottom: 1.5px solid var(--linha);
}
td { padding: 13px 14px; border-bottom: 1px solid var(--linha); font-size: 14px; vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafbf7; }
td .mono { font-family: var(--fonte-mono); font-size: 13px; }
.chip {
  display: inline-block; font-size: 11px; font-weight: 600; border-radius: 6px;
  padding: 3px 8px; background: var(--papel); color: var(--suave);
  border: 1px solid var(--linha);
}

/* ------------------------------------------------- cards transportadoras */
.grade-transp { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card-transp { display: flex; flex-direction: column; gap: 14px; }
.card-transp .cabeca { display: flex; align-items: center; gap: 13px; }
.avatar {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fonte-display); font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(150deg, var(--tinta-3), var(--tinta));
}
.card-transp .cabeca .nome-t { font-family: var(--fonte-display); font-weight: 600; font-size: 16px; line-height: 1.2; }
.card-transp .cabeca .cnpj { font-family: var(--fonte-mono); font-size: 11px; color: var(--suave); }
.card-transp .metricas { display: flex; gap: 22px; }
.card-transp .metricas .m .r { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--suave); }
.card-transp .metricas .m .v { font-family: var(--fonte-mono); font-weight: 600; font-size: 14.5px; }

/* ------------------------------------------------------------------ modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(13, 47, 48, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px); animation: aparecer-fundo .2s ease both;
}
@keyframes aparecer-fundo { from { opacity: 0; } }
.modal-card {
  background: #fff; border-radius: 16px; box-shadow: var(--sombra-alta);
  width: min(480px, calc(100vw - 40px)); max-height: 84vh; overflow: auto;
  padding: 26px; animation: surgir .3s cubic-bezier(.22, .8, .36, 1) both;
}
.modal-card h3 { font-family: var(--fonte-display); font-size: 17px; margin: 0 0 16px; }
.modal-card .acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ------------------------------------------------------------------ avisos */
.aviso-erro {
  background: var(--erro-claro); color: var(--erro); border-radius: 10px;
  padding: 12px 16px; font-size: 13.5px; margin-top: 14px;
  animation: surgir .3s ease both;
}
.aviso-erro:empty { display: none; }
.vazio { text-align: center; color: var(--suave); padding: 44px 20px; font-size: 14px; }
.vazio .icone { font-size: 30px; margin-bottom: 8px; opacity: .5; }

/* -------------------------------------------------------------- responsivo */
@media (max-width: 980px) {
  .lateral { width: 64px; }
  .lateral .logo .marca span, .lateral .menu a .rotulo-menu, .lateral .rodape, .logo .tag, .logo .marca small { display: none; }
  .logo { padding: 0 0 22px; text-align: center; }
  .menu a { justify-content: center; padding: 12px; }
  .conteudo { margin-left: 64px; padding: 24px 20px 48px; }
  .grade-kpi { grid-template-columns: repeat(2, 1fr); }
  .grade-2, .form-grade { grid-template-columns: 1fr; }
  .cotacao-layout { grid-template-columns: 1fr !important; }
  .resumo-fixo { position: static; }
}
