/* ================= Telas "Tabelas de apoio" e "Tarifas" (e07) =================
   Plano: auditoria/evidencias-construcao/e07/PLANO-VISUAL.md. Usa só os tokens da e03.
   Ordem: base → componentes das telas → @media (celular por último). */

/* ---------- Tabelas de apoio: lista à esquerda, registros à direita ---------- */
.ap-grade { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: var(--esp-4); align-items: start; }
.ap-lista { padding: var(--esp-2) 0 var(--esp-3); margin-bottom: 0; position: sticky; top: 76px; }
.ap-seletor { display: none; }
.ap-grupo h4 { margin: var(--esp-3) 20px 6px; font-size: var(--t-rotulo); color: var(--apoio); font-weight: 600; }
.ap-grupo ul { list-style: none; margin: 0; padding: 0 8px; }
.ap-tab {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'nome conta' 'dica conta';
  align-items: center; gap: 0 var(--esp-3); text-align: left; padding: 8px 12px; min-height: 0; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: var(--tinta); font-weight: 500;
}
.ap-tab:hover { background: var(--fundo-suave); }
.ap-tab.sel { background: var(--azul-claro-fundo); border-color: #C7DBF3; color: var(--azul-escuro); box-shadow: inset 3px 0 0 var(--azul); }
.ap-tab-nome { grid-area: nome; font-size: var(--t-corpo); line-height: 1.3; }
.ap-tab-dica { grid-area: dica; font-size: var(--t-nota); color: var(--apoio); font-weight: 400; }
.ap-conta { grid-area: conta; font-size: var(--t-rotulo); font-weight: 600; color: var(--apoio); min-width: 22px; text-align: right; }
.ap-tab.sel .ap-conta { color: var(--azul); }
.ap-conta .icone { width: 16px; height: 16px; }
.ap-painel { margin-bottom: 0; }
.ap-painel .bloco-cabeca h3 { display: inline-flex; align-items: center; gap: var(--esp-2); }
.ap-painel .bloco-cabeca h3 .selo { font-weight: 600; }
.ap-inativo { color: var(--apoio); font-weight: 500; text-decoration: line-through; text-decoration-color: var(--borda-forte); }
.ap-rodape { margin: 0; padding: 12px 20px 14px; border-top: 1px solid var(--borda); color: var(--apoio); font-size: var(--t-nota); }

/* histórico: linha do tempo com antes → depois */
.ap-linha { list-style: none; margin: 0; padding: 0 0 0 26px; position: relative; }
.ap-linha::before { content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--borda); border-radius: 2px; }
.ap-passo { position: relative; padding: 0 0 var(--esp-4); }
.ap-passo::before { content: ''; position: absolute; left: -26px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--branco); border: 2px solid var(--azul); }
.ap-passo.inativacao::before { border-color: var(--apoio); }
.ap-passo.inclusao::before { background: var(--azul); }
.ap-passo-topo { display: flex; flex-wrap: wrap; gap: 2px var(--esp-3); align-items: baseline; }
.ap-passo-topo span { color: var(--apoio); font-size: var(--t-rotulo); }
.ap-passo p { margin: 4px 0 0; color: #33445C; font-size: var(--t-rotulo); }
.ap-mudancas { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.ap-mudancas li { display: grid; grid-template-columns: 120px minmax(0, max-content) auto minmax(0, 1fr); gap: var(--esp-2); align-items: baseline; font-size: var(--t-rotulo); background: var(--fundo-suave); border-radius: 8px; padding: 6px 10px; }
.ap-campo { color: var(--apoio); }
.ap-mudancas s { color: var(--apoio); text-decoration-color: var(--erro); }
.ap-mudancas b { color: var(--tinta); font-weight: 600; }
.ap-h4 { margin-top: 0; }
.ap-hidros { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-hidros span { background: var(--fundo-suave); border: 1px solid var(--borda); border-radius: 8px; padding: 2px 8px; font-size: var(--t-rotulo); font-weight: 500; }
.ap-hidros small { color: var(--apoio); font-weight: 400; }

/* manutenção do banco: a faixa marinho desta tela */
.ap-banco { background: var(--marinho); color: var(--branco); border-radius: var(--raio); padding: 20px 24px; box-shadow: var(--sombra); margin-bottom: var(--esp-4); }
.ap-banco-topo { display: flex; flex-wrap: wrap; gap: var(--esp-3); align-items: flex-start; justify-content: space-between; }
.ap-banco-topo h3 { font-size: var(--t-bloco); font-weight: 600; }
.ap-banco-topo p { margin: 4px 0 0; color: #A9B8CC; font-size: var(--t-rotulo); }
.ap-banco-topo .acoes { display: flex; flex-wrap: wrap; gap: var(--esp-2); }
.ap-banco button.sec { background: transparent; color: var(--branco); border-color: rgba(255, 255, 255, .35); }
.ap-banco button.sec:hover { background: rgba(255, 255, 255, .08); border-color: var(--agua); }
.ap-numeros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: var(--esp-5) 0 0; }
.ap-numeros div { padding: 2px 16px; box-shadow: inset 1px 0 0 rgba(255, 255, 255, .12); }
.ap-numeros div:first-child { padding-left: 0; box-shadow: none; }
.ap-numeros dt { font-size: var(--t-rotulo); color: #A9B8CC; }
.ap-numeros dd { margin: 2px 0 0; font-size: var(--t-numero); font-weight: 600; letter-spacing: -.01em; }
.ap-numeros small { font-size: var(--t-rotulo); color: #A9B8CC; font-weight: 400; }
.ap-ultima { margin: var(--esp-4) 0 0; font-size: var(--t-rotulo); color: #C9D4E3; }
.ap-explica p { color: #33445C; max-width: 64ch; }
.ap-banco-baixo { margin-bottom: 0; }

/* ---------- Tarifas: linha do tempo das vigências (a faixa marinho) ---------- */
.tf-palco { background: var(--marinho); color: var(--branco); border-radius: var(--raio); padding: 20px 24px 18px; box-shadow: var(--sombra); margin-bottom: var(--esp-4); }
.tf-topo { display: flex; flex-wrap: wrap; gap: var(--esp-3) var(--esp-6); justify-content: space-between; align-items: flex-start; }
.tf-topo h3 { font-size: var(--t-bloco); font-weight: 600; }
.tf-topo p { margin: 4px 0 0; color: #A9B8CC; font-size: var(--t-rotulo); max-width: 60ch; }
.tf-escolhas { display: flex; flex-wrap: wrap; gap: var(--esp-2); }
.segmento.escuro { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
.segmento.escuro span { color: #C9D4E3; }
.segmento.escuro label:hover span { color: var(--branco); }
.segmento.escuro input:checked + span { background: var(--branco); color: var(--marinho); box-shadow: none; }

.tf-linha { list-style: none; margin: var(--esp-6) 0 0; padding: 0; display: flex; align-items: stretch; gap: 0; position: relative; }
.tf-linha::before { content: ''; position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: linear-gradient(90deg, rgba(169, 184, 204, .35), rgba(73, 179, 238, .55)); }
.tf-degrau { flex: 1 1 0; min-width: 0; position: relative; }
.tf-degrau button {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: transparent; border: 0; color: inherit; padding: 0 var(--esp-4) 10px 0; min-height: 0; border-radius: 0; font-weight: 400;
}
.tf-marco { width: 24px; height: 24px; border-radius: 50%; background: var(--marinho); border: 2px solid #A9B8CC; margin-bottom: 10px; position: relative; flex-shrink: 0; transition: transform .16s var(--ease); }
.tf-degrau.vigente .tf-marco { border-color: var(--agua); background: var(--agua); box-shadow: 0 0 0 5px rgba(73, 179, 238, .18); }
.tf-degrau.futura .tf-marco { border-color: var(--agua); border-style: dashed; }
.tf-degrau.nova .tf-marco { border-style: dashed; border-color: rgba(255, 255, 255, .45); }
.tf-degrau.nova .tf-marco::after { content: '+'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; line-height: 1; color: #C9D4E3; }
.tf-degrau button:hover .tf-marco { transform: scale(1.12); }
.tf-degrau b { font-size: var(--t-corpo); font-weight: 600; }
.tf-sit { font-size: var(--t-rotulo); color: #A9B8CC; }
.tf-degrau.vigente .tf-sit { color: var(--agua); font-weight: 500; }
.tf-resumo { font-size: var(--t-nota); color: #C9D4E3; }
.tf-trava { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: var(--t-nota); color: #F2C46D; }
.tf-trava .icone { width: 13px; height: 13px; }
.tf-degrau.sel button { background: rgba(255, 255, 255, .06); border-radius: 0 0 10px 10px; box-shadow: inset 0 -2px 0 var(--agua); padding-left: 8px; }
.tf-degrau.sel .tf-marco { margin-left: -8px; }
.tf-hoje { flex: 0 0 auto; align-self: flex-start; position: relative; margin: -22px var(--esp-4) 0 0; padding: 2px 8px; font-size: var(--t-nota); font-weight: 600; color: var(--marinho); background: var(--agua); border-radius: 999px; white-space: nowrap; }
.tf-hoje::after { content: ''; position: absolute; left: 50%; top: 100%; width: 2px; height: 14px; background: var(--agua); transform: translateX(-50%); }

/* editor e conta de exemplo */
.tf-meio { margin-bottom: 0; }
.tf-editor, .tf-exemplo { margin-bottom: 0; }
.tf-vig { max-width: 260px; margin-bottom: var(--esp-3); }
.tf-vig label { margin-top: 0; }
.tf-faixas th, .tf-faixas td { padding: 6px 8px; }
.tf-faixas th:first-child, .tf-faixas td:first-child { padding-left: 0; width: 52px; }
.tf-faixas td b { color: var(--apoio); font-weight: 600; }
.tf-faixas input { min-width: 84px; }
.tf-faixas input:disabled { background: var(--fundo-suave); color: var(--tinta); }
.tf-faixas tbody tr:hover td { background: transparent; }
.tf-mais { margin-top: var(--esp-2); }
.tf-extras { margin-top: var(--esp-3); }
.tf-botoes { display: flex; flex-wrap: wrap; gap: var(--esp-2); margin-top: var(--esp-4); }
.tf-editor .msg ul { margin: 4px 0 0; padding-left: 18px; }

.tf-regua { margin: var(--esp-4) 0 0; }
.tf-trilho { position: relative; height: 18px; border-radius: 6px; background: repeating-linear-gradient(90deg, var(--fundo-suave) 0 6px, #fff 6px 12px); box-shadow: inset 0 0 0 1px var(--borda); overflow: hidden; }
.tf-trecho { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; transition: left .18s var(--ease), width .18s var(--ease); }
.tf-trecho.t0 { background: #8FC9EF; }
.tf-trecho.t1 { background: var(--agua); }
.tf-trecho.t2 { background: var(--azul); }
.tf-trecho.t3 { background: var(--azul-escuro); }
.tf-furo { position: absolute; top: 0; bottom: 0; background: var(--erro-fundo); box-shadow: inset 0 0 0 2px var(--erro); border-radius: 4px; }
.tf-sobre { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, var(--erro) 0 4px, transparent 4px 8px); opacity: .85; }
.tf-marcas { position: relative; height: 18px; margin-top: 4px; font-size: var(--t-nota); color: var(--apoio); }
.tf-marcas span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tf-marcas span:first-child { transform: none; }
.tf-marcas .tf-inf { transform: translateX(-100%); font-size: 14px; line-height: 1; }
.tf-regua figcaption { font-size: var(--t-nota); color: var(--apoio); margin-top: 4px; }

.tf-ex-corpo { padding: 4px 8px 8px; }
.tf-ex th, .tf-ex td { padding: 9px 8px; }
.tf-ex th:first-child, .tf-ex td:first-child { padding-left: 12px; }
.tf-ex th:last-child, .tf-ex td:last-child { padding-right: 12px; }
.tf-dif { font-weight: 600; font-size: var(--t-rotulo); }
.tf-dif.sobe { color: var(--erro); }
.tf-dif.desce { color: var(--ok); }
.tf-dif.igual { color: var(--apoio); font-weight: 500; }

/* e14: descrição longa (plano de contas) quebra linha, para a situação e as ações caberem no painel */
.ap-painel .tab-cards td:not(.acao):not(:first-child) { white-space: normal; min-width: 12ch; }
/* e20: com quatro colunas e três botões a tabela passava da largura e o Inativar sumia; as ações empilham */
@media (min-width: 641px) {
  .ap-painel .tab-cards td:not(.acao):not(:first-child) { min-width: 9ch; }
  .ap-painel .tab-cards td.acao { width: 1%; }
  .ap-painel .tab-cards td.acao button { display: flex; width: 100%; margin: 3px 0; }
}

/* ---------- até 1100 px ---------- */
@media (max-width: 1100px) {
  .ap-grade { grid-template-columns: minmax(220px, 250px) minmax(0, 1fr); }
  .tf-meio { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- até 900 px: uma coluna ---------- */
@media (max-width: 900px) {
  .ap-grade { grid-template-columns: minmax(0, 1fr); }
  .ap-lista { position: static; padding: 12px 16px 14px; }
  .ap-seletor { display: block; }
  .ap-seletor label { margin-top: 0; }
  .ap-grupos { display: none; }
  .ap-numeros { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--esp-4); }
  .ap-numeros div:nth-child(3) { padding-left: 0; box-shadow: none; }
}

/* ---------- celular ---------- */
@media (max-width: 640px) {
  .ap-banco, .tf-palco { padding: 16px; }
  .ap-banco-topo .acoes, .ap-banco-topo .acoes button { width: 100%; }
  .ap-numeros dd { font-size: 22px; }
  .ap-mudancas li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ap-mudancas li > span[aria-hidden] { display: none; }
  .ap-rodape { padding: 12px 16px; }

  .tf-escolhas, .tf-escolhas .segmento { width: 100%; }
  .tf-escolhas .segmento span { padding: 0 6px; font-size: var(--t-rotulo); }
  /* a linha do tempo vira coluna */
  .tf-linha { flex-direction: column; margin-top: var(--esp-4); }
  .tf-linha::before { left: 11px; right: auto; top: 12px; bottom: 12px; width: 2px; height: auto; background: linear-gradient(180deg, rgba(169, 184, 204, .35), rgba(73, 179, 238, .55)); }
  .tf-degrau button { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 12px; padding: 6px 8px 10px 0; }
  .tf-degrau button > :not(.tf-marco) { grid-column: 2; }
  .tf-marco { grid-row: 1 / span 4; margin: 0; }
  .tf-degrau.sel button { margin-left: -6px; width: calc(100% + 6px); padding-left: 6px; border-radius: 10px; box-shadow: inset 2px 0 0 var(--agua); }
  .tf-degrau.sel .tf-marco { margin-left: 0; }
  .tf-hoje { align-self: flex-start; margin: 2px 0 8px 36px; }
  .tf-hoje::after { display: none; }
  /* cada faixa vira um cartão com os campos em 2x2 */
  .tf-faixas, .tf-faixas tbody { display: block; overflow: visible; }
  .tf-faixas thead { display: none; }
  .tf-faixas tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px 12px 12px; margin-bottom: 10px; border: 1px solid var(--borda); border-radius: 12px; }
  .tf-faixas td { display: block; padding: 0; border: 0; }
  .tf-faixas td:first-child { grid-column: 1; grid-row: 1; width: auto; align-self: center; }
  .tf-faixas td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; font-size: var(--t-nota); color: var(--apoio); margin-bottom: 2px; }
  .tf-faixas td.acao { grid-column: 2; grid-row: 1; text-align: right; }
  .tf-faixas td.acao button { min-height: 36px; }
  .tf-ex { font-size: var(--t-rotulo); }
  .tf-ex th, .tf-ex td { padding: 8px 4px; }
  .tf-ex-corpo { padding: 2px 4px 6px; }
  .tf-faixas td.acao:empty { display: none; }
  .tf-faixas input { min-width: 0; width: 100%; }
  .tf-editor .rolagem { overflow: visible; }
  .tf-vig { max-width: none; }
  .tf-botoes button { flex: 1 1 100%; }
}
