/* =============================================================
   Inteligência Municipal — Platform Shell
   Layout do app: rail (mini-menu) + secondary (submenu) +
   header + content (tabs + work).
   Extraído de legacy/designsystem/ui_kits/platform/index.html.
   Depende de: colors_and_type.css (tokens canônicos).
   ============================================================= */

/* Garante que [hidden] sempre esconde — UA stylesheet usa display:none
   sem !important e perde quando uma classe define display:flex/grid/etc.
   Regra global cobre todos os componentes (loaders, badges, empty states). */
[hidden] { display: none !important; }

/* =============================================================
   Ícones SVG (sprite em /css/im-icons.svg)
   Uso: <svg class="ico"><use href="/css/im-icons.svg#slug"/></svg>
   Cor herda de currentColor (do contexto).
   ============================================================= */
.ico {
    display: inline-block;
    flex-shrink: 0;
    vertical-align: middle;
    width: 16px; height: 16px;
    color: inherit;
    fill: none;
    stroke: currentColor;
}

/* ---- Page wrapper (apenas para a página template; em prod o shell ocupa tudo) */
body.kit-page {
    padding: 40px 48px 80px;
    background: #f4f5f7;
    color: #1a1a2e;
    font-family: var(--font-sans);
}
.kit-h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; color: #1a1a2e; }
.kit-sub { color: #525252; font-size: 14px; margin: 0 0 28px; max-width: 880px; line-height: 1.5; }
.kit-sub b { color: #1a1a2e; }
.section { margin-top: 56px; }
.section > h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 6px; color: #1a1a2e; }
.section > .lede { color: #525252; font-size: 13px; margin: 0 0 16px; max-width: 820px; line-height: 1.5; }
.frame { background: #ffffff; border: 1px solid #d9dde3; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,0.04); }

/* =============================================================
   Tokens locais do shell — referenciam os tokens canonicos do
   colors_and_type.css (que ja tem light/dark via [data-theme]).
   Assim os --pf-* herdam automaticamente o tema selecionado, sem
   precisar de bloco [data-theme="dark"] duplicado aqui.

   Mantidos com prefixo --pf-* pra documentar QUEM usa (componentes
   da plataforma) e abrir espaco pra ajustes locais sem mexer no
   design system base.
   ============================================================= */
:root {
    /* Brand = --brand-sky do design system (azul Inteligência Municipal, mesmo da logo
       e do legado). NAO usar --primary do DS aqui — ele eh indigo (#5749f4),
       que nao bate com a identidade visual real da Inteligência Municipal. Esse mapping
       fica isolado nos --pf-*; se outra parte do DS precisar do indigo,
       continua intacto. */
    --pf-primary:         var(--brand-sky);
    --pf-primary-hover:   var(--brand-sky-hover);
    --pf-primary-soft:    var(--brand-sky-soft);
    --pf-rail:            var(--bg-card);          /* alinhado com --pf-side (header) */
    --pf-rail-border:     var(--border);
    --pf-side:            var(--bg-card);
    --pf-side-border:     var(--border);
    --pf-side-hover:      var(--bg-elevated);
    --pf-side-active-bg:  var(--brand-sky-soft);
    --pf-text:            var(--fg);
    --pf-text-muted:      var(--fg-muted);
    --pf-text-subtle:     var(--fg-subtle);
    --pf-border:          var(--border);
    --pf-card-border:     var(--border);
    --pf-bg:              var(--bg);
}

/* =============================================================
   DARK MODE — paleta warm-neutral (inspirada na claude.ai dark).
   Substitui o stack indigo profundo do DS (#0d0b1e/#14122a) que ficava
   pesado pra uso prolongado. Surfaces ficam cinza-warm (off-black com
   tinta marrom sutil), bordas visiveis sem peso, texto cream.
   Brand Inteligência Municipal (indigo #6e62f6) entra so como ACCENT em estados active
   e focus — nao mais tinge as surfaces inteiras.
   ============================================================= */
[data-theme="dark"] {
    /* Surfaces — warm neutral, baixo carga visual. */
    --pf-bg:              #1f1e1c;   /* page bg (warm off-black) */
    --pf-side:            #2a2a28;   /* card/header/aside */
    --pf-rail:            #2a2a28;   /* alinhado com --pf-side (header) */
    --pf-side-hover:      #36352f;   /* hover perceptivel */
    /* Bordas — warm grey, visiveis pra delimitar sem peso. */
    --pf-card-border:     #3d3d3a;
    --pf-side-border:     #3d3d3a;
    --pf-rail-border:     #3d3d3a;
    /* Texto — cream warm, alinhado com a paleta neutra. */
    --pf-text:            #f0eee6;
    --pf-text-muted:      #b8b6ad;
    --pf-text-subtle:     #7c7a72;
    --pf-border:          #3d3d3a;
    /* Primary (Inteligência Municipal blue) — usa --brand-sky-bright (azul claro da logo)
       pra contraste em surfaces dark. Estados active/hover/soft tambem
       referenciam tokens do design system — sem hex hardcoded. */
    --pf-primary:         var(--brand-sky-bright);
    --pf-primary-hover:   var(--brand-sky);
    --pf-primary-soft:    var(--brand-sky-soft);
    --pf-side-active-bg:  var(--brand-sky-soft);
}

/* Body atras do shell — um pouquinho mais escuro que page bg. */
[data-theme="dark"] body { background: #1a1917; }

/* Controles nativos: garante que o menu aberto de qualquer <select> siga
   o tema ativo. Sem color-scheme, browsers podem abrir options claras mesmo
   quando o campo fechado esta estilizado em dark. */
[data-theme="light"] select {
    color-scheme: light;
}
[data-theme="dark"] select {
    color-scheme: dark;
    background-color: var(--pf-bg);
    color: var(--pf-text);
    border-color: var(--pf-border);
}
[data-theme="light"] select option,
[data-theme="light"] select optgroup {
    background-color: #fff;
    color: var(--pf-text);
}
[data-theme="dark"] select option,
[data-theme="dark"] select optgroup {
    background-color: var(--pf-side);
    color: var(--pf-text);
}
[data-theme="dark"] select option:checked {
    background-color: var(--pf-primary-soft);
    color: var(--pf-text);
}

/* =============================================================
   APP shell — grid (header full-width na row 1; rail/secondary/content na row 2)
   Header fica intacto; o botão Menu fecha rail+secondary com animação de slide.
   ============================================================= */
.app {
    display: grid;
    grid-template-columns: 56px 1fr;
    grid-template-rows: 44px 1fr;
    height: 760px;
    background: var(--pf-side);
    transition: grid-template-columns 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Estado fechado (botão Menu togglou). Rail some; content ocupa tudo. */
.app.menu-closed { grid-template-columns: 0px 1fr; }
.app.menu-closed .rail {
    transform: translateX(-100%);
    pointer-events: none;
}

/* App em tela cheia (sem o frame de demonstração) */
.app.fullscreen { height: 100vh; border-radius: 0; }

/* Slide do rail ao abrir/fechar Menu */
.rail {
    transform: translateX(0);
    transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* =============================================================
   Mini-rail (col 1, row 2) — menus principais
   Header full-width fica acima do rail.
   ============================================================= */
.rail {
    grid-column: 1; grid-row: 2;
    background: var(--pf-rail);
    border-right: 1px solid var(--pf-rail-border);
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 0;
    overflow: hidden;
}
.rail .logo {
    width: 32px; height: 32px; border-radius: 7px;
    background: #5749f4; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px; letter-spacing: -0.04em;
    margin-bottom: 10px;
}
.rail .ic {
    width: 36px; height: 36px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #6b6a7e; cursor: pointer; font-size: 14px;
    margin-bottom: 2px; position: relative;
}
.rail .ic:hover { background: var(--pf-primary-soft); color: var(--pf-text); }
.rail .ic.active { background: var(--pf-primary-soft); color: var(--pf-primary); }
.rail .ic.active::before {
    content: ""; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 2px;
    background: var(--pf-primary); border-radius: 0 2px 2px 0;
}
.rail .ic .badge {
    position: absolute; top: 4px; right: 4px;
    min-width: 14px; height: 14px; padding: 0 3px;
    border-radius: 7px; background: #ef4444; color: #fff;
    font-size: 9px; font-weight: 700; line-height: 14px;
    text-align: center; box-sizing: border-box;
}
.rail .sp { flex: 1; }

/* =============================================================
   Rail agrupado por setor (so portaladm — vide MenuQuery::railItemsPorSetor).
   Setores empresariais Operacao / Comercial / Financeiro / TI / Suporte são
   apenas semânticos: visualmente o rail continua só ícones em fila, sem
   separator nem label. Acessibilidade preservada via aria-label + title no
   container <div class="rail-group"> (screen reader anuncia o setor).
   ============================================================= */
.rail-group {
    display: flex; flex-direction: column; align-items: center;
    width: 100%;
}

/* =============================================================
   Skeleton lazy-content — placeholder durante page swap (?_partial=1).
   Shell.php pula queries pesadas, _work.php renderiza este skeleton
   com data-lazy-content="<url>"; JS faz fetch pos-swap e substitui.
   ============================================================= */
.lazy-content { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.lazy-skel { display: grid; gap: 12px; }
.lazy-skel.kpis-skel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lazy-skel.main-skel { grid-template-columns: 1fr; }
.lazy-skel-card { height: 88px; border-radius: 8px; background: var(--pf-rail-border, #e9eaf2); }
.lazy-skel-row  { height: 36px; border-radius: 6px; background: var(--pf-rail-border, #e9eaf2); }
.lazy-skel-card, .lazy-skel-row {
    background: linear-gradient(90deg,
        var(--pf-rail-border, #e9eaf2) 0%,
        rgba(255,255,255,0.6) 50%,
        var(--pf-rail-border, #e9eaf2) 100%);
    background-size: 200% 100%;
    animation: lazy-shimmer 1.2s ease-in-out infinite;
}
@keyframes lazy-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (max-width: 768px) {
    .lazy-skel.kpis-skel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =============================================================
   Secondary panel (col 2, row 2) — submenu + busca + lista
   ============================================================= */
.secondary {
    grid-column: 2; grid-row: 2;
    background: var(--pf-side);
    border-right: 1px solid var(--pf-side-border);
    display: flex; flex-direction: column;
    overflow: hidden;
    position: relative;
}
.sec-head {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--pf-side-border);
    display: flex; align-items: center; justify-content: space-between;
}
.sec-head .title-block .ctx {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--pf-text-subtle); margin-bottom: 3px;
}
.sec-head .title-block .scope {
    font-size: 13.5px; font-weight: 600; color: var(--pf-text); letter-spacing: -0.01em;
    display: flex; align-items: center; gap: 7px;
}
.sec-head .title-block .scope i { font-size: 12px; color: var(--pf-primary); }

.sec-collapse {
    width: 24px; height: 24px; border-radius: 5px; border: 0;
    background: transparent; color: var(--pf-text-subtle); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.sec-collapse:hover { background: var(--pf-side-hover); color: var(--pf-text); }

/* Submenu de páginas (links do módulo) */
.sec-menu { padding: 6px 8px; border-bottom: 1px solid var(--pf-side-border); }
.sec-group {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--pf-text-subtle); padding: 8px 8px 4px;
}
.sec-link {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 8px; border-radius: 5px;
    font-size: 12.5px; color: var(--pf-text);
    cursor: pointer; line-height: 1.2;
    text-decoration: none;
}
a.sec-link:hover { text-decoration: none; }
.sec-link i { width: 14px; text-align: center; font-size: 12px; color: var(--pf-text-muted); }
.sec-link:hover { background: var(--pf-side-hover); }
.sec-link.active { background: var(--pf-side-active-bg); color: var(--pf-primary); font-weight: 600; }
.sec-link.active i { color: var(--pf-primary); }
.sec-link .ct {
    margin-left: auto; font-size: 10px; font-weight: 600;
    padding: 1px 6px; border-radius: 999px;
    background: var(--pf-side-hover); color: var(--pf-text-muted);
}
.sec-link.active .ct { background: var(--pf-primary); color: #fff; }

/* Search + ações compactas */
.sec-search-bar {
    padding: 10px 10px 8px; border-bottom: 1px solid var(--pf-side-border);
    display: flex; gap: 6px; align-items: center;
}
.sec-search {
    flex: 1; height: 28px; border-radius: 5px; border: 1px solid var(--pf-card-border);
    background: var(--pf-bg); padding: 0 8px;
    display: flex; align-items: center; gap: 6px; min-width: 0;
}
.sec-search i { font-size: 11px; color: var(--pf-text-subtle); flex-shrink: 0; }
.sec-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; font-family: inherit; font-size: 12px; color: var(--pf-text); padding: 0; }
.sec-search input::placeholder { color: var(--pf-text-subtle); }
.sec-mini-btn {
    width: 28px; height: 28px; border-radius: 5px; border: 1px solid var(--pf-card-border);
    background: var(--pf-side); color: var(--pf-text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 11px;
    flex-shrink: 0;
}
.sec-mini-btn:hover { background: var(--pf-primary-soft); color: var(--pf-primary); border-color: var(--pf-primary-soft); }
.sec-mini-btn.pri { background: var(--pf-primary); color: #fff; border-color: var(--pf-primary); }
.sec-mini-btn.pri:hover { background: var(--pf-primary-hover); }

/* Lista de itens (contribuintes / módulos / etc) */
.sec-list-head {
    padding: 8px 12px 4px;
    font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--pf-text-subtle);
    display: flex; align-items: center;
}
.sec-list { flex: 1; overflow-y: auto; padding: 0 6px 8px; }
.sec-row {
    padding: 7px 8px; border-radius: 5px;
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; line-height: 1.25;
    border-left: 2px solid transparent;
    text-decoration: none; color: inherit;
}
.sec-row:hover,
.sec-row:focus-visible { background: var(--pf-primary-soft); text-decoration: none; outline: 0; }
.sec-row.active { background: var(--pf-primary-soft); border-left-color: var(--pf-primary); }
.sec-row .chk {
    width: 14px; height: 14px; border: 1.5px solid #cbd2da; border-radius: 3px;
    flex-shrink: 0; background: var(--pf-side); position: relative;
}
.sec-row .chk.on { background: var(--pf-primary); border-color: var(--pf-primary); }
.sec-row .chk.on::after {
    content: ""; position: absolute; left: 3px; top: 0px;
    width: 4px; height: 8px; border-right: 2px solid #fff; border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}
.sec-row .body { flex: 1; min-width: 0; }
.sec-row .nm { font-size: 12.5px; font-weight: 500; color: var(--pf-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-row.active .nm { color: var(--pf-primary); font-weight: 600; }
.sec-row .sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--pf-text-subtle); margin-top: 1px; }
.sec-row .dt {
    width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.sec-row .dt.warn { background: var(--status-warning-fg, #d97706); }
.sec-row .dt.err  { background: var(--color-negative, #dc2626); }
.sec-row .dt.ok   { background: var(--color-positive, #16a34a); }

/* =============================================================
   Skeleton placeholder rows (drawer com lazy_load=1).
   Renderizado server-side em vez de items reais; substituido pelo
   JS apos /api/dataset.php responder. Pulse animation suave pra
   sinalizar carregamento sem distrair.
   ============================================================= */
.sec-row-skeleton { cursor: default; pointer-events: none; }
.sec-row-skeleton .chk { background: var(--pf-side); }
.sec-row-skeleton .sk-bar,
.sec-row-skeleton .sk-dot {
    display: inline-block;
    background: linear-gradient(90deg,
        var(--pf-primary-soft, #eef2f7) 0%,
        var(--pf-side, #f5f7fa) 50%,
        var(--pf-primary-soft, #eef2f7) 100%);
    background-size: 200% 100%;
    animation: sk-shimmer 1.4s ease-in-out infinite;
    border-radius: 3px;
}
.sec-row-skeleton .sk-bar    { height: 10px; width: 70%; }
.sec-row-skeleton .sk-bar-sm { height: 8px;  width: 45%; margin-top: 3px; }
.sec-row-skeleton .sk-dot    { width: 6px; height: 6px; border-radius: 50%; }
.sec-row-skeleton .body { flex: 1; }
@keyframes sk-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =============================================================
   Skeleton placeholder rows (workspace surface — lazy_mode='auto'
   resolveu lazy=true ou lazy_mode='on'). Mantem o mesmo grid
   das rows reais (--cols) e altura 40px pra zero layout shift na
   troca skeleton -> items. Reusa @keyframes sk-shimmer global.
   ============================================================= */
.da-row-skeleton { cursor: default; pointer-events: none; }
.da-row-skeleton .chk { background: var(--pf-side); }
.da-row-skeleton .sk-bar {
    display: inline-block;
    height: 10px; width: 70%;
    background: linear-gradient(90deg,
        var(--pf-primary-soft, #eef2f7) 0%,
        var(--pf-side, #f5f7fa) 50%,
        var(--pf-primary-soft, #eef2f7) 100%);
    background-size: 200% 100%;
    animation: sk-shimmer 1.4s ease-in-out infinite;
    border-radius: 3px;
}

/* =============================================================
   .sec-list.is-grid — render multi-coluna driven por menu_lista.cols.
   Opt-in via classe; --cols vem inline no PHP (`grid-template-columns`).
   Layout: [chk 22px] + N cells configuradas no JSON.
   Regra de produto: nunca quebra linha. Truncate aplicado no PHP
   (full → 1a palavra → ellipsis); CSS so garante o nowrap+overflow.
   ============================================================= */
.sec-list.is-grid > .sec-row {
    display: grid;
    grid-template-columns: var(--cols);
    column-gap: 8px;
    align-items: center;
    padding: 7px 8px;
}
.sec-list.is-grid > .sec-row > .cell {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    color: var(--pf-text);
    line-height: 1.25;
}
.sec-list.is-grid > .sec-row.active   > .cell-nm,
.sec-list.is-grid > .sec-row.tab-open > .cell-nm,
.sec-list.is-grid > .sec-row.selected > .cell-nm { color: var(--pf-primary); font-weight: 600; }
.sec-list.is-grid > .sec-row > .cell-status {
    display: flex; align-items: center; justify-content: center;
    overflow: visible;
}

/* =============================================================
   Header (full-width — span de todas as colunas, row 1)
   Fica em cima do rail + secondary + content.
   ============================================================= */
.header {
    grid-column: 1 / -1; grid-row: 1;
    height: 44px; box-sizing: border-box;
    border-bottom: 1px solid var(--pf-side-border);
    display: flex; align-items: center; padding: 0 12px;
    background: var(--pf-side); gap: 8px;
}
/* Botão Menu (substitui os 2 toggles antigos) */
.header .h-menu-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 30px; padding: 0 12px;
    background: transparent; border: 0; cursor: pointer;
    color: var(--pf-text-muted);
    border-radius: 6px;
    font-family: inherit; font-size: 12.5px; font-weight: 500;
    line-height: 1;
}
.header .h-menu-btn i { font-size: 13px; }
.header .h-menu-btn:hover { background: var(--pf-side-hover); color: var(--pf-text); }
.header .h-menu-btn .label { letter-spacing: 0; }

/* Mobile: vira hamburger (esconde texto) */
@media (max-width: 768px) {
    .header .h-menu-btn { padding: 0; width: 30px; justify-content: center; }
    .header .h-menu-btn .label { display: none; }
}
.header .crumb-mini {
    font-size: 12.5px; color: var(--pf-text-muted);
    display: flex; align-items: center; gap: 6px;
}
.header .crumb-mini b { color: var(--pf-text); font-weight: 600; }
.header .crumb-mini i.fa-chevron-right { font-size: 9px; opacity: 0.5; }

/* Dropdown navegavel no ultimo crumb (subpaginas) — HTML nativo via <details>+<summary>.
   Zero JS: a11y, abrir/fechar com Tab/Enter/Escape, fecha sozinho ao navegar (DOM swap). */
.header .crumb-dd { position: relative; display: inline-block; }
.header .crumb-dd-toggle {
    list-style: none;                              /* remove marker default */
    cursor: pointer;
    padding: 2px 4px;
    display: inline-flex; align-items: center; gap: 4px;
    border-radius: 4px;
    font: inherit; color: inherit;
}
.header .crumb-dd-toggle::-webkit-details-marker { display: none; }   /* WebKit/Chromium */
.header .crumb-dd-toggle::marker { content: ''; }                     /* Firefox */
.header .crumb-dd-toggle:hover { background: var(--pf-side-hover); }
.header .crumb-dd[open] > .crumb-dd-toggle { background: var(--pf-primary-soft); }
.header .crumb-dd-toggle .ico { color: var(--pf-text-subtle); transition: transform 120ms; }
.header .crumb-dd[open] > .crumb-dd-toggle .ico { transform: rotate(180deg); color: var(--pf-primary); }
.header .crumb-dd-menu {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 100;
    min-width: 180px;
    background: var(--pf-side);
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(20, 24, 40, 0.12);
    padding: 4px;
    display: flex; flex-direction: column; gap: 1px;
}
.header .crumb-dd-item {
    padding: 7px 10px; border-radius: 4px;
    font-size: 12.5px; color: var(--pf-text);
    text-decoration: none; white-space: nowrap;
    display: flex; align-items: center; gap: 8px;
}
.header .crumb-dd-item > .ico { color: var(--pf-text-muted); flex-shrink: 0; }
.header .crumb-dd-item:hover { background: var(--pf-side-hover); }
.header .crumb-dd-item:hover > .ico { color: var(--pf-text); }
.header .crumb-dd-item.active { background: var(--pf-side-active-bg); color: var(--pf-primary); font-weight: 600; }
.header .crumb-dd-item.active > .ico { color: var(--pf-primary); }
.header .sp { flex: 1; }
.header .h-pill {
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 10px; border-radius: 6px;
    background: var(--pf-bg); border: 1px solid var(--pf-card-border);
    font-size: 11.5px; color: var(--pf-text-muted); cursor: pointer;
}
.header .h-pill b { color: var(--pf-text); font-weight: 600; }
.header .h-pill i { font-size: 10px; }
.header .h-pill:hover { background: var(--pf-primary-soft); }

/* ---------- Municipio dropdown (h-municipio-dd) — switch tenant via header.
   Mesmo idioma visual do .h-user-dd; light-dismiss via dropdowns.js
   (qualquer <details class="...-dd"> herda automaticamente). */
.header .h-municipio-dd { position: relative; }
.header .h-municipio-dd > summary { list-style: none; }
.header .h-municipio-dd > summary::-webkit-details-marker { display: none; }
.header .h-municipio-dd[open] > .h-pill { background: var(--pf-primary-soft); }
.header .h-municipio-dd[open] > .h-pill .ico:last-child {
    transform: rotate(180deg); color: var(--pf-primary);
}
.header .h-pill .ico:last-child { transition: transform 120ms; }

.header .h-municipio-menu {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 100;
    min-width: 260px; max-height: 380px;
    background: var(--pf-side);
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    display: flex; flex-direction: column;
    margin: 0; padding: 0;
}
.header .h-municipio-list {
    list-style: none; margin: 0; padding: 4px;
    overflow-y: auto;
}
.header .h-municipio-item {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 5px;
    font-size: 12.5px; font-family: inherit; color: var(--pf-text);
    background: transparent; border: 0; cursor: pointer; text-align: left;
}
.header .h-municipio-item:hover { background: var(--pf-primary-soft); }
.header .h-municipio-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header .h-municipio-item .uf {
    font-size: 10.5px; font-weight: 600; color: var(--pf-text-muted);
    background: var(--pf-bg); padding: 2px 6px; border-radius: 3px;
    flex-shrink: 0; letter-spacing: 0.5px;
}
.header .h-municipio-item.is-current {
    background: var(--pf-primary-soft);
}
.header .h-municipio-item.is-current .nm { color: var(--pf-primary); font-weight: 600; }
.header .h-municipio-item.is-current .uf { background: transparent; color: var(--pf-primary); }
.header .h-ic {
    width: 28px; height: 28px; border-radius: 6px;
    background: transparent; border: 0; color: var(--pf-text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px; position: relative;
}
.header .h-ic:hover { background: var(--pf-side-hover); color: var(--pf-text); }
.header .h-etl-wrap { position: relative; display: flex; }
.header .h-etl-pop {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--pf-card);
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    padding: 7px 12px;
    white-space: nowrap;
    font-size: 12.5px;
    color: var(--pf-text);
    box-shadow: 0 4px 14px rgba(0,0,0,.13);
    z-index: 300;
}
.header .h-ic .dot {
    position: absolute; top: 5px; right: 5px;
    width: 6px; height: 6px; border-radius: 50%; background: #ef4444;
    border: 1.5px solid #fff;
}
/* User trigger no header — virou summary do <details> dropdown.
   list-style:none e ::-webkit-details-marker tiram o triangulo default. */
.header .h-user-dd { position: relative; }
.header .h-user-dd > summary { list-style: none; }
.header .h-user-dd > summary::-webkit-details-marker { display: none; }
.header .h-user {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px; cursor: pointer;
    user-select: none;
}
.header .h-user:hover { background: var(--pf-primary-soft); }
.header .h-user-dd[open] > .h-user { background: var(--pf-primary-soft); }
.header .h-user-dd[open] > .h-user .ico { transform: rotate(180deg); color: var(--pf-primary); }
.header .h-user .nm { font-size: 12px; color: var(--pf-text); font-weight: 500; }
.header .h-user .ico { color: var(--pf-text-subtle); transition: transform 120ms; }

/* Dropdown do user (mesmo idioma visual do crumb-dd-menu). */
.header .h-user-menu {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 100;
    min-width: 240px;
    background: var(--pf-side);
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
.header .h-user-head {
    padding: 12px 14px;
    background: var(--pf-bg);
    border-bottom: 1px solid var(--pf-card-border);
}
.header .h-user-head .nm {
    font-size: 13px; font-weight: 600; color: var(--pf-text);
    line-height: 1.3;
}
.header .h-user-head .email {
    font-size: 11.5px; color: var(--pf-text-muted);
    margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header .h-user-list { list-style: none; margin: 0; padding: 4px; }
.header .h-user-list a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 5px;
    font-size: 12.5px; color: var(--pf-text);
    text-decoration: none;
}
.header .h-user-list a:hover { background: var(--pf-side-hover); }
.header .h-user-list a > .ico { color: var(--pf-text-muted); flex-shrink: 0; }
.header .h-user-list a:hover > .ico { color: var(--pf-text); }
.header .h-user-list a.danger { color: #dc2626; }
.header .h-user-list a.danger > .ico { color: #dc2626; }
.header .h-user-list a.danger:hover { background: rgba(220, 38, 38, 0.12); }

/* Theme picker. 3 botoes lado a lado; o ativo fica destacado.
   data-theme-active eh setado pelo JS de theme.js. */
.header .h-user-theme { padding: 8px 12px 10px; }
.header .h-user-theme .theme-label {
    display: block;
    font-size: 9.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--pf-text-subtle);
    margin-bottom: 6px;
}
.header .h-user-theme .theme-options {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
}
.header .theme-option {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 8px 4px; border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side); color: var(--pf-text-muted);
    font-family: inherit; font-size: 11px; font-weight: 500;
    cursor: pointer;
}
.header .theme-option:hover { background: var(--pf-side-hover); color: var(--pf-text); }
.header .theme-option[aria-checked="true"] {
    background: var(--pf-primary-soft); color: var(--pf-primary); border-color: var(--pf-primary-soft);
}
.header .theme-dot {
    width: 14px; height: 14px; border-radius: 50%;
    border: 1.5px solid var(--pf-card-border);
}
.header .theme-dot.light { background: #fff; }
.header .theme-dot.dark  { background: #1e293b; border-color: #1e293b; }
.header .theme-dot.sys   { background: linear-gradient(90deg, #fff 50%, #1e293b 50%); }

.header .h-user-divider { height: 1px; background: var(--pf-card-border); }

/* Logo Inteligência Municipal no canto direito — img com light/dark switch via CSS. */
.header .h-logo {
    display: inline-flex; align-items: center; justify-content: center;
    height: 28px; padding: 0 10px;
    margin-left: 6px;
    flex-shrink: 0;
    text-decoration: none;
}
.header .h-logo .logo-img {
    height: 22px; width: auto; display: block;
}
/* Default: light theme -> mostra logo original; dark -> branca. */
.header .h-logo .logo-dark { display: none; }
[data-theme="dark"] .header .h-logo .logo-light { display: none; }
[data-theme="dark"] .header .h-logo .logo-dark  { display: block; }

/* =============================================================
   Content (col 3, row 2) — tabs + workspace
   ============================================================= */
.content { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Quando ha drawer, .content vira grid 2x2:
     col 1 (1fr)              | col 2 (drawer)
   ┌─────────────────────────┬─────────────────┐
   │ tabs                    │ items-list      │  row 1 (38px tabs)
   ├─────────────────────────┤ (toolbar fica   │
   │ work                    │  alinhada com a │
   │ ↳ work-main             │  linha das tabs)│  row 2 (1fr)
   └─────────────────────────┴─────────────────┘
   .items-list spans rows 1-2 — sua toolbar (1o filho) ocupa row 1 visualmente. */
.content.has-drawer {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 30%);
    grid-template-rows: 38px 1fr;
}
.content.has-drawer > .tabs       { grid-column: 1; grid-row: 1; }
.content.has-drawer > .work       { grid-column: 1; grid-row: 2; }
.content.has-drawer > .items-list { grid-column: 2; grid-row: 1 / 3; }

/* Quando recolhido, col 2 some — work-main ocupa toda a largura, toggle
   migra naturalmente pro extremo direito da .tabs (margin-left: auto). */
.content.has-drawer.aside-collapsed {
    grid-template-columns: 1fr 0;
}

/* Tabs: 1 fixa + N flex */
.tabs {
    background: var(--pf-side); border-bottom: 1px solid var(--pf-side-border);
    padding: 0 8px; display: flex; gap: 0; align-items: stretch;
    height: 38px; box-sizing: border-box;
    overflow: hidden;
}
.tabs-scroll {
    flex: 1; min-width: 0;
    display: flex; align-items: stretch;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs-scroll::-webkit-scrollbar { display: none; }
.tab {
    padding: 0 12px; box-sizing: border-box;
    font-size: 12.5px; color: var(--pf-text-muted);
    cursor: pointer; border-bottom: 2px solid transparent;
    line-height: 1; white-space: nowrap; font-weight: 500;
    display: inline-flex; align-items: center; gap: 6px;
    flex-shrink: 0;
    border-right: 1px solid transparent;
}
.tab i.tab-ic { font-size: 11px; }
.tab:hover { color: var(--pf-text); background: transparent; }
/* Active = so underline + cor (mesmo padrao da .subtab.active). Sem mudar
   background — antes ficava `--pf-side` que destoava em dark. */
.tab.active { color: var(--pf-primary); border-bottom-color: var(--pf-primary); font-weight: 600; background: transparent; }
.tab .pin {
    font-size: 9px; color: var(--pf-text-subtle); margin-right: 2px;
}
/* close-x: cor brand (azul Inteligência Municipal) em todas as tabs. Lista 2 seletores
   porque tabs com href viram <a> aninhando outro <a class="close-x"> —
   HTML invalido faz o browser detachar o close-x pra ser irmao direto
   de .tabs-scroll (em vez de filho de .tab). Cobrimos ambos os casos. */
.tab .close-x,
.tabs-scroll > .close-x {
    width: 16px; height: 16px; border-radius: 3px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--pf-primary); font-size: 9px; margin-left: 4px;
    cursor: pointer;
}
.tab.active .close-x { color: var(--pf-primary); }
.tab .close-x:hover,
.tabs-scroll > .close-x:hover {
    background: var(--pf-side-hover); color: var(--pf-primary-hover);
}
.tab.flex { background: transparent; }
.tab.flex.active { background: transparent; }
.tab.flex .flex-name { white-space: nowrap; }
.tab.flex .flex-cnpj { font-family: var(--font-mono); font-size: 10.5px; color: var(--pf-text-subtle); padding: 1px 6px; border-radius: 3px; background: var(--pf-side-hover); }
.tab.flex.active .flex-cnpj { color: var(--pf-primary); background: var(--pf-primary-soft); }

.tabs-meta {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 8px;
    padding: 0 10px;
    font-size: 11px; color: var(--pf-text-subtle);
    border-left: 1px solid var(--pf-side-border);
}

/* Toggle do items-list (canto direito da .tabs). Visualmente alinhado com a
   borda esquerda do items-list quando expandido; quando colapsado, fica
   encostado na borda direita do shell. Icone flipa via classe is-collapsed. */
.tab-aside-toggle {
    flex-shrink: 0;
    margin-left: auto;     /* empurra pro extremo direito da .tabs */
    width: 32px; height: 100%;
    background: transparent; border: 0; cursor: pointer;
    color: var(--pf-text-muted);
    display: flex; align-items: center; justify-content: center;
    border-left: 1px solid var(--pf-side-border);
}
.tab-aside-toggle:hover { background: var(--pf-bg); color: var(--pf-primary); }
.tab-aside-toggle .ico { transition: transform 180ms; }
.content.aside-collapsed .tab-aside-toggle .ico { transform: rotate(180deg); }

/* Estado colapsado: items-list some por completo, work-main toma todo o espaco. */
.content.aside-collapsed .items-list { display: none; }
.tabs-meta .count {
    font-family: var(--font-mono); font-weight: 600;
    color: var(--pf-text);
}
.tabs-meta .count b { color: var(--pf-primary); }

/* Workspace — split em coluna principal (KPIs+tabela) e lateral (busca+lista) */
.work {
    flex: 1; min-height: 0; overflow: hidden;
    display: flex; flex-direction: row;
    background: var(--pf-bg);
}
.work-main {
    flex: 1; min-width: 0; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
    padding: 16px;
    /* Container query: charts-grid responde a largura REAL do workspace
       (nao da viewport). Quando .items-list colapsa, work-main cresce e
       a grid recalcula auto-fill -> mais colunas, sem media query. */
    container-type: inline-size;
    container-name: workspace;
}
/* KPIs e sub-abas ficam fixas no topo; o data-card ocupa o resto */
.work-main > .kpis,
.work-main > .subtabs { flex-shrink: 0; }
.work-main > .data-card {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.work-main > .data-card > .data-card-head { flex-shrink: 0; }
.work-main > .data-card > .data-card-body {
    flex: 1; min-height: 0;
    overflow: hidden;
    display: flex; flex-direction: column;
}
/* Tabela (.tbl) ocupa toda altura do data-card-body quando esta dentro dele */
.work-main > .data-card > .data-card-body > .tbl {
    flex: 1; min-height: 0;
}
.items-list {
    /* Items-list eh sempre grid item de .content.has-drawer (col 2, span rows 1-2).
       Sizing vem do grid-template-columns do parent — minmax(240px, 30%).
       Aqui so define o layout interno (toolbar/list em coluna) + decoracao. */
    display: flex; flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--pf-side-border);
    background: var(--pf-side);
}

/* =============================================================
   Drawer tabbed mode — aba IA (Pesquisa removida)
   - .drawer-tabs: nav 38px alinhada com .tabs do work-main
   - .drawer-panel: corpo da tab, flex 1 (preenche rest do drawer)
   ============================================================= */
.drawer-tabs {
    flex-shrink: 0;
    height: 38px; box-sizing: border-box;
    display: flex; gap: 0;
    background: var(--pf-side);
    border-bottom: 1px solid var(--pf-side-border);
}
.drawer-tabs--single .drawer-tab {
    flex: 1;
    cursor: default;
}
.drawer-tab {
    flex: 1; min-width: 0;
    background: transparent; border: 0; cursor: pointer;
    padding: 0 12px;
    font-size: 12.5px; font-weight: 500;
    color: var(--pf-text-muted);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-bottom: 2px solid transparent;
    line-height: 1; white-space: nowrap;
    transition: color 120ms, background 120ms, border-color 120ms;
}
.drawer-tab:hover:not(.active) {
    background: var(--pf-side-hover);
    color: var(--pf-text);
}
.drawer-tab.active {
    color: var(--pf-primary);
    border-bottom-color: var(--pf-primary);
}
.drawer-tab .ico { color: currentColor; }

.drawer-panel {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.drawer-panel[hidden] { display: none; }

/* Panel IA — chat mockup (estilo Claude/GPT vazio) */
.drawer-ia {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden;
}
.drawer-ia-thread {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.drawer-ia-empty {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; gap: 12px;
    padding: 24px 16px;
    color: var(--pf-text-muted);
}
.drawer-ia-empty .ico-large { color: var(--pf-text-subtle); opacity: 0.7; }
.drawer-ia-empty .muted { font-size: 12px; margin: 0; max-width: 220px; line-height: 1.5; }

.drawer-ia-composer {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid var(--pf-side-border);
    background: var(--pf-side);
    display: flex; align-items: flex-end; gap: 8px;
}
.drawer-ia-input {
    flex: 1; min-width: 0;
    background: var(--pf-bg);
    border: 1px solid var(--pf-side-border);
    border-radius: 10px;
    padding: 8px 10px;
    font: inherit; font-size: 13px; line-height: 1.4;
    color: var(--pf-text);
    resize: none;
    max-height: 120px;
    outline: 0;
    transition: border-color 120ms;
}
.drawer-ia-input:focus { border-color: var(--pf-primary); }
.drawer-ia-input::placeholder { color: var(--pf-text-subtle); }

.drawer-ia-send {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--pf-primary);
    color: #fff;
    border: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: opacity 120ms, background 120ms;
}
.drawer-ia-send:hover:not(:disabled) { background: var(--pf-primary-hover); }
.drawer-ia-send:disabled { opacity: 0.35; cursor: not-allowed; }
.drawer-ia-send .ico { transform: rotate(-90deg); }   /* chevron-right vira "up arrow" */
/* Em telas estreitas o aside roubaria todo o espaco do workspace.
   Esconde abaixo de 1100px e tambem colapsa o grid track — sem isso,
   o track de col 2 fica reservado e cria buraco a direita do work-main. */
@media (max-width: 1100px) {
    .items-list { display: none; }
    .content.has-drawer { grid-template-columns: 1fr 0; }
}

/* =============================================================
   Sub-abas (dentro do workspace, ex: Dados/Logs/Ações de um item)
   ============================================================= */
.subtabs {
    display: flex; gap: 2px; align-items: center;
    margin: -16px -16px 16px;
    padding: 0 12px;
    background: var(--pf-side);
    border-bottom: 1px solid var(--pf-card-border);
    height: 36px; box-sizing: border-box;
}
.subtab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 12px; height: 100%;
    font-size: 12px; color: var(--pf-text-muted);
    border-bottom: 2px solid transparent;
    text-decoration: none; font-weight: 500;
    cursor: pointer;
}
.subtab:hover { color: var(--pf-text); background: var(--pf-bg); text-decoration: none; }
.subtab.active { color: var(--pf-primary); border-bottom-color: var(--pf-primary); font-weight: 600; }

/* =============================================================
   Grid de campos (sub-aba "Dados" do detalhe de item)
   ============================================================= */
.fields-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px;
    padding: 16px;
}
.fields-grid-scroll {
    height: 100%;
    overflow: auto;
    padding: 16px;
}
.fields-grid-scroll .fields-grid {
    padding: 0;
    min-width: 640px;
}
@media (max-width: 720px) {
    .fields-grid { grid-template-columns: 1fr; }
    .fields-grid-scroll .fields-grid { min-width: 0; }
}
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field-lb {
    font-size: 10.5px; font-weight: 600; color: var(--pf-text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.field-vl {
    font-size: 13px; color: var(--pf-text);
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Filtros de sub-aba do detalhe (ex: Transacoes por ano/mes) */
.detalhe-filters {
    display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end;
    padding: 12px 16px; border-bottom: 1px solid var(--pf-border);
}
.detalhe-filter { display: flex; flex-direction: column; gap: 4px; }
.detalhe-filter-lb {
    font-size: 10.5px; font-weight: 600; color: var(--pf-text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.detalhe-filter select {
    font-size: 13px; color: var(--pf-text);
    background: var(--pf-bg); border: 1px solid var(--pf-card-border);
    border-radius: 6px; padding: 5px 8px; min-width: 120px;
}

/* Mensagem vazia em data-card */
.empty-msg {
    padding: 28px 16px; text-align: center;
    font-size: 12.5px; color: var(--pf-text-muted);
}

/* =============================================================
   KPIs — grid responsivo via container queries
   ============================================================= */
.kpis {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px;
    container-type: inline-size; container-name: kpis;
}
@container kpis (max-width: 880px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
}
@container kpis (max-width: 460px) {
    .kpis { grid-template-columns: 1fr; }
    .kpis .kpi { padding: 10px 12px; }
    .kpis .kpi .val { font-size: 18px; }
}
.kpi {
    background: var(--pf-side); border: 1px solid var(--pf-card-border); border-radius: 6px;
    padding: 12px 14px;
}
.kpi .lbl {
    font-size: 10.5px; font-weight: 600; color: var(--pf-text-muted);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
}
.kpi .lbl i { color: var(--pf-text-subtle); font-size: 10px; }
.kpi .lbl-short { display: none; }
@container kpis (max-width: 1080px) {
    .kpi .lbl-full { display: none; }
    .kpi .lbl-short { display: inline; }
}
@container kpis (max-width: 760px) {
    .kpi .lbl-short { display: none; }
    .kpi .lbl i { font-size: 11px; }
}
.kpi .val {
    font-size: 22px; font-weight: 700; letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums; color: var(--pf-text); line-height: 1.1;
}
.kpi .sub { font-size: 11px; color: var(--pf-text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub.up { color: #16a34a; font-weight: 600; }
.kpi .sub.down { color: #dc2626; font-weight: 600; }

/* =============================================================
   Data card + tabela (toolbar com container queries)
   ============================================================= */
.data-card { background: var(--pf-side); border: 1px solid var(--pf-card-border); border-radius: 6px; overflow: hidden; }
.data-card-head {
    padding: 10px 14px; border-bottom: 1px solid var(--pf-card-border);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.data-card-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--pf-text); }
.data-card-head .meta { font-size: 11px; color: var(--pf-text-muted); }
.data-card-head-end {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.data-card-head-end .cn-detail-icon {
    flex-shrink: 0;
}

.tbl-toolbar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--pf-card-border);
    background: var(--pf-bg);
    container-type: inline-size;
    container-name: tbar;
    flex-wrap: nowrap;
    overflow: hidden;
}
.tbl-toolbar .ft {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 10px;
    background: var(--pf-side); border: 1px solid var(--pf-card-border); border-radius: 6px;
    font-size: 12px; color: var(--pf-text); cursor: pointer;
    white-space: nowrap; flex-shrink: 0;
}
.tbl-toolbar .ft.icon { padding: 0; width: 28px; justify-content: center; }
.tbl-toolbar .ft i.fa-solid:first-child { color: var(--pf-text-muted); font-size: 11px; }
.tbl-toolbar .ft b { font-weight: 600; }
.tbl-toolbar .ft .chev { color: var(--pf-text-muted); font-size: 9px; margin-left: 2px; }
.tbl-toolbar .ft.primary { background: var(--pf-primary); border-color: var(--pf-primary); color: #fff; }
.tbl-toolbar .ft.primary i { color: rgba(255,255,255,.85); }
.tbl-toolbar .ft-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px; padding: 0 5px;
    background: var(--pf-primary); color: #fff;
    font-size: 10px; font-weight: 600; border-radius: 8px;
}
.tbl-toolbar .spread { flex: 1 1 auto; min-width: 0; }
.tbl-toolbar .search-wrap { flex: 0 1 220px; min-width: 0; }
.tbl-toolbar .search {
    width: 100%;
    height: 28px; padding: 0 10px 0 28px;
    border: 1px solid var(--pf-card-border); border-radius: 6px;
    background: var(--pf-side) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2371717a' stroke-width='1.6'><circle cx='7' cy='7' r='4.5'/><path d='M10.5 10.5L14 14'/></svg>") no-repeat 9px center / 12px;
    font-size: 12px;
}
.tbl-toolbar .show-md, .tbl-toolbar .show-sm { display: none; }
@container tbar (max-width: 720px) {
    .tbl-toolbar .hide-md { display: none; }
    .tbl-toolbar .show-md { display: inline-flex; }
}
@container tbar (max-width: 560px) {
    .tbl-toolbar .hide-lg { display: none; }
    .tbl-toolbar .search-wrap { display: none; }
    .tbl-toolbar .show-sm { display: inline-flex; }
    .tbl-toolbar .hide-sm { display: none; }
}

/* =============================================================
   Tabela (.tbl) — CSS Grid compartilhado entre head e body.
   N de colunas ilimitado: <div class="tbl" style="--cols: 24% 12% 1fr 50px">.

   Trick: .tbl-head e .tbl-body sao GRIDS proprios com mesmo
   grid-template-columns. As .tbl-row tem display:contents — suas cells
   viram filhas diretas do grid pai. Resultado: alinhamento perfeito
   entre header e rows, sem JS, sem hack semantico (roles ARIA preservadas).
   ============================================================= */
.tbl {
    display: flex; flex-direction: column;
    width: 100%; min-width: 0;
    font-family: var(--font-sans); font-size: 12.5px;
    background: var(--pf-side);
}
.tbl-head, .tbl-body {
    display: grid;
    grid-template-columns: var(--cols, repeat(auto-fill, minmax(80px, 1fr)));
}
.tbl-head {
    flex-shrink: 0;
    background: inherit;
    border-bottom: 1px solid var(--pf-card-border);
    /* Reserva espaco igual ao gutter do .tbl-body (que tem scrollbar-gutter:stable).
       overflow-y: scroll forca a barra (sempre 16px), mas pintamos
       transparente em vez de scrollbar-width:none — porque "none"
       em Chromium zera o gutter e quebra o alinhamento. */
    overflow-y: scroll;
    scrollbar-color: transparent transparent;     /* track + thumb invisiveis */
}
.tbl-head::-webkit-scrollbar { background: transparent; }
.tbl-head::-webkit-scrollbar-thumb { background: transparent; }
.tbl-body {
    flex: 1; min-height: 0;
    align-content: start;
    overflow-y: auto;
    /* reserva permanentemente o espaco da scrollbar, alinhando com
       o gutter do .tbl-head (overflow-y:scroll + scrollbar oculta) */
    scrollbar-gutter: stable;
    scrollbar-color: color-mix(in srgb, var(--pf-text-muted) 42%, transparent) var(--pf-side);
    scrollbar-width: thin;
}
.tbl-body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.tbl-body::-webkit-scrollbar-track {
    background: var(--pf-side);
}
.tbl-body::-webkit-scrollbar-thumb {
    border: 2px solid var(--pf-side);
    border-radius: 999px;
    background: color-mix(in srgb, var(--pf-text-muted) 42%, transparent);
}
[data-theme="dark"] .tbl-body {
    scrollbar-color: #5b5a54 #25241f;
}
[data-theme="dark"] .tbl-body::-webkit-scrollbar-track {
    background: #25241f;
}
[data-theme="dark"] .tbl-body::-webkit-scrollbar-thumb {
    border-color: #25241f;
    background: #5b5a54;
}
/* Rows como wrappers semanticos (role=row), sem caixa visual */
.tbl-row { display: contents; }
.tbl-cell {
    padding: 9px 14px;
    color: var(--pf-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    box-sizing: border-box;
    min-width: 0;
    /* min-height: sem isso, overflow+ellipsis+nowrap permite o grid calcular
       min-content da cell IGNORANDO o padding vertical — o track vira ~18px
       (line-height puro), o padding renderiza mas vaza pra fora, e cells
       consecutivas overlapam. Resultado visual: rows comprimidas + hover
       de uma cobre a vizinha. min-height fixo garante track > altura intrinsic. */
    min-height: 38px;
    align-self: center;
}
/* Border-bottom + hover por row (display:contents propaga hover do row pros filhos via :has) */
.tbl-body > .tbl-row > .tbl-cell { border-bottom: 1px solid var(--pf-card-border); }
.tbl-body > .tbl-row:has(> .tbl-cell:hover) > .tbl-cell { background: var(--pf-bg); }
/* Header cells */
.tbl-h {
    font-size: 10.5px; font-weight: 700; color: var(--pf-text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    text-align: left;
}
/* Variants — alinhamento + estilos especificos por celula */
/* Apenas text-align — sem justify-self (manteria o ITEM com tamanho do conteudo,
   visualmente igual mas confunde medicao de alinhamento de track) */
.tbl-cell.r { text-align: right; }
.tbl-cell.c { text-align: center; }
.tbl-cell.first { font-weight: 600; color: var(--pf-text); }
.tbl-cell.mono { font-family: var(--font-mono); font-size: 12px; color: var(--pf-text-muted); }
.tbl-cell.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; text-align: right; }
.tbl-cell.neg { color: #dc2626; }
.tbl-cell.pos { color: #16a34a; }

/* Status chips */
.chip-st {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 8px; border-radius: 4px;
    font-size: 10.5px; font-weight: 600; line-height: 1.2;
}
.chip-st .dt { width: 6px; height: 6px; border-radius: 50%; }
.chip-st.ok   { background: var(--status-success); color: var(--status-success-fg); }
.chip-st.ok   .dt { background: var(--color-positive, #16a34a); }
.chip-st.warn { background: var(--status-warning); color: var(--status-warning-fg); }
.chip-st.warn .dt { background: var(--status-warning-fg, #d97706); }
.chip-st.err  { background: var(--status-error); color: var(--status-error-fg); }
.chip-st.err  .dt { background: var(--color-negative, #dc2626); }
.chip-st.info { background: var(--brand-sky-soft, #dbeafe); color: var(--brand-sky, #155eef); }
.chip-st.info .dt { background: var(--brand-sky, #155eef); }
.sec-row .dt.info { background: var(--brand-sky, #155eef); }

.row-act { background: transparent; border: 0; color: var(--pf-text-muted); cursor: pointer; padding: 4px 6px; border-radius: 4px; font-size: 12px; }
.row-act:hover { background: var(--pf-side-hover); color: var(--pf-primary); }

/* =============================================================
   Anatomia (apenas para a página template — pode remover em prod)
   ============================================================= */
.annot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.annot .it { background: var(--pf-side); border: 1px solid var(--pf-card-border); border-radius: 6px; padding: 12px 14px; }
.annot .it .num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%; background: var(--pf-primary); color: #fff;
    font-size: 11px; font-weight: 700; margin-right: 8px;
}
.annot .it h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--pf-text); }
.annot .it p { margin: 0; font-size: 12px; color: var(--pf-text-muted); line-height: 1.5; }
code.tk { font-family: var(--font-mono); font-size: 11px; background: var(--pf-side-hover); color: var(--pf-primary); padding: 1px 5px; border-radius: 3px; }

/* =============================================================
   Items-list — toolbar com 3 botoes (filtro / ações / +) + popovers
   (Engine: ItemsListQuery -> /api/items-list.php -> js/items-list.js)

   Pattern: faceted-filter + contextual-bulk-toolbar + add-button
   (Linear, GitHub Issues, legacy `gerenciarUsuarios.php`).
   ============================================================= */

/* ---------- Toolbar ---------- */
.il-toolbar {
    display: flex; align-items: center; gap: 4px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--pf-side-border);
    flex-shrink: 0;
}
.il-search {
    flex: 1; min-width: 0;
    height: 28px; border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-bg); padding: 0 8px;
    display: flex; align-items: center; gap: 6px;
}
.il-search > .ico { color: var(--pf-text-subtle); flex-shrink: 0; }
.il-search-input {
    flex: 1; min-width: 0;
    border: 0; background: transparent; outline: 0;
    font-family: inherit; font-size: 12px; color: var(--pf-text);
}
.il-search-input::placeholder { color: var(--pf-text-subtle); }

/* Toolbar meta (selecionados + total) — entre search e icone filtrar */
.il-toolbar-meta {
    display: inline-flex; align-items: baseline; gap: 6px;
    font-size: 12px; color: var(--pf-text-muted);
    flex-shrink: 0;
}
.il-toolbar-meta .sel-count { color: var(--pf-primary); font-weight: 600; }
/* Count vira clicavel (limpa selecao) quando ha itens selecionados */
.il-toolbar-meta .sel-count:not([hidden]) ~ .count {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 2px;
    transition: color 120ms, text-decoration-color 120ms;
}
.il-toolbar-meta .sel-count:not([hidden]) ~ .count:hover {
    color: var(--pf-text);
    text-decoration-color: var(--pf-text-muted);
}

/* ---------- Botoes da toolbar (filtro, acoes, +) ---------- */
.il-btn {
    width: 28px; height: 28px; border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side); color: var(--pf-text-muted);
    cursor: pointer; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative; padding: 0;
}
/* Anchor-names pra popovers (CSS Anchor Positioning — Chrome 125+ / Safari TP).
   Cada botao define a propria ancora; o popover correspondente referencia. */
.il-btn-filter { anchor-name: --ancora-il-filter; }
.il-btn-bulk   { anchor-name: --ancora-il-bulk;   }
.il-btn:hover:not(:disabled) {
    background: var(--pf-primary-soft); color: var(--pf-primary); border-color: var(--pf-primary-soft);
}
.il-btn:disabled {
    opacity: 0.45; cursor: not-allowed;
}
/* Drawer lateral — novo boletim (Consultoria), estilo Supabase: slide da direita, 40% × 100% */
body.cn-add-open { overflow: hidden; }
.cn-add-popover {
    position: fixed; inset: 0; z-index: 1200;
    display: flex; align-items: stretch; justify-content: flex-end;
    pointer-events: none;
}
.cn-add-popover[hidden] { display: none; }
/* Só captura cliques quando aberto — evita overlay invisível bloquear a página
   se o popover ficar sem .is-open após fechar ou restaurar do bfcache. */
.cn-add-popover.is-open { pointer-events: auto; }
.cn-add-backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    border: 0; padding: 0; margin: 0;
    cursor: pointer;
    opacity: 0;
    transition: opacity 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cn-add-popover.is-open .cn-add-backdrop { opacity: 1; }
.cn-add-sheet {
    position: relative; z-index: 1;
    width: 40%;
    height: 100%;
    display: flex; flex-direction: column;
    background: var(--pf-side);
    border: none;
    border-left: 1px solid var(--pf-side-border);
    border-radius: 0;
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.16);
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cn-add-popover.is-open .cn-add-sheet { transform: translateX(0); }
.cn-detail-sheet {
    width: min(860px, 56%);
}
.cn-detail-sheet .cn-detail {
    height: 100%;
    overflow-y: auto;
}
.cm-detail {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.cm-detail-head {
    height: 48px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--pf-side-border);
}
.cm-detail .cn-detail-head.cm-detail-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--pf-side-border);
    grid-template-columns: unset;
}
.cm-detail-head-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}
.cm-detail-head-actions .cn-detail-icon {
    text-decoration: none;
}
.cm-detail .cn-detail-head .cn-detail-title--static {
    flex: 1;
    min-width: 0;
}
.cm-detail-head .cn-detail-head-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 2px;
}
.cm-detail-head .cn-detail-head-text .cn-detail-title {
    height: auto;
    padding: 0;
    line-height: 1.2;
}
.cm-detail-head .cn-detail-head-text .cn-detail-meta {
    color: var(--pf-text-subtle);
    font-size: 12px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.cm-detail-head strong {
    font-size: 14px;
    font-weight: 650;
    color: var(--pf-text);
}
.cm-detail-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
}
.cm-detail-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}
.cm-detail-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--pf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cm-detail-body .tbl {
    min-height: 0;
}
.cm-detail-tbl .tbl-cell.mono,
.cm-detail-tbl .tbl-cell.cm-col-data {
    color: var(--pf-text);
    background: transparent;
}
.cm-detail-tbl .tbl-body > .empty-msg {
    grid-column: 1 / -1;
    width: 100%;
}
.cm-detail-body .tbl .wrap {
    white-space: normal;
    word-break: break-word;
}
.da-cell-map-download {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: pointer;
}
.da-cell-map-download:hover,
.da-cell-map-download:focus-visible {
    color: var(--pf-primary);
    text-decoration: underline;
    outline: 0;
}
.cm-detail-body .subtabs {
    margin-bottom: 12px;
}
.cm-detail-body .kpi-grid,
.cm-detail-body .cards-grid {
    margin-bottom: 12px;
}
.cn-detail-loading {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--pf-text-muted);
    font-size: 13px;
}
.cn-detail-loading-error {
    color: var(--pf-text);
}
.cn-detail-loading-error span {
    color: var(--pf-text-muted);
}
@media (max-width: 640px) {
    .cn-add-sheet,
    .cn-detail-sheet { width: 100%; }
}
.cn-add-head {
    display: grid;
    grid-template-columns: minmax(56px, auto) minmax(0, 1fr) 28px auto;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--pf-side-border);
    flex-shrink: 0;
}
.cn-add-id {
    min-width: 56px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-bg);
    color: var(--pf-text-muted);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.cn-add-title-wrap {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.cn-add-title-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--pf-primary);
    flex: 0 0 auto;
}
.cn-add-close {
    width: 28px; height: 28px; border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side); color: var(--pf-text-muted);
    cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.cn-add-close:hover {
    background: var(--pf-primary-soft); color: var(--pf-primary); border-color: var(--pf-primary-soft);
}
.cn-add-title {
    margin: 0;
    min-width: 0;
    width: 100%;
    height: 28px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--pf-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: inherit;
    padding: 0 6px;
}
.cn-add-title:hover {
    border-color: var(--pf-card-border);
    background: var(--pf-bg);
}
.cn-add-title:focus {
    outline: 0;
    border-color: var(--pf-primary);
    background: var(--pf-bg);
    box-shadow: 0 0 0 3px var(--pf-primary-soft);
}
.cn-add-save {
    height: 28px;
    border-radius: 5px;
    border: 1px solid var(--pf-primary);
    background: var(--pf-primary);
    color: #fff;
    padding: 0 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.cn-add-save:hover:not(:disabled) {
    background: var(--pf-primary-hover);
    border-color: var(--pf-primary-hover);
}
.cn-add-save:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}
.cn-add-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 14px;
}
.cn-add-form {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.cn-add-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.cn-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cn-field-full { grid-column: 1 / -1; }
.cn-field .field-lb {
    font-size: 10px;
    font-weight: 700;
    color: var(--pf-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cn-field input:not([type="checkbox"]):not([type="radio"]),
.cn-field select,
.cn-field textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-bg);
    color: var(--pf-text);
    font-family: inherit;
    font-size: 12.5px;
}
.cn-field input:not([type="checkbox"]):not([type="radio"]),
.cn-field select {
    height: 34px;
    padding: 0 9px;
}
.cn-field textarea {
    min-height: 170px;
    resize: vertical;
    padding: 10px;
    line-height: 1.45;
}
.cn-field input:not([type="checkbox"]):not([type="radio"]):focus,
.cn-field select:focus,
.cn-field textarea:focus {
    outline: 0;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 3px var(--pf-primary-soft);
}
.cn-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}
.cn-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
}
.cn-tool,
.cn-color {
    height: 28px;
    border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side);
    color: var(--pf-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 12px;
}
.cn-tool {
    width: 28px;
    padding: 0;
    cursor: pointer;
}
.cn-tool:hover,
.cn-color:hover {
    background: var(--pf-primary-soft);
    color: var(--pf-primary);
    border-color: var(--pf-primary-soft);
}
.cn-color {
    gap: 6px;
    padding: 0 6px;
}
.cn-color select {
    height: 24px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.cn-attachments {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    min-height: 32px;
}
.cn-attach-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side);
    color: var(--pf-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}
.cn-attach-btn:hover {
    background: var(--pf-primary-soft);
    color: var(--pf-primary);
    border-color: var(--pf-primary-soft);
}
.cn-attach-btn input { display: none; }
.cn-attach-list {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cn-attach-chip {
    max-width: 210px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border-radius: 5px;
    background: var(--pf-bg);
    color: var(--pf-text-muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cn-attach-chip.is-error {
    color: #b42318;
    background: rgba(180, 35, 24, 0.08);
}
.cn-add-msg { min-height: 18px; font-size: 12px; margin-top: 12px; }
.cn-add-msg.ok { color: #067647; }
.cn-add-msg.erro { color: #b42318; }
.cn-check-grid {
    display: grid;
    gap: 8px 12px;
}
.cn-check-grid--mods {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cn-check-grid--dias {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}
.cn-check {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 12.5px;
    color: var(--pf-text);
    cursor: pointer;
}
.cn-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--pf-primary);
}
.cn-check span {
    min-width: 0;
    line-height: 1.3;
}
.cn-check-inline {
    margin-top: 10px;
}
.cn-drawer-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.cn-add-body .cn-detail-acc {
    margin-top: 14px;
}
#usr-add-popover .usr-drawer-head {
    grid-template-columns: minmax(56px, auto) minmax(0, 1fr) auto;
    gap: 8px;
}
#usr-add-popover .usr-drawer-head .cn-add-title-wrap {
    min-width: 0;
}
#usr-add-popover .usr-drawer-head .cn-drawer-actions .cn-detail-icon,
#usr-add-popover .usr-drawer-head .cn-drawer-actions .cn-detail-save {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
}
#mun-add-popover .mun-drawer-head {
    grid-template-columns: minmax(56px, auto) minmax(0, 1fr) 30px 30px;
    gap: 8px;
}
#mun-add-popover .mun-drawer-head.mun-drawer-head--edit {
    grid-template-columns: minmax(56px, auto) minmax(0, 1fr) 30px 30px 30px;
}
#mun-add-popover .mun-drawer-head .cn-detail-icon,
#mun-add-popover .mun-drawer-head .cn-detail-save {
    width: 30px;
    height: 30px;
}
#ic-detail-popover .ic-drawer-head {
    grid-template-columns: minmax(56px, auto) minmax(0, 1fr) 30px 30px;
    gap: 8px;
}
#ic-detail-popover .ic-drawer-head .cn-detail-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
}
#ic-detail-popover .cn-add-sheet {
    display: flex;
    flex-direction: column;
}
#ic-detail-popover .ic-drawer-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#ic-detail-popover .cn-add-title-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
#ic-detail-popover .cn-add-title--static {
    height: auto;
    min-height: 28px;
    line-height: 1.25;
    white-space: normal;
    border-color: transparent;
    background: transparent;
    cursor: default;
    pointer-events: none;
    padding-left: 0;
    padding-right: 0;
}
#ic-detail-popover .ic-drawer-sub {
    font-size: 12px;
    color: var(--pf-text-subtle);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    padding: 0 6px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#ic-detail-popover .ic-drawer-section-lb {
    display: block;
    margin-bottom: 10px;
}
#ic-detail-popover .ic-drawer-kpis {
    margin-bottom: 0;
}
#ic-detail-popover .ic-drawer-note {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--pf-text-muted);
    line-height: 1.45;
}
#ic-detail-popover .cn-add-body > .cn-detail-loading {
    min-height: 180px;
}

/* ISSSimples — drawer resumo RBT12 */
#sn-detail-popover .cn-add-sheet {
    display: flex;
    flex-direction: column;
    width: min(420px, 100vw);
}
#sn-detail-popover .sn-drawer-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#sn-detail-popover .sn-drawer-head {
    grid-template-columns: minmax(0, 1fr) 30px 30px;
    gap: 8px;
}
#sn-detail-popover .sn-drawer-head-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
#sn-detail-popover .sn-drawer-sub {
    font-size: 12px;
    color: var(--pf-text-subtle);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
#sn-detail-popover .sn-detail-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--pf-border-subtle);
}
#sn-detail-popover .sn-detail-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}
#sn-detail-popover .sn-detail-field select {
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--pf-border);
    background: var(--pf-surface);
}
#sn-detail-popover .sn-detail-body {
    flex: 1;
    overflow: auto;
    padding: 12px 16px 16px;
    min-height: 120px;
}
#sn-detail-popover .sn-drawer-section-lb {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--pf-text-muted);
}
#sn-detail-popover .sn-drawer-hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--pf-text-subtle);
    line-height: 1.4;
}
#sn-detail-popover .sn-calc-kpis {
    margin-bottom: 0;
}
#sn-detail-popover .sn-calc-note {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--pf-text-muted);
    line-height: 1.4;
}

/* ISSSimples — calculadora na aba flexível */
/* O card da calculadora nao tem header, entao o padding vem do proprio corpo
   (mesmo respiro da sub-aba Dados). */
.sn-calculadora-flex {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 200px;
    padding: 16px;
}
/* Selects empilhados a esquerda, cards ocupando o resto da linha. */
.sn-calc-flex-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.sn-calc-flex-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
    width: 132px;
}
.sn-calc-flex-cards-wrap {
    flex: 1;
    min-width: 0;
}
.sn-calc-flex-toolbar select {
    font-size: 13px;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-bg);
    color: var(--pf-text);
}
.sn-calc-flex-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}
.sn-calc-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 9px 12px;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
}
.sn-calc-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 1px;
    font-size: 13px;
    font-weight: 600;
    color: var(--pf-text);
}
/* Label e valor na mesma linha: .field empilha por padrao (sub-aba Dados). */
.sn-calc-card .field {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.sn-calc-card .field-lb {
    white-space: nowrap;
}
.sn-calc-card .field-vl {
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.sn-calc-subtabs {
    margin: 0;
    flex-wrap: wrap;
}
/* Reset do <button> sem perder o que vem de .subtab: a borda inferior e o
   tamanho de fonte precisam ser reafirmados, senao `border: none` e
   `font: inherit` matam o sublinhado da ativa e aumentam a fonte. */
.sn-calc-subtabs .sn-calc-subtab {
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
}
.sn-calc-subtabs .sn-calc-subtab.active {
    color: var(--pf-primary);
    border-bottom-color: var(--pf-primary);
    font-weight: 600;
}
.sn-calc-panel {
    overflow-x: auto;
}
/* Composicao do DAS tem 1 coluna por tributo: o .tbl cresce e o painel rola
   como um bloco so, senao .tbl-head e .tbl-body rolam separados e desalinham. */
.sn-calc-tbl {
    width: max-content;
    min-width: 100%;
}
.sn-calc-tbl .tbl-body > .empty-msg {
    grid-column: 1 / -1;
    width: 100%;
}
.sn-chip-origem.chip-st.info {
    background: var(--brand-sky-soft, #dbeafe);
    color: var(--brand-sky, #155eef);
}
.sn-chip-faixa.chip-st.ok {
    background: var(--status-success, #dcfce7);
    color: var(--color-positive, #16a34a);
}
.sn-chip-anexo.chip-st.warn {
    background: var(--status-warning, #fef3c7);
    color: var(--status-warning-fg, #d97706);
}
.sn-calc-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--pf-text-muted);
}
.sn-calc-note {
    margin: 0;
    font-size: 12px;
    color: var(--pf-text-muted);
    line-height: 1.4;
}
@media (max-width: 640px) {
    #sn-detail-popover .cn-detail-kv--quad {
        grid-template-columns: 1fr;
    }
    .sn-calc-flex-head {
        flex-direction: column;
    }
    .sn-calc-flex-toolbar {
        flex-direction: row;
        width: 100%;
    }
    .sn-calc-flex-toolbar select {
        flex: 1;
        min-width: 0;
    }
    .sn-calc-flex-cards-wrap {
        width: 100%;
    }
}

.cn-detail-sheet > .cn-detail-loading:not([hidden]) {
    flex: 1;
}
@media (max-width: 840px) {
    .cn-add-head {
        grid-template-columns: minmax(48px, auto) minmax(0, 1fr) auto;
    }
    #usr-add-popover .usr-drawer-head {
        grid-template-columns: minmax(48px, auto) minmax(0, 1fr) auto;
    }
    #mun-add-popover .mun-drawer-head {
        grid-template-columns: minmax(48px, auto) minmax(0, 1fr) 30px 30px;
    }
    #mun-add-popover .mun-drawer-head.mun-drawer-head--edit {
        grid-template-columns: minmax(48px, auto) minmax(0, 1fr) 30px 30px 30px;
    }
    #ic-detail-popover .ic-drawer-head {
        grid-template-columns: minmax(48px, auto) minmax(0, 1fr) 30px 30px;
    }
    .cn-add-save {
        grid-column: 1 / -1;
        width: 100%;
    }
    .cn-add-grid {
        grid-template-columns: 1fr;
    }
    .cn-check-grid--mods {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .cn-check-grid--dias {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.cn-detail {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px;
    color: var(--pf-text);
}
.cn-detail-form,
.cn-sub-form {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cn-detail-head {
    display: grid;
    grid-template-columns: minmax(54px, auto) minmax(180px, 1fr) minmax(138px, 170px) 30px 30px 30px;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--pf-side-border);
}
.sup-detail-head {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-template-columns: unset;
}
.sup-detail-head .cn-detail-title {
    flex: 1;
    min-width: 0;
}
.sup-detail-head-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}
.sup-detail-head-actions .cn-detail-icon {
    text-decoration: none;
}
.cn-detail-id {
    height: 28px;
    min-width: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-bg);
    color: var(--pf-text-muted);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.cn-detail-title {
    width: 100%;
    min-width: 0;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--pf-text);
    font: inherit;
    font-size: 15px;
    font-weight: 650;
    padding: 0 8px;
}
.cn-detail-title:hover {
    border-color: var(--pf-card-border);
    background: var(--pf-bg);
}
.cn-detail-title:focus {
    outline: 0;
    border-color: var(--pf-primary);
    background: var(--pf-bg);
    box-shadow: 0 0 0 3px var(--pf-primary-soft);
}
.cn-detail-title--static {
    display: flex;
    align-items: center;
    cursor: default;
    user-select: text;
}
.cn-detail-title--static:hover,
.cn-detail-title--static:focus {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}
.cn-detail-date {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cn-detail-date span,
.cn-detail-meta span,
.cn-detail-field span {
    color: var(--pf-text-subtle);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cn-detail-date input,
.cn-detail-meta select,
.cn-detail-meta input:not([type="checkbox"]):not([type="radio"]),
.cn-detail-meta-input,
.cn-detail-field textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-bg);
    color: var(--pf-text);
    font-family: inherit;
    font-size: 12.5px;
}
.cn-detail-date input,
.cn-detail-meta select,
.cn-detail-meta input:not([type="checkbox"]):not([type="radio"]),
.cn-detail-meta-input {
    height: 32px;
    padding: 0 9px;
}
.cn-detail-field textarea {
    min-height: 150px;
    resize: vertical;
    padding: 10px;
    line-height: 1.45;
}
.cn-detail-date input:focus,
.cn-detail-meta select:focus,
.cn-detail-meta input:not([type="checkbox"]):not([type="radio"]):focus,
.cn-detail-meta-input:focus,
.cn-detail-field textarea:focus {
    outline: 0;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 3px var(--pf-primary-soft);
}
.cn-detail-icon,
.cn-detail-save,
.cn-sub-form summary button,
.cn-detail-anexo button {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side);
    color: var(--pf-text-muted);
    cursor: pointer;
    padding: 0;
}
.cn-detail-icon:hover,
.cn-detail-save:hover:not(:disabled),
.cn-sub-form summary button:hover:not(:disabled),
.cn-detail-anexo button:hover {
    background: var(--pf-primary-soft);
    color: var(--pf-primary);
    border-color: var(--pf-primary-soft);
}
.cn-detail-save {
    background: var(--pf-primary);
    border-color: var(--pf-primary);
    color: #fff;
}
.cn-detail-save:disabled,
.cn-sub-save:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}
.cn-detail-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.cn-detail-meta label,
.cn-detail-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cn-detail-acc {
    border-top: 1px solid var(--pf-side-border);
    padding-top: 10px;
}
.cn-detail-acc summary {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--pf-text);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.cn-detail-acc summary::marker { color: var(--pf-text-muted); }
.cn-detail-acc summary:has(.cn-sub-save) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}
.cn-detail-acc .cn-add-grid {
    margin-top: 8px;
}
.cn-detail-empty {
    margin: 4px 0 0;
    color: var(--pf-text-muted);
    font-size: 12.5px;
}
.cn-detail-kv {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 4px;
}
.cn-detail-kv--quad {
    grid-template-rows: repeat(4, auto);
}
.cn-detail-kv-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cn-detail-kv-label {
    color: var(--pf-text-subtle);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cn-detail-kv-val {
    display: flex;
    align-items: center;
    min-height: 32px;
    padding: 0 9px;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-bg);
    color: var(--pf-text);
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}
.cn-detail-kv-link {
    text-decoration: none;
    color: var(--pf-primary);
    font-weight: 600;
}
.cn-detail-kv-link:hover {
    text-decoration: underline;
}
.cn-detail-panel {
    border-top: 1px solid var(--pf-side-border);
    padding-top: 10px;
}
.cn-detail-panel-title {
    margin: 0 0 10px;
    color: var(--pf-text);
    font-size: 13px;
    font-weight: 700;
}
.cn-detail-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.cn-detail-panel-head .cn-detail-panel-title {
    margin: 0;
}
.cn-detail-kv > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cn-detail-kv-wide {
    grid-column: 1 / -1;
}
.cn-detail-kv strong {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pf-text);
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}
.cn-detail-anexos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
    margin: 8px 0;
}
.cn-detail-anexo {
    max-width: 280px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-bg);
    font-size: 11.5px;
}
.cn-detail-anexo a {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--pf-text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cn-detail-anexo a:hover { color: var(--pf-primary); }
.cn-detail-anexo small {
    flex: 0 0 auto;
    color: var(--pf-text-muted);
}
.cn-detail-anexo button {
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
}
.cn-detail-attach,
.cn-detail-add-sub {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 6px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side);
    color: var(--pf-text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0 10px;
}
.cn-detail-attach:hover,
.cn-detail-add-sub:hover {
    background: var(--pf-primary-soft);
    color: var(--pf-primary);
    border-color: var(--pf-primary-soft);
}
.cn-detail-attach input { display: none; }
.cn-detail-add-sub {
    width: 100%;
    margin-top: 8px;
    color: var(--pf-primary);
}
.cn-sub-form[hidden] { display: none; }
.cn-sub-form {
    padding-top: 2px;
    border-top: 1px solid var(--pf-side-border);
}
.cn-sub-form .cn-detail-acc {
    border-top: 0;
    padding-top: 0;
}
.cn-sub-form summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px auto;
}
.cn-sub-save {
    width: auto !important;
    padding: 0 11px !important;
    background: var(--pf-primary) !important;
    border-color: var(--pf-primary) !important;
    color: #fff !important;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
}
.cn-sub-date {
    width: min(220px, 100%);
    margin: 4px 0 10px;
}
.cn-detail-toolbar {
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.cn-sub-list {
    border-top: 1px solid var(--pf-side-border);
    padding-top: 12px;
}
.cn-sub-list h3 {
    margin: 0 0 10px;
    color: var(--pf-text);
    font-size: 13px;
    font-weight: 700;
}
.cn-sub-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cn-sub-item {
    position: relative;
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--pf-card-border);
    border-radius: 7px;
    background: var(--pf-side);
    cursor: pointer;
}
.cn-sub-item:hover {
    border-color: var(--pf-primary-soft);
    background: var(--pf-bg);
}
.cn-sub-item time {
    color: var(--pf-text-muted);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.cn-sub-item strong {
    display: block;
    color: var(--pf-text);
    font-size: 12px;
    font-weight: 700;
}
.cn-sub-item p {
    margin: 3px 0 0;
    color: var(--pf-text-muted);
    font-size: 12px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cn-sub-item small {
    display: inline-block;
    margin-top: 4px;
    color: var(--pf-primary);
    font-size: 11px;
    font-weight: 600;
}
.cn-sub-empty,
.cn-detail-msg {
    min-height: 18px;
    margin: 0;
    color: var(--pf-text-muted);
    font-size: 12px;
}
.cn-detail-msg.ok { color: #067647; }
.cn-detail-msg.erro { color: #b42318; }
@media (max-width: 980px) {
    .cn-detail-head {
        grid-template-columns: minmax(52px, auto) minmax(0, 1fr) repeat(3, 30px);
    }
    .cn-detail-head .cn-detail-date {
        grid-column: 1 / -1;
        width: min(260px, 100%);
    }
    .cn-detail-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .cn-detail-kv {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .cn-detail {
        padding: 10px;
    }
    .cn-detail-head,
    .cn-detail-meta,
    .cn-detail-kv,
    .cn-sub-item {
        grid-template-columns: 1fr;
    }
    .cn-detail-id,
    .cn-detail-icon,
    .cn-detail-save {
        justify-self: start;
    }
    .cn-sub-form summary {
        grid-template-columns: minmax(0, 1fr) 30px;
    }
    .cn-detail-acc summary:has(.cn-sub-save) {
        grid-template-columns: minmax(0, 1fr);
    }
    .cn-sub-save {
        grid-column: 1 / -1;
        width: 100% !important;
    }
}

.il-btn-add {
    background: var(--pf-primary); color: #fff; border-color: var(--pf-primary);
}
.il-btn-add:hover:not(:disabled) {
    background: var(--pf-primary-hover); color: #fff; border-color: var(--pf-primary-hover);
}
/* Badge "tem filtros aplicados" no botao de filtro */
.il-btn .il-badge {
    position: absolute; top: -3px; right: -3px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--pf-primary); border: 2px solid #fff;
}

/* ---------- Popovers (filtro + ações) ---------- */
/* Posicionamento ancorado puro CSS (legacy/css/v2/components/filter-bar.css):
   - position-anchor liga ao anchor-name do botao
   - position-area: bottom span-left -> abre abaixo, alinhado a direita
   - position-try-fallbacks: flip-block -> auto-vira pra cima se bater no fundo
   - inset/margin zerados pra remover o auto-center default do <div popover>
   Layout (flex) so :popover-open — antes disso o display:none default
   do popover deve valer (bug pego em validacao browser 2026-05-04). */
.il-popover {
    padding: 0;
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    background: var(--pf-side);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
    width: min(280px, calc(100vw - 32px));
    max-height: min(70vh, 480px);
    overflow: hidden;
    inset: unset;
    margin: 0;
    margin-top: 4px;
    position-area: bottom span-left;
    position-try-fallbacks: flip-block;
}
.il-filter-panel { position-anchor: --ancora-il-filter; }
.il-bulk-panel   { position-anchor: --ancora-il-bulk;   }
.il-popover:popover-open {
    display: flex;
    flex-direction: column;
    animation: il-pop-in 100ms ease-out;
}
@keyframes il-pop-in {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0);    }
}
.il-popover-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--pf-side-border);
    flex-shrink: 0;
}
.il-popover-title {
    font-size: 11.5px; font-weight: 600; color: var(--pf-text);
}
.il-popover-clear {
    background: transparent; border: 0;
    color: var(--pf-primary); cursor: pointer;
    font-family: inherit; font-size: 11px; font-weight: 500;
    padding: 2px 6px; border-radius: 4px;
}
.il-popover-clear:hover { background: var(--pf-primary-soft); }
.il-popover-body {
    flex: 1; overflow-y: auto;
    padding: 8px 12px;
}

/* ---------- Filter popover: grupos + opcoes ---------- */
.il-filter-group {
    margin: 0 0 14px;
    padding: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.il-filter-group:last-child { margin-bottom: 0; }
.il-filter-group > legend {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--pf-text-subtle);
    margin-bottom: 6px;
    padding: 0;
}
.il-filter-option {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 6px; margin: 0 -6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px; color: var(--pf-text);
}
.il-filter-option:hover { background: var(--pf-side-hover); }
.il-filter-option > input { margin: 0; cursor: pointer; }
.il-filter-option > span { line-height: 1.3; }
.il-filter-select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-bg);
    color: var(--pf-text);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
}
.il-filter-select:focus {
    outline: 0;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 3px var(--pf-primary-soft);
}

/* ---------- Bulk action popover: lista de botoes ---------- */
.il-bulk-panel .il-popover-body {
    padding: 6px;
}
.il-bulk-action {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 7px 8px; margin: 0;
    border: 0; border-radius: 4px;
    background: transparent; color: var(--pf-text);
    font-family: inherit; font-size: 12px; font-weight: 500;
    cursor: pointer; text-align: left;
}
.il-bulk-action:hover:not(:disabled),
.il-bulk-action:focus-visible {
    background: var(--pf-primary-soft); color: var(--pf-primary); outline: 0;
}
.il-bulk-action:disabled { opacity: 0.4; cursor: not-allowed; }
.il-bulk-action .ico { color: inherit; flex-shrink: 0; }
.il-bulk-action .lbl { flex: 1; }

/* =============================================================
   Modal — <dialog> singleton (componentes/modal.php + js/modal.js)
   API: window.Modal.confirm({title,message,onConfirm,...}) / .alert / .open
   ============================================================= */
.modal {
    border: 0; padding: 0; background: transparent;
    max-width: min(440px, calc(100vw - 32px));
    width: 100%;
}
.modal::backdrop {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}
.modal-card {
    background: var(--pf-side);
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 64px);
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--pf-card-border);
    flex-shrink: 0;
}
.modal-title {
    margin: 0; font-size: 14px; font-weight: 600; color: var(--pf-text);
}
.modal-close {
    background: transparent; border: 0; cursor: pointer;
    padding: 4px; border-radius: 4px;
    color: var(--pf-text-subtle);
    display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--pf-side-hover); color: var(--pf-text); }
.modal-body {
    padding: 18px 16px;
    flex: 1; overflow-y: auto;
    font-size: 13px; color: var(--pf-text); line-height: 1.55;
}
.modal-message { margin: 0; }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--pf-card-border);
    background: var(--pf-bg);
    flex-shrink: 0;
}
.modal-btn {
    height: 32px; padding: 0 14px; border-radius: 5px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side); color: var(--pf-text);
    font-family: inherit; font-size: 12.5px; font-weight: 500;
    cursor: pointer; line-height: 1;
}
.modal-btn:hover { background: var(--pf-side-hover); }
.modal-btn.is-primary {
    background: var(--pf-primary); color: #fff; border-color: var(--pf-primary);
}
.modal-btn.is-primary:hover { background: var(--pf-primary-hover); border-color: var(--pf-primary-hover); }
.modal-btn.is-primary.is-danger {
    background: #dc2626; border-color: #dc2626;
}
.modal-btn.is-primary.is-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* Estados unificados da row (drawer + workspace, mesmo padrao visual):
   - `active`   = aba flex ATUALMENTE focada (border-left primary no drawer)
   - `tab-open` = aba flex aberta no tabs bar (visual igual selected, sem foco)
   - `selected` = checkbox marcado
   Os tres compartilham: fundo soft + label primary + bold. SEM sublinhado. */
.sec-row.tab-open,
.sec-row.selected { background: var(--pf-primary-soft); }
.sec-row.tab-open  .nm,
.sec-row.tab-open  .cell-nm,
.sec-row.selected  .nm,
.sec-row.selected  .cell-nm { color: var(--pf-primary); font-weight: 600; }
/* Checkbox marcado preenchido (so quando .selected, nao quando tab-open) */
.sec-row.selected .chk { background: var(--pf-primary); border-color: var(--pf-primary); }
.sec-row.selected .chk::after {
    content: ""; position: absolute; left: 3px; top: 0px;
    width: 4px; height: 8px; border-right: 2px solid #fff; border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}

/* Sentinel = elemento invisivel monitorado pelo IntersectionObserver pra
   disparar lazy-load. Altura > 0 garante que o observer dispare antes do
   ultimo row sumir do viewport. */
.sec-list-sentinel {
    height: 1px; width: 100%; flex-shrink: 0;
}

/* Loader inline durante fetch (centralizado abaixo das rows). */
.sec-list-loader {
    display: flex; justify-content: center; padding: 10px 0;
}
.sec-list-loader .spin {
    width: 14px; height: 14px;
    border: 2px solid var(--pf-card-border);
    border-top-color: var(--pf-primary);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Estado vazio (filtro/busca sem resultado). */
.sec-list-empty {
    padding: 18px 12px; text-align: center;
    font-size: 11.5px; color: var(--pf-text-subtle);
}

/* Estado de fetch — desfoca a lista enquanto carrega novo filtro/busca. */
.sec-list.is-loading > .sec-row { opacity: 0.55; pointer-events: none; transition: opacity 120ms; }

/* =============================================================
   Charts grid — usado pelos templates `dashboard` e `misto`.

   Grid ADAPTATIVA via container queries (declaradas em .work-main):

   - `repeat(auto-fill, minmax(280px, 1fr))` calcula colunas dinamicamente
     a partir da largura REAL do workspace:
       work-main 600px  -> 2 cols
       work-main 1200px -> 4 cols
       work-main 1800px -> 6 cols
     Quando items-list colapsa, work-main cresce -> mais colunas
     automaticamente. Sem media query, sem JS.

   - `--span` (1/2/3) = quantas COLUNAS o chart ocupa horizontalmente.
   - `--row-span` (1/2) = quantas LINHAS de altura. Charts importantes
     podem ocupar 2x altura.
   - `grid-auto-rows: 1fr` distribui altura disponivel igualmente.
     `minmax(140px, ...)` garante chart minimamente legivel.

   - Template `dashboard` (.work-main--dashboard): work-main rola vertical/
     horizontalmente quando KPIs + grid excedem a viewport.
   - Template `misto`: charts-grid no meio mantem altura natural; tabela
     embaixo continua com scroll interno no .data-card.
   ============================================================= */
.charts-grid {
    display: grid;
    /* `auto-fit` (nao auto-fill): colunas vazias COLAPSAM, charts existentes
       crescem pra preencher o espaco. Quando items-list colapsa ou em monitor
       largo, charts ficam maiores (em vez de deixar buracos). */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: minmax(140px, 1fr);
    gap: 12px;
}
.work-main > .charts-grid {
    flex-shrink: 0;
}
/* Dashboard puro: grid cresce com conteudo minimo legivel; scroll no work-main. */
.work-main.work-main--dashboard {
    overflow: auto;
}
.work-main.work-main--dashboard > .charts-grid:last-child,
.work-main.work-main--dashboard > .cards-grid:last-child {
    flex: 0 0 auto;
    overflow: visible;
    align-content: start;
}
.work-main.work-main--dashboard > .charts-grid:last-child {
    grid-auto-rows: minmax(180px, auto);
}

/* /modulos/issobras/dashboard — doughnut unico nao deve esticar full-width. */
.charts-grid.charts-grid--issobras {
    justify-items: start;
}
.charts-grid.charts-grid--issobras > .data-card.is-chart {
    width: 100%;
    max-width: 360px;
}


/* /adm/inicio/boas-vindas — landing admin com murais condicionais.
   Altura vem do .work-main; scroll fica no body de cada mural (nao no pai). */
.work-main > .boas-vindas {
    flex: 1 1 auto;
    min-height: 0;
}
.boas-vindas {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}
.boas-vindas-murais {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    align-content: flex-start;
    overflow: hidden;
}
.boas-vindas-murais > .data-card {
    flex: 0 1 auto;
    width: max-content;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.boas-vindas-murais > .data-card > .data-card-head {
    flex-shrink: 0;
}
.boas-vindas-murais > .data-card > .data-card-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}
/* Um unico grid: head/body/row com display:contents compartilham --cols
   (max-content alinham titulo e conteudo; grids separados divergiam). */
.boas-vindas-tbl {
    display: grid;
    grid-template-columns: var(--cols);
    width: max-content;
    max-width: 100%;
    flex-direction: unset;
}
.boas-vindas-tbl .tbl-head,
.boas-vindas-tbl .tbl-body,
.boas-vindas-tbl .tbl-row {
    display: contents;
}
.boas-vindas-tbl .tbl-head {
    overflow: visible;
}
.boas-vindas-tbl .tbl-body {
    overflow: visible;
    flex: unset;
    min-height: 0;
}
/* Titulos: fonte unica (sem herdar .mono/.num/.first do body). */
.boas-vindas-tbl .tbl-h {
    font-family: var(--font-sans);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--pf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--pf-card-border);
}
.boas-vindas-tbl .tbl-cell:not(.tbl-h) {
    font-weight: 400;
}
/* .mono global (colors_and_type) aplica chip cinza — aqui so fonte tabular. */
.boas-vindas-tbl .tbl-cell.mono,
.boas-vindas-tbl .tbl-cell.num {
    background: transparent;
    padding: 9px 14px;
    border-radius: 0;
}
.boas-vindas-tbl .tbl-cell.num.c {
    text-align: center;
}
.boas-vindas-tbl .tbl-row--link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.boas-vindas-tbl .tbl-row--link:hover .tbl-cell {
    background: var(--pf-side-hover);
}
.boas-vindas-tbl .tbl-row--link:focus-visible .tbl-cell {
    outline: 2px solid var(--pf-accent, #2563eb);
    outline-offset: -2px;
}

/* /adm/financeiro/dashboard — status (col 1, 2 linhas) + grade 2×2 à direita. */
.charts-grid.charts-grid--financeiro-2x2 {
    grid-template-columns: minmax(200px, 1fr) repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row;
    min-width: 520px;
}
.work-main.work-main--dashboard > .charts-grid.charts-grid--financeiro-2x2:last-child {
    min-height: 360px;
    grid-auto-rows: minmax(160px, auto);
}

/* Card de chart: flex column pra body crescer ate 100% do cell.
   --span e --row-span vem do PHP via style inline. */
.data-card.is-chart {
    grid-column: span var(--span, 1);
    grid-row:    span var(--row-span, 1);
    display: flex; flex-direction: column;
    min-height: 0; min-width: 0;
}

/* Posicionamento fixo — sobrescreve --span/--row-span do inline style. */
.charts-grid.charts-grid--financeiro-2x2 > .data-card.is-chart:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / span 2;
}
.charts-grid.charts-grid--financeiro-2x2 > .data-card.is-chart:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}
.charts-grid.charts-grid--financeiro-2x2 > .data-card.is-chart:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
}
.charts-grid.charts-grid--financeiro-2x2 > .data-card.is-chart:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
}
.charts-grid.charts-grid--financeiro-2x2 > .data-card.is-chart:nth-child(5) {
    grid-column: 3;
    grid-row: 2;
}
.data-card.is-chart .data-card-head { flex: 0 0 auto; }
.data-card.is-chart .data-card-body {
    flex: 1; min-height: 0;
    height: auto;
    padding: 8px 12px 12px;
    position: relative;
    overflow: hidden;
}
.data-card.is-chart .data-card-body > canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
.data-card.is-chart .data-card-head h3 {
    display: inline-flex; align-items: center; gap: 6px;
}
.data-card.is-chart .data-card-head .ico { color: var(--pf-text-muted); }

/* Default da paleta categórica (consumida por charts.js via getComputedStyle).
   Tema escuro pode sobrescrever em [data-theme="dark"] :root quando precisar. */
:root {
    --pf-chart-1: #2563eb;
    --pf-chart-2: #16a34a;
    --pf-chart-3: #f59e0b;
    --pf-chart-4: #dc2626;
    --pf-chart-5: #7c3aed;
    --pf-chart-6: #0891b2;
    --pf-chart-7: #db2777;
    --pf-chart-8: #65a30d;
}
[data-theme="dark"] {
    --pf-chart-1: #60a5fa;
    --pf-chart-2: #4ade80;
    --pf-chart-3: #fbbf24;
    --pf-chart-4: #f87171;
    --pf-chart-5: #a78bfa;
    --pf-chart-6: #22d3ee;
    --pf-chart-7: #f472b6;
    --pf-chart-8: #a3e635;
}

/* =============================================================
   .cards-grid + .module-card — template `cards`.

   Grid responsivo de cards clicaveis (1 por modulo contratado).
   Mesma logica do .charts-grid: auto-fit + minmax pra adaptar. Sem media
   query, sem JS. Cards crescem/encolhem com o espaco disponivel.

   Cor de cada card vem do banco (data-cor=primary|ok|warn|err|muted) e
   pinta a faixa lateral + icone. Click leva pra /<slug> da pagina do modulo.
   ============================================================= */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    grid-auto-rows: minmax(110px, auto);
    gap: 12px;
}
.work-main > .cards-grid {
    flex-shrink: 0;
}
.work-main > .cards-grid:last-child {
    flex: 1; min-height: 0;
}
.work-main.work-main--dashboard > .cards-grid:last-child {
    flex: 0 0 auto;
    overflow: visible;
}

