:root {
    --vt-dark: #20252a;
    --vt-dark-2: #171b1f;
    --vt-surface: #ffffff;
    --vt-page: #f3f5f7;
    --vt-border: #dfe3e7;
    --vt-muted: #667085;
    --vt-danger-soft: #f5d2d5;
    --vt-warning-soft: #fff1c7;
    --vt-success-soft: #d9f0df;
    --vt-radius: 12px;
    --vt-shadow: 0 4px 16px rgba(18, 25, 33, .08);
}

html, body { min-height: 100%; }
body.virginia-admin {
    margin: 0;
    color: #111827;
    background: var(--vt-page);
    font-size: .94rem;
}

/* Estrutura geral */
.app-main { min-height: calc(100vh - 64px); }
.app-container {
    max-width: 1580px;
    margin: 0 auto;
    padding: 24px 22px 42px;
}

/* Navbar no padrão da tela de referência */
.navbar {
    min-height: 64px;
    background: var(--vt-dark) !important;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 2px 8px rgba(0,0,0,.14) !important;
}
.navbar .container-fluid { max-width: 1760px; }
.navbar-brand { font-size: 1.15rem; letter-spacing: .01em; }
.navbar-brand img { width: 34px; height: 34px; object-fit: contain; }
.navbar-dark .navbar-nav .nav-link { color: rgba(255,255,255,.68); padding: .75rem .9rem; }
.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link.show { color: #fff; }
.dropdown-menu { border: 0; border-radius: 10px; box-shadow: 0 14px 36px rgba(0,0,0,.18); padding: .45rem; }
.dropdown-item { border-radius: 7px; padding: .55rem .7rem; }
.dropdown-item i { width: 1.25rem; display: inline-block; }
.dropdown-submenu { position: relative; }
.dropdown-submenu > .dropdown-menu { top: 0; left: 100%; margin-left: .1rem; }

/* Cards: cabeçalho escuro em todo o sistema */
.card {
    border: 1px solid var(--vt-border) !important;
    border-radius: var(--vt-radius) !important;
    background: var(--vt-surface);
    box-shadow: var(--vt-shadow);
    overflow: visible;
}
.card-header {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: .85rem 1rem;
    color: #fff !important;
    background: var(--vt-dark) !important;
    border-bottom: 0 !important;
    border-radius: calc(var(--vt-radius) - 1px) calc(var(--vt-radius) - 1px) 0 0 !important;
}
.card-header h1, .card-header h2, .card-header h3,
.card-header h4, .card-header h5, .card-header h6 { margin: 0; color: #fff; font-weight: 700; }
.card-header small, .card-header .text-muted { color: rgba(255,255,255,.7) !important; }
.card-body { padding: 1rem 1.1rem; }
.card-footer { background: #fff; border-top: 1px solid var(--vt-border); }

/* Títulos isolados ganham presença sem obrigar alteração de PHP */
.app-container > h1, .app-container > h2, .app-container > h3,
.app-container > h4, .app-container > h5 {
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Formulários */
.form-label { font-weight: 650; color: #344054; margin-bottom: .38rem; }
.form-control, .form-select, .input-group-text {
    min-height: 40px;
    border-color: #cfd5dc;
    border-radius: 8px;
}
.form-control:focus, .form-select:focus {
    border-color: #737d87;
    box-shadow: 0 0 0 .2rem rgba(32,37,42,.12);
}
textarea.form-control { min-height: 96px; }

/* Botões */
.btn { border-radius: 8px; font-weight: 650; }
.btn-dark, .btn-primary { background: var(--vt-dark); border-color: var(--vt-dark); }
.btn-dark:hover, .btn-primary:hover { background: var(--vt-dark-2); border-color: var(--vt-dark-2); }
.btn-sm { border-radius: 7px; }

/* Tabelas */
.table-responsive { border-radius: 0 0 var(--vt-radius) var(--vt-radius); }
.table { margin-bottom: 0; vertical-align: middle; }
.table > :not(caption) > * > * { padding: .72rem .78rem; border-color: #d8dde2; }
.table thead th {
    color: #111;
    background: #fff !important;
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .015em;
    white-space: nowrap;
    border-bottom-width: 1px;
}
.table tbody tr:hover > * { filter: brightness(.985); }
.table-dark { --bs-table-bg: #fff; --bs-table-color: #111; --bs-table-border-color: #d8dde2; }

/* Linhas de status semelhantes à referência */
.table-danger, tr.table-danger > * { --bs-table-bg: var(--vt-danger-soft); }
.table-warning, tr.table-warning > * { --bs-table-bg: var(--vt-warning-soft); }
.table-success, tr.table-success > * { --bs-table-bg: var(--vt-success-soft); }

/* Badges */
.badge { border-radius: 999px; font-weight: 750; padding: .42em .66em; }

/* Alertas e resumos */
.alert { border: 0; border-radius: 9px; }
.summary-card, .resumo-card { height: 100%; }

/* Modais */
.modal-content { border: 0; border-radius: 14px; box-shadow: 0 22px 70px rgba(0,0,0,.26); overflow: hidden; }
.modal-header { background: var(--vt-dark) !important; color: #fff !important; border-bottom: 0; }
.modal-title { font-weight: 700; }

/* Autocomplete global */
.search-results,
[id^="res_"],
#resultado_clientes {
    position: absolute;
    z-index: 9999;
    width: 100%;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border-radius: 0 0 9px 9px;
    box-shadow: 0 12px 28px rgba(0,0,0,.16);
}
[id^="res_"] > div,
#resultado_clientes > a,
.search-results > * {
    display: block;
    padding: .62rem .8rem;
    color: #1f2937;
    border-bottom: 1px solid #edf0f2;
    cursor: pointer;
}
[id^="res_"] > div:hover,
#resultado_clientes > a:hover,
.search-results > *:hover { background: #f3f5f7; }

/* A tabela de previsão utiliza cartões de produto internos */
.produto-sugerido, .produto-card, .suggestion-card {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: .65rem .75rem;
    margin-bottom: .5rem;
}

/* Utilitários de página */
.page-toolbar { background: #f8f9fa; border-bottom: 1px solid var(--vt-border); padding: 1rem; }
.page-description { color: #5f6670; }

@media (max-width: 991.98px) {
    .app-container { padding: 16px 12px 30px; }
    .navbar .dropdown-menu { box-shadow: none; }
    .dropdown-submenu > .dropdown-menu { left: 0; margin-left: 1rem; }
    .card-header { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 575.98px) {
    body.virginia-admin { font-size: .9rem; }
    .card-body { padding: .85rem; }
    .table > :not(caption) > * > * { padding: .58rem; }
}

/* =========================================================
   Camadas (z-index)
   Garante que o menu principal e seus dropdowns fiquem acima
   dos cabeçalhos, tabelas, filtros, autocompletes e cards.
   ========================================================= */
body.virginia-admin {
    position: relative;
}

.navbar {
    position: relative;
    z-index: 12000 !important;
    isolation: isolate;
    overflow: visible !important;
}

.navbar .container-fluid,
.navbar .navbar-collapse,
.navbar .navbar-nav,
.navbar .nav-item,
.navbar .dropdown {
    position: relative;
    overflow: visible !important;
}

.navbar .dropdown-menu {
    z-index: 12100 !important;
}

.navbar .dropdown-submenu > .dropdown-menu {
    z-index: 12200 !important;
}

/* Navegação e identificação do usuário */
.navbar .nav-link .bi { margin-right: .28rem; }
.navbar .nav-link.active { color: #fff; font-weight: 700; }
.vt-user-nav { border-left: 1px solid rgba(255,255,255,.12); padding-left: .75rem; }
.vt-user-menu { display: flex; align-items: center; gap: .65rem; padding-top: .4rem !important; padding-bottom: .4rem !important; }
.vt-user-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; color: #20252a; background: #fff; font-size: .76rem; font-weight: 800; }
.vt-user-copy { display: flex; flex-direction: column; max-width: 170px; line-height: 1.15; }
.vt-user-copy strong, .vt-user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vt-user-copy strong { color: #fff; font-size: .86rem; }
.vt-user-copy small { margin-top: .2rem; color: rgba(255,255,255,.58); font-size: .7rem; }
.vt-account-menu { min-width: 245px; }

/* Dashboard */
.vt-dashboard { padding: 1.1rem; background: #f7f8fa; border-radius: 0 0 var(--vt-radius) var(--vt-radius); }
.vt-dashboard-welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.vt-dashboard-welcome h2 { margin: .15rem 0; font-size: 1.65rem; }
.vt-dashboard-welcome p { margin: 0; color: var(--vt-muted); }
.vt-eyebrow { color: #68717b; font-size: .68rem; font-weight: 800; letter-spacing: .12em; }
.vt-dashboard-date { color: #4b5563; font-size: .82rem; white-space: nowrap; }
.vt-metric-card { display: flex; align-items: center; gap: .9rem; min-height: 100px; padding: 1rem; border: 1px solid var(--vt-border); border-radius: 12px; background: #fff; box-shadow: 0 3px 12px rgba(18,25,33,.05); }
.vt-metric-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 11px; font-size: 1.2rem; }
.vt-metric-card strong, .vt-metric-card small { display: block; }
.vt-metric-card strong { font-size: 1.45rem; line-height: 1.1; }
.vt-metric-card small { margin-top: .25rem; color: var(--vt-muted); font-size: .78rem; }
.vt-metric-card:hover { border-color: #aeb7c2; box-shadow: 0 5px 16px rgba(18,25,33,.1); }
.vt-dashboard-panel { overflow: hidden; border: 1px solid var(--vt-border); border-radius: 12px; background: #fff; box-shadow: 0 3px 12px rgba(18,25,33,.05); }
.vt-dashboard-panel__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 72px; padding: 1rem 1.1rem; border-bottom: 1px solid var(--vt-border); }
.vt-dashboard-panel__header h3 { margin: .12rem 0 0; font-size: 1.05rem; }
.vt-quick-actions { padding: .45rem; }
.vt-quick-actions a { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: .7rem; padding: .8rem; color: #1f2937; border-radius: 9px; text-decoration: none; }
.vt-quick-actions a:hover { background: #f1f3f5; }
.vt-quick-actions a > .bi:first-child { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: #fff; background: var(--vt-dark); }
.vt-quick-actions span, .vt-quick-actions strong, .vt-quick-actions small { display: block; }
.vt-quick-actions small { margin-top: .12rem; color: var(--vt-muted); }
.vt-empty-state { padding: 3rem 1rem; color: var(--vt-muted); text-align: center; }
.vt-empty-state .bi { font-size: 2rem; }
.vt-empty-state p { margin: .6rem 0 0; }

/* Controles padronizados das listagens */
.vt-list-controls { display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--vt-border); background: #fafbfc; }
.vt-list-controls--inline { align-self: flex-end; flex: 0 0 auto; width: auto; padding: 0; border: 0; background: transparent; }
.d-flex > .vt-list-controls--inline { margin-left: auto; }
.vt-column-picker { position: relative; align-self: flex-end; }
.vt-column-picker summary { min-height: 40px; display: flex; align-items: center; gap: .4rem; padding: .45rem .75rem; border: 1px solid var(--vt-dark); border-radius: 8px; color: var(--vt-dark); background: #fff; font-weight: 700; cursor: pointer; list-style: none; }
.vt-column-picker[open] summary { color: #fff; background: var(--vt-dark); }
.vt-column-picker summary::-webkit-details-marker { display: none; }
.vt-column-picker__menu { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 100; min-width: 220px; max-height: 300px; overflow-y: auto; padding: .5rem; border: 1px solid var(--vt-border); border-radius: 9px; background: #fff; box-shadow: 0 14px 36px rgba(0,0,0,.16); }
.vt-column-picker__menu label { display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem; border-radius: 6px; color: #344054; font-size: .8rem; cursor: pointer; }
.vt-column-picker__menu label:hover { background: #f3f5f7; }
.vt-sortable-heading { width: 100%; display: inline-flex; align-items: center; justify-content: space-between; gap: .45rem; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; text-align: left; text-transform: inherit; letter-spacing: inherit; white-space: nowrap; }
.vt-sortable-heading__icon { color: #a1abb4; font-size: .72rem; }
.vt-sortable-heading.is-active { color: #111827; }
.vt-sortable-heading.is-active .vt-sortable-heading__icon { color: var(--vt-dark); }
.vt-pagination-bar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-top: 1px solid var(--vt-border); background: #fafbfc; }
.vt-pagination-bar p { margin: 0; color: var(--vt-muted); font-size: .78rem; }
.vt-pagination-bar nav { display: flex; align-items: center; gap: .25rem; }
.vt-pagination-bar button { min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 .4rem; border: 0; border-radius: 7px; color: #4b5563; background: transparent; font-size: .78rem; }
.vt-pagination-bar button:hover:not(:disabled) { background: #e7eaee; }
.vt-pagination-bar button.is-current { color: #fff; background: var(--vt-dark); font-weight: 700; }
.vt-pagination-bar button:disabled { opacity: .3; cursor: default; }

/* O conteúdo da página deve permanecer em uma camada inferior. */
.app-main,
.app-container,
.card,
.card-header,
.page-toolbar,
.table-responsive {
    position: relative;
    z-index: auto;
}

/* Autocomplete continua acima do conteúdo, porém abaixo do menu principal. */
.search-results,
[id^="res_"],
#resultado_clientes {
    z-index: 9000 !important;
}

/* Modais do Bootstrap devem continuar acima de tudo. */
.modal-backdrop {
    z-index: 12900 !important;
}

.modal {
    z-index: 13000 !important;
}


/* =========================================================
   PADRÃO VISUAL ÚNICO DE PÁGINAS
   Cabeçalho global renderizado pelo index.php para todas as telas.
   ========================================================= */
.vt-page-header {
    margin-bottom: 0;
    border: 1px solid var(--vt-border);
    border-radius: var(--vt-radius) var(--vt-radius) 0 0;
    background: #fff;
    box-shadow: var(--vt-shadow);
    overflow: hidden;
}
/* Mesmo espaçamento interno dos filtros nos cabeçalhos de todas as páginas. */
.vt-page-header__main,
.vt-page-header__description,
.vt-portal-header {
    padding: 1rem 1.1rem;
}
.vt-page-header__main {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: #fff;
    background: var(--vt-dark);
}
.vt-page-header__title {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 0;
    color: #fff;
    font-size: 1.08rem;
    line-height: 1.25;
    font-weight: 750;
}
.vt-page-header__title .bi { font-size: 1.15rem; }
.vt-page-header__action { margin-left: auto; }
.vt-page-header__description {
    min-height: 54px;
    display: flex;
    align-items: center;
    color: #5f6670;
    background: #f8f9fa;
    border-bottom: 1px solid var(--vt-border);
}
.vt-page-content {
    border: 1px solid var(--vt-border);
    border-top: 0;
    border-radius: 0 0 var(--vt-radius) var(--vt-radius);
    background: #fff;
    box-shadow: var(--vt-shadow);
    overflow: visible;
}
.vt-page-content > .card:first-child,
.vt-page-content > .container > .card:first-child,
.vt-page-content > .container-fluid > .card:first-child {
    border: 0 !important;
    border-radius: 0 0 var(--vt-radius) var(--vt-radius) !important;
    box-shadow: none !important;
}
/* Remove cabeçalhos duplicados das páginas antigas, mantendo subtítulos internos. */
.vt-legacy-page-title { display: none !important; }
.vt-page-content > h1:first-child,
.vt-page-content > h2:first-child,
.vt-page-content > h3:first-child,
.vt-page-content > h4:first-child,
.vt-page-content > h5:first-child { display: none !important; }
.vt-page-content > .page-header:first-child { display: none !important; }
/* Barras de filtro e ações */
.vt-toolbar,
.vt-page-content > .row:first-child,
.vt-page-content > .d-flex:first-child {
    padding: 1rem;
    margin: 0 !important;
    background: #fff;
    border-bottom: 1px solid var(--vt-border);
}
.vt-page-content .card { box-shadow: none; }
.vt-page-content .card-header { font-size: .98rem; }
.vt-page-content .card-header .bi { margin-right: .4rem; }
.vt-page-content .table-responsive { border-radius: 0; }
.vt-page-content .table thead.sticky-top { z-index: 20; }
/* Ações consistentes */
.vt-page-content .btn .bi { margin-right: .25rem; }
.vt-page-content .btn-icon .bi { margin-right: 0; }
/* Cabeçalhos legados repetidos são identificados pelo componente global. */
[data-vt-duplicate-header="true"] { display: none !important; }
/* Cards internos reais permanecem visíveis. */
.vt-page-content .card .card-header { display: flex; }
.vt-page-content > .card:first-child > .card-header.vt-keep-header { display: flex; }
@media (max-width: 767.98px) {
    .vt-page-header__main { align-items: flex-start; }
    .vt-page-header__description { min-height: auto; }
    .vt-page-content > .row:first-child { row-gap: .75rem; }
}

@media (max-width: 1199.98px) {
    .vt-user-nav { margin-top: .5rem; border-top: 1px solid rgba(255,255,255,.12); border-left: 0; padding-top: .5rem; padding-left: 0; }
    .vt-user-copy { max-width: none; }
}

@media (max-width: 575.98px) {
    .vt-dashboard { padding: .75rem; }
    .vt-dashboard-welcome { align-items: flex-start; flex-direction: column; }
    .vt-list-controls { align-items: stretch; flex-direction: column; }
    .vt-list-controls--inline { width: 100%; }
    .d-flex > .vt-list-controls--inline { margin-left: 0; }
    .vt-column-picker { align-self: stretch; }
    .vt-column-picker summary { justify-content: space-between; }
    .vt-pagination-bar { align-items: flex-start; flex-direction: column; }
    .vt-pagination-bar nav { max-width: 100%; flex-wrap: wrap; }
}

/* Portal de consulta do bolador: navegação própria e listagens compartilhadas. */
.portal-producao [id], .portal-producao { scroll-margin-top: 90px; }
.portal-producao .vt-list-controls { margin-bottom: 12px; }
.portal-producao .table td { font-size: .9rem; }
@media (max-width: 575px) {
    .portal-producao .h3 { font-size: 1.3rem; }
    .portal-producao .card-body { padding: .8rem; }
}

.selecao-correcao { min-width: 220px; }
.selecao-equipe-form fieldset { max-height: 280px; overflow-y: auto; padding: 4px; }
