/* =========================================================================
   PBS Web — Design system inspirado na Apple (Human Interface Guidelines)
   Tipografia do sistema (SF Pro), muito respiro, cantos suaves, azul Apple,
   sombras discretas, foco com halo e dark mode automático.
   ========================================================================= */

:root {
    color-scheme: light dark;

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
            "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Light — tokens iguais ao Soft-Fácil */
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-2: color-mix(in srgb, #1d1d1f 4%, #ffffff);
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #8e8e93;
    --border: rgba(0, 0, 0, 0.10);
    --border-strong: rgba(0, 0, 0, 0.16);
    --field-bg: #ffffff;
    --accent: #007aff;
    --accent-hover: #0a6fe0;
    --accent-ring: rgba(0, 122, 255, .12);
    --danger: #ff3b30;
    --danger-bg: rgba(255, 59, 48, .12);
    --ok: #34c759;

    /* Shell SAP Fiori (Belize): barra superior, rail e painel do menu.
       Constante nos dois temas — o "chrome" é sempre navy como no SAP. */
    --sap-shell: #354a5f;
    --sap-shell-hover: #42596e;
    --sap-shell-active: #427cac;
    --sap-shell-border: rgba(255, 255, 255, .12);
    --sap-on-shell: #ffffff;
    --sap-on-shell-dim: #bcc6d0;
    --sap-shell-field: rgba(255, 255, 255, .10);

    --shadow: 0 4px 16px rgba(0, 0, 0, .08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .16);
    --radius-lg: 18px;
    --radius: 12px;
    --radius-sm: 7px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1c1e;
        --surface: #2c2c2e;
        --surface-2: color-mix(in srgb, #f5f5f7 5%, #2c2c2e);
        --text: #f5f5f7;
        --text-secondary: #aeaeb2;
        --text-tertiary: #8e8e93;
        --border: rgba(255, 255, 255, 0.12);
        --border-strong: rgba(255, 255, 255, 0.20);
        --field-bg: #2c2c2e;
        --accent: #0a84ff;
        --accent-hover: #409cff;
        --accent-ring: rgba(10, 132, 255, .20);
        --danger: #ff453a;
        --danger-bg: rgba(255, 69, 58, .24);
        --ok: #30d158;
        --shadow: 0 4px 16px rgba(0, 0, 0, .5);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
    }
}

* { box-sizing: border-box; }

/* O Blazor foca o <h1> ao navegar (FocusOnNavigate, acessibilidade); esconder
   o contorno de foco nos títulos para não aparecer uma borda ao carregar. */
h1:focus, h1:focus-visible, [tabindex="-1"]:focus, [tabindex="-1"]:focus-visible {
    outline: none;
}

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    font-size: 15px;
    line-height: 1.45;
}

/* ------------------------------------------------------------------ Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 44px 40px 40px;
    animation: cardIn .5s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.login-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
    box-shadow: 0 6px 18px var(--accent-ring);
}
.login-logo svg { width: 28px; height: 28px; color: #fff; }

.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand h1 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.15;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    color: var(--text);
}
.login-brand p { margin: 0; color: var(--text-secondary); font-size: 15px; }

.campo { display: block; margin-bottom: 16px; }
.campo > span {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin: 0 0 6px 2px;
    color: var(--text-secondary);
}

.input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .15s ease, box-shadow .15s ease;
    appearance: none;
    -webkit-appearance: none;
}
.input::placeholder { color: var(--text-secondary); opacity: .7; }
.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}

select.input {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path fill='%236e6e73' d='M4.5 6l3.5 3.5L11.5 6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.btn-entrar {
    width: 100%;
    height: 46px;
    margin-top: 8px;
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s ease, transform .06s ease, opacity .15s ease;
}
.btn-entrar:hover:not(:disabled) { background: var(--accent-hover); }
.btn-entrar:active:not(:disabled) { transform: scale(.985); }
.btn-entrar:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn-entrar:disabled { opacity: .45; cursor: not-allowed; }
/* Variante em link (ex.: "Voltar ao login" da tela de verificação expirada) */
a.btn-entrar { display: block; box-sizing: border-box; text-decoration: none;
    text-align: center; line-height: 46px; }