.module-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--pf-side);
    border: 1px solid var(--pf-card-border);
    border-left: 3px solid var(--pf-primary);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, background .15s, transform .15s;
}
.module-card:hover {
    background: var(--pf-primary-soft);
    border-color: var(--pf-primary);
    transform: translateY(-1px);
}
.module-card:focus-visible {
    outline: 2px solid var(--pf-primary);
    outline-offset: 2px;
}

.module-card-icon {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: var(--pf-primary-soft);
    color: var(--pf-primary);
    flex-shrink: 0;
}
.module-card-icon svg { display: block; }

.module-card-body { min-width: 0; }
.module-card-title {
    margin: 0;
    font-size: 14px; font-weight: 600;
    color: var(--pf-text);
    line-height: 1.2;
}
.module-card-desc {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--pf-text-muted);
    line-height: 1.35;
    /* Trunca em 2 linhas pra cards uniformes mesmo com descricao longa. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.module-card-count {
    text-align: right;
    flex-shrink: 0;
}
.module-card-count-val {
    display: block;
    font-size: 18px; font-weight: 700;
    color: var(--pf-text);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.module-card-count-lbl {
    display: block;
    margin-top: 2px;
    font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--pf-text-muted);
}

/* Cor por card via data-cor — usa tokens existentes do design system. */
.module-card[data-cor="ok"]    { border-left-color: var(--pf-ok); }
.module-card[data-cor="ok"]    .module-card-icon { background: var(--pf-ok-soft, var(--pf-primary-soft)); color: var(--pf-ok); }
.module-card[data-cor="warn"]  { border-left-color: var(--pf-warn); }
.module-card[data-cor="warn"]  .module-card-icon { background: var(--pf-warn-soft, var(--pf-primary-soft)); color: var(--pf-warn); }
.module-card[data-cor="err"]   { border-left-color: var(--pf-err); }
.module-card[data-cor="err"]   .module-card-icon { background: var(--pf-err-soft, var(--pf-primary-soft)); color: var(--pf-err); }
.module-card[data-cor="muted"] { border-left-color: var(--pf-text-muted); }
.module-card[data-cor="muted"] .module-card-icon { background: var(--pf-side-2, var(--pf-primary-soft)); color: var(--pf-text-muted); }

