/* ============================================================================
   Bot BPO (#bot-bpo-view) — onda 2c do redesign (13/10/2026)
   ----------------------------------------------------------------------------
   Régua: docs/design-diretrizes.md, arquétipo "Tabela de trabalho" (§2.2).
   Mesmas soluções de Lançamentos (onda 2b, js/financial-entries.js): faixa
   única (recorte + busca + filtros), KPI compacto em pílula logo abaixo, card
   opaco da tabela que a partir de 1025 px cabe na janela (altura medida em JS,
   --bpo-h, ajustaAlturaBpo) e rola por dentro com o th grudado e sólido;
   painel de detalhe no <body> com véu --veil-* e camada --ds-z-modal.
   Cor, raio e camada vêm SÓ dos tokens do Hub (css/tokens.css, css/styles.css);
   estado = .ds-chip / --st-*; número = .ds-num (css/components/ds.css).
   ========================================================================== */

/* ── Tela ────────────────────────────────────────────────────────────────── */
.bpo-tela { display: flex; flex-direction: column; }

/* ── Faixa de controles: mês + busca + filtros à esquerda, estado à direita ── */
.bpo-faixa {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 var(--ds-gap-irmaos);
}
.bpo-filtro {
    height: 40px;
    padding: 0 14px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-field);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}
/* base 0 + mínimo 160: a busca cede espaço antes de a linha quebrar */
.bpo-busca { position: relative; flex: 1 1 0; min-width: 160px; max-width: 360px; }
.bpo-busca > i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
    pointer-events: none;
}
.bpo-busca input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-field);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}
.bpo-busca input::placeholder { color: var(--text-muted); }
.bpo-filtro:focus-visible,
.bpo-busca input:focus,
.bpo-campo:focus,
.bpo-botao-filtros:focus-visible,
.bpo-kpi:focus-visible,
.bpo-pag:focus-visible,
.bpo-x:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}

/* Botão "Filtros": controle em fill (camada 2); ativo/aberto = fill mais forte. */
.bpo-pop-ancora { position: relative; }
.bpo-botao-filtros {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-pill);
    corner-shape: round;
    background: var(--ds-fill);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease;
}
.bpo-botao-filtros i { font-size: 15px; color: var(--text-secondary); }
.bpo-botao-filtros:hover,
.bpo-botao-filtros.is-active { background: var(--ds-fill-press); }
/* Contador de filtros: neutro invertido, nunca neon (§5: badge não é neon). */
.bpo-contador {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    corner-shape: round;
    background: var(--text-primary);
    color: var(--bg-card);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Mensagem de estado (carregando, erro): aria-live, à direita da faixa. */
.bpo-status {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 12.5px;
    white-space: nowrap;
}
.bpo-status:empty { display: none; }
.bpo-status.is-erro { color: var(--st-erro); font-weight: 600; white-space: normal; }

/* Popover de filtros: camada 4. Visual = `.ds-pop` (css/components/ds.css §9), top layer por
   `data-ds-pop` (js/ds-popover.js). Aqui só posição, tamanho e o padding de painel. */
.bpo-pop {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    padding: 18px;
    z-index: var(--ds-z-dropdown);
}
.bpo-pop.is-open { display: block; }
.bpo-pop__topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.bpo-pop__titulo { color: var(--text-primary); font-size: 15px; font-weight: 600; }
.bpo-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}
.bpo-link:hover { color: var(--text-primary); }
.bpo-pop__campos { display: flex; flex-direction: column; gap: 12px; }
.bpo-par { display: flex; gap: 8px; align-items: center; }
.bpo-par > .bpo-campo { flex: 1; width: 0; }

/* Rótulo de campo: caixa normal, 12/600 (§4). */
.bpo-rotulo {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}
.bpo-campo {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-field);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}
select.bpo-campo { cursor: pointer; }
.bpo-campo[type="date"] { color-scheme: dark; }
[data-theme="light"] .bpo-campo[type="date"] { color-scheme: light; }
.bpo-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12.5px;
    cursor: pointer;
}
.bpo-check input,
.bpo-tabela input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent-color);
    cursor: pointer;
}

