/* ==========================================================================
   SISPACK · Movimentação de Pastas — base visual do painel
   --------------------------------------------------------------------------
   Mesma estrutura do painel EPCVIEW, com a identidade SISPACK: tudo em verde.
   O verde da marca (um tom abaixo do verde da Odebrecht) nos botões e no
   símbolo, verde bem escuro como estrutura (barra lateral) e verde-limão
   como acento (item ativo, destaques).

   Paleta:
     Verde SISPACK   #146C3B   (marca, botões)
     Verde médio     #2E9E5B   (foco, seleção)
     Verde-limão     #8DC63F   (acento)
     Verde escuro    #0F3A22   (barra lateral)
     Verde texto     #0F4F2B   (nome SISPACK no fundo claro)
   ========================================================================== */

:root {
    /* Marca */
    --verde: #146C3B;
    --verde-texto: #0F4F2B;
    --destaque: #2E9E5B;
    --lima: #8DC63F;
    /* Faixa em três verdes: assinatura da marca no topo da lateral, títulos e modais */
    --faixa-marca: linear-gradient(90deg, #0F4F2B 0 33.3%, #146C3B 33.3% 66.6%, #8DC63F 66.6% 100%);
    /* Estrutura escura (barra lateral) */
    --fundo-escuro: #0F3A22;
    --fundo-escuro-2: #154A2D;
    --fundo-escuro-3: #1D5C38;

    /* Primárias */
    --primary: #146C3B;
    --primary-dark: #0E5129;
    --primary-light: #8DC63F;
    --primary-soft: #E8F4EC;
    --primary-glow: rgba(46, 158, 91, .22);

    /* Secundárias */
    --green: #12B76A;
    --green-dark: #027A48;
    --green-soft: #E7F8EF;

    --amber: #F79009;
    --amber-soft: #FFF6E0;

    --red: #D92D20;
    --red-soft: #FEF3F2;

    /* Superfícies */
    --bg: #F2F4F7;
    --surface: #ffffff;
    --surface-soft: #F9FAFB;

    /* Texto */
    --text: #1E2B24;
    --text-muted: #4B5D53;
    --text-light: #86968C;

    /* Bordas */
    --border: rgba(27, 31, 36, .09);
    --border-strong: rgba(27, 31, 36, .18);

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(27, 31, 36, .06), 0 2px 8px rgba(27, 31, 36, .04);
    --shadow-md: 0 8px 28px rgba(27, 31, 36, .09);
    --shadow-lg: 0 20px 60px rgba(27, 31, 36, .14);
    --shadow-xl: 0 30px 80px rgba(27, 31, 36, .2);

    /* Raios — retos, tom corporativo de engenharia */
    --radius-xs: 3px;
    --radius-sm: 5px;
    --radius-md: 7px;
    --radius-lg: 9px;
    --radius-xl: 12px;
    --radius-full: 100px;

    /* Espaçamento (base 4px) */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-7: 28px; --space-8: 32px;
    --space-10: 40px; --space-12: 48px;

    /* Tipografia */
    --font: "Inter", system-ui, -apple-system, sans-serif;
    --font-marca: "Nunito", "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;

    --text-xs: 11px;  --text-sm: 12px;  --text-base: 14px; --text-md: 15px;
    --text-lg: 16px;  --text-xl: 18px;  --text-2xl: 22px;  --text-3xl: 28px;

    /* Layout */
    --sidebar-width: 268px;
    --sidebar-width-collapsed: 76px;

    /* Transições */
    --transition: .3s cubic-bezier(.4, 0, .2, 1);
    --transition-fast: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv02', 'cv03', 'cv04';
}

.tabular { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Scrollbar
   -------------------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: rgba(27, 31, 36, .16) transparent; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(27, 31, 36, .16); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(27, 31, 36, .32); }

.barra-lateral { scrollbar-color: rgba(255, 255, 255, .14) transparent; }
.barra-lateral ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); }

/* --------------------------------------------------------------------------
   Acessibilidade
   -------------------------------------------------------------------------- */