/* =============================================================
   .dataset-analytic — surface workspace do dataset (template `analitico`)
   Tabela full-width com search/filtros/checkbox/bulk/click-row.
   Reusa tokens do .items-list (cores, popovers, chip-st) — so divergencia
   visual eh layout (full-width vs side 240px) e densidade (mais respiro).
   ============================================================= */

.dataset-analytic {
    display: flex; flex-direction: column;
    width: 100%; height: 100%;
    background: var(--pf-side);
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    overflow: hidden;
}

/* ---------- Toolbar ---------- */
.da-toolbar {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--pf-side-border);
    flex-shrink: 0;
}
.da-search {
    flex: 1; min-width: 0;
    height: 32px; border-radius: 6px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-bg); padding: 0 10px;
    display: flex; align-items: center; gap: 6px;
}
.da-search > .ico { color: var(--pf-text-subtle); flex-shrink: 0; }
.da-search-input {
    flex: 1; min-width: 0;
    border: 0; background: transparent; outline: 0;
    font-family: inherit; font-size: 13px; color: var(--pf-text);
}
.da-search-input::placeholder { color: var(--pf-text-subtle); }

/* Toolbar meta (selecionados + total) — entre search e icone filtrar */
.da-toolbar-meta {
    display: inline-flex; align-items: baseline; gap: 6px;
    font-size: 13px; color: var(--pf-text-muted);
    flex-shrink: 0;
}
.da-toolbar-meta .sel-count { color: var(--pf-primary); font-weight: 600; }
/* Count vira clicavel (limpa selecao) quando ha itens selecionados */
.da-toolbar-meta .sel-count:not([hidden]) ~ .count {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 2px;
    transition: color 120ms, text-decoration-color 120ms;
}
.da-toolbar-meta .sel-count:not([hidden]) ~ .count:hover {
    color: var(--pf-text);
    text-decoration-color: var(--pf-text-muted);
}

