@font-face { font-family: "Saira"; font-weight: 400; font-display: swap; src: url("fonts/saira-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Saira"; font-weight: 500; font-display: swap; src: url("fonts/saira-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Saira"; font-weight: 600; font-display: swap; src: url("fonts/saira-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Saira"; font-weight: 700; font-display: swap; src: url("fonts/saira-latin-700-normal.woff2") format("woff2"); }

:root {
  --roxo: #44134D;
  --roxo-2: #5c2a66;
  --roxo-claro: #f3eef4;
  --verde: #A1BF2F;
  --verde-escuro: #6f8619;
  --texto: #231a25;
  --sutil: #6b6170;
  --borda: #e3dce5;
  --fundo: #faf8fb;
  --branco: #fff;
  --alerta: #b4570b;
  --erro: #b3261e;
  --ok: #3f7d20;
  --raio: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Saira", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--texto); background: var(--fundo); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--roxo); }
button, input, select, textarea { font: inherit; color: inherit; }
.carregando { padding: 40px; text-align: center; color: var(--sutil); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--branco); }
.login-box { width: 100%; max-width: 380px; }
.login-box img { width: 190px; display: block; margin: 0 auto 8px; }
.login-box h1 { text-align: center; font-size: 18px; font-weight: 500; color: var(--sutil); margin: 0 0 28px; }
.login-box .campo { margin-bottom: 14px; }
.login-box .links { margin-top: 14px; text-align: center; font-size: 14px; }

/* ---------- Estrutura ---------- */
.topo {
  position: sticky; top: 0; z-index: 20; background: var(--branco); border-bottom: 3px solid var(--verde);
  display: flex; align-items: center; gap: 24px; padding: 8px 20px; height: 60px;
}
.topo img { height: 30px; }
.topo nav { display: flex; gap: 4px; flex: 1; }
.topo nav a {
  text-decoration: none; color: var(--texto); padding: 8px 14px; border-radius: 8px; font-weight: 500;
}
.topo nav a:hover { background: var(--roxo-claro); }
.topo nav a.ativo { background: var(--roxo); color: var(--branco); }
.topo .usuario { font-size: 13px; color: var(--sutil); display: flex; align-items: center; gap: 10px; }
main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 90px; }
.cabecalho { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.cabecalho h1 { margin: 0; font-size: 24px; color: var(--roxo); font-weight: 600; line-height: 1.2; }
.cabecalho .sub { color: var(--sutil); font-size: 14px; margin-top: 2px; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.voltar { font-size: 14px; text-decoration: none; color: var(--sutil); display: inline-block; margin-bottom: 6px; }
.nav-baixo { display: none; }

/* ---------- Botões / campos ---------- */
.btn {
  border: 1px solid var(--roxo); background: var(--roxo); color: var(--branco); border-radius: 8px;
  padding: 9px 16px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: var(--roxo-2); }
.btn.sec { background: var(--branco); color: var(--roxo); }
.btn.sec:hover { background: var(--roxo-claro); }
.btn.perigo { background: var(--branco); color: var(--erro); border-color: #e3b5b2; }
.btn.peq { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { background: none; border: 0; color: var(--roxo); cursor: pointer; padding: 0; text-decoration: underline; }
label { display: block; font-size: 12.5px; color: var(--sutil); font-weight: 500; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--borda); border-radius: 8px; background: var(--branco);
  min-height: 38px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde); outline-offset: 0; border-color: var(--verde); }
input[readonly] { background: var(--fundo); color: var(--sutil); }
.grade { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.grade .l2 { grid-column: span 2; }
.grade .l4 { grid-column: 1 / -1; }
.dica { font-size: 12px; color: var(--sutil); margin-top: 3px; }
.erro-msg { color: var(--erro); font-size: 14px; margin-top: 10px; }

/* ---------- Cartões ---------- */
.card { background: var(--branco); border: 1px solid var(--borda); border-radius: var(--raio); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 14px; color: var(--roxo); font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--branco); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px 16px; text-decoration: none; color: inherit; border-top: 4px solid var(--borda); }
.kpi:hover { border-color: var(--roxo); }
.kpi .rot { font-size: 13px; color: var(--sutil); font-weight: 500; }
.kpi .val { font-size: 26px; font-weight: 700; color: var(--texto); line-height: 1.15; margin-top: 2px; }
.kpi .val small { font-size: 14px; font-weight: 500; color: var(--sutil); }
.kpi .det { font-size: 13px; color: var(--sutil); }
.kpi.s1 { border-top-color: #b9aebd; } .kpi.s2 { border-top-color: #6c8ebf; } .kpi.s3 { border-top-color: #d08b2c; }
.kpi.s4 { border-top-color: #b4570b; } .kpi.s6, .kpi.s7 { border-top-color: var(--verde); } .kpi.sc { border-top-color: var(--roxo); }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Tabelas ---------- */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--sutil); font-size: 12.5px; padding: 8px 10px; border-bottom: 2px solid var(--borda); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--roxo-claro); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.vazio { text-align: center; color: var(--sutil); padding: 26px; }
tfoot td { font-weight: 700; border-top: 2px solid var(--borda); border-bottom: 0; }
table input, table select { min-height: 32px; padding: 4px 8px; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: #eee; }
.st1 { background: #eee9ef; color: #5d5162; }              /* Contratado */
.st2 { background: #e3ecf8; color: #2d5287; }              /* Programado */
.st3 { background: #fbecd9; color: #8a4b05; }              /* Em trânsito */
.st4 { background: #fde3c4; color: #8a3f05; }              /* No porto / aguardando */
.st5 { background: #fff2bf; color: #6d5600; }              /* Registrado */
.st6 { background: #eef5d6; color: #4b5d10; }              /* Desembaraçado */
.st7 { background: #dcedc4; color: #33550f; }              /* Em estoque / ok */
.st8 { background: #e9e9e9; color: #555; }                 /* Encerrado */
.st9 { background: #f8e1df; color: var(--erro); }         /* Cancelado */
.alerta-lista { list-style: none; margin: 0; padding: 0; }
.alerta-lista li { padding: 9px 0; border-bottom: 1px solid var(--borda); display: flex; gap: 10px; align-items: baseline; }
.alerta-lista li:last-child { border-bottom: 0; }
.alerta-lista .ico { width: 8px; height: 8px; border-radius: 50%; background: var(--alerta); flex: none; transform: translateY(-1px); }
.alerta-lista .ico.erro { background: var(--erro); }
.alerta-lista .ico.info { background: #6c8ebf; }
.sem-alerta { color: var(--sutil); }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filtros > * { width: auto; min-width: 150px; }
.filtros input[type=search] { min-width: 240px; flex: 1; }

/* ---------- Abas ---------- */
.abas { display: flex; gap: 2px; border-bottom: 2px solid var(--borda); margin-bottom: 16px; overflow-x: auto; }
.abas button { background: none; border: 0; padding: 10px 16px; cursor: pointer; font-weight: 600; color: var(--sutil); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.abas button.ativo { color: var(--roxo); border-bottom-color: var(--verde); }

/* ---------- Custo ---------- */
.custo-res { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.custo-res > div { background: var(--roxo-claro); border-radius: 8px; padding: 12px; }
.custo-res .rot { font-size: 12.5px; color: var(--sutil); }
.custo-res .val { font-size: 20px; font-weight: 700; }
.custo-res .destaque { background: var(--roxo); color: var(--branco); }
.custo-res .destaque .rot { color: #e6d7ea; }
.linha-total td { font-weight: 700; background: var(--fundo); }

/* ---------- Barra de status do processo ---------- */
.trilha { display: flex; gap: 0; margin: 4px 0 18px; overflow-x: auto; }
.trilha div { flex: 1; min-width: 92px; text-align: center; font-size: 12.5px; color: var(--sutil); position: relative; padding-top: 18px; }
.trilha div::before { content: ""; position: absolute; top: 5px; left: 0; right: 0; height: 4px; background: var(--borda); }
.trilha div::after { content: ""; position: absolute; top: 0; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--branco); border: 3px solid var(--borda); }
.trilha div.feito::before, .trilha div.feito::after { background: var(--verde); border-color: var(--verde); }
.trilha div.atual { color: var(--roxo); font-weight: 700; }
.trilha div.atual::after { background: var(--roxo); border-color: var(--roxo); }
.trilha small { display: block; font-weight: 400; color: var(--sutil); }

/* ---------- Barras (volume por mês) ---------- */
.barras { display: flex; flex-direction: column; gap: 8px; }
.barra { display: grid; grid-template-columns: 70px 1fr 70px; gap: 10px; align-items: center; font-size: 13.5px; }
.barra .trilho { height: 18px; background: var(--fundo); border-radius: 4px; display: flex; overflow: hidden; }
.barra .seg { height: 100%; }
.barra .seg.s1 { background: #b9aebd; } .barra .seg.s2 { background: #6c8ebf; } .barra .seg.s3 { background: #d08b2c; } .barra .seg.s6 { background: var(--verde); }
.legenda { display: flex; gap: 14px; font-size: 12.5px; color: var(--sutil); margin-top: 10px; flex-wrap: wrap; }
.legenda span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c); }

/* ---------- Toast / modal ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--texto); color: var(--branco); padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; max-width: 90vw; }
#toast.mostra { opacity: 1; }
#toast.erro { background: var(--erro); }
.modal-fundo { position: fixed; inset: 0; background: rgba(35, 26, 37, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--branco); border-radius: 12px; padding: 22px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 16px; color: var(--roxo); font-size: 18px; }
.modal .rodape { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.salvar-barra { position: sticky; bottom: 0; background: var(--branco); border-top: 1px solid var(--borda); padding: 12px 0; display: flex; gap: 8px; justify-content: flex-end; z-index: 5; }
.aviso { background: #fbf3e4; border: 1px solid #efd7a8; border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .duas { grid-template-columns: 1fr; }
  .grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .custo-res { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topo { padding: 8px 14px; height: 52px; }
  .topo nav { display: none; }
  .topo .usuario span { display: none; }
  main { padding: 16px 12px 96px; }
  .cabecalho h1 { font-size: 20px; }
  .grade { grid-template-columns: 1fr; }
  .grade .l2, .grade .l4 { grid-column: auto; }
  .kpi .val { font-size: 22px; }
  .filtros > * { flex: 1 1 100%; }
  .nav-baixo {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--branco); border-top: 1px solid var(--borda);
    z-index: 30; padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-baixo a { flex: 1; text-align: center; padding: 10px 4px; font-size: 12.5px; text-decoration: none; color: var(--sutil); font-weight: 600; }
  .nav-baixo a.ativo { color: var(--roxo); box-shadow: inset 0 3px 0 var(--verde); }
  table.cartoes thead { display: none; }
  table.cartoes, table.cartoes tbody, table.cartoes tr, table.cartoes td { display: block; width: 100%; }
  table.cartoes tr { border: 1px solid var(--borda); border-radius: 10px; margin-bottom: 10px; padding: 8px 12px; background: var(--branco); }
  table.cartoes td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.cartoes td::before { content: attr(data-l); color: var(--sutil); font-size: 13px; text-align: left; }
  table.cartoes td.n { white-space: normal; }
  table.cartoes td.m-oculto { display: none; }
  table.cartoes td.vazio { display: block; }
  table.cartoes td.vazio::before { content: none; }
}

/* ---------- v2 ---------- */
.txt-erro { color: var(--erro); }
.sutil { color: var(--sutil); font-size: 13px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--texto); font-weight: 400; margin: 0; cursor: pointer; }
.chk input { width: 18px; height: 18px; min-height: 0; margin: 0; flex: none; accent-color: var(--roxo); }
.grade > div > .chk { margin-top: 26px; }
.filtros .chk { min-width: 0; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.chks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.sub-t { font-size: 14px; color: var(--roxo); margin: 16px 0 8px; font-weight: 600; }
.card h2 .acoes { margin: 0; }
.card h2 > span:not(.chip):not(.acoes) { font-size: 13px; color: var(--sutil); font-weight: 500; }
.gerar h2 .chip { font-size: 12px; }
.modal.largo { max-width: 920px; }
.modal .grade { margin-bottom: 4px; }
.rateio { max-height: 280px; overflow: auto; border: 1px solid var(--borda); border-radius: 8px; }
.rateio td { padding: 6px 10px; }
.rateio input[data-rt] { width: 130px; }
td .acoes { justify-content: flex-end; flex-wrap: nowrap; }
td > span { display: contents; }
@media (max-width: 640px) {
  .checklist { grid-template-columns: 1fr; }
  td .acoes { flex-wrap: wrap; justify-content: flex-start; }
  .grade > div > .chk { margin-top: 4px; }
  table.cartoes td > span { display: block; text-align: right; }
}
@media print {
  .topo, .nav-baixo, .acoes, .salvar-barra, .abas, .filtros { display: none !important; }
  main { padding: 0; }
}