/* --------------------------------------- Verificação em duas etapas (TOTP) */
.mfa-passos { margin: 0 0 18px; padding-left: 22px; color: var(--text-secondary);
    font-size: 13.5px; line-height: 1.6; }
.mfa-passos b { color: var(--text); font-weight: 600; }
.mfa-qr { display: grid; place-items: center; margin-bottom: 16px; }
.mfa-qr img { display: block; padding: 10px; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); image-rendering: pixelated; }
.mfa-dica { margin: 0 0 18px; color: var(--text-secondary); font-size: 13.5px; text-align: center; }
.mfa-manual { margin-bottom: 18px; font-size: 13px; color: var(--text-secondary); }
.mfa-manual summary { cursor: pointer; user-select: none; }
.mfa-manual p { margin: 8px 0 0; }
.mfa-chave { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: 1px;
    color: var(--text); background: var(--surface-2); padding: 9px 11px; border-radius: 8px;
    word-break: break-all; user-select: all; }
/* Campo do código: dígitos grandes e espaçados, para conferir ao digitar */
.input--codigo { text-align: center; font-family: ui-monospace, Consolas, monospace;
    font-size: 24px; letter-spacing: 8px; text-indent: 8px; }
.mfa-rodape { margin: 16px 0 0; text-align: center; font-size: 13px; }
.mfa-rodape a { color: var(--text-secondary); }

.alert {
    padding: 11px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 18px;
    line-height: 1.35;
}
.alert-erro { background: var(--danger-bg); color: var(--danger); }

/* framework validation */
.valid.modified:not([type=checkbox]) { outline: none; }
.invalid { border-color: var(--danger) !important; }
.validation-message { color: var(--danger); font-size: 13px; }

/* ------------------------------------------------------------------ Shell */
/* Altura travada na viewport: o scroll acontece dentro das áreas internas
   (grade, conteúdo), nunca fazendo o shell crescer e empurrar o rodapé/pager. */
.app-shell { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 22px;
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
}
.topbar-brand { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--text-secondary); }
.user-info { color: var(--text); }
.user-base { color: var(--text-secondary); }

.logout-form { margin: 0; }
.btn-sair {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    background: transparent;
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease;
}
.btn-sair:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.layout-body { display: flex; flex: 1; min-height: 0; align-items: stretch; }

.content { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }

/* Páginas normais (Home, Abrir): centralizadas, com rolagem própria. */
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 36px 32px; max-width: 1040px; width: 100%; margin: 0 auto; }
/* Página cheia (Formulário): ocupa toda a largura e altura; nunca rola a página inteira. */
.view-full { max-width: none; margin: 0; padding: 18px 24px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.fpage { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }

/* --------------------------------------------------------- Menu (rail+painel) */
.menu-nav {
    display: flex;
    flex: none;
    position: relative;   /* âncora do painel flutuante */
}

.menu-rail {
    width: 72px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 8px;
    background: var(--sap-shell);
    border-right: 1px solid var(--sap-shell-border);
    position: relative;
    z-index: 60;          /* acima do backdrop, sempre clicável */
}

/* Backdrop transparente: clique fora fecha o menu flutuante. */
.menu-backdrop { position: fixed; top: 52px; left: 0; right: 0; bottom: 0; z-index: 40; }
.menu-rail-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 9px 4px;
    border: none;
    background: transparent;
    border-radius: 12px;
    color: var(--sap-on-shell-dim);
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.menu-rail-btn:hover { background: var(--sap-shell-hover); color: var(--sap-on-shell); }
.menu-rail-btn.ativo { background: var(--sap-shell-active); color: var(--sap-on-shell); }
.menu-rail-btn img { display: block; }

.menu-panel {
    width: 264px;
    flex: none;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface-2);
    overflow: hidden;
}
/* Painel flutuante: sobrepõe o conteúdo à direita do rail; conteúdo usa a
   largura toda quando o menu está fechado. */
