:root {
    --brand-dark: #276c98;
    --brand-mid: #4394bc;
    --brand-light: #48a2d2;
    --brand-steel: #5583a6;
    --brand-soft: #6d95b3;
    --primary: var(--brand-dark);
    --secondary: #3b82f6;
    --success: #10b981;
    --background: #f3f7fa;
    --surface: #ffffff;
    --text-main: #334155;
    --border: #e2e8f0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
}

.main-header {
    background-color: var(--primary);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-header h1 {
    font-size: 1.5rem;
}

.subtitle {
    font-size: 0.85rem;
    color: #475569;
}

.main-header .subtitle {
    color: #fff;
}

.dashboard-container {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.filters-card, .kpi-card, .table-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chart-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-card canvas {
    flex: 1;
    max-height: 310px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    align-items: center;
}

.filter-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.filter-group input, .filter-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-primary { background-color: var(--secondary); color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }
.btn-secondary { background-color: #e2e8f0; color: #334155; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }
.btn-success { background-color: var(--success); color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card h3 {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.4rem;
}

.kpi-value {
    font-size: 1.35rem;
    font-weight: bold;
    color: var(--primary);
    white-space: nowrap;
}

.charts-row {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.charts-row.double {
    grid-template-columns: 1fr 1fr;
}

/* RESPONSIVIDADE E SCROLL DAS TABELAS */
.table-responsive {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 400px;
    scrollbar-width: thin;
}

.table-responsive::-webkit-scrollbar { width: 6px; height: 6px; }
.table-responsive::-webkit-scrollbar-track { background: #f1f5f9; }
.table-responsive::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.table-responsive thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f1f5f9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.table-responsive .table-total td {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: #f1f5f9;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background-color: #f1f5f9; }

.table-header-flex { display: flex; justify-content: space-between; align-items: center; }
.pagination-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.ranking-header-controls { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.ranking-header-controls label { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.ranking-header-controls select { padding: 0.4rem; border: 1px solid var(--border); border-radius: 4px; }
.table-total td { background-color: #f1f5f9; font-weight: 700; border-top: 2px solid var(--border); }
.kpi-badge { display: inline-block; margin-top: 0.35rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.kpi-badge.badge-neutro { background-color: #f1f5f9; color: #64748b; }
.kpi-badge.badge-alerta { background-color: #fef3c7; color: #92400e; }
.kpi-badge.badge-ok { background-color: #dcfce7; color: #166534; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.header-actions .btn-secondary, .header-actions a { text-decoration: none; display: inline-block; }
.analise-filters { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.analise-filters .filter-group { min-width: 160px; }

/* DRILL-DOWN DE REPASSES */
.repasse-rede-row { transition: background-color 0.18s ease, box-shadow 0.18s ease; }
.repasse-rede-row:hover { background-color: #f8fafc; }
.btn-drilldown { border: none; background: transparent; color: var(--primary); cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 0.65rem; font: inherit; font-weight: 600; text-align: left; transition: color 0.18s ease; }
.btn-drilldown:hover { color: var(--secondary); }
.drilldown-icon { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--secondary); flex-shrink: 0; transition: transform 0.22s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease; }
.btn-drilldown:hover .drilldown-icon { background-color: #eff6ff; border-color: #bfdbfe; box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15); }
.btn-drilldown[aria-expanded="true"] .drilldown-icon { transform: rotate(90deg); background-color: #eff6ff; border-color: #bfdbfe; color: var(--secondary); }
.repasse-especie-row { background-color: #f8fafc; transition: background-color 0.18s ease, opacity 0.18s ease; }
.repasse-especie-row:hover { background-color: #f1f5f9; }
.repasse-especie-row td { color: #64748b; font-size: 0.86rem; border-bottom: 1px solid #eef2f7; }
.repasse-especie-row td:first-child { padding-left: 3.4rem; position: relative; }
.repasse-especie-row td:first-child::before { content: ""; position: absolute; left: 1.45rem; top: 0; bottom: 0; width: 1px; background-color: #cbd5e1; }
.repasse-especie-row td:first-child::after { content: ""; position: absolute; left: 1.45rem; top: 50%; width: 1rem; height: 1px; background-color: #cbd5e1; }
.drilldown-especie { display: inline-flex; align-items: center; font-weight: 500; color: #475569; }
.repasse-filter { display: flex; align-items: center; gap: 0.6rem; }
.repasse-filter label { font-size: 0.8rem; font-weight: 600; color: #64748b; white-space: nowrap; }
.repasse-filter select { min-width: 190px; padding: 0.55rem 2rem 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; background-color: var(--surface); color: var(--text-main); font-size: 0.85rem; cursor: pointer; outline: none; transition: border-color 0.18s ease, box-shadow 0.18s ease; }
.repasse-filter select:hover { border-color: #cbd5e1; }
.repasse-filter select:focus { border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12); }
.repasse-rede-row.rede-sem-especie { display: none; }

/* BOTÕES DE EXPORTAÇÃO */
.header-actions-small { display: flex; align-items: center; gap: 0.5rem; }
.btn-export { padding: 0.4rem 0.75rem; border-radius: 4px; border: none; font-size: 0.8rem; font-weight: 600; cursor: pointer; color: white; transition: opacity 0.2s, transform 0.1s; display: inline-flex; align-items: center; gap: 0.3rem; }
.btn-export:hover { opacity: 0.85; }
.btn-export:active { transform: scale(0.96); }
.btn-export:disabled { opacity: 0.6; cursor: wait; }
.btn-export.pdf { background-color: #ef4444; }
.btn-export.excel { background-color: #10b981; }

/* MODAL DE DETALHES */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.modal-content { background: var(--surface); width: 90%; max-width: 600px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); overflow: hidden; }
.modal-header { background: var(--primary); color: white; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.btn-close-modal { background: transparent; border: none; color: white; font-size: 1.5rem; cursor: pointer; line-height: 1; }
.btn-close-modal:hover { background: rgb(255 255 255 / 10%); }
.btn-close-modal:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.tr-cursor-context { cursor: context-menu; }
.tr-cursor-context:hover { background-color: #f1f5f9; }

/* MENU DE CONTEXTO */
.custom-context-menu { position: absolute; background-color: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: none; z-index: 10000; min-width: 180px; overflow: hidden; }
.custom-context-menu ul { list-style: none; margin: 0; padding: 0.5rem 0; }
.custom-context-menu li { padding: 0.6rem 1rem; cursor: pointer; font-size: 0.85rem; color: var(--text-main); display: flex; align-items: center; gap: 0.5rem; transition: background-color 0.2s; }
.custom-context-menu li:hover { background-color: #f1f5f9; color: var(--secondary); }

.spin-icon { animation: girar 1s linear infinite; display: inline-block; }
@keyframes girar { 100% { transform: rotate(360deg); } }

table:not(.modo-avancado) .col-ajuste { display: none; }
.dataTables_wrapper { margin-top: 20px !important; }
.table-header-flex { margin-bottom: 5px !important; }
#tblInadimplencia_filter { margin-bottom: 10px; }

@media(max-width: 1024px) { .charts-row.double { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
    .table-header-flex { flex-wrap: wrap; gap: 0.5rem; }
    .ranking-header-controls { margin-bottom: 0; }
    .repasse-filter { width: 100%; margin-top: 0.75rem; }
    .repasse-filter select { flex: 1; min-width: 0; }
    .btn-drilldown { gap: 0.5rem; }
    .drilldown-icon { width: 24px; height: 24px; }
    .repasse-especie-row td:first-child { padding-left: 2.8rem; }
}

/* FLUXO DE CAIXA */
.table-responsive.expandido { max-height: none !important; overflow-y: visible !important; }
#tituloImpressaoFC { display: none; }
@media print {
    body * { visibility: hidden; }
    #areaImpressaoFC, #areaImpressaoFC * { visibility: visible; }
    #areaImpressaoFC { position: absolute; top: 0; left: 0; width: 100%; }
    #tituloImpressaoFC { display: block !important; margin-bottom: 12px; }
    #tituloImpressaoFC h2 { margin: 0 0 4px 0; color: #1e293b; }
    #tituloImpressaoFC p { margin: 0; color: #64748b; font-size: 0.85rem; }
    .table-responsive { max-height: none !important; overflow: visible !important; }
    .main-header, .filters-card, .table-header-flex button, .table-header-flex label { display: none !important; }
    table { font-size: 9px; }
    th, td { padding: 4px 6px !important; }
}
#tblFluxoCaixa th, #tblFluxoCaixa td { padding: 0.35rem 0.5rem; font-size: 0.82rem; line-height: 1.25; }
#tblFluxoCaixa .fc-input { padding: 0.25rem 0.4rem; font-size: 0.82rem; height: 26px; line-height: 1; }
#tblFluxoCaixa thead th { padding: 0.5rem; font-size: 0.8rem; }

/* LOADING OVERLAY (z-index acima dos modais, que usam 9999) */
.loading-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center; justify-content: center; z-index: 10001; opacity: 0; pointer-events: none; transition: opacity 0.15s ease; }
.loading-overlay.active { opacity: 1; pointer-events: all; }
.loading-overlay__box { background: #fff; border-radius: 12px; padding: 28px 36px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); min-width: 180px; }
.loading-overlay__spinner { width: 40px; height: 40px; border: 4px solid #e2e8f0; border-top-color: #3b82f6; border-radius: 50%; animation: loading-overlay-spin 0.8s linear infinite; }
.loading-overlay__text { font-size: 14px; color: #1e293b; font-weight: 500; text-align: center; }
@keyframes loading-overlay-spin { to { transform: rotate(360deg); } }

/* INAUGURAÇÕES E NAVBAR */
.badge { padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-pago { background:#dcfce7; color:#166534; }
.badge-pendente { background:#e5e7eb; color:#374151; }
.badge-proximo { background:#fef3c7; color:#92400e; }
.badge-atrasado { background:#fee2e2; color:#991b1b; }
tr.linha-atrasada { background-color: #fef2f2; }
tr.linha-proxima { background-color: #fffbeb; }
tr.linha-paga { opacity: 0.6; }
.btn-icon { border:none; background:transparent; cursor:pointer; padding:4px 6px; color:#475569; }
.btn-icon:hover { color:#1e293b; }
.form-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.form-grid .filter-group { display: flex; flex-direction: column; min-width: 160px; }
#tblInauguracoes { margin-top: 0; }
#tblInauguracoes-wrapper { max-height: 430px; overflow-y: auto; overflow-x: auto; }
#tblInauguracoes thead th { position: sticky; top: 0; z-index: 20; background-color: #f1f5f9; }
#tblInauguracoes tfoot td { position: sticky; bottom: 0; z-index: 20; background-color: #f1f5f9; font-weight: 700; border-top: 2px solid var(--border); }
#tblInauguracoes tfoot td:first-child { text-align: right; }
#totalValorInauguracoes { text-align: right; white-space: nowrap; }

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    background-color: var(--brand-dark);
    background-image:
        linear-gradient(135deg, transparent 0%, rgb(2 6 23 / 26%) 55%, rgb(2 6 23 / 34%) 100%),
        linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 55%, var(--brand-light) 100%);
    padding: 0 24px;
    height: 60px;
    box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.navbar-logo { display: grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; padding: 6px; border-radius: 8px; background: #fff; color: var(--brand-dark); }
.navbar-logo img { width: 100%; height: 100%; object-fit: contain; }
.navbar-logo i { font-size: 1.25rem; }
.navbar-menu { display: flex; align-items: center; gap: 4px; height: 100%; }
.nav-link { display: flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; padding: 0 14px; height: 100%; font-size: 0.9rem; font-weight: 600; background: none; border: none; cursor: pointer; transition: background-color 0.15s; }
.nav-link:hover, .nav-link.active { background-color: rgb(255 255 255 / 8%); }
.nav-link.active { box-shadow: inset 0 -2px rgb(255 255 255 / 75%); }
.navbar-brand:focus-visible, .nav-link:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.nav-caret { font-size: 0.65rem; margin-left: 2px; transition: transform 0.15s; }
.nav-dropdown { position: relative; height: 100%; }
.nav-dropdown-menu { position: absolute; top: 100%; left: 0; background: #fff; min-width: 220px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); padding: 6px; display: none; flex-direction: column; margin-top: 6px; z-index: 200; }
.nav-dropdown.open .nav-dropdown-menu { display: flex; }
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }
.nav-dropdown-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; color: #334155; text-decoration: none; font-size: 0.88rem; font-weight: 500; }
.nav-dropdown-menu a:hover { background: var(--background); }
.nav-dropdown-menu a.active { background: color-mix(in srgb, var(--brand-soft) 12%, white); color: var(--brand-dark); }
.nav-dropdown-menu a:focus-visible { outline: 2px solid var(--brand-light); outline-offset: -2px; }
.navbar [hidden] { display: none; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }

/* HOME */
.home-container { display: flex; flex-direction: column; align-items: center; padding: 40px 20px; max-width: 1200px; margin: 0 auto; }
.home-header { text-align: center; margin-bottom: 40px; }
.home-header h1 { font-size: 2.2rem; color: #1f2937; margin-bottom: 10px; }
.home-header p { font-size: 1.1rem; color: #6b7280; }
.home-menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; width: 100%; max-width: 900px; }
.home-menu-card { background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 30px 20px; text-align: center; text-decoration: none; color: #1f2937; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; display: flex; flex-direction: column; align-items: center; }
.home-menu-card:hover { transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); border-color: #3b82f6; }
.home-menu-card i { font-size: 3rem; color: #3b82f6; margin-bottom: 15px; }
.home-menu-card h3 { font-size: 1.25rem; margin-bottom: 8px; }
.home-menu-card p { font-size: 0.9rem; color: #6b7280; }

.kpi-compare { display: block; font-size: 0.8rem; margin-top: 4px; font-weight: 600; }
.kpi-compare.compare-up { color: #16a34a; }
.kpi-compare.compare-down { color: #dc2626; }
.aging-container { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.aging-item { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; font-weight: 500; color: #4b5563; }
.aging-label { width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aging-bar-track { flex: 1; height: 10px; background-color: #f3f4f6; border-radius: 5px; margin: 0 15px; overflow: hidden; }
.aging-bar-fill { height: 100%; border-radius: 5px; transition: width 0.8s ease-out; }
.aging-value { width: 85px; text-align: right; font-weight: 600; color: #1f2937; }


/* ============================================================
   COMPONENTE MULTISELECT COM PESQUISA (NOVO)
   ============================================================ */
.multiselect-especie {
    position: relative;
    user-select: none;
    width: 100%;
}

.multiselect-especie.open {
    z-index: 999;
}

.multiselect-especie-trigger {
    width: 100%;
    min-height: 38px;
    padding: 8px 38px 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #fff;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.multiselect-especie-trigger:hover { border-color: #9ca3af; }
.multiselect-especie.open .multiselect-especie-trigger { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.10); }
.multiselect-especie-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 5px; font-size: 13px; }
.multiselect-especie-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 11px; color: #6b7280; transition: transform 0.2s ease; pointer-events: none; }
.multiselect-especie.open .multiselect-especie-arrow { transform: translateY(-50%) rotate(180deg); }

.multiselect-especie-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: none;
    width: max-content;
    min-width: 100%;
    max-width: 450px; 
    overflow: hidden;
}
.multiselect-especie.open .multiselect-especie-dropdown { display: block; }

.multiselect-search { padding: 8px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.multiselect-search input { width: 100%; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.85rem; outline: none; transition: border-color 0.2s; }
.multiselect-search input:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

.multiselect-options-list { max-height: 250px; overflow-y: auto; padding: 4px 0; }
.multiselect-especie-option { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 7px 12px; cursor: pointer; color: #374151; background: #fff; transition: background-color 0.12s ease; font-size: 14px; }
.multiselect-especie-option:hover { background-color: #f3f4f6; }
.multiselect-especie-option input[type="checkbox"] { width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: #2563eb; flex-shrink: 0; }
.multiselect-especie-option-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 20px; }
.multiselect-especie-option.todas { border-bottom: 1px solid #e5e7eb; margin-bottom: 4px; font-weight: 500; }
.multiselect-especie-option.selected { background-color: #eff6ff; }
.multiselect-especie-option.selected:hover { background-color: #dbeafe; }
.multiselect-especie-option.hidden { display: none !important; }

.multiselect-options-list::-webkit-scrollbar { width: 7px; }
.multiselect-options-list::-webkit-scrollbar-track { background: #f9fafb; }
.multiselect-options-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
.multiselect-options-list::-webkit-scrollbar-thumb:hover { background: #9ca3af; }


@media (max-width: 768px) {
    .multiselect-especie-dropdown { max-width: 100vw; }
    .multiselect-especie-option { min-height: 40px; padding: 8px 12px; }
}


/* ============================================================
   DFC - TABELA
   ============================================================ */
#tblDFC { margin-top: 0; }
#tblDFC th, #tblDFC td { padding: 0.35rem 0.5rem; font-size: 0.82rem; line-height: 1.25; white-space: nowrap; }
#tblDFC thead th:first-child, #tblDFC tbody td:first-child { position: sticky; left: 0; min-width: 260px; }
#tblDFC thead th:first-child { z-index: 12; }
#tblDFC tbody td:first-child { z-index: 5; background-color: var(--surface); }
#tblDFC .dfc-num { text-align: right; font-variant-numeric: tabular-nums; }
#tblDFC .dfc-neg { color: #dc2626; }
#tblDFC tr.dfc-total td { background-color: #004C94; color: #fff; font-weight: 700; }
#tblDFC tr.dfc-total .dfc-neg { color: #fca5a5; }
#tblDFC tr.dfc-grupo td { background-color: #006ECF; color: #fff; font-weight: 700; }
#tblDFC tr.dfc-sub-grupo td { background-color: #3C93FA; font-weight: 700; }
#tblDFC tr.dfc-conta td:first-child { padding-left: 1.5rem; }

/* DFC - Abas Diário / Mensal */
.dfc-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0.75rem 0 0.5rem; }
.dfc-tab { background: none; border: none; border-bottom: 3px solid transparent; padding: 0.55rem 1.5rem; font-size: 0.9rem; font-weight: 600; color: #64748b; cursor: pointer; }
.dfc-tab:hover { color: var(--primary); }
.dfc-tab.active { color: var(--primary); border-bottom-color: #16a34a; }
#grpReferenciaDFC[hidden] { display: none; }

/* DFC - Seletor de meses (aba Mensal) */
.dfc-meses-group { position: relative; grid-column: span 2; }
.dfc-meses-group[hidden], .filter-group[hidden] { display: none; }
.dfc-meses-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; background: #fff; color: var(--text-main); font-size: 0.9rem; cursor: pointer; text-align: left; }
.dfc-meses-btn:focus-visible, .dfc-mes:focus-visible { outline: 2px solid var(--secondary); outline-offset: 1px; }
.dfc-meses-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 500; width: 300px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); padding: 12px; }
.dfc-meses-pop[hidden] { display: none; }
.dfc-meses-ano { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dfc-meses-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dfc-mes { padding: 0.55rem 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text-main); cursor: pointer; font-size: 0.85rem; text-transform: capitalize; }
.dfc-mes:hover { background: #f1f5f9; }
.dfc-mes.sel { background: var(--secondary); border-color: var(--secondary); color: #fff; font-weight: 600; }
.dfc-meses-info { margin: 8px 0; font-size: 0.78rem; color: #64748b; min-height: 1.1em; }
.dfc-meses-acoes { display: flex; justify-content: flex-end; gap: 6px; }

/* DFC - Lupa e modal de lançamentos */
#tblDFC .dfc-cel { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
#tblDFC .dfc-lupa { background: none; border: none; padding: 0 2px; cursor: pointer; color: inherit; opacity: 0.45; font-size: 0.8rem; line-height: 1; }
#tblDFC .dfc-lupa:hover, #tblDFC .dfc-lupa:focus-visible { opacity: 1; }
#tblDFC .dfc-lupa:focus-visible { outline: 2px solid var(--secondary); border-radius: 3px; }
#tblDFC tr.dfc-detalhe td:first-child { padding-left: 1.5rem; }

.dfc-modal-lanc { max-width: 1100px; width: 95%; max-height: 85vh; display: flex; flex-direction: column; }
.dfc-modal-acoes { display: flex; align-items: center; gap: 10px; }
.dfc-modal-corpo { padding: 1rem 1.25rem; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.dfc-modal-resumo { font-size: 0.85rem; color: #475569; margin-bottom: 0.75rem; font-weight: 600; }
.dfc-modal-tabela { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: 6px; }
.dfc-modal-tabela table { margin-top: 0; font-size: 0.78rem; white-space: nowrap; }
.dfc-modal-tabela th { position: sticky; top: 0; background: #f1f5f9; z-index: 2; }
.dfc-modal-tabela th, .dfc-modal-tabela td { padding: 0.35rem 0.6rem; }
.dfc-modal-tabela td.dfc-num { text-align: right; font-variant-numeric: tabular-nums; }
.dfc-modal-vazio { text-align: center; color: #64748b; padding: 1.5rem 0; }

/* ============================================================
   DFC - GRUPO E SUBGRUPOS DE SAÍDAS OPERACIONAIS (CINZA)
   ============================================================ */

/* Aumenta a altura do container da DFC para exibir todas as linhas recolhidas sem scroll */
.table-responsive:has(#tblDFC) {
    max-height: calc(100vh - 180px);
    min-height: 540px;
}

/* Grupo Principal: SAÍDAS OPERACIONAIS (Cinza Escuro) */
#tblDFC tr.dfc-grupo-saida td {
  background-color: #6c7e75;
  color: #ffffff;
  font-weight: 700;
}

/* Subgrupos: (-) IMPOSTOS SOBRE A RECEITA, (-) DESPESAS DE TRADE, etc. (Cinza Claro) */
#tblDFC tr.dfc-sub-grupo-saida td {
  background-color: #d4d4d4;
  color: #171717;
  font-weight: 700;
}

/* Destaque ao passar o mouse */
#tblDFC tr.dfc-grupo-saida.dfc-linha-expansivel:hover td {
  filter: brightness(1.15);
}

#tblDFC tr.dfc-sub-grupo-saida.dfc-linha-expansivel:hover td {
  filter: brightness(0.95);
}


/* DFC - Grupos recolhíveis e expansão hierárquica */

#tblDFC .dfc-linha-expansivel {
  cursor: pointer;
}

#tblDFC .dfc-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 1.2rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

#tblDFC .dfc-toggle-icone {
  display: inline-flex;
  flex: 0 0 0.8rem;
  justify-content: center;
  font-size: 0.7rem;
}

#tblDFC .dfc-toggle:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 2px;
}

#tblDFC tr[hidden] {
  display: none !important;
}

/* Mantém o destaque visual ao passar o mouse nos grupos. */
#tblDFC tr.dfc-grupo.dfc-linha-expansivel:hover td {
  filter: brightness(1.08);
}

#tblDFC tr.dfc-sub-grupo.dfc-linha-expansivel:hover td {
  filter: brightness(0.96);
}

/* DFC - Aparência institucional, selecionável no cabeçalho da tabela */
#painelTabelaDFC .table-header-flex { flex-wrap: wrap; gap: 0.75rem; }
.dfc-acoes-tabela, .dfc-botoes-tabela { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.dfc-acoes-tabela { gap: 0.75rem; }
.dfc-acoes-tabela [hidden], .dfc-unidade { display: none; }
.dfc-seletor-layout { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; font-weight: 600; }
.dfc-seletor-layout select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--brand-steel);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand-dark);
  font: inherit;
}
.dfc-seletor-layout select:focus-visible, #wrapperDFC:focus-visible { outline: 2px solid var(--brand-light); outline-offset: 2px; }

#painelTabelaDFC[data-layout="institucional"] {
  --dfc-azul-secao: color-mix(in srgb, var(--brand-soft) 15%, var(--surface));
  --dfc-azul-grupo: color-mix(in srgb, var(--brand-steel) 8%, var(--surface));
  --dfc-azul-destaque: color-mix(in srgb, var(--brand-light) 19%, var(--surface));
  --dfc-borda: color-mix(in srgb, var(--brand-soft) 23%, var(--surface));
  --dfc-negativo: #a12634;
  --dfc-largura-indicador: clamp(16rem, 36vw, 30rem);
  --dfc-passo-recuo: 0.95rem;
  border-color: var(--dfc-borda);
  border-radius: 12px;
}
[data-layout="institucional"] .dfc-unidade { display: block; margin-top: 0.2rem; color: #475569; font-size: 0.8rem; }
[data-layout="institucional"] .dfc-tab.active { border-bottom-color: var(--brand-dark); }
[data-layout="institucional"] #btnExportarDFC { background-color: var(--brand-dark); }
[data-layout="institucional"] #btnExportarDFC:hover { background-color: var(--brand-mid); color: #0f172a; opacity: 1; }
[data-layout="institucional"] #btnExpandirDFC { background-color: var(--dfc-azul-grupo); color: var(--brand-dark); }
[data-layout="institucional"] #btnExpandirDFC:hover { background-color: var(--dfc-azul-secao); }

[data-layout="institucional"] #wrapperDFC {
  min-height: 0;
  max-height: max(18rem, calc(100dvh - 180px));
  border: 1px solid var(--dfc-borda);
  border-radius: 8px;
}
[data-layout="institucional"] #tblDFC { border-collapse: separate; border-spacing: 0; }
[data-layout="institucional"] #tblDFC :is(th, td) { padding: 0.48rem 0.65rem; border-color: var(--dfc-borda); }
[data-layout="institucional"] #tblDFC thead th { background: var(--dfc-azul-grupo); color: var(--brand-dark); box-shadow: none; }
[data-layout="institucional"] #tblDFC :is(thead th, tbody td):first-child {
  width: var(--dfc-largura-indicador);
  min-width: var(--dfc-largura-indicador);
  max-width: var(--dfc-largura-indicador);
  white-space: normal;
  overflow-wrap: anywhere;
}
[data-layout="institucional"] #tblDFC td:only-child {
  position: static;
  min-width: 0;
  max-width: none;
}
[data-layout="institucional"] #tblDFC tbody td {
  background-color: var(--dfc-fundo-linha, var(--surface));
  color: var(--dfc-texto-linha, var(--text-main));
  font-weight: var(--dfc-peso-linha, 400);
}
[data-layout="institucional"] #tblDFC tr:last-child td { border-bottom: 0; }
[data-layout="institucional"] #tblDFC tr:is(.dfc-grupo, .dfc-grupo-saida) {
  --dfc-fundo-linha: var(--dfc-azul-secao);
  --dfc-texto-linha: var(--brand-dark);
  --dfc-peso-linha: 700;
}
[data-layout="institucional"] #tblDFC tr:is(.dfc-grupo, .dfc-grupo-saida) td:first-child {
  box-shadow: inset 3px 0 var(--brand-steel);
}
[data-layout="institucional"] #tblDFC tr:is(.dfc-grupo, .dfc-grupo-saida):has(.dfc-toggle[aria-expanded="true"]) {
  --dfc-fundo-linha: var(--dfc-azul-destaque);
}
[data-layout="institucional"] #tblDFC tr:is(.dfc-sub-grupo, .dfc-sub-grupo-saida) { --dfc-peso-linha: 600; }
[data-layout="institucional"] #tblDFC tr.dfc-grupo-intermediario { --dfc-fundo-linha: var(--dfc-azul-grupo); }
[data-layout="institucional"] #tblDFC tr.dfc-linha-expansivel:hover td {
  filter: none;
  background-color: color-mix(in srgb, var(--brand-light) 6%, var(--dfc-fundo-linha, var(--surface)));
}
[data-layout="institucional"] #tblDFC .dfc-recuo-classico { display: none; } /* O Excel lê os recuos pelo textContent. */
[data-layout="institucional"] #tblDFC tr[data-dfc-nivel="1"] { --dfc-nivel: 1; }
[data-layout="institucional"] #tblDFC tr[data-dfc-nivel="2"] { --dfc-nivel: 2; }
[data-layout="institucional"] #tblDFC tr[data-dfc-nivel="3"] { --dfc-nivel: 3; }
[data-layout="institucional"] #tblDFC tbody tr[data-dfc-nivel] td:first-child {
  padding-left: calc(0.65rem + var(--dfc-nivel, 0) * var(--dfc-passo-recuo));
}
[data-layout="institucional"] #tblDFC tbody tr:is(.dfc-detalhe, .dfc-total) td:first-child {
  padding-left: calc(1.85rem + var(--dfc-nivel, 0) * var(--dfc-passo-recuo));
}
[data-layout="institucional"] #tblDFC tr.dfc-total {
  --dfc-fundo-linha: var(--dfc-azul-grupo);
  --dfc-peso-linha: 700;
}
[data-layout="institucional"] #tblDFC tr:is([data-dfc-totalizador="fluxo_caixa_operacional_total"], [data-dfc-totalizador="caixa_geral_livre"]) {
  --dfc-fundo-linha: var(--dfc-azul-destaque);
  --dfc-texto-linha: var(--brand-dark);
}
[data-layout="institucional"] #tblDFC tr[data-dfc-totalizador="saldo_final_dfc"] {
  --dfc-fundo-linha: var(--brand-dark);
  --dfc-texto-linha: #fff;
  --dfc-negativo: #ffe0e5;
}
[data-layout="institucional"] #tblDFC tr[data-dfc-totalizador="divergencia"] { --dfc-texto-linha: #475569; }
[data-layout="institucional"] #tblDFC td:is(.dfc-neg, .dfc-divergencia-valor) { color: var(--dfc-negativo); }
[data-layout="institucional"] #tblDFC .dfc-lupa { opacity: 0.8; }
[data-layout="institucional"] #tblDFC .dfc-lupa:is(:hover, :focus-visible) { opacity: 1; }
[data-layout="institucional"] #tblDFC :is(.dfc-toggle, .dfc-lupa):focus-visible { outline-color: var(--brand-light); }

@media (max-width: 640px) {
  #painelTabelaDFC[data-layout="institucional"] {
    --dfc-largura-indicador: clamp(8rem, 40vw, 15rem);
    --dfc-passo-recuo: 0.5rem;
    padding: 0.75rem;
  }
}



/* =========================================================
   RESUMO FINANCEIRO DO DASHBOARD
   ========================================================= */

.resumo-financeiro-card {
  margin-top: 14px;
  margin-bottom: 20px;
  padding: 16px 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.resumo-financeiro-cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.resumo-financeiro-cabecalho h3 {
  margin: 0;
  color: #1e293b;
  font-size: 1rem;
  font-weight: 700;
}

.resumo-financeiro-cabecalho p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.78rem;
}

.resumo-status {
  padding: 4px 9px;
  border-radius: 20px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.72rem;
  white-space: nowrap;
}

.resumo-status.sucesso {
  background: #dcfce7;
  color: #166534;
}

.resumo-status.erro {
  background: #fee2e2;
  color: #991b1b;
}

.resumo-financeiro-itens {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
}

.resumo-item {
  display: flex;
  flex: 1 1 175px;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #f8fafc;
}

.resumo-item span {
  color: #64748b;
  font-size: 0.78rem;
}

.resumo-item strong {
  color: #0f172a;
  font-size: 0.88rem;
  white-space: nowrap;
}

.resultado-final-linha {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 13px 15px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.resultado-final-linha > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resultado-final-linha span {
  color: #1e3a8a;
  font-size: 0.9rem;
  font-weight: 700;
}

.resultado-final-linha small {
  color: #475569;
  font-size: 0.72rem;
  line-height: 1.5;
}

.resultado-final-linha strong {
  color: #166534;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 800;
  white-space: nowrap;
}

.resultado-final-linha strong.negativo {
  color: #b91c1c;
}

@media (max-width: 600px) {
  .resumo-financeiro-card {
    padding: 12px;
  }

  .resumo-item {
    flex-basis: 100%;
  }

  .resultado-final-linha {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* Modal de lançamentos do dashboard (colar no final do style.css) */
.modal-overlay[hidden] { display: none; }
.modal-lancamentos { max-width: 900px; width: 95%; max-height: 90vh; display: flex; flex-direction: column; }
.modal-lancamentos__corpo { padding: 1.25rem 1.5rem; overflow: auto; }
.modal-lancamentos__form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; align-items: end; margin-bottom: 1.25rem; }
.modal-lancamentos__acoes { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.modal-lancamentos__msg { margin-right: auto; font-size: 0.8rem; color: #64748b; }
.modal-lancamentos__msg[data-tipo="ok"] { color: #166534; }
.modal-lancamentos__msg[data-tipo="erro"] { color: #b91c1c; }
.btn-success:disabled { opacity: 0.6; cursor: wait; }

/* Utilitários usados pelo resumo financeiro e pelo modal (antes vinham do Bootstrap, que não está na página) */
.text-end { text-align: right; }
.text-center { text-align: center; }
.text-success { color: #16a34a; }
.text-danger { color: #dc2626; }
.text-muted { color: #94a3b8; }
.resumo-financeiro-acoes { display: flex; align-items: center; gap: 0.5rem; }

/* =========================================================
   Administração visual e versionada da DFC
   ========================================================= */

body.modal-open {
  overflow: hidden;
}

.dfc-page-actions,
.dfc-admin-actions,
.dfc-editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.dfc-preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid #f59e0b;
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.dfc-preview-badge[hidden] {
  display: none !important;
}

.dfc-preview-badge::before {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #f59e0b;
  content: "";
}

.dfc-admin-modal {
  width: min(96vw, 1280px);
  max-width: 1280px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dfc-admin-modal .modal-header {
  flex: 0 0 auto;
  gap: 1rem;
}

.dfc-admin-modal .modal-header p {
  margin: 0.3rem 0 0;
  color: inherit;
  font-size: 0.8rem;
}

.dfc-admin-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.dfc-admin-status {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  color: #64748b;
  font-size: 0.8rem;
}

.dfc-admin-status strong {
  color: #0f172a;
}

.dfc-version-status {
  display: inline-flex;
  margin-left: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.dfc-version-status.draft { background: #fef3c7; color: #92400e; }
.dfc-version-status.published { background: #dcfce7; color: #166534; }
.dfc-version-status.archived { background: #e2e8f0; color: #475569; }

.dfc-admin-message {
  min-height: 0;
  padding: 0 1.25rem;
  color: #475569;
  font-size: 0.82rem;
}

.dfc-admin-message:not(:empty) {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.dfc-admin-message[data-tipo="ok"] { background: #f0fdf4; color: #166534; }
.dfc-admin-message[data-tipo="erro"] { background: #fef2f2; color: #b91c1c; }
.dfc-admin-message[data-tipo="info"] { background: #eff6ff; color: #1e40af; }

.dfc-inline-action {
  padding: 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.dfc-admin-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 0.25rem;
  padding: 0.55rem 1.25rem 0;
  border-bottom: 1px solid #cbd5e1;
  background: #fff;
  overflow-x: auto;
}

.dfc-admin-tab {
  padding: 0.65rem 0.9rem;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #64748b;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.dfc-admin-tab:hover { color: #0f172a; }
.dfc-admin-tab.active { border-bottom-color: #2563eb; color: #1d4ed8; }

.dfc-admin-body {
  min-height: 0;
  flex: 1 1 auto;
  padding: 1rem 1.25rem 1.25rem;
  overflow: auto;
  background: #f8fafc;
}

.dfc-admin-panel { display: none; }
.dfc-admin-panel.active { display: block; }

.dfc-admin-split {
  display: grid;
  grid-template-columns: minmax(310px, 0.9fr) minmax(420px, 1.35fr);
  gap: 1rem;
  align-items: start;
}

.dfc-rules-layout {
  grid-template-columns: minmax(330px, 0.8fr) minmax(480px, 1.4fr);
}

.dfc-admin-list-column,
.dfc-admin-editor,
.dfc-history-item {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dfc-admin-list-column,
.dfc-admin-editor {
  padding: 1rem;
}

.dfc-admin-editor h4 {
  margin: 0 0 0.9rem;
  color: #0f172a;
}

.dfc-admin-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.dfc-admin-section-title > div:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.15rem;
}

.dfc-admin-section-title small {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 400;
}

.dfc-admin-empty {
  margin: 0;
  padding: 1.25rem;
  border: 1px dashed #cbd5e1;
  border-radius: 7px;
  color: #64748b;
  text-align: center;
}

.dfc-structure-tree,
.dfc-rules-list,
.dfc-condition-tree {
  max-height: 58vh;
  overflow: auto;
}

.dfc-structure-branch {
  position: relative;
}

.dfc-structure-node {
  width: 100%;
  min-height: 2.8rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.25rem;
  padding: 0.45rem 0.6rem 0.45rem calc(0.6rem + var(--tree-level, 0) * 1.15rem);
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #334155;
  text-align: left;
  cursor: pointer;
}

.dfc-structure-node:hover { background: #f1f5f9; }
.dfc-structure-node.selected { border-color: #93c5fd; background: #eff6ff; color: #1e40af; }
.dfc-structure-node.inactive { opacity: 0.55; }

.dfc-structure-node span:nth-child(2) {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dfc-structure-node strong,
.dfc-structure-node small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dfc-structure-node small { color: #64748b; font-size: 0.66rem; }

.dfc-active-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #22c55e;
}

.dfc-structure-node.inactive .dfc-active-dot { background: #94a3b8; }

.dfc-admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.dfc-admin-form-grid label,
.dfc-condition-form label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.3rem;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
}

.dfc-admin-form-grid .span-2 { grid-column: span 2; }

.dfc-rule-destination {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.3rem;
}

.dfc-admin-form-grid input,
.dfc-admin-form-grid select,
.dfc-admin-form-grid textarea,
.dfc-condition-form input,
.dfc-condition-form select {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-weight: 400;
}

.dfc-admin-form-grid input:focus,
.dfc-admin-form-grid select:focus,
.dfc-admin-form-grid textarea:focus,
.dfc-condition-form input:focus,
.dfc-condition-form select:focus {
  border-color: #60a5fa;
  outline: 3px solid rgba(96, 165, 250, 0.18);
}

.dfc-admin-form-grid :disabled {
  background: #f1f5f9;
  color: #64748b;
}

.dfc-rule-combobox {
  position: relative;
}

.dfc-rule-combobox input {
  padding-right: 2rem;
  text-overflow: ellipsis;
}

.dfc-rule-combobox input[aria-expanded="false"]:not([title=""]) {
  font-weight: 600;
}

.dfc-rule-combobox-clear {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #64748b;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.dfc-rule-combobox-clear:not(:disabled):hover,
.dfc-rule-combobox-clear:focus-visible {
  background: #e2e8f0;
  color: #0f172a;
}

.dfc-rule-combobox-menu {
  position: absolute;
  z-index: 2;
  top: calc(100% + 0.25rem);
  inset-inline: 0;
  max-height: min(16rem, 40vh);
  overflow-y: auto;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.14);
}

.dfc-rule-combobox-group {
  padding: 0.45rem 0.6rem;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
}

.dfc-rule-combobox-option {
  padding: 0.45rem 0.75rem 0.45rem 1rem;
  color: #0f172a;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.dfc-rule-combobox-option[aria-selected="true"] {
  color: #1e40af;
  font-weight: 600;
}

.dfc-rule-combobox-option:hover,
.dfc-rule-combobox-option.active {
  background: #dbeafe;
}

.dfc-editor-actions {
  margin-top: 0.9rem;
}

.dfc-rule-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  text-align: left;
  cursor: pointer;
}

.dfc-rule-card:hover { border-color: #93c5fd; }
.dfc-rule-card.selected { border-color: #60a5fa; background: #eff6ff; }
.dfc-rule-card.inactive { opacity: 0.58; }

.dfc-rule-card > span:first-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dfc-rule-card small { color: #64748b; }

.dfc-rule-badges {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.dfc-rule-badges em {
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.6rem;
  font-style: normal;
  font-weight: 800;
}

.dfc-condition-builder {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.dfc-condition-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.3rem calc(var(--condition-level, 0) * 1.15rem);
  border: 1px solid #e2e8f0;
  border-left: 4px solid #94a3b8;
  border-radius: 6px;
  background: #fff;
}

.dfc-condition-node > button:first-child {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  background: transparent;
  color: #334155;
  text-align: left;
  cursor: pointer;
}

.dfc-condition-node.selected { border-color: #60a5fa; background: #eff6ff; }
.dfc-condition-node.group { font-weight: 800; }
.dfc-condition-node.operator-e { border-left-color: #2563eb; }
.dfc-condition-node.operator-ou { border-left-color: #16a34a; }
.dfc-condition-node.operator-nao { border-left-color: #dc2626; background: #fff7f7; }

.dfc-condition-node.operator-e > button:first-child::after,
.dfc-condition-node.operator-ou > button:first-child::after,
.dfc-condition-node.operator-nao > button:first-child::after {
  margin-left: auto;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}

.dfc-condition-node.operator-e > button:first-child::after { content: "E"; background: #dbeafe; color: #1d4ed8; }
.dfc-condition-node.operator-ou > button:first-child::after { content: "OU"; background: #dcfce7; color: #15803d; }
.dfc-condition-node.operator-nao > button:first-child::after { content: "NÃO"; background: #fee2e2; color: #b91c1c; }

.dfc-condition-delete {
  margin-right: 0.35rem;
  padding: 0.35rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}

.dfc-condition-delete:hover { background: #fee2e2; color: #dc2626; }

.dfc-condition-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.8rem;
  padding: 0.85rem;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #eff6ff;
}

.dfc-condition-form .dfc-editor-actions { grid-column: 1 / -1; }

.dfc-history-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.8rem;
}

.dfc-history-item {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.9rem;
}

.dfc-history-item > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dfc-history-item p { margin: 0; color: #475569; }
.dfc-history-item small { color: #64748b; }
.dfc-history-item button { align-self: flex-end; }

.dfc-admin-modal button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .dfc-admin-split,
  .dfc-rules-layout {
    grid-template-columns: 1fr;
  }

  .dfc-structure-tree,
  .dfc-rules-list,
  .dfc-condition-tree {
    max-height: 38vh;
  }
}

@media (max-width: 640px) {
  .dfc-admin-modal {
    width: 100vw;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .dfc-admin-toolbar,
  .dfc-admin-section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .dfc-admin-body { padding: 0.75rem; }
  .dfc-admin-tabs { padding-left: 0.75rem; padding-right: 0.75rem; }
  .dfc-admin-form-grid,
  .dfc-condition-form { grid-template-columns: 1fr; }
  .dfc-admin-form-grid .span-2 { grid-column: auto; }
  .dfc-page-actions { align-items: flex-end; flex-direction: column; }
}

/* Gerenciamento de acessos */
.acessos-pagina .page-header { align-items: center; }
.acessos-pagina h1 { color: var(--primary); font-size: 1.5rem; }
.acessos-pagina .table-header-flex h2 { font-size: 1.1rem; }
.acessos-pagina button:disabled { opacity: 0.6; cursor: not-allowed; }
.acessos-tabela { max-height: none; }
.acessos-tabela :is(th, td) { vertical-align: middle; }
.acessos-tabela :is(th, .badge, button) { white-space: nowrap; }
.acessos-tabela td small { margin-left: 0.5rem; white-space: nowrap; }
.acessos-email { color: #475569; overflow-wrap: anywhere; }
.acessos-mensagem { font-size: 0.9rem; padding-block: 0.5rem; }
.acessos-mensagem:empty { padding: 0; }
.acessos-mensagem[data-tipo="erro"] { color: #b91c1c; }
.acessos-mensagem[data-tipo="sucesso"] { color: #166534; }

.acessos-switch {
  appearance: none;
  background: #64748b;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  width: 2.4rem;
  height: 1.35rem;
  padding: 0.13rem;
  vertical-align: middle;
}
.acessos-switch::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: #fff;
}
.acessos-switch:checked { justify-content: flex-end; background: #166534; }
.acessos-switch:disabled { opacity: 0.6; cursor: not-allowed; }
.acessos-switch:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 3px; }

.acessos-dialog {
  width: min(44rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  border: 0;
  color: var(--text-main);
  margin: auto;
}
.acessos-dialog::backdrop { background: rgba(15, 23, 42, 0.6); }
.acessos-dialog .modal-header h2 { font-size: 1.1rem; }
.acessos-dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 6rem); }
.acessos-dialog-corpo { overflow: auto; padding: 1rem 1.5rem; }
.acessos-campos { border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.acessos-campos[hidden] { display: none; }
.acessos-permissoes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.acessos-categoria { min-width: 0; }
.acessos-categoria h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.acessos-grupo { min-width: 0; border: 0; border-top: 1px solid var(--border); padding-top: 0.25rem; }
.acessos-grupo + .acessos-grupo { margin-top: 0.45rem; }
.acessos-grupo legend { padding-right: 0.4rem; font-size: 0.8rem; font-weight: 600; color: #475569; }
.acessos-opcao { display: flex; align-items: flex-start; gap: 0.55rem; padding: 0.45rem 0; font-size: 0.9rem; }
.acessos-opcao input { flex: none; margin-top: 0.25rem; accent-color: #1d4ed8; }
.acessos-opcao small { display: block; margin-top: 0.15rem; color: #475569; font-size: 0.8rem; }
.acessos-dialog-acoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.acessos-dialog-acoes .acessos-mensagem:not(:empty) { flex-basis: 100%; }
.acessos-botoes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.acessos-pagina .acessos-botao-senha { background: var(--brand-dark); }
.acessos-pagina .acessos-botao-senha:enabled:hover { background: var(--brand-mid); color: #0f172a; }
.acessos-pagina .acessos-botao-senha:focus-visible { outline: 2px solid var(--brand-mid); outline-offset: 2px; }
.acessos-senha-dialog { width: min(27rem, calc(100% - 2rem)); }
.acessos-senha-campos { display: grid; gap: 0.75rem; border: 0; margin: 1rem 0; }
.acessos-senha-campos .filter-group { margin: 0; }
.acessos-senha-campos [role="status"]:empty { display: none; }

@media (max-width: 1100px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0.65rem 1rem;
  }
  .navbar-menu {
    flex-wrap: wrap;
    height: auto;
  }
  .nav-link {
    padding: 0.55rem 0.45rem;
    border-radius: 6px;
  }
}

@media (max-width: 640px) {
  .navbar-menu { position: relative; width: 100%; }
  .nav-dropdown { position: static; }
  .nav-dropdown-menu { right: 0; }
  .acessos-pagina { padding: 1rem; }
  .acessos-pagina .table-card { padding: 1rem; }
  .acessos-permissoes, .acessos-campos { grid-template-columns: 1fr; }
}