/* ---------- Botoes da toolbar (filtro, acoes, +) ---------- */
.da-btn {
    width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side); color: var(--pf-text-muted);
    cursor: pointer; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative; padding: 0;
}
.da-btn-filter    { anchor-name: --ancora-da-filter; }
.da-btn-bulk      { anchor-name: --ancora-da-bulk;   }
.da-btn-cols      { anchor-name: --ancora-da-cols;   }
.da-btn-simulator { anchor-name: --ancora-da-simulator; }
.da-btn:hover:not(:disabled) {
    background: var(--pf-primary-soft); color: var(--pf-primary); border-color: var(--pf-primary-soft);
}
.da-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.da-btn-add {
    background: var(--pf-primary); color: #fff; border-color: var(--pf-primary);
}
.da-btn-add:hover:not(:disabled) {
    background: var(--pf-primary-hover); color: #fff; border-color: var(--pf-primary-hover);
}
.da-btn .da-badge {
    position: absolute; top: -3px; right: -3px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--pf-primary); border: 2px solid var(--pf-side);
}

/* ---------- Popovers (filtro + acoes) ---------- */
.da-popover {
    padding: 0;
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    background: var(--pf-side);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.05);
    width: min(320px, calc(100vw - 32px));
    max-height: min(70vh, 480px);
    overflow: hidden;
    inset: unset;
    margin: 0;
    margin-top: 4px;
    position-area: bottom span-left;
    position-try-fallbacks: flip-block;
}
.da-filter-panel    { position-anchor: --ancora-da-filter; }
.da-bulk-panel      { position-anchor: --ancora-da-bulk; }
.da-cols-panel      { position-anchor: --ancora-da-cols; }
.da-simulator-panel { position-anchor: --ancora-da-simulator; }
.da-popover:popover-open {
    display: flex; flex-direction: column;
    animation: da-pop-in 100ms ease-out;
}
@keyframes da-pop-in {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0);    }
}
.da-popover-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--pf-side-border);
    flex-shrink: 0;
}
.da-popover-title {
    font-size: 12px; font-weight: 600; color: var(--pf-text);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.da-popover-clear {
    background: none; border: 0; cursor: pointer;
    color: var(--pf-primary); font-size: 11px; font-weight: 500;
    padding: 3px 8px; border-radius: 4px;
}
.da-popover-clear:hover { background: var(--pf-primary-soft); }
.da-popover-body { padding: 10px 12px; overflow-y: auto; flex: 1; }

/* Filter groups dentro do popover */
.da-filter-group {
    border: 0; padding: 0; margin: 0 0 14px;
    display: flex; flex-direction: column; gap: 4px;
}
.da-filter-group:last-child { margin-bottom: 0; }
.da-filter-group > legend {
    font-size: 10.5px; font-weight: 600; color: var(--pf-text-muted);
    text-transform: uppercase; letter-spacing: 0.4px; padding: 0 0 4px;
}
.da-filter-option {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 6px; border-radius: 4px;
    font-size: 12.5px; color: var(--pf-text);
    cursor: pointer; user-select: none;
}
.da-filter-option:hover { background: var(--pf-side-hover); }
.da-filter-option > input { margin: 0; cursor: pointer; }
.da-filter-option > span { line-height: 1.3; }
.da-filter-select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-bg);
    color: var(--pf-text);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
}
.da-filter-select:focus {
    outline: 0;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 3px var(--pf-primary-soft);
}