.menu-panel.flutuante {
    position: absolute;
    left: 100%;
    top: 0;
    bottom: 0;
    width: 450px;
    z-index: 50;
    background: color-mix(in srgb, var(--text) 4%, var(--surface));
    box-shadow: 6px 0 28px rgba(0, 0, 0, .16);
    animation: menuIn .16s ease;
}
@keyframes menuIn { from { opacity: 0; transform: translateX(-8px); } }
.menu-panel-head {
    flex: none;
    padding: 14px 16px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-secondary);
}

.sidebar-search {
    position: relative;
    padding: 14px 14px 10px;
    flex: none;
}
.search-icon {
    position: absolute;
    left: 24px; top: 50%; transform: translateY(-30%);
    color: var(--text-secondary);
    pointer-events: none;
}
.search-input {
    width: 100%;
    height: 36px;
    padding: 0 30px 0 34px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    appearance: none; -webkit-appearance: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search-clear {
    position: absolute; right: 22px; top: 50%; transform: translateY(-30%);
    border: none; background: transparent; color: var(--text-secondary);
    font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px;
}

.sidebar-tree { flex: 1; overflow-y: auto; padding: 4px 8px 20px; }
.sidebar-msg { color: var(--text-secondary); font-size: 13px; padding: 12px 10px; }
.sidebar-msg.erro { color: var(--danger); }
.mi-results-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); padding: 8px 10px 4px; }

.mi-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s ease;
}
.mi-row:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.mi-item.active, .mi-row:active { background: color-mix(in srgb, var(--accent) 16%, transparent); }

.mi-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-count {
    font-size: 11px; color: var(--text-secondary);
    background: color-mix(in srgb, var(--text-secondary) 16%, transparent);
    border-radius: 10px; padding: 1px 7px; flex: none;
}

.mi-caret { display: inline-flex; color: var(--text-secondary); transition: transform .15s ease; flex: none; }
.mi-caret.open { transform: rotate(90deg); }