:focus-visible {
    outline: 2px solid var(--destaque);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Qualquer classe com display vence o [hidden] do navegador: esta regra vale para a página inteira. */
[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Componentes
   -------------------------------------------------------------------------- */

.cartao {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.campo {
    width: 100%;
    padding: 10px var(--space-3);
    font-family: inherit;
    font-size: var(--text-base);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.campo::placeholder { color: var(--text-light); }
.campo:focus { outline: none; border-color: var(--destaque); box-shadow: 0 0 0 4px var(--primary-glow); }
.campo:disabled { background: var(--surface-soft); color: var(--text-light); cursor: not-allowed; }
select.campo { padding-right: var(--space-8); cursor: pointer; }
textarea.campo { resize: vertical; min-height: 72px; line-height: 1.45; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 38px;
    padding: 0 var(--space-5);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-icone { width: 30px; height: 30px; padding: 0; }

.btn-primario { background: var(--primary); color: #fff; box-shadow: 0 2px 10px rgba(20, 108, 59, .22); }
.btn-primario:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 6px 18px rgba(20, 108, 59, .28); }

.btn-acao { background: var(--fundo-escuro); color: #fff; }
.btn-acao:hover:not(:disabled) { background: var(--fundo-escuro-3); }

.btn-suave { background: transparent; color: var(--text-muted); }
.btn-suave:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }

.btn-contorno { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-contorno:hover:not(:disabled) { background: var(--surface-soft); border-color: var(--primary); }

.btn-perigo { background: transparent; color: var(--text-light); }
.btn-perigo:hover:not(:disabled) { background: var(--red-soft); color: var(--red); }

.etiqueta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px var(--space-3);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: .02em;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}
.etiqueta-admin { background: var(--primary-soft); color: var(--primary-dark); }
.etiqueta-operador { background: var(--surface-soft); color: var(--text-muted); border: 1px solid var(--border); }
.etiqueta-inativo { background: var(--surface-soft); color: var(--text-light); border: 1px dashed var(--border-strong); }

/* Selo de status: a cor vem do cadastro (style="--cor: #rrggbb") */
.selo-status {
    display: inline-flex; align-items: center; gap: 6px;
    max-width: 100%;
    padding: 3px 10px 3px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-sm); font-weight: 600; white-space: nowrap;
    color: var(--cor, #475467);
    background: color-mix(in srgb, var(--cor, #475467) 11%, #fff);
    border: 1px solid color-mix(in srgb, var(--cor, #475467) 28%, #fff);
}
.selo-status::before { content: ''; width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--cor, #475467); }
.selo-vazio { color: var(--text-light); font-style: italic; font-size: var(--text-sm); white-space: nowrap; }

/* Formulários */
.grupo { margin-bottom: var(--space-4); }
.rotulo { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.rotulo small { font-weight: 400; color: var(--text-light); }
.dica { font-size: var(--text-xs); color: var(--text-light); margin: 5px 0 0; line-height: 1.45; }
.linha-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }

.marcar {
    display: flex; align-items: flex-start; gap: var(--space-2);
    padding: 10px var(--space-3);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); cursor: pointer;
    font-size: var(--text-sm);
}
.marcar input { margin-top: 2px; accent-color: var(--primary); }
.marcar strong { display: block; font-size: var(--text-sm); }
.marcar span.ajuda { display: block; margin-top: 2px; color: var(--text-muted); line-height: 1.4; }
.marcar:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* Tabelas */
.tabela { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tabela th {
    position: sticky; top: 0; z-index: 1;
    text-align: left; padding: 10px var(--space-3);
    font-size: 10.5px; font-weight: 800; letter-spacing: .07em;
    color: var(--text-light); text-transform: uppercase; white-space: nowrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.tabela td { padding: 10px var(--space-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr:hover { background: var(--surface-soft); }
.tabela tbody tr.selecionada { background: var(--primary-soft); }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela .acoes { display: flex; gap: 4px; justify-content: flex-end; }
.tabela .mono { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.tabela a { color: var(--text); text-decoration: none; font-weight: 600; }
.tabela a:hover { color: var(--primary); text-decoration: underline; }
.tabela td.num a { color: var(--primary); }
.tabela .fraco { color: var(--text-light); font-size: var(--text-sm); }
.tabela input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.rolagem-tabela { overflow: auto; max-height: calc(100vh - 270px); }

/* Barra de filtros */
.filtros {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
}
.filtros .grupo { margin: 0; min-width: 150px; flex: 1 1 160px; }
.filtros .grupo.largo { flex: 2 1 240px; }
.filtros .campo { padding: 8px 10px; }
.filtros-rodape {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
    padding: 10px var(--space-4); border-bottom: 1px solid var(--border);
    font-size: var(--text-sm); color: var(--text-muted);
}

/* Abas */
.abas { display: flex; gap: var(--space-5); margin-bottom: var(--space-5); border-bottom: 1px solid var(--border); overflow-x: auto; }
.aba {
    padding: 10px 2px 12px; margin-bottom: -1px;
    border: none; border-bottom: 2px solid transparent;
    background: none; cursor: pointer; font-family: inherit; white-space: nowrap;
    font-size: 13px; font-weight: 700; color: var(--text-light);
    text-decoration: none;
}
.aba:hover { color: var(--text); }
.aba.ativa { color: var(--primary); border-bottom-color: var(--primary); }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.kpi { padding: var(--space-4) var(--space-5); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.kpi span { display: block; font-size: var(--text-sm); color: var(--text-muted); font-weight: 600; }
.kpi strong { display: block; margin-top: 4px; font-size: var(--text-3xl); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--text-light); }

.secao-titulo { margin: 0; padding: var(--space-4) var(--space-5); font-size: var(--text-md); font-weight: 700; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.secao-titulo a { font-size: var(--text-sm); font-weight: 600; color: var(--primary); text-decoration: none; }

.duas-linhas { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --------------------------------------------------------------------------
   Animações
   -------------------------------------------------------------------------- */
@keyframes surgir { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.surgir { animation: surgir .32s cubic-bezier(.4, 0, .2, 1) both; }

/* --------------------------------------------------------------------------
   Marca SISPACK
   Símbolo em SVG (o mesmo do favicon) + nome em HTML, para usar a fonte da
   página. Montada em UHNUI.logo() (assets/ui.js). Tamanho por font-size.
   -------------------------------------------------------------------------- */
.logo-marca { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1; color: #fff; text-decoration: none; }
.logo-marca-linha { display: inline-flex; align-items: center; gap: .3em; }
.logo-marca-simbolo { width: 1.25em; height: 1.25em; flex-shrink: 0; }
.logo-marca-nome { font-family: var(--font-marca); font-weight: 800; font-size: 1em; letter-spacing: .04em; white-space: nowrap; }
.logo-marca-nome b { font-weight: 800; color: var(--lima); }
.logo-marca-sub {
    margin-top: .55em;
    font-family: var(--font); font-weight: 700;
    font-size: .34em; letter-spacing: .16em; text-transform: uppercase;
    white-space: nowrap; color: rgba(255, 255, 255, .7);
}
.logo-marca-claro { color: var(--verde-texto); }
.logo-marca-claro .logo-marca-nome b { color: var(--verde); }
.logo-marca-claro .logo-marca-sub { color: var(--text-muted); }

/* ==========================================================================
   Shell — barra lateral, topo e conteúdo
   ========================================================================== */

.app { display: flex; height: 100vh; overflow: hidden; }

.barra-lateral {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(380px 220px at 0% 100%, rgba(141, 198, 63, .16), transparent 70%),
        linear-gradient(180deg, var(--fundo-escuro) 0%, #0A2A18 100%);
    border-right: 1px solid rgba(255, 255, 255, .05);
    color: #f8f9fb;
    transition: width var(--transition);
    position: relative;
}
/* Faixa vermelha no topo: assinatura da marca */
.barra-lateral::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--faixa-marca); }

.bl-topo { display: flex; align-items: center; padding-right: var(--space-3); }
.bl-marca {
    flex: 1; min-width: 0;
    display: flex; align-items: center;
    padding: var(--space-6) var(--space-5) var(--space-5);
    text-decoration: none; color: inherit;
}
.bl-marca-logo { display: block; font-size: 22px; }
.bl-marca-icone { display: none; width: 34px; height: 34px; flex-shrink: 0; }

.bl-nav { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-2) var(--space-4); display: flex; flex-direction: column; gap: 2px; }

.bl-item {
    position: relative;
    display: flex; align-items: center; gap: var(--space-3);
    padding: 10px var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-md); font-weight: 500;
    color: rgb(255, 255, 3);
    text-decoration: none; white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.bl-item:hover { background: rgba(255, 255, 255, .06); color: #fff; transform: translateX(3px); }
.bl-item.ativo {
    background: linear-gradient(90deg, rgba(141, 198, 63, .26), rgba(141, 198, 63, .05));
    color: #fff; font-weight: 600;
    box-shadow: inset 3px 0 0 var(--lima);
}
.bl-item svg { flex-shrink: 0; }
.bl-item.ativo svg { color: var(--lima); }

.bl-secao {
    margin: var(--space-4) 0 var(--space-1);
    padding: 0 var(--space-4);
    font-size: 10px; font-weight: 700; letter-spacing: .18em;
    text-transform: uppercase; color: rgba(255, 255, 255, .36);
}
.bl-secao:first-child { margin-top: 0; }
body.lateral-recolhida .bl-secao { visibility: hidden; height: 1px; margin: var(--space-2) 0; overflow: hidden; }

/* Rótulo flutuante da lateral recolhida (ui.js posiciona) */
.bl-flutuante {
    position: fixed; z-index: 500;
    padding: var(--space-1) var(--space-3);
    background: var(--fundo-escuro-2);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    color: #fff; font-size: var(--text-sm); font-weight: 700; white-space: nowrap;
    opacity: 0; transform: translateX(-4px); pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.bl-flutuante.visivel { opacity: 1; transform: none; }

.bl-recolher {
    display: flex; align-items: center; justify-content: center; gap: var(--space-2);
    margin: 0 var(--space-4) var(--space-3);
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .06);
    color: #fff; font-family: inherit; font-size: var(--text-sm); font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.bl-recolher:hover { background: rgba(255, 255, 255, .13); }
.bl-recolher svg { transition: transform var(--transition); }

.bl-usuario {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.bl-avatar {
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--verde); color: #fff;
    display: grid; place-items: center;
    font-size: var(--text-sm); font-weight: 700;
}
.bl-usuario-info { min-width: 0; flex: 1; }
.bl-usuario-nome { margin: 0; font-size: var(--text-base); font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-usuario-papel { margin: 2px 0 0; font-size: var(--text-xs); color: rgba(255, 255, 255, .5); }
.bl-sair {
    background: none; border: none; cursor: pointer;
    color: rgba(255, 255, 255, .6);
    padding: var(--space-2); border-radius: var(--radius-xs);
    display: grid; place-items: center;
}
.bl-sair:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* Recolhida ---------------------------------------------------------------- */
body.lateral-recolhida .barra-lateral { width: var(--sidebar-width-collapsed); }
body.lateral-recolhida .bl-item span,
body.lateral-recolhida .bl-usuario-info,
body.lateral-recolhida .bl-recolher span { display: none; }
body.lateral-recolhida .bl-topo { padding-right: 0; }
body.lateral-recolhida .bl-marca { justify-content: center; padding: var(--space-6) var(--space-2) var(--space-5); }
body.lateral-recolhida .bl-marca-logo { display: none; }
body.lateral-recolhida .bl-marca-icone { display: block; }
body.lateral-recolhida .bl-item { justify-content: center; padding: var(--space-3); }
body.lateral-recolhida .bl-item:hover { transform: none; }
body.lateral-recolhida .bl-usuario { justify-content: center; padding: var(--space-4) var(--space-2); }
body.lateral-recolhida .bl-sair { display: none; }
body.lateral-recolhida .bl-nav { padding: var(--space-2); }
body.lateral-recolhida .bl-recolher { margin: 0 var(--space-2) var(--space-3); }
body.lateral-recolhida .bl-recolher svg { transform: rotate(180deg); }

/* Conteúdo ----------------------------------------------------------------- */

.conteudo { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topo {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap;
    padding: var(--space-5) var(--space-7);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.topo h1 { margin: 0; font-size: var(--text-2xl); font-weight: 600; letter-spacing: -.02em; }
.topo h1::before {
    content: ''; display: block;
    width: 28px; height: 3px; margin-bottom: var(--space-2);
    background: var(--faixa-marca);
}
.topo p { margin: 3px 0 0; font-size: var(--text-base); color: var(--text-muted); }
.topo-acoes { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.corpo { flex: 1; overflow: auto; padding: var(--space-7); }

/* Avisos ------------------------------------------------------------------- */

.pilha-avisos {
    position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 600;
    display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2);
    pointer-events: none;
}
.aviso {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--fundo-escuro);
    box-shadow: var(--shadow-md);
    font-size: var(--text-base); font-weight: 500; color: var(--text);
    max-width: 26rem;
    pointer-events: auto;
    opacity: 0; transform: translateX(16px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.aviso.visivel { opacity: 1; transform: none; }
.aviso-sucesso { border-left-color: var(--green); color: var(--green-dark); }
.aviso-erro    { border-left-color: var(--red); color: var(--red); }
.aviso-alerta  { border-left-color: var(--amber); color: #8a5200; }

/* Modal -------------------------------------------------------------------- */

.modal-fundo {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(27, 31, 36, .6);
    backdrop-filter: blur(3px);
    display: grid; place-items: center;
    padding: var(--space-5);
}
.modal {
    width: 100%; max-width: 28rem;
    max-height: calc(100dvh - 2 * var(--space-5)); overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    background-image: var(--faixa-marca);
    background-size: 100% 4px;
    background-repeat: no-repeat;
    box-shadow: var(--shadow-xl);
    padding: var(--space-7);
}
.modal-largo { max-width: 52rem; }
.modal-titulo { margin: 0 0 var(--space-2); font-size: var(--text-xl); font-weight: 700; }
.modal-texto { margin: 0 0 var(--space-6); font-size: var(--text-base); color: var(--text-muted); line-height: 1.6; white-space: pre-line; }
.modal-acoes { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); }
.btn-confirmar-perigo { background: var(--red); color: #fff; }
.btn-confirmar-perigo:hover:not(:disabled) { background: #a81f1f; }

/* Estado vazio ------------------------------------------------------------- */

.vazio {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-muted);
}
.vazio-icone {
    width: 60px; height: 60px;
    border-radius: var(--radius-lg);
    background: var(--primary-soft);
    color: var(--primary);
    display: grid; place-items: center;
    margin-bottom: var(--space-4);
}
.vazio h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); font-weight: 700; color: var(--text); }
.vazio p { margin: 0; font-size: var(--text-base); max-width: 28rem; line-height: 1.6; }
.vazio .btn { margin-top: var(--space-5); }

/* Responsivo --------------------------------------------------------------- */

.barra-movel { display: none; }
.bl-fundo { display: none; }
.bl-menu-btn {
    display: none; place-items: center; flex-shrink: 0;
    width: 40px; height: 40px;
    border: none; border-radius: var(--radius-sm);
    background: none; color: inherit; cursor: pointer;
}
.bl-menu-btn:hover { background: rgba(255, 255, 255, .1); }
.bl-fechar { display: none; }

/* Tablet estreito: barra lateral só com ícones */
@media (min-width: 769px) and (max-width: 900px) {
    .barra-lateral { width: var(--sidebar-width-collapsed); }
    .bl-item span, .bl-usuario-info, .bl-recolher span { display: none; }
    .bl-topo { padding-right: 0; }
    .bl-marca { justify-content: center; padding: var(--space-6) var(--space-2) var(--space-5); }
    .bl-marca-logo { display: none; }
    .bl-marca-icone { display: block; }
    .bl-item { justify-content: center; padding: var(--space-3); }
    .bl-usuario { justify-content: center; padding: var(--space-4) var(--space-2); }
    .bl-sair { display: none; }
    .bl-secao { visibility: hidden; height: 1px; margin: var(--space-2) 0; overflow: hidden; }
}

@media (max-width: 900px) {
    .corpo { padding: var(--space-4); }
    .topo { padding: var(--space-4); }
    .topo h1 { font-size: var(--text-xl); }
    .linha-campos { grid-template-columns: minmax(0, 1fr); }
    .rolagem-tabela { max-height: none; }
}

/* Celular e tablet em pé: a barra lateral vira gaveta */
@media (max-width: 768px) {
    .app { height: 100dvh; }

    .barra-lateral {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 300;
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(-100%);
        transition: transform var(--transition);
    }
    body.menu-aberto .barra-lateral { transform: none; box-shadow: var(--shadow-xl); }
    .bl-fundo {
        display: block; position: fixed; inset: 0; z-index: 290;
        background: rgba(27, 31, 36, .55);
        opacity: 0; pointer-events: none;
        transition: opacity var(--transition);
    }
    body.menu-aberto .bl-fundo { opacity: 1; pointer-events: auto; }
    body.menu-aberto { overflow: hidden; }

    .bl-fechar {
        display: grid; place-items: center;
        margin-left: auto; width: 36px; height: 36px;
        border: none; border-radius: var(--radius-sm);
        background: none; color: rgba(255, 255, 255, .7); cursor: pointer;
    }
    .bl-marca { padding: var(--space-5) var(--space-4) var(--space-4) var(--space-5); }
    .bl-recolher { display: none; }
    .bl-item:hover { transform: none; }

    .barra-movel {
        display: flex; align-items: center; gap: var(--space-2);
        height: 52px; padding: 0 var(--space-2);
        flex-shrink: 0;
        background: var(--faixa-marca) top / 100% 3px no-repeat, var(--fundo-escuro);
        color: #fff;
    }
    .barra-movel .logo-marca { font-size: 18px; }
    .bl-menu-btn { display: grid; }

    .topo { gap: var(--space-3); }
    .topo > div { min-width: 0; }

    .cartao:has(table) { overflow-x: auto; }
    .tabela th, .tabela td { white-space: nowrap; }

    .pilha-avisos { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); align-items: stretch; }
    .aviso { max-width: none; }
    .campo { font-size: 16px; }   /* evita o zoom do iPhone ao focar */
}

/* Botão "Filtros" (criado pelo ui.js): só aparece no celular */
.filtros-alternar { display: none; }

@media (max-width: 900px) {
    /* Filtros recolhidos: o botão abre e fecha */
    .filtros-alternar { display: inline-flex; margin: var(--space-3) var(--space-4) 0; }
    .filtros:not(.filtros-abertos) { display: none; }
    .filtros .grupo, .filtros .grupo.largo { flex: 1 1 calc(50% - var(--space-3)); min-width: 0; }

    /* Tabelas: colunas sempre lado a lado; o que não cabe, arrasta para o lado */
    .cartao:has(table), .rolagem-tabela { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
    .tabela th, .tabela td { white-space: nowrap; }
    /* Textos longos (descrição, observações) quebram dentro de uma coluna de largura fixa */
    .tabela td.pa-desc, .tabela td.hi-obs { white-space: normal; min-width: 220px; max-width: 320px; }
    .tabela .chips { flex-wrap: wrap; min-width: 240px; max-width: 420px; }
    .tabela td:has(> .chips) { white-space: normal; }
    /* Linha de "nenhum resultado" não rola: ocupa a largura visível */
    .tabela td[colspan] { white-space: normal; }
}

@media (max-width: 480px) {
    .corpo { padding: var(--space-3); }
    .topo { padding: var(--space-3) var(--space-4); }
    .modal { padding: var(--space-5); }
    .modal-acoes { flex-wrap: wrap; }
    .modal-acoes .btn { flex: 1 1 auto; }
}