/* ── Resumo: KPI compacto em pílula (§2.4), clicável = filtra o status ───── */
.bpo-kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 8px var(--ds-gap-irmaos);
    margin: 0 0 var(--ds-gap-faixas);
}
.bpo-kpi {
    flex: 1 1 140px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    corner-shape: round;
    box-shadow: var(--shadow-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.bpo-kpi--total { flex: 1.6 1 220px; }
.bpo-kpi:hover { background: var(--ds-fill); }
.bpo-kpi.is-active { border-color: var(--text-secondary); background: var(--ds-fill); }
.bpo-kpi__ponto { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.bpo-kpi__rotulo {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
}
/* O número nunca é cortado: quem cede espaço é o rótulo. */
.bpo-kpi__valor { margin-left: auto; flex: none; font-weight: 600; }
.bpo-kpi__meta { flex: none; color: var(--text-secondary); font-size: 12.5px; }
.bpo-kpi .skeleton { flex: 1; height: 12px; }
.bpo-cor-ok      { color: var(--st-ok); }
.bpo-cor-info    { color: var(--st-info); }
.bpo-cor-atencao { color: var(--st-atencao); }
.bpo-cor-erro    { color: var(--st-erro); }
.bpo-cor-neutro  { color: var(--st-neutro); }

/* ── Tabela: card opaco (camada 1). ≥ 1025 px a altura vem de --bpo-h e quem
   rola é a tabela, com o th grudado e sólido. ──────────────────────────── */
.bpo-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    corner-shape: squircle;
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.bpo-rolagem { overflow: auto; }
@media (min-width: 1025px) {
    .bpo-card { height: var(--bpo-h, auto); }
    .bpo-rolagem { flex: 1 1 auto; min-height: 0; }
}
/* Barra de lote: substitui nada, entra no topo do card enquanto há seleção. */
.bpo-lote {
    display: none;
    flex: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 20px;
    background: var(--ds-fill);
    border-bottom: 1px solid var(--border-color);
}
.bpo-lote.is-open { display: flex; }
.bpo-lote__info { color: var(--text-primary); font-size: 13px; font-weight: 600; }
.bpo-lote__acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.bpo-tabela {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.bpo-tabela th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 10px 8px;
    background: var(--bg-card);
    box-shadow: inset 0 -1px 0 var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    white-space: nowrap;
}
.bpo-tabela th.bpo-ord { cursor: pointer; user-select: none; transition: color 0.15s ease; }
.bpo-tabela th.bpo-ord:hover { color: var(--text-secondary); }
.bpo-seta { font-size: 11px; color: var(--text-muted); }
.bpo-seta.is-active { color: var(--text-primary); }
.bpo-tabela td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
.bpo-tabela :is(th, td):first-child { padding-left: 20px; width: 36px; }
.bpo-tabela :is(th, td):last-child { padding-right: 20px; }
.bpo-tabela tbody tr:last-child td { border-bottom: 0; }
.bpo-tabela tbody tr.bpo-linha { cursor: pointer; transition: background 0.12s ease; }
.bpo-tabela tbody tr.bpo-linha:hover { background: var(--ds-fill); }
.bpo-tabela tbody tr.is-selecionada { background: var(--ds-fill); }
.bpo-tabela td.bpo-col-forte { color: var(--text-primary); font-weight: 500; }
.bpo-tabela td.bpo-col-msg { max-width: 260px; }
.bpo-tabela td.bpo-col-data { font-variant-numeric: tabular-nums; }
.bpo-tabela td.ds-num { color: var(--text-primary); font-weight: 600; max-width: none; }
.bpo-tabela td.bpo-vazio-cel { padding: 0; border-bottom: 0; max-width: none; white-space: normal; }
.bpo-tabela .skeleton { display: block; width: 80%; height: 12px; margin: 6px 0; }

/* Vazio: diz o que fazer (§6). */
.bpo-vazio {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13.5px;
}
@media (max-width: 768px) {
    .bpo-vazio { position: sticky; left: 0; box-sizing: border-box; width: calc(100vw - 48px); max-width: 100%; padding: 40px 16px; overflow-wrap: anywhere; white-space: normal; }
}
.bpo-vazio > i { font-size: 28px; color: var(--text-muted); }
.bpo-vazio__titulo { color: var(--text-primary); font-size: 15px; font-weight: 600; }

/* Paginação */
.bpo-paginacao { flex: none; padding: 12px 20px; border-top: 1px solid var(--border-color); }
.bpo-pag-linha {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.bpo-pag-grupo { display: flex; align-items: center; gap: 4px; }
.bpo-pag-info { color: var(--text-secondary); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-right: 8px; }
.bpo-pag-rotulo { color: var(--text-secondary); font-size: 12.5px; margin-right: 4px; }
.bpo-campo--sm { width: auto; height: 28px; padding: 0 8px; font-size: 12.5px; }
.bpo-pag {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border: 0;
    border-radius: var(--radius-pill);
    corner-shape: round;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background 0.15s ease;
}
.bpo-pag:hover:not(:disabled) { background: var(--ds-fill); color: var(--text-primary); }
.bpo-pag.is-active { background: var(--ds-fill-press); color: var(--text-primary); font-weight: 600; }
.bpo-pag:disabled { opacity: 0.4; cursor: default; }
.bpo-pag-reticencias { color: var(--text-muted); padding: 0 4px; }

/* ── Ações: .btn-primary / .btn-secondary do Hub; aqui só medida e ícone ── */
.bpo-acao.btn-primary,
.bpo-acao.btn-secondary,
.bpo-acao.bpo-acao--perigo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 18px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}
.bpo-acao--sm.bpo-acao { height: 32px; padding: 0 12px; font-size: 12.5px; }
.bpo-acao i { font-size: 15px; }
.bpo-acao.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.bpo-acao.btn-secondary:hover { background: var(--ds-fill); }
.bpo-acao.bpo-acao--perigo {
    background: transparent;
    border: 1px solid var(--st-erro);
    border-radius: var(--radius-pill);
    corner-shape: round;
    color: var(--st-erro);
    transition: background 0.15s ease;
}
.bpo-acao.bpo-acao--perigo:hover { background: var(--st-erro-bg); }
.bpo-acao:disabled { opacity: 0.5; cursor: default; }
.bpo-acao:active,
.bpo-botao-filtros:active,
.bpo-kpi:active,
.bpo-pag:active,
.bpo-x:active { transform: scale(0.97); }

/* Botão fechar (pílula em fill) */
.bpo-x {
    width: 32px;
    height: 32px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--ds-fill);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.bpo-x:hover { background: var(--ds-fill-press); color: var(--text-primary); }

/* ── Painel de detalhe: mora no <body> (portal), véu do Hub, camada
   --ds-z-modal; folha opaca à direita, raio 24, a 10 px das bordas. ─────── */
.bpo-veu {
    position: fixed;
    inset: 0;
    background: var(--veil-bg);
    -webkit-backdrop-filter: var(--veil-bf);
    backdrop-filter: var(--veil-bf);
    z-index: var(--ds-z-modal);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.bpo-veu.is-open { opacity: 1; pointer-events: auto; }
.bpo-painel {
    position: fixed;
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: 440px;
    max-width: calc(100vw - 20px);
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    corner-shape: squircle;
    box-shadow: var(--shadow-card);
    z-index: var(--ds-z-modal);
    overflow: hidden;
    visibility: hidden;
    transform: translateX(calc(100% + 20px));
    transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.45s;
}
.bpo-painel.is-open {
    visibility: visible;
    transform: translateX(0);
    transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
}
.bpo-painel__topo {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}
.bpo-painel__titulo { margin: 0; color: var(--text-primary); font-size: 17px; font-weight: 600; }
.bpo-painel__corpo {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 24px;
}
.bpo-painel__acoes {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
}
.bpo-painel__acoes > .bpo-acao { flex: 1 1 0; }
.bpo-painel__nota { flex: 1 1 100%; color: var(--st-info); font-size: 13px; font-weight: 600; text-align: center; }
.bpo-painel__msg { flex: 1 1 100%; color: var(--st-erro); font-size: 12.5px; font-weight: 600; }
.bpo-painel__msg:empty { display: none; }

/* Superfície interna (camada 1b): bloco do painel. */
.bpo-bloco {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-field);
    corner-shape: squircle;
    color: var(--text-secondary);
    font-size: 13.5px;
}
.bpo-bloco--centro { text-align: center; }
.bpo-midia {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    text-align: center;
}
.bpo-midia img {
    max-width: 100%;
    max-height: 350px;
    border-radius: var(--radius-tile);
    cursor: zoom-in;
}
.bpo-midia a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.bpo-midia a > i { font-size: 36px; color: var(--text-secondary); }
.bpo-midia__aviso { color: var(--text-secondary); font-size: 12.5px; }
.bpo-pessoa { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bpo-avatar {
    flex: none;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ds-fill);
    color: var(--text-secondary);
    font-size: 18px;
}
.bpo-pessoa__nome { color: var(--text-primary); font-size: 14px; font-weight: 600; }
.bpo-pessoa__meta { color: var(--text-secondary); font-size: 12px; }
.bpo-linha-meta { color: var(--text-secondary); font-size: 12.5px; }
.bpo-citacao {
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--ds-fill);
    border-radius: var(--radius-tile);
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.bpo-valor-grande {
    margin: 2px 0 14px;
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.bpo-campos { display: grid; gap: 10px; }
.bpo-campo-valor { margin-top: 2px; color: var(--text-primary); font-size: 13.5px; overflow-wrap: anywhere; }
.bpo-bloco > i { display: block; margin-bottom: 6px; font-size: 22px; color: var(--text-muted); }

/* Lightbox da imagem: acima do painel, mesmo véu. */
.bpo-lightbox {
    position: fixed;
    inset: 0;
    z-index: calc(var(--ds-z-modal) + 10);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--veil-bg);
    -webkit-backdrop-filter: var(--veil-bf);
    backdrop-filter: var(--veil-bf);
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.bpo-lightbox.is-open { opacity: 1; }
.bpo-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius-field);
    cursor: default;
}
.bpo-lightbox .bpo-x {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    color: var(--text-primary);
}

@media (prefers-reduced-motion: reduce) {
    .bpo-painel,
    .bpo-painel.is-open,
    .bpo-veu,
    .bpo-lightbox { transition: none; }
    .bpo-acao:active,
    .bpo-botao-filtros:active,
    .bpo-kpi:active,
    .bpo-pag:active,
    .bpo-x:active { transform: none; }
}

/* ── ≤ 1024: a página volta a rolar (altura automática, regra do ≥ 1025 acima) ── */

/* ── Celular (≤ 768): faixa empilha, KPIs 2 por linha, tabela rola na
   horizontal, painel em tela cheia, alvos de 44 px. ───────────────────── */
@media (max-width: 768px) {
    .bpo-busca { flex: 1 1 100%; max-width: none; order: -1; }
    .bpo-filtro { flex: 1 1 140px; }
    .bpo-status { flex: 1 1 100%; margin-left: 0; white-space: normal; }
    .bpo-filtro,
    .bpo-busca input,
    .bpo-botao-filtros,
    .bpo-acao.btn-primary,
    .bpo-acao.btn-secondary,
    .bpo-acao.bpo-acao--perigo { height: 44px; }
    .bpo-kpis { gap: 8px; margin-bottom: var(--ds-gap-irmaos); }
    .bpo-kpi { flex: 1 1 calc(50% - 4px); padding: 0 12px; }
    .bpo-kpi--total { flex-basis: 100%; }
    .bpo-tabela { min-width: 820px; }
    /* o popover ancora na faixa inteira, logo abaixo dela */
    .bpo-faixa { position: relative; }
    .bpo-pop-ancora { position: static; }
    .bpo-pop { left: 0; right: 0; width: auto; max-width: none; }
    .bpo-painel { top: 0; right: 0; bottom: 0; width: 100%; max-width: none; border-radius: 0; border: 0; }
    .bpo-painel__acoes > .bpo-acao { flex-basis: 100%; }
    .bpo-pag { min-width: 36px; height: 36px; }
}

.bpo-chk-alvo { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

/* Alvo de toque 44 px no celular (14/10/2026): o quadrado visual segue 16 px. */
@media (max-width: 768px) {
    .bpo-check { min-height: 44px; margin-top: 0; }
    /* padding em checkbox nativo é ignorado pelo Chrome: o alvo é o <label> em volta (bot-bpo.js) */
    .bpo-chk-alvo { min-width: 44px; min-height: 44px; margin: -14px; }
}
