:root { --laranja: #f05f02; --laranja-esc: #c94d00; --escuro: #17171a; --cinza: #f3f3f5; --borda: #dcdce1; --texto: #1d1d22; --suave: #6b6b75; --verde: #1f9d55; --vermelho: #d33; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.4 "Open Sans", "Segoe UI", system-ui, Arial, sans-serif; color: var(--texto); background: var(--cinza); }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { border: 1px solid var(--borda); border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f05f0255; border-color: var(--laranja); }
textarea { resize: vertical; }
label { display: block; font-size: 12px; color: var(--suave); font-weight: 600; margin-bottom: 3px; }
.btn { border: 1px solid var(--borda); background: #fff; border-radius: 6px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #f7f7f9; }
.btn.pri { background: var(--laranja); border-color: var(--laranja); color: #fff; }
.btn.pri:hover { background: var(--laranja-esc); }
.btn.perigo { color: var(--vermelho); }
.btn.mini { padding: 3px 8px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* topo */
.topo { background: var(--escuro); color: #fff; display: flex; align-items: center; gap: 22px; padding: 0 22px; height: 54px; position: sticky; top: 0; z-index: 20; border-bottom: 3px solid var(--laranja); }
.topo .logo { font-weight: 800; letter-spacing: .3px; }
.topo .logo b { color: var(--laranja); }
.topo a { color: #cfcfd6; text-decoration: none; font-weight: 600; padding: 15px 0; }
.topo a.ativo, .topo a:hover { color: #fff; }
.topo .esp { flex: 1; }
.topo button { background: none; border: 0; color: #cfcfd6; cursor: pointer; font-weight: 600; }
.pagina { max-width: 1500px; margin: 0 auto; padding: 22px; }
.pagina.estreita { max-width: 980px; }
.cab-pag { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cab-pag h1 { font-size: 22px; flex: 1; }
.cartao { background: #fff; border: 1px solid var(--borda); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.cartao > h2 { font-size: 15px; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--laranja-esc); }
.grade { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grade.g2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

/* login */
.login { max-width: 400px; margin: 9vh auto; background: #fff; padding: 28px; border-radius: 12px; border: 1px solid var(--borda); border-top: 5px solid var(--laranja); }
.login h1 { font-size: 21px; margin-bottom: 4px; }
.login p { color: var(--suave); margin: 0 0 18px; }
.login .campo { margin-bottom: 12px; }
.erro { color: var(--vermelho); font-weight: 600; margin: 8px 0; min-height: 20px; }

/* tabela de propostas / catálogo */
table.lista { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--borda); border-radius: 10px; overflow: hidden; }
table.lista th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--suave); padding: 10px 12px; background: #fafafb; border-bottom: 1px solid var(--borda); }
table.lista td { padding: 9px 12px; border-bottom: 1px solid #eee; }
table.lista tr.clic { cursor: pointer; }
table.lista tr.clic:hover td { background: #fff6f0; }
.etq { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #eee; }
.etq.enviada { background: #e3efff; color: #1b5fb8; } .etq.aprovada { background: #dcf5e6; color: #167a41; } .etq.perdida { background: #fde4e4; color: #b52a2a; }
.filtros { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filtros input { max-width: 360px; } .filtros select { max-width: 200px; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.lista td input { padding: 5px 7px; }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .resumo { position: static !important; } }
.resumo { position: sticky; top: 72px; }
.resumo .linha { display: flex; justify-content: space-between; padding: 4px 0; gap: 10px; }
.resumo .linha span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.resumo .forte { border-top: 1px solid var(--borda); margin-top: 6px; padding-top: 8px; font-weight: 800; }
.resumo .pos { color: var(--verde); } .resumo .neg { color: var(--vermelho); }
.resumo small { color: var(--suave); display: block; margin-top: 6px; }
.resumo .entrada { margin: 10px 0; }
.secao-cab { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.secao-cab input.tit { font-weight: 700; font-size: 16px; flex: 1; min-width: 220px; }
.secao-cab select { width: auto; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #eee; color: #555; }
.tag.interno { background: #fff3cd; color: #8a6500; } .tag.invest { background: #e8e3ff; color: #5a3fc0; } .tag.extra { background: #ffe6d6; color: var(--laranja-esc); }
.rolagem { overflow-x: auto; }
table.itens { border-collapse: collapse; width: 100%; min-width: 1240px; }
table.itens th { font-size: 11px; text-transform: uppercase; color: var(--suave); text-align: left; padding: 4px 4px; white-space: nowrap; }
table.itens td { padding: 3px 3px; vertical-align: middle; }
table.itens td input { padding: 6px 6px; }
table.itens td.val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 8px; font-size: 14px; }
.w-dias { width: 58px; } .w-qtd { width: 64px; } .w-unit { width: 90px; } .w-marg { width: 66px; } .w-val { width: 100px; } .w-forn { width: 84px; } .w-qpdf { width: 74px; } .w-acao { width: 64px; }
.busca { position: relative; min-width: 250px; }
table.itens td.c-texto { min-width: 270px; }
.sugestoes { position: fixed; z-index: 60; background: #fff; border: 1px solid var(--borda); border-radius: 8px; box-shadow: 0 8px 24px #0003; width: 480px; max-height: 340px; overflow: auto; }
.sugestoes div { padding: 7px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #f0f0f2; }
.sugestoes div:hover, .sugestoes div.sel { background: #fff1e8; }
.sugestoes small { color: var(--suave); display: block; }
.sugestoes b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rodape-sec { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 12px; flex-wrap: wrap; }
.rodape-sec .tot { color: var(--suave); font-size: 13px; }
.rodape-sec .tot b { color: var(--texto); }
.status { font-size: 13px; font-weight: 600; color: var(--suave); }
.status.salvo { color: var(--verde); } .status.erro { color: var(--vermelho); }
#aviso { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 99; }
#aviso.on { opacity: 1; }
.dica { color: var(--suave); font-size: 13px; margin: 4px 0 10px; }
.linha-botoes { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
details.cartao summary { list-style-position: inside; }
a.btn { text-decoration: none; color: inherit; display: inline-block; } a.btn.pri { color: #fff; }

/* painel */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--borda); border-radius: 10px; padding: 14px 16px; }
.kpi-r { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--suave); letter-spacing: .3px; }
.kpi-v { font-size: 26px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-s { font-size: 12px; color: var(--suave); }
.pos { color: var(--verde); } .neg { color: var(--vermelho); }
.dist { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 6px 0 12px; }
.leg { display: grid; gap: 6px; font-size: 14px; }
.leg i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 7px; }
.barras { display: flex; gap: 10px; align-items: flex-end; height: 190px; }
.barra-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.barra-trilho { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.barra-fill { width: 100%; background: #f6b88f; border-radius: 4px 4px 0 0; min-height: 2px; }
.barra-col.atual .barra-fill { background: var(--laranja); }
.barra-val { font-size: 11px; font-weight: 700; height: 16px; white-space: nowrap; }
.barra-rot { font-size: 12px; color: var(--suave); margin-top: 4px; }
.cartao table.lista { border: 0; }
.grade.dois { grid-template-columns: 1fr 1fr; } @media (max-width: 900px) { .grade.dois { grid-template-columns: 1fr; } }

.sel-status { width: auto; padding: 4px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; cursor: pointer; border: 1px solid transparent; background: #eee; }
.sel-status.enviada { background: #e3efff; color: #1b5fb8; } .sel-status.aprovada { background: #dcf5e6; color: #167a41; } .sel-status.perdida { background: #fde4e4; color: #b52a2a; }

.acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.acoes .btn.mini { font-size: 12px; padding: 4px 8px; }

/* ---------------- celular e tablet ---------------- */
html { -webkit-text-size-adjust: 100%; }
@media (max-width: 820px) {
  body { font-size: 16px; }
  .topo { gap: 16px; padding: 0 12px; height: 48px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .topo::-webkit-scrollbar { display: none; }
  .topo .logo, .topo .esp, .topo > span { display: none; }
  .topo a, .topo button { padding: 13px 0; flex: none; }
  .pagina { padding: 12px; }
  .cab-pag { gap: 8px; }
  .cab-pag h1 { font-size: 19px; flex-basis: 100%; }
  .cab-pag .btn { flex: 1 1 auto; text-align: center; }
  .cab-pag select { width: 100% !important; }
  .btn { padding: 10px 14px; }
  .btn.mini { padding: 7px 11px; }
  input, select, textarea { font-size: 16px; padding: 10px; }
  .cartao { padding: 14px; }
  .grade, .grade.g2 { grid-template-columns: 1fr; }
  .filtros input, .filtros select { max-width: none; width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi-v { font-size: 19px; }
  .barra-val { font-size: 9px; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor > div { min-width: 0; }
  .resumo { position: static; order: -1; }

  /* tabelas de listas viram cartões */
  table.lista, table.lista tbody, table.lista tr, table.lista td { display: block; width: 100%; }
  table.lista { background: none; border: 0; }
  table.lista thead { display: none; }
  table.lista tr { background: #fff; border: 1px solid var(--borda); border-radius: 10px; margin-bottom: 10px; padding: 6px 12px; }
  table.lista td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 6px 0; text-align: right; }
  table.lista td::before { content: attr(data-label); font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--suave); text-align: left; flex: none; }
  table.lista td[data-label=""]::before, table.lista td:not([data-label])::before { content: none; }
  table.lista td[colspan] { display: block; text-align: center; }
  table.lista td[colspan]::before { content: none; }
  table.lista td input { width: 62%; }
  .sel-status { font-size: 14px; padding: 7px 10px; }
  .acoes { justify-content: flex-end; }

  /* itens da proposta: cada linha vira um cartão */
  .rolagem { overflow: visible; }
  table.itens, table.itens tbody { display: block; min-width: 0; width: 100%; }
  table.itens thead { display: none; }
  table.itens tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; border: 1px solid var(--borda); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fafafb; }
  table.itens td { display: block; padding: 0; min-width: 0; }
  table.itens td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; color: var(--suave); text-transform: uppercase; margin-bottom: 2px; }
  table.itens td:nth-child(3), table.itens td.c-texto, table.itens td:last-child { grid-column: 1 / -1; }
  table.itens td:last-child::before { content: none; }
  table.itens td:last-child { display: flex; gap: 6px; flex-wrap: wrap; }
  table.itens td.val { text-align: left; font-size: 15px; }
  table.itens td input, .w-dias, .w-qtd, .w-unit, .w-marg, .w-val, .w-forn, .w-qpdf { width: 100% !important; }
  .busca { min-width: 0; }
  table.itens td.c-texto { min-width: 0; }
  .secao-cab input.tit { min-width: 0; flex-basis: 100%; }
  .secao-cab select { width: 100%; }
  .rodape-sec { flex-direction: column; align-items: stretch; }
}
@media (max-width: 340px) { .kpis { grid-template-columns: 1fr; } }
#aviso { max-width: 92vw; width: max-content; text-align: center; }
