/* Modais globais: home e Transparência. Largura padrão definida somente aqui. */
:root {--modal-overlay:rgba(0,0,0,.92)}
/* Reserva a largura da barra de rolagem ao abrir/fechar as janelas. */
html {scrollbar-gutter:stable !important}
dialog.modal {position:fixed; inset:0; box-sizing:border-box; width:min(var(--modal-largura,1200px),calc(100% - 32px)); max-width:none; max-height:calc(100dvh - 32px); margin:auto; padding:0; overflow:hidden; overscroll-behavior:contain; border:1px solid var(--linha); border-radius:14px; color:var(--modal-texto); background:var(--modal-fundo); box-shadow:var(--card-sombra)}
dialog.modal:not([open]) {display:none}
dialog.modal[open] {display:flex; flex-direction:column}
dialog.modal::backdrop {background:var(--modal-overlay)}
/* Trava compartilhada, inclusive para formas nativas de abrir/fechar o dialog. */
html:has(dialog[open]), html:has(#appModal.active), html:has(.modal-global-overlay.active), body:has(dialog.modal:modal), body.modal-aberto, html.modal-aberto {overflow:hidden !important}
html:has(dialog[open]), html.modal-aberto {background:#0a0a0a; scrollbar-gutter:stable !important}
dialog.modal > .modal-topo, dialog.modal > .modal-rodape {flex:none; padding:12px 20px}
dialog.modal > .modal-topo {display:flex; align-items:center; justify-content:space-between; gap:12px; border-bottom:1px solid var(--linha)}
dialog.modal .modal-logo {display:block; max-width:calc(100% - 50px); max-height:46px; width:auto; object-fit:contain}
dialog.modal .modal-fechar {flex:none; width:38px; height:38px; padding:0; border:0; border-radius:6px; color:var(--modal-texto); background:var(--fundo-destaque); font:400 26px/1 Roboto,sans-serif; cursor:pointer}
dialog.modal .modal-fechar:focus-visible {outline:2px solid var(--link); outline-offset:3px}
dialog.modal .modal-titulo {margin:0 0 18px; color:var(--titulo); font:600 22px/1.3 Roboto,sans-serif}
dialog.modal .modal-texto {margin:0 0 14px; color:var(--texto-suave)}
dialog.modal > .modal-conteudo {min-height:0; padding:20px; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#8d9aa4 var(--modal-fundo)}
dialog.modal > .modal-conteudo::-webkit-scrollbar {width:6px}
dialog.modal > .modal-conteudo::-webkit-scrollbar-track {background:var(--modal-fundo)}
dialog.modal > .modal-conteudo::-webkit-scrollbar-thumb {background:#8d9aa4; border-radius:6px}
dialog.modal > .modal-conteudo::-webkit-scrollbar-thumb:hover {background:#63717c}
dialog.modal > .modal-rodape {border-top:1px solid var(--linha); color:var(--texto-suave); font:400 12px/1.4 Roboto,sans-serif; text-align:center}
@media (prefers-reduced-motion: no-preference) {
    dialog.modal[open], dialog.modal[open]::backdrop {animation:modal-aparecer .32s ease-out}
    @keyframes modal-aparecer {from {opacity:0}}
}

/* Compatibilidade com janelas antigas e demonstrações ainda não migradas. */
.modal-global-overlay {display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:var(--modal-overlay); z-index:9999; align-items:center; justify-content:center}
html .app-modal-overlay {background:var(--modal-overlay)}
.modal-global-overlay.active {display:flex}
.modal-global {background:#fff; border-radius:8px; width:90%; max-width:900px; max-height:88vh; overflow:hidden; box-shadow:0 8px 40px rgba(0,0,0,0.22); display:flex; flex-direction:column; scrollbar-width:thin; scrollbar-color:#c8cdd5 #f2f4f6}
.modal-global::-webkit-scrollbar {width:10px; height:12px}
.modal-global::-webkit-scrollbar-track {background:#f2f4f6; border-radius:10px}
.modal-global::-webkit-scrollbar-thumb {background:#c8cdd5; border-radius:10px}
.modal-global::-webkit-scrollbar-thumb:hover {background:#aab1ba}
.modal-global-header {background:#1a6eb5; color:#fff; padding:16px 20px; display:flex; align-items:center; justify-content:space-between; flex-shrink:0; border-radius:8px 8px 0 0}
.modal-global-header h3 {margin:0; font-size:15px; font-weight:700; color:#fff}
.modal-global-close {background:transparent; border:2px solid rgba(255,255,255,0.6); color:#fff; border-radius:50%; width:30px; height:30px; font-size:16px; cursor:pointer; display:flex; align-items:center; justify-content:center}
.modal-global-close:hover {background:rgba(255,255,255,0.15)}
.modal-global-body {padding:24px 24px 16px; flex:1; overflow-y:auto}
.modal-global-body .objeto-texto {background:#f8f9fa; border-left:3px solid #1a6eb5; padding:10px 14px; border-radius:0 4px 4px 0; font-size:13px; color:#333; margin-top:4px; line-height:1.5}
.modal-global-body .secao-titulo {font-size:13px; font-weight:700; color:#1a6eb5; text-transform:uppercase; margin:18px 0 10px; border-bottom:2px solid #e0eaf5; padding-bottom:5px}
.modal-global-body .form-group {margin-bottom:14px}
.modal-global-body .form-group label {display:block; font-size:11px; text-transform:uppercase; letter-spacing:.4px; color:#888; padding-left:2px; margin-bottom:4px}
.modal-global-body .form-control {height:auto; min-height:36px; padding:8px 12px; background:#f8f9fa; border:1px solid #e0e6ed; border-left:3px solid #1a6eb5; border-radius:4px; font-weight:600; color:#333}
.modal-global-body .arquivo-item {display:flex; align-items:center; gap:10px; padding:9px 12px; border:1px solid #dee2e6; border-radius:5px; margin-bottom:7px; background:#f8f9fa; text-decoration:none; color:#333; transition:background 0.15s; cursor:pointer}
.modal-global-body .arquivo-item:hover {background:#e8f0fb}
.modal-global-body .arquivo-item .arq-icone {font-size:20px; color:#dc3545; flex-shrink:0}
.modal-global-body .arquivo-item .arq-info {flex:1}
.modal-global-body .arquivo-item .arq-nome {font-size:13px; font-weight:600; color:#1a6eb5; display:block}
.modal-global-body .arquivo-item .arq-data {font-size:11px; color:#888; margin-top:1px; display:block}
.modal-global-footer {padding:14px 24px; border-top:1px solid #e9ecef; display:flex; gap:10px; flex-wrap:wrap; flex-shrink:0; background:#fff; border-radius:0 0 8px 8px}
.modal-global .btn-imprimir, .modal-global .btn-salvar, .modal-global .btn-fechar {border:none; padding:8px 16px; border-radius:4px; cursor:pointer; font-size:13px}
.modal-global .btn-imprimir, .modal-global .btn-salvar {display:flex; align-items:center; gap:6px; color:#fff}
.modal-global .btn-imprimir {background:#6c757d}
.modal-global .btn-imprimir:hover {background:#5a6268}
.modal-global .btn-salvar {background:#17a2b8}
.modal-global .btn-salvar:hover {background:#138496}
.modal-global .btn-fechar {background:#fff; color:#555; border:1px solid #ced4da; margin-left:auto}
.modal-global .btn-fechar:hover {background:#f0f0f0}
@media(max-width:600px) {.modal-global {width:98%}}

/* Conteúdo específico do dialog compartilhado das listagens. */
#appModal .trans-modal-acoes    {display:flex; flex-wrap:wrap; justify-content:center; gap:10px; margin-bottom:12px}
#appModal .objeto-texto         {background:var(--fundo-suave); border-left:3px solid var(--base3); padding:10px 14px; border-radius:0 4px 4px 0; font-size:13px; color:var(--texto); margin-top:4px; line-height:1.5; overflow-wrap:anywhere}
#appModal .secao-titulo         {font-size:13px; font-weight:700; color:var(--link); text-transform:uppercase; margin:18px 0 10px; border-bottom:2px solid var(--linha); padding-bottom:5px}
#appModal .form-group label     {font-size:11px; text-transform:uppercase; letter-spacing:.4px; color:var(--texto-suave); padding-left:2px; margin-bottom:4px}
#appModal .form-control         {height:auto; min-height:36px; padding:8px 12px; background:var(--campo-fundo); border:1px solid var(--campo-linha); border-left:3px solid var(--base3); border-radius:4px; font-weight:600; color:var(--campo-texto); overflow-wrap:anywhere}
#appModal .arquivo-item         {display:flex; align-items:center; gap:10px; padding:9px 12px; border:1px solid var(--linha); border-radius:5px; margin-bottom:7px; background:var(--fundo-suave); text-decoration:none; color:var(--texto); transition:background .15s; cursor:pointer}
#appModal .arquivo-item:hover   {background:var(--fundo-destaque)}
#appModal .arquivo-item .arq-icone {font-size:20px; color:var(--link); flex-shrink:0}
#appModal .arquivo-item .arq-info {flex:1; min-width:0}
#appModal .arquivo-item .arq-nome {font-size:13px; font-weight:600; color:var(--link); display:block; overflow-wrap:anywhere}
#appModal .arquivo-item .arq-data {font-size:11px; color:var(--texto-suave); margin-top:1px; display:block}
#appModal .arq-download         {color:var(--texto-suave); font-size:14px}
#appModal .sem-arquivos         {color:var(--texto-suave); font-size:13px; font-style:italic}
#appModal .app-modal-filtros-arq {display:flex; gap:8px; margin-bottom:12px; flex-wrap:wrap; background:var(--fundo-suave); border:1px solid var(--linha); border-radius:6px; padding:10px 12px}
#appModal .app-modal-filtros-arq input {box-sizing:border-box; padding:7px 10px; border:1px solid var(--campo-linha); border-radius:4px; font-size:13px; height:36px; background:var(--campo-fundo); color:var(--campo-texto); min-width:0; max-width:100%}
#appModal .app-modal-filtros-arq input[type="text"] {flex:2 1 160px}
#appModal .app-modal-filtros-arq input[type="date"] {flex:1 1 130px}
#appModal .app-modal-filtros-arq input:focus-visible {outline:2px solid var(--link); outline-offset:2px}
#appModal .app-modal-tabs       {display:flex; flex-wrap:wrap; gap:4px; margin:18px 0 0; border-bottom:2px solid var(--linha)}
#appModal .app-modal-tab        {background:var(--fundo-suave); border:1px solid var(--linha); border-bottom:none; color:var(--texto); padding:7px 14px; border-radius:4px 4px 0 0; cursor:pointer; font-size:12px; font-weight:600}
#appModal .app-modal-tab.active {background:var(--botao-fundo); color:var(--botao-texto); border-color:var(--botao-fundo)}
#appModal .app-modal-tab:hover:not(.active) {background:var(--fundo-destaque)}
#appModal .app-tabcontent       {display:none; padding:16px 0 8px}
#appModal .app-tabcontent.active {display:block}
#appModal .app-exec-item        {border-left:3px solid var(--base3); padding:10px 14px; margin-bottom:12px; background:var(--fundo-suave); border-radius:0 4px 4px 0}
#appModal .app-img-grid         {display:flex; flex-wrap:wrap; gap:8px}
#appModal .app-img-grid .app-img-item {width:calc(25% - 6px)}
#appModal .app-img-grid img     {width:100%; height:200px; object-fit:cover; border-radius:4px; border:2px solid var(--linha); display:block}
#appModal .app-video-item       {margin-bottom:12px}
#appModal .app-video-item iframe {width:100%; height:380px; border-radius:4px}
#appModal .app-capa             {text-align:center; margin-bottom:12px}
#appModal .app-capa img         {max-width:100%; border-radius:6px; display:inline-block}
@media(max-width:600px)         {#appModal .app-img-grid .app-img-item {width:calc(50% - 4px)}}