.mi-badge { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.mi-badge.grande { width: 30px; height: 30px; border-radius: 8px; }
.mi-badge.tipo-1 { background: #0071e3; } /* formulário */
.mi-badge.tipo-2 { background: #34c759; } /* consulta   */
.mi-badge.tipo-3 { background: #ff9500; } /* relatório  */
.mi-badge.tipo-5 { background: #af52de; } /* cubo       */
.mi-badge.tipo-9, .mi-badge.tipo-0 { background: var(--border); }

/* --------------------------------------------------------------- Abrir */
.abrir { max-width: 720px; }
.abrir-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.abrir-head h1 { margin: 0; }
.abrir-sub { margin: 2px 0 0; color: var(--text-secondary); font-size: 14px; }
.abrir-info p { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }

/* ===== Formulário (grade + form, padrão alinhado ao softfacil) ===== */
/* Botões */
.sf-btn { appearance: none; border: 1px solid transparent; font-family: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .15s, transform .05s, opacity .15s; }
.sf-btn:active { transform: scale(.97); }
.sf-btn:disabled { opacity: .5; cursor: not-allowed; }
.sf-btn--primary { background: var(--accent); color: #fff; }
.sf-btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.sf-btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.sf-btn--secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--text-secondary) 8%, transparent); }
.sf-btn--danger-solid { background: var(--danger); color: #fff; }

.sf-input { width: 100%; font-family: inherit; font-size: 14.5px; color: var(--text); background: var(--field-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; transition: border-color .15s, box-shadow .15s; }
.sf-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.sf-input[readonly] { background: var(--surface-2); }
.sf-input.num-r { text-align: right; }
.sf-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }

/* Cabeçalho de página */
.page__head { flex: none; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page__head h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; }
/* Cabeçalho do registro compacto: título menor, modo entre parênteses, botões
   na mesma linha — sobra mais espaço vertical para os campos. */
.page__head--reg { align-items: center; margin-bottom: 10px; }
.reg-titulo { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.reg-modo { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.page__sub { color: var(--text-secondary); font-size: 13px; margin: 2px 0 0; }
.page__actions { display: flex; gap: 10px; }

/* Card que hospeda a grade principal: a grade preenche e rola internamente. */
.list-card { flex: 1; min-height: 0; min-width: 0; display: flex; overflow: hidden; }
/* Área da grade de detalhe dentro do card (a grade rola internamente). */
.reg-detgrid { flex: 1; min-height: 0; min-width: 0; display: flex; }

/* Grade que preenche a altura e rola internamente */
.list { flex: 1; min-height: 0; min-width: 0; overflow: auto; padding: 0; }
/* min-width:max-content = respeita a LARGURA (px) das colunas e gera scroll
   horizontal quando não cabem; quando sobra espaço, os fr preenchem. */
.row.grow { display: grid; grid-template-columns: var(--cols); align-items: center; padding: 0 14px; min-height: 42px; border-bottom: 1px solid var(--border); min-width: max-content; }
.row.grow:last-child { border-bottom: none; }
.row--data:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.row--head { position: sticky; top: 0; z-index: 2; min-height: 38px; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: color-mix(in srgb, var(--text) 4%, var(--surface)); }
.row--filtros { position: sticky; top: 38px; z-index: 1; min-height: 40px; background: var(--surface); }
.cell { padding: 4px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell--sort { cursor: pointer; user-select: none; }
.cell--sort:hover { color: var(--text); }
.cell--sort i { font-style: normal; font-size: 9px; color: var(--accent); margin-left: 3px; }
.cell--acoes { display: flex; justify-content: flex-end; gap: 2px; opacity: 0; transition: opacity .12s; }
.row--data:hover .cell--acoes { opacity: 1; }
.fin { width: 100%; min-width: 0; font-family: inherit; font-size: 12.5px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--field-bg); color: var(--text); }
.fin:focus { outline: none; border-color: var(--accent); }

.iconbtn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; border: none; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 14px; transition: background .12s, color .12s; }
.iconbtn:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.iconbtn--danger:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

/* Pager (25/50/100 + navegação) */
.pager { flex: none; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 12px 4px 2px; font-size: 13px; color: var(--text-secondary); }
.pager__info { font-variant-numeric: tabular-nums; }
.pager__controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pager__size { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pager__size-btn { appearance: none; border: none; background: var(--surface); color: var(--text-secondary); font-family: inherit; font-size: 12.5px; padding: 5px 10px; cursor: pointer; border-left: 1px solid var(--border); }
.pager__size-btn:first-child { border-left: none; }
.pager__size-btn:hover { background: color-mix(in srgb, var(--text-secondary) 8%, transparent); }
.pager__size-btn.on { background: var(--accent); color: #fff; }
.pager__nav { appearance: none; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; cursor: pointer; }
.pager__nav:hover:not(:disabled) { background: color-mix(in srgb, var(--text-secondary) 8%, transparent); }
.pager__nav:disabled { opacity: .4; cursor: not-allowed; }
.pager__pos { font-variant-numeric: tabular-nums; min-width: 108px; text-align: center; }

/* ===== Grade (tabela fixa, header/filtros sticky, colunas congeladas) ===== */
.gx-wrap { flex: 1; min-height: 0; min-width: 0; overflow: auto; }
.gx { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; font-size: 13px; }
.gx th, .gx td {
    padding: 6px 10px; text-align: left; box-sizing: border-box;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
}
.gx thead th {
    position: sticky; top: 0; z-index: 3; font-weight: 600; color: var(--text-secondary);
    background: color-mix(in srgb, var(--text) 4%, var(--surface));
}
/* Altura fixa do cabeçalho = top da linha de filtros (sem vão que deixe os
   dados aparecerem por trás ao rolar). */
.gx thead .gx-head th { height: 34px; }
.gx thead .gx-filtros th { top: 34px; z-index: 3; padding: 4px 6px; background: var(--surface); }
.gx-sort { cursor: pointer; user-select: none; }
.gx-sort:hover { color: var(--text); }
.gx-sort i { font-style: normal; font-size: 9px; color: var(--accent); margin-left: 3px; }
.gx tbody td { background: var(--surface); }
.gx-row:hover td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.cons-params { padding: 14px 16px; margin-bottom: 12px; flex: none; }
/* Cubo (AG Grid Enterprise / SSRM) */
/* --------------------------------------------------- Sem permissão de acesso */
.sem-perm { max-width: 520px; margin: 48px auto; padding: 30px 28px; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow); }
.sem-perm-icone { color: var(--text-secondary); margin-bottom: 12px; }
.sem-perm h1 { margin: 0 0 10px; font-size: 20px; font-weight: 600; }
.sem-perm p { margin: 0 0 22px; color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.sem-perm-acoes { display: flex; gap: 10px; justify-content: center; }

/* Cubo: grade do PivotGrid (a escolha de campos é o popup do Seletor de Colunas) */
.cubo-grid { flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.cubo-aviso { padding: 0 2px 6px; color: var(--warn, #b45309); }
/* Janelinha de escolha de colunas (checkbox por coluna) */
.cols-pop { min-width: 240px; max-height: 60vh; overflow-y: auto; padding: 6px; }
.cols-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.cols-item:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cols-item input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.gx-acoes { white-space: nowrap; }
.gx thead .gx-head th { position: relative; }
.gx-resizer { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; user-select: none; }
.gx-resizer:hover { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.gx tfoot td { position: sticky; bottom: 0; z-index: 3; font-weight: 600;
    background: color-mix(in srgb, var(--text) 6%, var(--surface)); border-top: 1px solid var(--border-strong); }
/* Coluna espaçadora: absorve a folga à direita mantendo as demais em largura
   fixa (a de ações não estica). Sem borda; colapsa a 0 quando há scroll. */
.gx-spacer { padding: 0 !important; border-right: none !important; background: var(--surface); }
.gx thead .gx-spacer { background: color-mix(in srgb, var(--text) 4%, var(--surface)); }
.gx-empty { text-align: center; color: var(--text-secondary); padding: 18px; background: var(--surface); }
/* Alinhamento por tipo de dado: N (numérico) à direita; A/D à esquerda. */
.gx .gx-num { text-align: right; }
.gx .gx-num .cellin { text-align: right; }

/* Sem setinhas (spinner) em inputs numéricos. */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Colunas congeladas (scroll horizontal nas demais).
   Empilhamento: corpo fixo (2) < header/dados roláveis (3) < header fixo (6),
   assim as células fixas do cabeçalho/filtro cobrem as roláveis ao rolar. */
.gx tbody td.gx-fix { position: sticky; z-index: 2; background: var(--surface); }
.gx-row:hover td.gx-fix { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.gx thead th.gx-fix { position: sticky; z-index: 6; }
.gx .gx-fix.gx-last { border-right: 2px solid var(--border-strong); }
.gx .fin { width: 100%; min-width: 0; font-family: inherit; font-size: 12.5px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--field-bg); color: var(--text); }
.gx .fin:focus { outline: none; border-color: var(--accent); }

/* Edição inline nas células da grade */
.gx .cellin { width: 100%; min-width: 0; font-family: inherit; font-size: 12.5px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg); color: var(--text); }
.gx .cellin:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.gx td.gx-edit { padding: 3px 6px; overflow: visible; }
.gx td.gx-edit input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Estados */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 50px 20px; color: var(--text-secondary); font-size: 14px; }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: sf-spin .7s linear infinite; }
@keyframes sf-spin { to { transform: rotate(360deg); } }

/* Layout fluido do master — respeita LARGURA de CAMPOS */
.form-master { margin: 0 0 16px; padding: 18px 20px; }
.form-flow { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.ff { display: flex; flex-direction: column; gap: 5px; }
.ff > label { font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
/* Boolean: checkbox centralizado sob o título */
.ff--check { align-items: center; text-align: center; }
.ff--check input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

/* Campo lookup: código + descrição + botão ... */
.lookup-row { display: flex; gap: 6px; align-items: stretch; }
.lookup-row .lk-cod { flex: 0 0 96px; }
.lookup-row .lk-desc { flex: 1; min-width: 0; }
.lookup-row .lk-btn { flex: none; padding: 0 12px; }

/* Overlay + modal + lista (picker) */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.32); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; }
.overlay--top { z-index: 120; }   /* popup de aviso acima de outros modais */
.modal { width: 100%; max-width: 440px; min-width: 0; padding: 22px 24px; }
.modal--sm { max-width: 380px; }
.modal--lista { max-width: 480px; }
.modal--form { max-width: 760px; }
.modal__form { max-height: 60vh; overflow-y: auto; padding: 2px; }
/* Consulta auxiliar: cresce até o conteúdo, porém SEMPRE dentro da viewport
   (menos a margem do overlay) para o cabeçalho/fechar não saírem da tela. */
.modal--wide {
    width: fit-content; min-width: min(380px, calc(100vw - 40px));
    max-width: calc(100vw - 40px); max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
}
/* No modo compacto o grid tem a largura do conteúdo; não deixa esticar. */
.modal--wide .aux-grid { justify-content: flex-start; }
.modal--wide .aux-grid .gx-wrap { flex: 0 1 auto; max-width: 100%; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex: none; }
.modal__head .modal__title { margin: 0; }
.aux-grid { flex: 1; min-height: 0; min-width: 0; display: flex; }

/* Menu flutuante de Consultas Auxiliares (ancorado ao botão) */
.aux-wrap { position: relative; display: inline-flex; }
.aux-backdrop { position: fixed; inset: 0; z-index: 90; }
.aux-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 91;
    min-width: 280px; max-width: 460px; max-height: 60vh; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
}
.aux-item {
    display: block; width: 100%; text-align: left; border: none; background: transparent;
    font-family: inherit; font-size: 14px; color: var(--text);
    padding: 9px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; transition: background .12s;
}
.aux-item:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.modal__title { font-size: 18px; margin: 0 0 14px; }
.modal__text { color: var(--text); font-size: 14px; margin: 0 0 8px; }
.modal__hint { color: var(--text-secondary); font-size: 12px; margin: 0; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.searchbox__input { width: 100%; font-family: inherit; font-size: 14px; color: var(--text); background: var(--field-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; }
.searchbox__input:focus { outline: none; border-color: var(--accent); }
.lista { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.lrow { appearance: none; border: 1px solid var(--border); background: var(--surface); font: inherit; display: flex; align-items: center; gap: 12px; padding: 10px 13px; border-radius: 9px; cursor: pointer; color: var(--text); text-align: left; }
.lrow:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); border-color: var(--accent); }
.lrow span:first-child { font-weight: 600; min-width: 70px; }
.empty-lista { color: var(--text-secondary); font-size: 13.5px; padding: 8px 0; }

/* Registro: splitter master (rolável) / detail */
.reg-split { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
/* Altura automática: encolhe quando há poucos campos, dando espaço à detail;
   se exceder, limita e rola. O splitter (JS) pode sobrescrever a altura. */
.reg-master { flex: none; height: auto; max-height: 52vh; overflow-y: auto; padding: 16px 18px; }
.reg-master--full { max-height: none; flex: 1; }
.reg-divider { flex: none; height: 12px; display: flex; align-items: center; justify-content: center; cursor: row-resize; }
.reg-divider .grip { width: 46px; height: 4px; border-radius: 2px; background: var(--border-strong); transition: background .12s; }
.reg-divider:hover .grip { background: var(--accent); }
.reg-detail { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; padding: 0; }

/* Abas de detalhe: botões roláveis horizontalmente (nunca rola a página) */
.tabs-head { flex: none; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; min-width: 0; padding: 10px 12px; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.tab { flex: none; border: 1px solid var(--border); background: var(--surface-2); padding: 7px 14px; border-radius: 9px; font-family: inherit; font-size: 13px; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .12s, color .12s, border-color .12s; }
.tab:hover { color: var(--text); background: color-mix(in srgb, var(--text-secondary) 8%, transparent); }
.tab.ativo { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.tab-count { font-size: 11px; background: color-mix(in srgb, currentColor 18%, transparent); border-radius: 9px; padding: 0 6px; }
.det-scroll { flex: 1; min-height: 0; min-width: 0; overflow: auto; border: none; border-radius: 0; }
.det-toolbar { flex: none; display: flex; justify-content: flex-end; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.det-toolbar .sf-btn { padding: 5px 12px; font-size: 13px; }
.pager--det { padding: 8px 12px; border-top: 1px solid var(--border); }
.cellin { width: 100%; min-width: 60px; font: inherit; font-size: 12.5px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg); color: var(--text); }
.cellin:focus { outline: none; border-color: var(--accent); }

/* Requerido */
.req { color: var(--danger); font-weight: 700; }

/* Banner de erro no topo do formulário (validação/gravação) */
.erro-banner {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius);
    background: var(--danger-bg); color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
    font-size: 14px; font-weight: 500;
}
.erro-banner__msg { flex: 1; }
.erro-banner__x { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border: none; background: transparent; color: var(--danger); cursor: pointer; border-radius: 7px; }
.erro-banner__x:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }

.rot180 { display: inline-flex; transform: rotate(180deg); }

/* Busy (ampulheta / processando) */
.busy { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 30%, transparent); backdrop-filter: blur(1px); }
.spinner--lg { width: 40px; height: 40px; border-width: 3px; }
/* Ampulheta com mensagem de etapa e progresso do download (cubo) */
.busy-box { display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 22px 26px; border-radius: 12px; background: var(--surface);
    border: 1px solid var(--border); box-shadow: var(--shadow); }
.busy-msg { font-size: 13.5px; color: var(--text-secondary); text-align: center; }
.busy-msg--sm { font-size: 12px; }
.busy-prog { width: 280px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.busy-prog > i { display: block; height: 100%; background: var(--accent); transition: width .15s linear; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 210; max-width: 90%; }

.grid-wrap { overflow-x: auto; }
.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
.grid th, .grid td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid th { background: var(--surface-2); font-weight: 600; color: var(--text-secondary); position: sticky; top: 0; z-index: 1; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.grid-empty { color: var(--text-secondary); text-align: center; padding: 16px; }

@media (max-width: 720px) {
    .menu-nav { width: 100%; height: auto; position: static; }
    .menu-panel { flex: 1; }
    .layout-body { flex-direction: column; }
    .menu-nav { border-bottom: 1px solid var(--border); }
}
.content h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 8px; }

/* ------------------------------------------------------------ Cards/Home */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
    margin-top: 24px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 26px;
    box-shadow: var(--shadow);
}
.card h2 {
    margin: 0 0 16px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; font-size: 14px; }
.card dt { color: var(--text-secondary); }
.card dd { margin: 0; color: var(--text); text-align: right; }

.permissoes {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    font-size: 14px;
}
.permissoes li { display: flex; align-items: center; gap: 8px; color: var(--text); }
.permissoes .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.permissoes .on .dot { background: var(--ok); }
.permissoes .off .dot { background: var(--border); }
.permissoes .off { color: var(--text-secondary); }

/* --------------------------------------------------- Blazor error overlay */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "Ocorreu um erro."; }

#blazor-error-ui {
    color-scheme: light;
    background: #ffe8a3;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