/* Cols visibility dentro do popover (mesmo idioma visual dos filter options) */
.da-cols-panel .da-popover-body { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.da-cols-option {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 4px;
    font-size: 12.5px; color: var(--pf-text);
    cursor: pointer; user-select: none;
}
.da-cols-option:hover { background: var(--pf-primary-soft); color: var(--pf-primary); }
.da-cols-option > input { margin: 0; cursor: pointer; }
.da-cols-option > span { line-height: 1.3; flex: 1; }

.da-cols-group {
    border: 0; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.da-cols-group + .da-cols-group {
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--pf-card-border);
}
.da-cols-group > legend {
    font-size: 10.5px; font-weight: 600; color: var(--pf-text-muted);
    text-transform: uppercase; letter-spacing: 0.4px;
    padding: 0 0 6px; margin: 0;
}

/* Simulador ISSQN (popover com inputs + aplicar) */
.da-simulator-body {
    display: flex; flex-direction: column; gap: 10px;
}
.da-simulator-field {
    display: flex; flex-direction: column; gap: 4px;
}
.da-simulator-label {
    font-size: 10.5px; font-weight: 600; color: var(--pf-text-muted);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.da-simulator-input {
    width: 100%; box-sizing: border-box;
    height: 32px; padding: 0 10px;
    border: 1px solid var(--pf-card-border); border-radius: 6px;
    background: var(--pf-bg); color: var(--pf-text);
    font-family: inherit; font-size: 13px;
}
.da-simulator-input[data-sim-type="money"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.da-simulator-input[data-sim-type="percent"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.da-simulator-input.is-invalid {
    border-color: var(--pf-danger, #dc2626);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}
.da-simulator-input:focus {
    outline: 0; border-color: var(--pf-primary);
    box-shadow: 0 0 0 2px var(--pf-primary-soft);
}
.da-simulator-apply {
    margin-top: 4px; width: 100%; height: 34px;
    border: 0; border-radius: 6px; cursor: pointer;
    background: var(--pf-primary); color: #fff;
    font-family: inherit; font-size: 12.5px; font-weight: 600;
}
.da-simulator-apply:hover {
    background: var(--pf-primary-hover);
}

.da-cell-sim { padding: 2px 4px; }
.da-cell-sim .da-sim-row-input {
    width: 100%; box-sizing: border-box;
    height: 26px; padding: 0 6px;
    border: 1px solid var(--pf-card-border); border-radius: 4px;
    background: var(--pf-bg); color: var(--pf-text);
    font-family: inherit; font-size: 12px;
    text-align: right; font-variant-numeric: tabular-nums;
}
.da-cell-sim .da-sim-row-input:focus {
    outline: 0; border-color: var(--pf-primary);
    box-shadow: 0 0 0 2px var(--pf-primary-soft);
}
.da-sim-output {
    display: block; width: 100%;
    text-align: right; font-variant-numeric: tabular-nums;
    font-size: 12px; color: var(--pf-text);
}

/* Detalhe — toolbar do simulador (sub-aba Cursos IES) */
.det-sim-toolbar {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 10px; flex-wrap: wrap;
}
.det-sim-btn-mestres {
    width: auto; min-width: 32px; padding: 0 10px; gap: 6px;
}
.det-sim-btn-mestres span {
    font-size: 12px; font-weight: 500; color: inherit;
}
.tbl-cell.is-col-hidden { display: none !important; }

/* Bulk actions dentro do popover */
.da-bulk-panel .da-popover-body { padding: 6px; }
.da-bulk-action {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 8px 10px; border-radius: 4px;
    border: 0; background: transparent;
    color: var(--pf-text); font-size: 12.5px; text-align: left;
    cursor: pointer;
}
.da-bulk-action:hover:not(:disabled),
.da-bulk-action:focus-visible {
    background: var(--pf-primary-soft); color: var(--pf-primary); outline: 0;
}
.da-bulk-action:disabled { opacity: 0.4; cursor: not-allowed; }
.da-bulk-action .ico { flex-shrink: 0; }
.da-bulk-action .lbl { flex: 1; }

/* ---------- Tabela: header sticky + body scrollable ---------- */
.da-table {
    flex: 1; min-height: 0; min-width: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
/* Scroll horizontal quando a soma das colunas (censo + sim) excede a largura. */
.da-table-scroll {
    flex: 1; min-height: 0; min-width: 0;
    display: flex; flex-direction: column;
    overflow-x: auto;
    overflow-y: hidden;
}
.da-table-scroll .da-thead,
.da-table-scroll .da-list {
    min-width: max-content;
}
.da-thead {
    flex-shrink: 0;
    border-bottom: 1px solid var(--pf-side-border);
    overflow-y: scroll;
    scrollbar-color: transparent transparent;
}
.da-thead::-webkit-scrollbar { width: 14px; background: transparent; }
.da-thead::-webkit-scrollbar-thumb { background: transparent; }

.da-row {
    display: grid;
    justify-content: space-between;
    grid-template-columns: var(--cols);
    align-items: center;
    border-bottom: 1px solid var(--pf-side-border);
    text-decoration: none; color: inherit;
    transition: background 100ms;
}
.da-row-h { border-bottom: 0; height: 36px; }
.da-cell {
    padding: 0 8px;
    font-size: 12.5px; color: var(--pf-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Colunas numericas usam .mono (fonte tabular) sem o chip cinza global de code/.mono */
.da-table .da-cell.mono,
.da-table .da-sim-output {
    background: transparent;
    padding: 0 8px;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 0.92em;
}
.da-table .da-cell.wrap {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    hyphens: none;
    overflow-wrap: break-word;
    line-height: 1.35;
    align-self: start;
}
.da-row:has(.da-cell.wrap) { align-items: start; }
.da-cell.c { text-align: center; }
.da-cell.r { text-align: right; }
.da-cell-h {
    font-weight: 600;
    color: var(--pf-text-muted);
    display: flex; align-items: center; gap: 4px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.da-cell-h.c { justify-content: center; }
.da-cell-h.r { justify-content: flex-end; }

/* Sortable header — clicavel + chevron up/down/idle ao lado do label.
   3-state: none -> asc (^) -> desc (v) -> none. Idle mostra um chevron
   sutil (so aparece no hover) pra sinalizar afford sem poluir visual. */
.da-cell-h.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 100ms;
}
.da-cell-h.sortable:hover { color: var(--pf-text); }
.da-cell-h.sortable.sort-asc,
.da-cell-h.sortable.sort-desc { color: var(--pf-primary); }

.da-cell-h .sort-ico {
    display: inline-block;
    width: 8px; height: 8px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask-position: center; mask-position: center;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-size: 8px 8px; mask-size: 8px 8px;
    opacity: 0;                                     /* idle: invisible */
    transition: opacity 100ms;
    /* default = both arrows (idle hint, so aparece no hover) */
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M4 0 L7 3 H1 Z M4 8 L1 5 H7 Z' fill='black'/></svg>");
    mask-image:         url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M4 0 L7 3 H1 Z M4 8 L1 5 H7 Z' fill='black'/></svg>");
}
.da-cell-h.sortable:hover .sort-ico { opacity: 0.6; }
.da-cell-h.sort-asc .sort-ico,
.da-cell-h.sort-desc .sort-ico { opacity: 1; }
.da-cell-h.sort-asc .sort-ico {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M4 1 L7 5 H1 Z' fill='black'/></svg>");
    mask-image:         url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M4 1 L7 5 H1 Z' fill='black'/></svg>");
}
.da-cell-h.sort-desc .sort-ico {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M4 7 L1 3 H7 Z' fill='black'/></svg>");
    mask-image:         url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path d='M4 7 L1 3 H7 Z' fill='black'/></svg>");
}
.da-cell-chk {
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}

/* Body scrollavel — reserva-gutter pra simetria com thead */
.da-list {
    flex: 1; min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* Row body — hover + estados (active/tab-open/selected) compartilham o mesmo
   fundo soft primary. Status chip (.chip-st) mantem seu pill independente. */
.da-list .da-row { height: 40px; cursor: pointer; text-decoration: none; }
.da-list .da-row.da-row-static { cursor: default; }
.da-list .da-row.da-row-static:hover,
.da-list .da-row.da-row-static:focus-visible { background: transparent; }
.da-list .da-row.da-row-static.active,
.da-list .da-row.da-row-static.tab-open,
.da-list .da-row.da-row-static.selected { background: transparent; }
/* Linha com link de painel (render=cnpj): estados visuais no row, link clicável na célula */
.da-list .da-row.da-row-static:has(.da-cell-panel-link).active,
.da-list .da-row.da-row-static:has(.da-cell-panel-link).tab-open,
.da-list .da-row.da-row-static:has(.da-cell-panel-link).selected {
    background: var(--pf-primary-soft);
}
.da-cell-panel-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.da-cell-panel-link:hover,
.da-cell-panel-link:focus-visible {
    color: var(--pf-primary);
    text-decoration: underline;
    outline: 0;
}
.da-row.active .da-cell-panel-link,
.da-row.tab-open .da-cell-panel-link {
    color: var(--pf-primary);
    font-weight: 600;
}
/* Linha com drawer-link (nome): mesmo contrato visual do panel-link */
.da-list .da-row.da-row-static:has(.da-cell-drawer-link).selected {
    background: var(--pf-primary-soft);
}
.da-cell-drawer-link {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: pointer;
}
.da-cell-drawer-link:hover,
.da-cell-drawer-link:focus-visible {
    color: var(--pf-primary);
    text-decoration: underline;
    outline: 0;
}
.sn-detail-sheet { width: min(420px, 100vw); }
.sn-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.sn-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--pf-border);
}
.sn-detail-head-text { min-width: 0; }
.sn-detail-nome {
    display: block;
    font-size: 15px;
    line-height: 1.3;
    word-break: break-word;
}
.sn-detail-meta {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--pf-text-muted);
}
.sn-detail-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--pf-border);
}
.sn-detail-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.sn-detail-field .field-lb {
    font-size: 12px;
    color: var(--pf-text-muted);
}
.sn-detail-field select {
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--pf-border);
    border-radius: 8px;
    background: var(--pf-surface);
    color: var(--pf-text);
}
.sn-detail-field select:focus {
    outline: 2px solid var(--pf-primary-soft);
    border-color: var(--pf-primary);
}
.sn-detail-body {
    flex: 1;
    padding: 16px;
    overflow: auto;
}
.sn-detail-placeholder {
    margin: 0;
    font-size: 13px;
    color: var(--pf-text-muted);
}
.da-list .da-row:hover,
.da-list .da-row:focus-visible,
.da-list .da-row.active,
.da-list .da-row.tab-open,
.da-list .da-row.selected { background: var(--pf-primary-soft); text-decoration: none; outline: 0; }
.da-list .da-row.active   .da-cell.first,
.da-list .da-row.tab-open .da-cell.first,
.da-list .da-row.selected .da-cell.first { color: var(--pf-primary); font-weight: 600; }

/* Chip Status dentro de row (cellClass='chip') reaproveita .chip-st global */
.da-cell .chip-st {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 500;
    line-height: 1.4;
}

/* Estados especiais */
.da-list-empty {
    padding: 32px; text-align: center;
    color: var(--pf-text-muted); font-size: 12.5px;
}
.da-list-loader { display: flex; justify-content: center; padding: 12px; }
.da-list-loader .spin {
    width: 14px; height: 14px;
    border: 2px solid var(--pf-card-border);
    border-top-color: var(--pf-primary);
    border-radius: 50%;
    animation: da-spin 800ms linear infinite;
}
@keyframes da-spin { to { transform: rotate(360deg); } }
.da-list-sentinel { height: 1px; }
.da-list.is-loading { opacity: 0.6; transition: opacity 120ms; }

/* Checkbox no workspace (dentro de .da-cell-chk). Drawer mantem o legado
   .sec-row .chk acima nesta folha. */
.da-cell-chk .chk {
    width: 16px; height: 16px; border-radius: 3px;
    border: 1.5px solid var(--pf-card-border);
    cursor: pointer; flex-shrink: 0;
    transition: background 120ms, border-color 120ms;
    position: relative;
}
.da-cell-chk .chk[aria-checked="true"] {
    background: var(--pf-primary); border-color: var(--pf-primary);
}
.da-cell-chk .chk[aria-checked="true"]::after {
    content: ''; position: absolute;
    left: 4px; top: 1px; width: 4px; height: 8px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.da-cell-chk .chk:focus-visible { outline: 2px solid var(--pf-primary-soft); outline-offset: 2px; }

.work-main > .dataset-analytic { height: 100%; }

/* ---------- Pagination footer (pages mode) ----------
   Aparece abaixo do .da-table quando pagination_mode='pages'. Layout 3-cols:
   info esquerda · controles centro · size selector direita. */
.da-pagination {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    border-top: 1px solid var(--pf-side-border);
    font-size: 12px;
}
.da-pagination-info { color: var(--pf-text-muted); flex-shrink: 0; }
.da-pagination-controls { display: inline-flex; align-items: center; gap: 2px; flex: 1; justify-content: center; }
.da-pagination-btn {
    min-width: 28px; height: 28px;
    border: 1px solid var(--pf-card-border);
    background: var(--pf-side); color: var(--pf-text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px; font-family: inherit;
    padding: 0 6px;
    transition: background 100ms, color 100ms, border-color 100ms;
}
.da-pagination-btn:hover:not(:disabled) {
    background: var(--pf-primary-soft);
    color: var(--pf-primary);
    border-color: var(--pf-primary-soft);
}
.da-pagination-btn.active {
    background: var(--pf-primary);
    color: #fff;
    border-color: var(--pf-primary);
    font-weight: 600;
}
.da-pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.da-pagination-gap {
    color: var(--pf-text-muted);
    padding: 0 4px;
    user-select: none;
}
.da-pagination-size-select {
    height: 28px; padding: 0 6px;
    border: 1px solid var(--pf-card-border);
    border-radius: 4px;
    background: var(--pf-side); color: var(--pf-text);
    font-size: 12px; font-family: inherit;
    cursor: pointer;
}

/* ---------- Virtual mode (windowed list pra > 10k rows) ----------
   .da-list em virtual mode tem 3 children: top spacer + window + bot spacer.
   Spacers tem height dinamico via JS pra simular total scroll height.
   Rows na window tem altura fixa (40px) — JS depende disso pra calcular indices. */
.da-list[data-pagination-mode="virtual"] .da-virtual-spacer-top,
.da-list[data-pagination-mode="virtual"] .da-virtual-spacer-bot {
    width: 100%;
    pointer-events: none;
}
.da-list[data-pagination-mode="virtual"] .da-virtual-window {
    display: contents;   /* rows herdam grid template do .da-list */
}
.da-list[data-pagination-mode="virtual"] .da-row {
    height: 40px;        /* fixo — virtual scroll calcula offsets baseado nisso */
}

@media (max-width: 1100px) {
    .da-cell { font-size: 11.5px; }
}

/* ============================================================
 * /adm/conversores — sub-aba "Importar" (kind=importar)
 * ============================================================ */

.conv-importar-card { /* card wrapper — herda de data-card */ }

.conv-importar { display: flex; flex-direction: column; gap: 14px; padding: 4px 0; }

.conv-importar.is-busy .conv-form { opacity: .55; pointer-events: none; }

.conv-form { display: flex; flex-direction: column; gap: 12px; }

.conv-form .conv-meta {
    margin: 0;
    font-size: 12.5px;
    color: var(--pf-text-muted, #6b7c93);
    line-height: 1.5;
}
.conv-form .conv-meta code {
    background: var(--pf-side, #f5f7fa);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11.5px;
}

.conv-field { display: flex; flex-direction: column; gap: 4px; }
.conv-field .field-lb {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--pf-text-muted, #6b7c93);
    letter-spacing: .02em;
    text-transform: uppercase;
}
.conv-field input[type="file"],
.conv-field input[type="month"],
.conv-field select {
    padding: 8px 10px;
    border: 1px solid var(--pf-card-border, #e2e8f0);
    border-radius: 5px;
    background: var(--pf-side, #fff);
    color: var(--pf-text, #2d3748);
    font: inherit;
    width: 100%;
    max-width: 420px;
}
.conv-field .field-hint {
    font-size: 11px;
    color: var(--pf-text-muted, #97a3b3);
    margin-top: 2px;
}
.conv-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.conv-fieldset > .field-lb { margin-bottom: 2px; }
.conv-check-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
}
.conv-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--pf-text, #2d3748);
}

.conv-submit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 8px 14px;
    border-radius: 5px;
    border: 0;
    background: var(--pf-primary, #2563eb);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.conv-submit:hover:not(:disabled) {
    background: var(--pf-primary-hover, #1d4ed8);
}
.conv-submit:disabled { opacity: .55; cursor: not-allowed; }
.conv-submit .ico { fill: currentColor; }

.conv-progress {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--pf-card-border, #e2e8f0);
    padding-top: 12px;
}

.conv-progress-stage {
    display: grid;
    grid-template-columns: 180px 1fr 60px;
    gap: 10px;
    align-items: center;
    font-size: 12px;
}
.conv-progress-label { color: var(--pf-text, #2d3748); font-weight: 500; }
.conv-progress-bar {
    height: 6px;
    background: var(--pf-card-border, #e2e8f0);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}
.conv-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--pf-primary, #2563eb);
    border-radius: 3px;
    transition: width 240ms ease-out;
}
.conv-progress-stage.indeterminate .conv-progress-fill {
    animation: conv-indeterminate 1.4s linear infinite;
}
@keyframes conv-indeterminate {
    0%   { transform: translateX(-100%); width: 40%; }
    100% { transform: translateX(250%); width: 40%; }
}
.conv-progress-pct {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--pf-text-muted, #6b7c93);
}

.conv-progress-result {
    padding: 10px 12px;
    border-radius: 5px;
    font-size: 13px;
    border: 1px solid var(--pf-card-border, #e2e8f0);
}
.conv-progress-result.ok {
    background: rgba(34, 197, 94, .08);
    border-color: rgba(34, 197, 94, .35);
    color: #166534;
}
.conv-progress-result.err {
    background: rgba(220, 38, 38, .08);
    border-color: rgba(220, 38, 38, .35);
    color: #b91c1c;
}

@media (max-width: 700px) {
    .conv-progress-stage {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* =============================================================
   Workspace: Importadores (split 20/80 + side menu + upload+preview)
   Usado por workspace-importadores.php (template 'importadores').
   ============================================================= */
.workspace-importadores.split-20-80 {
    display: grid;
    grid-template-columns: minmax(220px, 20%) 1fr;
    gap: 16px;
    height: 100%;
    min-height: 0;
}
.wi-side {
    display: flex; flex-direction: column; gap: 12px;
    padding: 12px;
    background: var(--pf-side, var(--pf-bg));
    border: 1px solid var(--pf-border);
    border-radius: 6px;
    min-height: 0;
}
.wi-mun-picker { display: flex; flex-direction: column; gap: 4px; }
.wi-label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--pf-text-muted);
}
.wi-select {
    appearance: none;
    height: 32px; padding: 0 28px 0 10px;
    border: 1px solid var(--pf-border); border-radius: 4px;
    background: var(--pf-bg) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path fill="%2399a" d="M0 0l5 6 5-6z"/></svg>') no-repeat right 10px center;
    color: var(--pf-text);
    font-size: 13px;
    cursor: pointer;
}
.wi-select:focus { outline: 2px solid var(--pf-primary); outline-offset: 1px; }

.workspace-dados { display: flex; flex-direction: column; gap: 16px; padding: 4px 0; }
.wd-header { display: flex; flex-direction: column; gap: 4px; }
.wd-title { margin: 0; font-size: 18px; font-weight: 600; }
.wd-lead { margin: 0; font-size: 13px; }
.wd-mun-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px;
}
.wd-mun-picker { max-width: 360px; flex: 1 1 240px; }
.wd-mun-meta {
    display: flex; flex-wrap: wrap; gap: 16px 20px;
    padding-bottom: 2px;
}
.wd-mun-meta-item { display: flex; flex-direction: column; gap: 4px; min-width: 72px; }
.wd-mun-meta-val {
    font-size: 13px; font-weight: 500; color: var(--pf-text);
    font-family: var(--font-mono);
}
.wd-select {
    appearance: none;
    height: 32px; padding: 0 28px 0 10px;
    border: 1px solid var(--pf-border); border-radius: 4px;
    background-color: #fff;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path fill="%2399a" d="M0 0l5 6 5-6z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: var(--pf-text);
    font-size: 13px;
    cursor: pointer;
}
.wd-select:focus { outline: 2px solid var(--pf-primary); outline-offset: 1px; }
.wd-footnote { margin: 0; font-size: 12px; }
/* Dados: datas mono sem texto/fundo acinzentado (espelha .da-table .da-cell.mono) */
.wd-tbl .tbl-cell.wd-col-data,
.wd-tbl .tbl-cell.wd-col-data.mono {
    color: var(--pf-text);
    background: transparent;
}
.wd-tbl .tbl-head,
.wd-tbl .tbl-body { justify-content: space-between; }
.wd-tbl .tbl-cell.wd-col-nome {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wd-tbl .tbl-row > .tbl-cell:first-child { padding: 9px 4px; }
.wd-tbl .tbl-body > .tbl-row:has(> .tbl-cell:hover) > .tbl-cell { background: var(--pf-primary-soft); }
.wd-check-row,
.wd-check-all {
    width: 14px; height: 14px;
    accent-color: var(--pf-primary);
    cursor: pointer; margin: 0; vertical-align: middle;
}

.wi-menu { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.wi-menu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: 4px;
    color: var(--pf-text);
    font-size: 13px;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.wi-menu-item:hover { background: var(--pf-bg); }
.wi-menu-item.is-active {
    background: color-mix(in srgb, var(--pf-primary) 14%, transparent);
    color: var(--pf-primary);
    font-weight: 600;
}
.wi-menu-item .ico { flex-shrink: 0; }

.wi-content {
    display: flex; flex-direction: column;
    min-height: 0; min-width: 0;
    background: var(--pf-side, var(--pf-bg));
    border: 1px solid var(--pf-border);
    border-radius: 6px;
    overflow: hidden;
}
.wi-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--pf-border);
    flex-shrink: 0;
}
.wi-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--pf-text); }
.wi-actions { display: flex; gap: 8px; align-items: center; }
.wi-actions .btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 12px;
    margin: 0; /* reset do app.css */
    border-radius: 4px;
    font-size: 12px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s, opacity .12s;
}
.wi-actions .btn-secondary {
    background: transparent;
    color: var(--pf-text);
    border-color: var(--pf-border);
}
.wi-actions .btn-secondary:hover { background: var(--pf-bg); }
.wi-actions .btn-primary {
    background: var(--pf-primary);
    color: #fff;
    border-color: var(--pf-primary);
}
.wi-actions .btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--pf-primary) 88%, #000);
}
.wi-actions .btn:disabled,
.wi-actions .btn[disabled] {
    opacity: .45; cursor: not-allowed; filter: grayscale(.4);
}

/* Header variante com botao-icone a esquerda do titulo (pipeline + logs).
   Header denso, sem padding extra entre titulo e descricao. */
.wi-header--with-lead {
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: none;
}
.wi-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    padding: 0; margin: 0;
    background: transparent;
    color: var(--pf-text-muted);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s, opacity .12s;
}
.wi-icon-btn:hover { background: var(--pf-side, var(--pf-bg)); color: var(--pf-text); border-color: var(--pf-text-muted); }
.wi-icon-btn:focus-visible { outline: 2px solid var(--pf-primary); outline-offset: 1px; }
.wi-icon-btn:disabled, .wi-icon-btn[disabled] {
    opacity: .45; cursor: not-allowed;
}
.wi-icon-btn > .ico { width: 14px; height: 14px; }

/* Toggle do acordion: titulo + chevron viram um botao clicavel.
   Quando aberto, chevron gira 180deg. Hover sutil reforca affordance. */
.wi-source-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0; margin: 0;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
}
.wi-source-toggle:focus-visible {
    outline: 2px solid var(--pf-primary);
    outline-offset: 3px;
    border-radius: 3px;
}
.wi-source-toggle .wi-title { cursor: pointer; }
.wi-source-toggle:hover .wi-title { color: var(--pf-primary); }
.wi-chevron {
    color: var(--pf-text-muted);
    transition: transform .15s ease;
}
.wi-source-toggle[aria-expanded="true"] .wi-chevron {
    transform: rotate(180deg);
}

/* Meta "ultima atualizacao" alinhada a direita do titulo. */
.wi-title-meta {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--pf-text-muted);
    white-space: nowrap;
}
.wi-title-meta strong {
    color: var(--pf-text);
    font-weight: 600;
}

/* Cartao de fonte do dado: 2 colunas (80/20). Recolhido por padrao;
   click no titulo expande. Esquerda = descricao + links (fonte/manual)
   editaveis inline. Direita = card de config (periodicidade). */
.wi-source {
    display: grid;
    grid-template-columns: minmax(0, 8fr) minmax(180px, 2fr);
    gap: 12px;
    padding: 0 14px 8px;
    background: transparent;
    border-bottom: none;
    font-size: 12.5px;
    color: var(--pf-text);
    align-items: start;
}
.wi-source-main {
    min-width: 0;
}

/* Card direito: dados nao-editaveis (ultima atualizacao) + dropdown
   de periodicidade. Background sutil pra distinguir da coluna esquerda. */
.wi-config-card {
    display: flex; flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: var(--pf-bg);
    border: 1px solid var(--pf-border);
    border-radius: 5px;
    font-size: 12px;
}
.wi-config-row {
    display: flex; flex-direction: column;
    gap: 2px;
}
.wi-config-label {
    color: var(--pf-text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.wi-config-value {
    color: var(--pf-text);
    font-size: 12.5px;
}
.wi-config-value strong { font-weight: 600; }
.wi-config-select {
    width: 100%;
    padding: 5px 8px;
    background: var(--pf-side, var(--pf-bg));
    color: var(--pf-text);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}
.wi-config-select:focus {
    outline: none;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--pf-primary) 25%, transparent);
}
.wi-config-select:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 720px) {
    .wi-source { grid-template-columns: 1fr; }
}
.wi-source-field {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 1px 0;
}
.wi-source-field + .wi-source-field { margin-top: 0; }
.wi-source-field .wi-source-value {
    flex: 1 1 auto;
    margin: 0;
    line-height: 1.35;
    color: var(--pf-text);
    word-break: break-word;
}
.wi-source-field .wi-source-value .muted,
.wi-source-field .wi-source-value a + .muted { color: var(--pf-text-muted); }
.wi-source-field .wi-source-value a {
    color: var(--pf-primary);
    text-decoration: none;
}
.wi-source-field .wi-source-value a:hover { text-decoration: underline; }
.wi-source-label {
    color: var(--pf-text-muted);
    font-weight: 600;
    flex-shrink: 0;
}
.wi-source-edit { flex: 1 1 auto; }
.wi-source-input {
    width: 100%;
    padding: 6px 8px;
    background: var(--pf-side, var(--pf-bg));
    color: var(--pf-text);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    font: inherit;
    font-size: 12.5px;
}
.wi-source-input:focus {
    outline: none;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--pf-primary) 25%, transparent);
}
textarea.wi-source-input { resize: vertical; min-height: 60px; }
.wi-source-actions {
    display: inline-flex; align-items: center; gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .12s;
}
.wi-source-field:hover .wi-source-actions,
.wi-source-field.is-editing .wi-source-actions,
.wi-source-field:focus-within .wi-source-actions {
    opacity: 1;
}
.wi-source-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    padding: 0; margin: 0;
    background: transparent;
    color: var(--pf-text-muted);
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.wi-source-btn:hover { background: var(--pf-side, var(--pf-bg)); color: var(--pf-text); border-color: var(--pf-border); }
.wi-source-btn:focus-visible { outline: 2px solid var(--pf-primary); outline-offset: 1px; }
.wi-source-btn--save:hover { color: var(--pf-success, #28a745); border-color: var(--pf-success, #28a745); }
.wi-source-btn--cancel:hover { color: var(--pf-danger, #dc3545); border-color: var(--pf-danger, #dc3545); }
.wi-source-btn > .ico { width: 12px; height: 12px; }
.wi-source-field.is-saving { opacity: .6; pointer-events: none; }

.wi-source-links {
    list-style: none;
    margin: 2px 0 0;
    padding: 0;
    display: flex; flex-direction: column;
    gap: 0;
}

.wi-file-meta {
    display: flex; gap: 12px; align-items: center;
    padding: 8px 16px;
    background: var(--pf-bg);
    border-bottom: 1px solid var(--pf-border);
    font-size: 12px;
    color: var(--pf-text-muted);
}
.wi-file-name { font-weight: 600; color: var(--pf-text); }

.wi-preview-wrap {
    flex: 1; min-height: 0;
    overflow: auto;
    padding: 16px;
}
.wi-preview-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%;
    color: var(--pf-text-muted); font-size: 13px; text-align: center;
}
.wi-preview-empty p { margin: 4px 0; }
.wi-preview-empty .muted { font-size: 12px; }
.wi-preview-table table {
    width: 100%; border-collapse: collapse; font-size: 12px;
}
.wi-preview-table th, .wi-preview-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--pf-border);
    text-align: left; white-space: nowrap;
    color: var(--pf-text);
}
.wi-preview-table th {
    background: var(--pf-bg);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--pf-text-muted);
    position: sticky; top: 0; z-index: 1;
}
.wi-preview-table tbody tr:hover { background: var(--pf-bg); }

.wi-history-wrap {
    padding: 0 14px 14px;
    overflow: auto;
}
.wi-history-table {
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--pf-side);
}
.wi-history-head,
.wi-history-row {
    display: grid;
    grid-template-columns: 32px minmax(220px, 1fr) minmax(150px, 190px);
    align-items: stretch;
}
.wi-history-head {
    background: inherit;
    border-bottom: 1px solid var(--pf-card-border);
}
.wi-history-row {
    color: var(--pf-text);
    text-decoration: none;
    border-bottom: 1px solid var(--pf-card-border);
    transition: background .12s, color .12s;
}
.wi-history-row:last-child { border-bottom: 0; }
.wi-history-row:hover {
    background: var(--pf-primary-soft);
    color: var(--pf-text);
}
.wi-history-cell {
    min-width: 0;
    padding: 9px 12px;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.wi-history-h {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--pf-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.wi-history-status {
    font-weight: 600;
    justify-content: center;
    white-space: nowrap;
}
.wi-history-head .wi-history-cell:first-child,
.wi-history-status {
    padding-left: 6px;
    padding-right: 6px;
}
.wi-history-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 2px var(--pf-side);
}
.wi-history-dot--ok { background: #16a34a; }
.wi-history-dot--warn { background: #d97706; }
.wi-history-dot--primary { background: var(--pf-primary); }
.wi-history-dot--err { background: #dc2626; }
.wi-history-data {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}
.wi-history-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}
.wi-history-name .ico {
    color: var(--pf-text-muted);
    flex-shrink: 0;
}
.wi-history-meta {
    color: var(--pf-text-muted);
    font-size: 11.5px;
    line-height: 1.3;
}
.wi-history-last {
    justify-content: flex-end;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--pf-text);
    text-align: right;
}

@media (max-width: 760px) {
    .wi-history-head { display: none; }
    .wi-history-row {
        grid-template-columns: 1fr;
        padding: 8px 0;
    }
    .wi-history-cell {
        padding: 4px 12px;
    }
    .wi-history-last {
        justify-content: flex-start;
        text-align: left;
    }
}


.wi-rf-periodo {
    min-width: 160px;
    max-width: 220px;
}
.wi-rf-stats {
    font-size: 12px;
    color: var(--pf-text-muted);
    margin-left: auto;
}
/* Flash apos sync upstream — destaca a mensagem de delta por uns segundos. */
.wi-rf-stats.is-sync-flash {
    color: var(--pf-primary);
    font-weight: 600;
    animation: wi-sync-pulse .8s ease;
}
@keyframes wi-sync-pulse {
    0%   { transform: scale(1);     opacity: .7; }
    50%  { transform: scale(1.05);  opacity: 1;  }
    100% { transform: scale(1);     opacity: 1;  }
}

/* Badge "novo" no nome do arquivo quando aparece pela primeira vez na
   sincronizacao. Visual sutil + cor primary do design system. */
.wi-rf-badge-novo {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #fff;
    background: var(--pf-primary);
    border-radius: 3px;
    vertical-align: middle;
}
.wi-rf-tbl .tbl-row.is-novo {
    background: color-mix(in srgb, var(--pf-primary) 8%, transparent);
}

/* Modo agrupado: header do grupo (1 row clicavel) + linhas dos arquivos.
   Headers ocupam todas as colunas (span: 4). */
.wi-rf-tbl-agrupada .wi-rf-grupo-head {
    background: color-mix(in srgb, var(--pf-text) 4%, transparent);
    cursor: default;
    font-size: 12.5px;
}
.wi-rf-tbl-agrupada .wi-rf-grupo-head.is-completo {
    background: color-mix(in srgb, #22c55e 6%, transparent);
}
.wi-rf-grupo-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 2px 0; margin: 0;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    width: 100%;
    text-align: left;
}
.wi-rf-grupo-toggle:hover .wi-rf-grupo-periodo { color: var(--pf-primary); }
.wi-rf-grupo-toggle:focus-visible {
    outline: 2px solid var(--pf-primary);
    outline-offset: 2px;
    border-radius: 3px;
}
.wi-rf-grupo-periodo {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.wi-rf-grupo-stat {
    color: var(--pf-text-muted);
    font-size: 11.5px;
    margin-left: 4px;
}
.wi-rf-grupo-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #fff;
    background: #22c55e;
    border-radius: 3px;
}
.wi-rf-grupo-head .wi-chevron {
    color: var(--pf-text-muted);
    transition: transform .15s ease;
    flex-shrink: 0;
}
.wi-rf-grupo-head .wi-chevron.is-open { transform: rotate(180deg); }
/* Arquivos sob o grupo: indent sutil pra hierarquia visivel sem CSS pesado. */
.wi-rf-tbl-agrupada .wi-rf-arquivo-row .tbl-cell.first {
    padding-left: 16px;
}
.wi-rf-table-wrap {
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--pf-side);
}
.wi-content > .wi-rf-table-wrap {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    margin: 0 14px 14px;
    min-height: 0;
}
/* Adota o padrao .tbl/.tbl-head/.tbl-body do workspace-analitico (grid +
   sticky header + scroll do body). No painel de pipeline, a tabela ocupa
   a altura restante e so rola quando esse espaco acaba. */
.wi-rf-tbl {
    max-height: none;
}
.wi-content > .wi-rf-table-wrap > .wi-rf-tbl {
    flex: 1 1 auto;
    min-height: 0;
}
/* Tabela de periodos: bolinha de status centralizada na coluna St. */
.wi-rf-tbl-periodos .tbl-body .tbl-cell.c {
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Subaba Logs: tabela full-width sem side-menu. Mais espaco vertical
   que as etapas individuais — ocupa quase a viewport toda. */
.wi-logs { padding: 16px 20px; }
.workspace-etl.wi-queue {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}
.wi-logs .wi-rf-panel-head { margin: 0 0 10px; }
.wi-logs-tbl { max-height: calc(100vh - 280px); }
.wi-queue-tbl { max-height: calc(100vh - 220px); }
.wi-logs-slug { font-family: var(--font-mono); font-size: 11.5px; }
.wi-queue-toolbar {
    padding: 0;
    margin: 0;
    border-bottom: 0;
    background: transparent;
    overflow: visible;
}
.wi-queue-toolbar .wi-queue-updated { margin-left: 2px; }
.wi-queue-updated { margin-left: auto; font-size: 12px; }
.wi-queue-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--pf-side);
}
.wi-queue-dot--ok { background: #16a34a; }
.wi-queue-dot--warn { background: #d97706; }
.wi-queue-dot--err { background: #dc2626; }
.wi-queue-dot--stale { background: #7c3aed; }
.wi-queue-filter {
    position: relative;
    anchor-name: --ancora-wi-queue-filter;
}
.wi-queue-filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 14px;
    height: 14px;
    padding: 0 4px;
    border: 2px solid var(--pf-side);
    border-radius: 999px;
    background: var(--pf-primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 10px;
    text-align: center;
}
.wi-queue-popover {
    padding: 0;
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    background: var(--pf-side);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.05);
    width: min(280px, calc(100vw - 32px));
    max-height: min(70vh, 420px);
    overflow: hidden;
    inset: unset;
    margin: 0;
    margin-top: 4px;
    position-area: bottom span-left;
    position-try-fallbacks: flip-block;
}
.wi-queue-filter-panel { position-anchor: --ancora-wi-queue-filter; }
.wi-queue-popover:popover-open {
    display: flex;
    flex-direction: column;
    animation: da-pop-in 100ms ease-out;
}
.wi-queue-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--pf-side-border);
    flex-shrink: 0;
}
.wi-queue-popover-title {
    color: var(--pf-text);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.wi-queue-popover-clear {
    padding: 3px 8px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--pf-primary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
}
.wi-queue-popover-clear:hover { background: var(--pf-primary-soft); }
.wi-queue-popover-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}
.wi-queue-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}
.wi-queue-filter-group:last-child { margin-bottom: 0; }
.wi-queue-filter-group > legend {
    padding: 0 0 4px;
    color: var(--pf-text-muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.wi-queue-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 4px;
    color: var(--pf-text);
    cursor: pointer;
    font-size: 12.5px;
    user-select: none;
}
.wi-queue-filter-option:hover { background: var(--pf-side-hover); }
.wi-queue-filter-option > input {
    margin: 0;
    cursor: pointer;
}
.wi-queue-tbl .tbl-body .tbl-row > .tbl-cell:first-child {
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Dropdowns na toolbar herdam .ft mas precisam de width minimo pra rotulos
   nao ficarem cortados. */
.tbl-toolbar select.ft { min-width: 140px; padding-right: 6px; }
.tbl-toolbar select.ft:focus-visible { outline: 2px solid var(--pf-primary); outline-offset: 1px; }
.wi-rf-check {
    display: inline-block;
    color: #22c55e;                        /* green-500 — bom em dark e light */
    font-weight: 600;
}
.wi-rf-check.is-no {
    color: var(--pf-text-subtle);
    opacity: 0.5;
}
/* Coluna 0 (status/checkbox) — reduz padding pra caber bem em 32px */
.wi-rf-tbl .tbl-row > .tbl-cell:first-child {
    padding: 9px 4px;
}
.wi-rf-check-row,
.wi-rf-check-all {
    width: 14px;
    height: 14px;
    accent-color: var(--pf-primary);
    cursor: pointer;
    margin: 0;
    vertical-align: middle;
}
.wi-rf-baixar .ico { color: rgba(255, 255, 255, 0.9); }
.wi-rf-baixar-count {
    font-weight: 500;
    opacity: 0.85;
}
.wi-rf-baixar:disabled .wi-rf-baixar-count { opacity: 0.6; }
.wi-rf-todo {
    padding: 18px;
    border: 1px dashed var(--pf-card-border);
    border-radius: 6px;
    color: var(--pf-text-muted);
    font-size: 13px;
    background: var(--pf-side);
}

.wi-rf-open-row {
    cursor: pointer;
}
.wi-rf-open-row:hover {
    background: color-mix(in srgb, var(--pf-primary) 6%, transparent);
}
.wi-rf-open-row input,
.wi-rf-open-row button {
    cursor: auto;
}

.wi-import-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(15, 23, 42, 0.18);
}
.wi-import-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 91;
    width: min(1200px, 92vw);
    display: flex;
    flex-direction: column;
    background: var(--pf-bg);
    border-left: 1px solid var(--pf-card-border);
    box-shadow: -18px 0 38px rgba(15, 23, 42, 0.18);
}
.wi-import-drawer[hidden],
.wi-import-drawer-backdrop[hidden] {
    display: none;
}
.wi-import-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--pf-card-border);
    background: var(--pf-side);
}
.wi-import-drawer-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.wi-import-drawer-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--pf-text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.wi-import-drawer-title {
    margin: 0;
    color: var(--pf-text);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.wi-import-drawer-close {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-bg);
    color: var(--pf-text-muted);
    cursor: pointer;
}
.wi-import-drawer-close:hover {
    color: var(--pf-text);
    background: var(--pf-side-hover);
}
.wi-import-drawer-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 16px 18px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 0;
}
.wi-import-col-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding-right: 18px;
}
.wi-import-col-right {
    min-width: 0;
    min-height: 0;
    padding-left: 18px;
    border-left: 1px solid var(--pf-card-border);
    overflow-y: auto;
    scrollbar-color: color-mix(in srgb, var(--pf-text-muted) 42%, transparent) var(--pf-side);
    scrollbar-width: thin;
}
.wi-import-files {
    flex: 0 0 30%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pf-card-border);
    scrollbar-color: color-mix(in srgb, var(--pf-text-muted) 42%, transparent) var(--pf-side);
    scrollbar-width: thin;
}
.wi-import-estagio {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 12px;
    scrollbar-color: color-mix(in srgb, var(--pf-text-muted) 42%, transparent) var(--pf-side);
    scrollbar-width: thin;
}
.wi-import-message {
    margin-bottom: 0;
}
.wi-import-stages h4,
.wi-import-estagio h4,
.wi-import-message h4 {
    margin: 0 0 8px;
    color: var(--pf-text);
    font-size: 13px;
}
.wi-import-files-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.wi-import-drawer-download {
    color: var(--pf-primary);
}
.wi-import-download-mode {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--pf-text-muted);
}
.wi-import-mode-opt {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    white-space: nowrap;
}
.wi-import-section-head {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.wi-import-section-head--tools {
    align-items: center;
}
.wi-import-section-title {
    min-width: 0;
    margin: 0;
    color: var(--pf-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wi-import-estagio-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}
.wi-import-estagio-totals {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 10px;
    border-right: 1px solid var(--pf-card-border);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--pf-text-muted);
}
.wi-estat--banco      { color: #16a34a; }
.wi-estat--staging    { color: #4f46e5; }
.wi-estat--tratamento { color: #0891b2; }
.wi-estat--download   { color: #d97706; }
.wi-estat--fila       { color: #64748b; }
.wi-estat--sem-dados  { color: #94a3b8; }
.wi-estat--err        { color: #dc2626; }
.wi-estat-sep {
    color: var(--pf-card-border);
    font-weight: 400;
    user-select: none;
}
.wi-import-estagio-search {
    flex: 1;
    min-width: 80px;
    height: 30px;
    padding: 0 9px;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-bg);
    color: var(--pf-text);
    font: inherit;
    font-size: 12px;
}
.wi-estat-btn {
    cursor: pointer;
    border-radius: 3px;
    padding: 1px 3px;
    margin: -1px -3px;
    transition: background 0.1s;
}
.wi-estat-btn:hover { background: var(--pf-side-hover); }
.wi-estat-btn.is-active { text-decoration: underline; }
.wi-import-estagio-search::placeholder {
    color: var(--pf-text-subtle);
}
.wi-import-estagio-search:focus {
    outline: 2px solid color-mix(in srgb, var(--pf-primary) 36%, transparent);
    outline-offset: 1px;
}
.wi-import-filter-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    anchor-name: --ancora-wi-import-filter;
}
.wi-import-filter-btn.is-active {
    color: var(--pf-primary);
    border-color: color-mix(in srgb, var(--pf-primary) 42%, var(--pf-card-border));
    background: color-mix(in srgb, var(--pf-primary) 10%, var(--pf-side));
}
.wi-import-filter-panel {
    position-anchor: --ancora-wi-import-filter;
    width: min(230px, calc(100vw - 32px));
}
.wi-import-summary-table .tbl-body .tbl-cell.c,
.wi-import-stage-table .tbl-body .tbl-cell.c {
    display: flex;
    align-items: center;
    justify-content: center;
}
.wi-import-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}
.wi-import-status-dot--banco      { background: #16a34a; color: #16a34a; }
.wi-import-status-dot--run        { background: #eab308; color: #eab308; }
.wi-import-status-dot--disponivel { background: #3b82f6; color: #3b82f6; }
.wi-import-status-dot--staging    { background: #4f46e5; color: #4f46e5; }
.wi-import-status-dot--tratamento { background: #0891b2; color: #0891b2; }
.wi-import-status-dot--download   { background: #d97706; color: #d97706; }
.wi-import-status-dot--fila       { background: #64748b; color: #64748b; }
.wi-import-status-dot--sem-dados  { background: #94a3b8; color: #94a3b8; }
.wi-import-status-dot--err        { background: #dc2626; color: #dc2626; }
.wi-import-summary-table .tbl-head,
.wi-import-summary-table .tbl-body {
    grid-template-columns: 72px 110px minmax(180px, 1fr);
}
.wi-import-summary-table .tbl-cell,
.wi-import-stage-table .tbl-cell {
    padding-left: 10px;
    padding-right: 10px;
}
.wi-import-stage-table .tbl-head,
.wi-import-stage-table .tbl-body {
    grid-template-columns: 72px 110px minmax(110px, 1fr) 90px 40px;
}
.wi-import-stage-table .tbl-body {
    max-height: 260px;
    overflow: auto;
}
.wi-import-stage-tag {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--pf-text);
    font-size: 11.5px;
    font-weight: 700;
}
.wi-import-stage-file {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Drawer: lista de arquivos do periodo (checkbox | status | arquivo |
   tamanho | %). Mesma engine .tbl do resto do app. */
.wi-import-files-table .tbl-head,
.wi-import-files-table .tbl-body {
    grid-template-columns: 40px 56px minmax(120px, 1fr) 90px 52px;
}
.wi-import-drawer .tbl-head,
.wi-import-drawer .tbl-body {
    display: flex;
    flex-direction: column;
}
.wi-import-drawer .tbl-row {
    display: grid;
    align-items: stretch;
    min-height: 40px;
    width: 100%;
}
.wi-import-drawer .tbl-cell {
    display: flex;
    align-items: center;
    align-self: stretch;
    min-height: 40px;
}
.wi-import-drawer .tbl-cell.c {
    justify-content: center;
}
.wi-import-drawer .tbl-cell.r,
.wi-import-drawer .tbl-cell.num {
    justify-content: flex-end;
}
.wi-import-files-table .tbl-row {
    grid-template-columns: 40px 56px minmax(0, 1fr) 90px 100px;
}
.wi-import-files-table .tbl-cell {
    padding-left: 10px;
    padding-right: 10px;
}
.wi-import-files-table .tbl-body .tbl-cell.c {
    display: flex;
    align-items: center;
    justify-content: center;
}
.wi-import-files-list {
    max-height: min(220px, 28vh);
    overflow: auto;
}
.wi-import-estagio-title {
    color: var(--pf-text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.wi-import-estagio-table .tbl-head,
.wi-import-estagio-table .tbl-body {
    grid-template-columns: 32px 44px minmax(120px, 1fr) 80px 52px;
}
.wi-import-estagio-table .tbl-row {
    grid-template-columns: 32px 44px minmax(0, 1fr) 80px 52px;
}
.wi-import-estagio-table .tbl-cell {
    padding-left: 8px;
    padding-right: 8px;
}
.wi-import-estagio-table .tbl-body .tbl-cell.c {
    display: flex;
    align-items: center;
    justify-content: center;
}
.wi-import-estagio-list {
    max-height: 160px;
    overflow: auto;
}
.wi-import-estagio-row {
    cursor: pointer;
}
.wi-import-estagio-row:hover {
    background: color-mix(in srgb, var(--pf-primary) 6%, transparent);
}
.wi-import-estagio-stats {
    margin: 6px 0 0;
    font-size: 12px;
}
.wi-import-estagio-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}
.wi-import-estagio-foot .wi-import-estagio-stats {
    margin: 0;
}
.wi-import-estagio-pages {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
}
.wi-import-page-btn {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border: 1px solid var(--pf-card-border);
    border-radius: 5px;
    background: var(--pf-bg);
    color: var(--pf-text-muted);
    font: inherit;
    font-size: 11.5px;
    cursor: pointer;
}
.wi-import-page-btn:hover,
.wi-import-page-btn.is-active {
    border-color: var(--pf-primary);
    background: color-mix(in srgb, var(--pf-primary) 12%, transparent);
    color: var(--pf-text);
}
.wi-import-page-gap {
    padding: 0 3px;
    color: var(--pf-text-muted);
    font-size: 11.5px;
}
.wi-import-drawer-body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.wi-import-drawer-body::-webkit-scrollbar-track {
    background: var(--pf-side);
}
.wi-import-drawer-body::-webkit-scrollbar-thumb {
    border: 2px solid var(--pf-side);
    border-radius: 999px;
    background: color-mix(in srgb, var(--pf-text-muted) 42%, transparent);
}
[data-theme="dark"] .wi-import-drawer-body {
    scrollbar-color: #5b5a54 #25241f;
}
[data-theme="dark"] .wi-import-drawer-body::-webkit-scrollbar-track {
    background: #25241f;
}
[data-theme="dark"] .wi-import-drawer-body::-webkit-scrollbar-thumb {
    border-color: #25241f;
    background: #5b5a54;
}
.wi-import-file-check,
.wi-import-file-all {
    width: 14px;
    height: 14px;
    accent-color: var(--pf-primary);
    cursor: pointer;
    margin: 0;
    vertical-align: middle;
}
.wi-import-message {
    padding: 12px;
    border: 1px solid var(--pf-card-border);
    border-radius: 6px;
    background: var(--pf-side);
}
.wi-import-message p {
    margin: 0;
    color: var(--pf-text-muted);
    font-size: 12.5px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.wi-import-message-text {
    display: block;
}
.wi-import-message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.wi-import-json-preview {
    max-height: 200px;
    overflow-y: auto;
    font-size: 11px;
    background: var(--pf-bg, #f8f9fa);
    padding: 8px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0 0 8px;
    color: var(--pf-text);
}
.wi-import-message-btn {
    min-height: 28px;
    padding: 0 12px;
    font-size: 12px;
}
.wi-import-timeline {
    margin-top: 16px;
}
.wi-import-timeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.wi-import-timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
}
.wi-import-timeline-icon {
    flex: 0 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 1px;
}
.wi-import-timeline-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.wi-import-timeline-item--done .wi-import-timeline-icon { color: #16a34a; }
.wi-import-timeline-item--running .wi-import-timeline-icon { color: var(--pf-primary); }
.wi-import-timeline-item--error .wi-import-timeline-icon { color: #dc2626; }
.wi-import-timeline-item--pending .wi-import-timeline-icon,
.wi-import-timeline-item--queued .wi-import-timeline-icon { color: var(--pf-text-muted); }
@keyframes wi-spin { to { transform: rotate(360deg); } }
.wi-timeline-spin { animation: wi-spin 1s linear infinite; display: inline-block; transform-origin: center; }
.wi-import-timeline-label {
    color: var(--pf-text);
}
.wi-import-timeline-item--pending .wi-import-timeline-label,
.wi-import-timeline-item--queued .wi-import-timeline-label { color: var(--pf-text-muted); }
.wi-import-timeline-progress {
    color: var(--pf-text-muted);
    font-variant-numeric: tabular-nums;
    font-size: 11px;
}
.wi-import-timeline-msg {
    width: 100%;
    color: #dc2626;
    font-size: 11px;
    overflow-wrap: anywhere;
}

@media (max-width: 700px) {
    .wi-import-summary-table .tbl-head,
    .wi-import-summary-table .tbl-body {
        min-width: 420px;
    }
    .wi-import-stage-table .tbl-head,
    .wi-import-stage-table .tbl-body,
    .wi-import-estagio-table .tbl-head,
    .wi-import-estagio-table .tbl-body,
    .wi-import-files-table .tbl-head,
    .wi-import-files-table .tbl-body {
        min-width: 560px;
    }
    .wi-import-stage-file {
        white-space: normal;
    }
}

/* Drawer de detalhe de log de auditoria */
.audit-log-meta {
    display: grid;
    gap: 0.5rem 1rem;
    margin: 0 0 1rem;
    grid-template-columns: minmax(6rem, auto) 1fr;
    font-size: 0.8125rem;
}
.audit-log-meta-row {
    display: contents;
}
.audit-log-meta dt {
    margin: 0;
    color: var(--muted, #64748b);
    font-weight: 500;
}
.audit-log-meta dd {
    margin: 0;
    word-break: break-word;
}
.audit-log-json-title {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
}
.audit-log-json-pre {
    margin: 0;
    padding: 0.75rem;
    border-radius: 6px;
    background: var(--surface-2, #f1f5f9);
    font-size: 0.75rem;
    line-height: 1.45;
    overflow: auto;
    max-height: min(60vh, 480px);
    white-space: pre-wrap;
    word-break: break-word;
}
[data-theme="dark"] .audit-log-json-pre {
    background: var(--surface-2, #1e293b);
}

/* Tabela de logs — linha clicável + checkbox */
.is-audit-log-table .audit-log-row {
    cursor: pointer;
}
.is-audit-log-table .audit-log-row:hover,
.is-audit-log-table .audit-log-row:focus-visible {
    background: var(--pf-primary-soft);
    outline: 0;
}
.is-audit-log-table .audit-log-row.selected {
    background: var(--pf-primary-soft);
}
.is-audit-log-table .da-cell-chk .chk {
    width: 14px;
    height: 14px;
    border: 1.5px solid #cbd2da;
    border-radius: 3px;
    flex-shrink: 0;
    background: var(--pf-side);
    position: relative;
    margin: 0 auto;
}
.is-audit-log-table .da-cell-chk .chk.on {
    background: var(--pf-primary);
    border-color: var(--pf-primary);
}
.is-audit-log-table .da-cell-chk .chk.on::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 0;
    width: 4px;
    height: 8px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}
.is-audit-log-table .da-cell-chk .chk.indeterminate {
    background: var(--pf-primary-soft);
    border-color: var(--pf-primary);
}
.is-audit-log-table .da-cell-chk .chk.indeterminate::after {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    top: 5px;
    height: 2px;
    background: var(--pf-primary);
    transform: none;
    border: 0;
}

.audit-log-head {
    grid-template-columns: minmax(54px, auto) minmax(0, 1fr) minmax(0, 1fr) 30px 30px;
    padding: 12px 16px 10px;
}
.audit-log-head .cn-detail-title {
    grid-column: auto;
}
.audit-log-head-spacer {
    display: block;
}
.audit-log-body {
    padding: 0 16px 16px;
    overflow-y: auto;
}
.audit-log-popover .cn-detail-sheet {
    width: min(480px, 100vw);
}
