/* V1651 — Revisão estratégica de preços: espaçamento, cartões de resumo e tabela sem barra de rolagem. */
/* Espaço entre os botões e as mensagens, e entre os blocos */
.rpe-card .btn-row { margin-top: 16px; gap: 10px; flex-wrap: wrap; }
#rpe-status:not(:empty) { margin-top: 16px; }
#rpe-status .rpe-alerta-info { margin: 0; }
.rpe-card { margin-bottom: 18px; }
.rpe-resumo { margin: 0 0 18px; }
.rpe-resumo:empty { display: none; }

/* Cartões de resumo */
.rpe-resumo-grid { gap: 14px; }
.rpe-metric { display: flex !important; align-items: center; gap: 14px; padding: 16px 18px !important; border: 1px solid #e3e9f1; border-left: 4px solid var(--rpe-tom, #9aa8b8); border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(23, 43, 77, .05); }
.rpe-m-ic { flex: none; width: 42px; height: 42px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: var(--rpe-tom-bg, #f1f4f8); color: var(--rpe-tom, #536273); }
.rpe-m-ic svg { width: 21px; height: 21px; }
.rpe-m-txt { display: grid; gap: 3px; min-width: 0; }
.rpe-metric small { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #5b6b80; }
.rpe-metric b { font-size: 28px !important; line-height: 1.05; font-weight: 800; color: #1b2735; }
.rpe-metric em { font-style: normal; font-size: 12px; color: #718096; line-height: 1.35; }
.rpe-m-azul { --rpe-tom: #2f6fc0; --rpe-tom-bg: #eaf2fd; }
.rpe-m-verde { --rpe-tom: #17803d; --rpe-tom-bg: #e8f6ee; }
.rpe-m-vermelho { --rpe-tom: #c42b2b; --rpe-tom-bg: #fdecec; }
.rpe-m-vermelho b { color: #b42318 !important; }
.rpe-m-ambar { --rpe-tom: #c27407; --rpe-tom-bg: #fff4e2; }
.rpe-m-neutro { --rpe-tom: #8a97a8; --rpe-tom-bg: #f1f4f8; }

/* Tabela: cabe na largura, sem barra de rolagem horizontal */
.rpe-table-wrap { width: 100%; overflow: visible; }
.rpe-table { table-layout: fixed !important; min-width: 0 !important; width: 100%; }
.rpe-table thead th { white-space: normal !important; line-height: 1.25; vertical-align: bottom; padding: 10px 6px !important; }
.rpe-table tbody td { padding: 12px 6px !important; overflow-wrap: break-word; }
.rpe-table .rpe-th-sel { width: 34px; }
.rpe-table .rpe-th-peca { width: 24%; }
.rpe-table th:nth-child(3) { width: 58px; }
.rpe-table th:nth-child(10) { width: 13%; }
.rpe-peca { min-width: 0 !important; max-width: none !important; }
.rpe-preco-editavel { width: 100% !important; min-width: 0 !important; max-width: 120px; }
.rpe-status { white-space: normal !important; }
.rpe-futuro { max-width: none; }
.rpe-legenda { margin-top: 14px; }

/* Telas menores: cada linha vira um cartão */
@media (max-width: 1250px) {
  .rpe-table, .rpe-table tr, .rpe-table td { display: block; width: 100%; }
  .rpe-table tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
  .rpe-table thead { display: none; }
  .rpe-table tbody tr { position: relative; margin: 0; padding: 12px 14px 8px 46px; border: 1px solid #e3e9f1; border-radius: 12px; background: #fff; }
  .rpe-table tbody tr.rpe-selecionada { border-color: #f3c99c; background: #fffaf4; }
  .rpe-table tbody td { padding: 6px 0 !important; border: 0 !important; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .rpe-table tbody td[data-label]::before { content: attr(data-label); font-size: 11px; font-weight: 700; color: #5b6b80; text-transform: uppercase; letter-spacing: .03em; flex: none; font-family: Inter, "Segoe UI", Arial, sans-serif; }
  .rpe-table td.rpe-td-sel { position: absolute; left: 14px; top: 14px; width: auto; padding: 0 !important; }
  .rpe-table td.rpe-td-peca { display: block; padding-bottom: 10px !important; margin-bottom: 4px; border-bottom: 1px solid #eef2f6 !important; }
  .rpe-preco-editavel { max-width: 140px; }
}
@media (max-width: 1250px) {
  #rpe-tabela .rpe-table tbody td, #main #rpe-tabela table.rpe-table > tbody > tr > td { border: 0 !important; box-shadow: none !important; background: transparent !important; }
  #main #rpe-tabela table.rpe-table > tbody > tr > td[data-label] + td[data-label] { border-top: 1px solid #eef2f6 !important; }
  #main #rpe-tabela table.rpe-table > tbody > tr > td.rpe-td-peca { border-bottom: 1px solid #e3e9f1 !important; }
  #rpe-tabela .rpe-table tbody tr, #rpe-tabela .rpe-table tbody tr:nth-child(even) { background: #fff !important; }
  #rpe-tabela .rpe-table tbody tr.rpe-selecionada { background: #fffaf4 !important; }
}
@media (max-width: 640px) { .rpe-resumo-grid { grid-template-columns: 1fr !important; } }
@media (min-width: 1251px) {
  .rpe-table th:nth-child(3) { width: 64px; }
  .rpe-table th:nth-child(8) { width: 12%; }
  .rpe-unidade { white-space: nowrap; }
}
.rpe-table thead th { font-size: 10px !important; letter-spacing: 0 !important; overflow-wrap: normal; word-break: normal; hyphens: none; }
.rpe-table td.mono, .rpe-table td[data-label*="Margem"] { white-space: nowrap; overflow-wrap: normal; }

/* V1652 — Histórico de revisões: % de reajuste, cabeçalho legível e tabela sem rolagem */
.rpe-hist { margin-top: 12px; border: 1px solid #e3e9f1; border-radius: 12px; background: #fff; overflow: hidden; }
.rpe-hist[open] { box-shadow: 0 2px 8px rgba(23, 43, 77, .06); }
.rpe-hist > summary { list-style: none; display: flex; align-items: center; gap: 14px; padding: 14px 18px; cursor: pointer; background: #f8fafd; }
.rpe-hist > summary::-webkit-details-marker { display: none; }
.rpe-hist[open] > summary { border-bottom: 1px solid #e3e9f1; }
.rpe-hist-n { flex: none; padding: 5px 10px; border-radius: 8px; background: #eaf2fd; color: #1d4f91; font-size: 12.5px; font-weight: 800; }
.rpe-hist-meta { display: grid; gap: 2px; min-width: 0; flex: 1; }
.rpe-hist-meta b { font-size: 13.5px; color: #1b2735; }
.rpe-hist-meta small { font-size: 12px; color: #718096; }
.rpe-hist-seta { flex: none; color: #8a97a8; font-size: 14px; transition: transform .15s; }
.rpe-hist:not([open]) .rpe-hist-seta { transform: rotate(-90deg); }
.rpe-hist-pct { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rpe-hist > summary .rpe-hist-pct { font-size: 14px; padding: 5px 12px; }
.rpe-hist-pct.sobe { background: #e8f6ee; color: #17663c; border: 1px solid #c5e8d2; }
.rpe-hist-pct.desce { background: #fff0f0; color: #a32121; border: 1px solid #f3c2c2; }
.rpe-hist-pct.neutro { background: #f1f4f8; color: #536273; border: 1px solid #dfe5ec; }
.rpe-hist-corpo { padding: 14px 18px 16px; }
.rpe-hist-info { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-bottom: 14px; font-size: 13px; color: #1b2735; }
.rpe-hist-info span { display: grid; gap: 2px; }
.rpe-hist-info small { font-size: 10.5px; font-weight: 700; color: #718096; text-transform: uppercase; letter-spacing: .04em; }
.rpe-hist-tab { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12.5px; border: 1px solid #e3e9f1; border-radius: 10px; overflow: hidden; }
#main #rpe-historico-area table.rpe-hist-tab > thead > tr > th { padding: 10px 10px; background: #f4f7fb; color: #42536a; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; text-align: left; white-space: normal; line-height: 1.25; border-bottom: 1px solid #e3e9f1 !important; }
#main #rpe-historico-area table.rpe-hist-tab > tbody > tr > td { padding: 11px 10px; vertical-align: middle; border-bottom: 1px solid #eef2f6 !important; background: #fff; }
#main #rpe-historico-area table.rpe-hist-tab > tbody > tr:last-child > td { border-bottom: 0 !important; }
.rpe-hist-tab th:nth-child(1) { width: 28%; }
.rpe-hist-tab th:nth-child(2) { width: 64px; }
.rpe-hist-tab th:nth-child(5) { width: 96px; }
.rpe-hist-tab th:nth-child(7) { width: 17%; }
.rpe-hist-tab .rpe-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rpe-hist-peca { display: grid; gap: 2px; }
.rpe-hist-peca b { color: #1d4f91; font-size: 11px; }
.rpe-hist-peca span { color: #1b2735; font-weight: 700; line-height: 1.3; }
@media (max-width: 900px) {
  .rpe-hist > summary { flex-wrap: wrap; gap: 8px 12px; }
  .rpe-hist-tab, .rpe-hist-tab tbody, .rpe-hist-tab tr, .rpe-hist-tab td { display: block; width: 100%; }
  .rpe-hist-tab, #main #rpe-historico-area table.rpe-hist-tab { border: 0; table-layout: auto; min-width: 0 !important; width: 100% !important; }
  .rpe-hist-tab tr, .rpe-hist-tab td { box-sizing: border-box; min-width: 0; }
  .rpe-hist-tab td { width: auto !important; }
  .rpe-hist-corpo { padding: 12px; }
  .rpe-hist-tab thead { display: none; }
  .rpe-hist-tab tbody { display: grid; gap: 10px; }
  .rpe-hist-tab tr { border: 1px solid #e3e9f1; border-radius: 10px; padding: 6px 12px; }
  #main #rpe-historico-area table.rpe-hist-tab > tbody > tr > td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid #eef2f6 !important; }
  #main #rpe-historico-area table.rpe-hist-tab > tbody > tr > td:last-child { border-bottom: 0 !important; }
  .rpe-hist-tab td::before { content: attr(data-label); font-size: 10.5px; font-weight: 700; color: #718096; text-transform: uppercase; letter-spacing: .03em; flex: none; }
  .rpe-hist-tab td[data-label="Peça"] { display: block !important; }
  .rpe-hist-tab td[data-label="Peça"]::before { content: none; }
}
