/*
 * fin_theme.css — CSS Consolidado do Financeiro SED!
 * financeiro.documentos-casamaria.com.br
 * Versão: 1.0.0 — 2026-05-13
 *
 * Inclui:
 *  - Variáveis globais (tokens)
 *  - Topbar SIGEPE fiel (hambúrguer real, ícones, avatar, dropdown)
 *  - Breadcrumb com barra laranja esquerda (padrão SIGEPE)
 *  - Sidebar completa com toggle
 *  - Cards de módulos (SIGEPE tree)
 *  - Status cards
 *  - Utilitários: flash, separadores, footer
 *  - Responsivo mobile
 */

/* ============================================================
   TOKENS
============================================================ */
:root {
    --fin-azul-escuro:  #071d41;
    --fin-azul:         #005c99;
    --fin-laranja:      #e3701c;
    --fin-bg:           #f0f2f5;
    --fin-border:       #dde3ec;
    --fin-sidebar-w:    258px;
    --fin-header-h:     60px;
    --fin-bc-h:         29px;
    --fin-verde:        #15803d;
    --fin-vermelho:     #b91c1c;
    --fin-roxo:         #7c3aed;
    --fin-amarelo:      #92400e;
}

/* ============================================================
   RESET BASE
============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--fin-bg);
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    margin: 0;
    color: #222;
    font-size: 14px;
}

/* ============================================================
   TOPBAR — SIGEPE FIEL
   Estrutura: [hambúrguer laranja] [logo] [spacer] [ícones] [avatar+dropdown]
============================================================ */
.fin-topbar {
    background: var(--fin-azul);
    height: var(--fin-header-h);
    display: flex;
    align-items: stretch;
    box-shadow: 0 2px 6px rgba(0,0,0,.28);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1050;
}

/* --- Hambúrguer: três linhas reais (não caractere) --- */
.fin-toggle {
    background: var(--fin-laranja);
    width: var(--fin-header-h);
    min-width: var(--fin-header-h);
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    flex-shrink: 0;
}
.fin-toggle:hover { background: #c75e15; }
.fin-toggle span {
    display: block;
    width: 22px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}

/* --- Marca (SED! | Financeiro) --- */
.fin-brand {
    display: flex;
    align-items: center;
    padding: 0 18px;
    border-left: 1px solid rgba(255,255,255,.18);
    text-decoration: none;
    gap: 0;
}
.fin-brand-logo {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 1px;
    color: #fff;
    line-height: 1;
}
.fin-brand-sep {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,.3);
    margin: 0 10px;
}
.fin-brand-sub {
    font-weight: 300;
    font-size: .85rem;
    color: rgba(255,255,255,.88);
    line-height: 1.2;
}
.fin-brand-sub strong {
    display: block;
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #fff;
}

/* --- Spacer --- */
.fin-spacer { flex: 1; }

/* --- Ícones do lado direito (casa, sino, ?, perfil) --- */
.fin-topicons {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 8px;
}
.fin-topicon {
    width: 40px;
    height: 40px;
    border-radius: 3px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,.85);
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    transition: background .15s;
}
.fin-topicon:hover { background: rgba(255,255,255,.15); color: #fff; }
.fin-topicon .fin-badge {
    position: absolute;
    top: 5px; right: 4px;
    background: #e3701c;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 1px solid var(--fin-azul);
}

/* --- Área do usuário com dropdown --- */
.fin-user-area {
    display: flex;
    align-items: center;
    padding: 0 12px 0 8px;
    border-left: 1px solid rgba(255,255,255,.15);
    cursor: pointer;
    position: relative;
    gap: 8px;
}
.fin-user-area:hover { background: rgba(255,255,255,.08); }

/* Avatar verde (igual SIGEPE) */
.fin-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #4caf50;
    border: 2px solid rgba(255,255,255,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}
.fin-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.fin-user-nome {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}
.fin-user-perfil {
    font-size: 10px;
    color: rgba(255,255,255,.65);
    font-weight: 400;
}
.fin-caret {
    color: rgba(255,255,255,.6);
    font-size: 10px;
}

/* Dropdown do usuário */
.fin-user-dropdown {
    position: absolute;
    top: calc(var(--fin-header-h) - 2px);
    right: 0;
    background: #fff;
    border: 1px solid var(--fin-border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    min-width: 220px;
    z-index: 2000;
    display: none;
}
.fin-user-area.aberto .fin-user-dropdown { display: block; }
.fin-dropdown-header {
    background: var(--fin-azul-escuro);
    color: #fff;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.fin-dropdown-meta {
    padding: 8px 14px;
    font-size: 11px;
    color: #555;
    border-bottom: 1px solid var(--fin-border);
}
.fin-dropdown-meta span { color: var(--fin-laranja); font-weight: 700; }
.fin-dropdown-title {
    padding: 8px 14px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #888;
    display: flex;
    align-items: center;
    gap: 5px;
}
.fin-dropdown-title i { color: var(--fin-laranja); }
.fin-dropdown-item {
    display: block;
    padding: 7px 14px 7px 22px;
    font-size: 12px;
    color: #333;
    text-decoration: none;
    transition: background .1s;
}
.fin-dropdown-item:hover { background: #f0f4f8; color: var(--fin-azul); }
.fin-dropdown-sair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    background: #b91c1c;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    border-top: 1px solid var(--fin-border);
    transition: background .15s;
    border-radius: 0 0 4px 4px;
}
.fin-dropdown-sair:hover { background: #991b1b; color: #fff; }

/* ============================================================
   BREADCRUMB — barra laranja esquerda, exatamente como SIGEPE
============================================================ */
.fin-breadcrumb {
    background: #fff;
    border-bottom: 1px solid var(--fin-border);
    border-left: 4px solid var(--fin-laranja); /* barra laranja característica SIGEPE */
    padding: 0 16px;
    height: var(--fin-bc-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: var(--fin-header-h);
    left: 0; right: 0;
    z-index: 1040;
    font-size: 11px;
    font-weight: 700;
    /* cor base: cinza — os itens herdam isso */
    color: #555;
    letter-spacing: .5px;
    text-transform: uppercase;
}
/* "VOCÊ ESTÁ AQUI:" — laranja, exatamente como SIGEPE */
.fin-breadcrumb .bc-label {
    color: var(--fin-laranja);
    font-weight: 700;
    margin-right: 2px;
}
/* Itens do caminho (página atual e anteriores) — cinza escuro */
.fin-breadcrumb .bc-item {
    color: #555;
    font-weight: 700;
}
/* Página atual (último item) — cinza um pouco mais escuro */
.fin-breadcrumb .bc-item.atual {
    color: #222;
}
.fin-breadcrumb a.bc-item {
    color: #555;
    text-decoration: none;
}
.fin-breadcrumb a.bc-item:hover { text-decoration: underline; color: var(--fin-azul); }
.fin-breadcrumb .bc-sep { margin: 0 4px; color: #aaa; font-weight: 400; }
.fin-breadcrumb .bc-clock { font-weight: 400; font-size: 11px; color: #888; text-transform: none; letter-spacing: 0; }

/* ============================================================
   SIDEBAR
============================================================ */
.fin-sidebar {
    width: var(--fin-sidebar-w);
    background: var(--fin-azul-escuro);
    position: fixed;
    top: calc(var(--fin-header-h) + var(--fin-bc-h));
    left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .25s ease;
    z-index: 1030;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
    /* Sidebar começa aberta em desktop, fechada no mobile via JS */
}
.fin-sidebar.fechado { transform: translateX(calc(-1 * var(--fin-sidebar-w))); }
.fin-sidebar::-webkit-scrollbar { width: 4px; }
.fin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.fin-sb-grupo {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.3);
    text-transform: uppercase;
    padding: 16px 14px 5px;
}
.fin-sb-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    font-size: 12.5px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .12s, border-color .12s, color .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fin-sb-item:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
    border-left-color: var(--fin-laranja);
}
.fin-sb-item.ativo {
    background: rgba(255,255,255,.11);
    color: #fff;
    border-left-color: var(--fin-laranja);
    font-weight: 600;
}
.fin-sb-item .bi { font-size: 14px; opacity: .75; flex-shrink: 0; }
.fin-sb-badge {
    margin-left: auto;
    background: var(--fin-laranja);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
    flex-shrink: 0;
}
.fin-sb-sep { border-top: 1px solid rgba(255,255,255,.07); margin: 6px 0; }
.fin-sb-rodape {
    padding: 14px;
    font-size: 10px;
    color: rgba(255,255,255,.28);
    line-height: 1.5;
    border-top: 1px solid rgba(255,255,255,.07);
    margin-top: 10px;
}


/* Fallback: links dentro da sidebar sem classe fin-sb-item herdam o mesmo estilo */
.fin-sidebar a:not(.fin-sb-item) {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    font-size: 12.5px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .12s, border-color .12s, color .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fin-sidebar a:not(.fin-sb-item):hover {
    background: rgba(255,255,255,.07);
    color: #fff;
    border-left-color: var(--fin-laranja);
}
/* ============================================================
   OVERLAY MOBILE
============================================================ */
.fin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1020;
}
.fin-overlay.ativo { display: block; }

/* ============================================================
   LAYOUT (page-body + main-content)
============================================================ */
.fin-page-body {
    display: block;
    width: 100%;
    margin-top: calc(var(--fin-header-h) + var(--fin-bc-h));
    min-height: calc(100vh - var(--fin-header-h) - var(--fin-bc-h));
}
.fin-main {
    /* margin-left e width controlados via JS — sem valor fixo aqui */
    padding: 22px 48px 60px;
    transition: margin-left .25s ease, width .25s ease;
    box-sizing: border-box;
}
.fin-main.expandido {
    margin-left: 0 !important;
    width: 100% !important;
}

/* ============================================================
   FLASH / ALERTAS INTERNOS
============================================================ */
.fin-flash {
    padding: 10px 16px;
    border-radius: 3px;
    font-size: 13px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fin-flash:empty { display: none; margin: 0; padding: 0; }
.fin-flash.ok      { background: #dcfce7; border-left: 4px solid var(--fin-verde); color: #14532d; }
.fin-flash.alerta  { background: #fef3c7; border-left: 4px solid #d97706; color: #78350f; }
.fin-flash.erro    { background: #fee2e2; border-left: 4px solid var(--fin-vermelho); color: #7f1d1d; }

/* ============================================================
   HEADER DA ÁREA DE TRABALHO
============================================================ */
.fin-at-header {
    background: #fff;
    border: 1px solid var(--fin-border);
    border-radius: 4px;
    padding: 14px 20px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.fin-at-header h4 {
    font-size: 14px;
    font-weight: 800;
    color: var(--fin-azul-escuro);
    margin: 0 0 3px;
    letter-spacing: .5px;
    text-transform: uppercase;
}
.fin-at-header p { font-size: 11px; color: #888; margin: 0; }
.fin-at-right { text-align: right; font-size: 11px; color: #777; }
.fin-at-mes   { font-size: 13px; font-weight: 700; color: var(--fin-azul); }

/* ============================================================
   CARDS DE STATUS
============================================================ */
.fin-status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.fin-sc {
    background: #fff;
    border: 1px solid var(--fin-border);
    border-top: 3px solid var(--fin-azul);
    border-radius: 4px;
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.fin-sc.laranja  { border-top-color: var(--fin-laranja); }
.fin-sc.verde    { border-top-color: var(--fin-verde); }
.fin-sc.vermelho { border-top-color: var(--fin-vermelho); }
.fin-sc.roxo     { border-top-color: var(--fin-roxo); }
.fin-sc .sc-l  { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: #888; text-transform: uppercase; margin-bottom: 4px; }
.fin-sc .sc-v  { font-size: 24px; font-weight: 800; color: var(--fin-azul-escuro); line-height: 1.1; }
.fin-sc .sc-s  { font-size: 11px; color: #aaa; margin-top: 2px; }
.fin-sc .sc-ico { position: absolute; right: 12px; top: 12px; font-size: 30px; opacity: .06; }

/* ============================================================
   SEÇÕES DE MÓDULOS (SIGEPE tree)
============================================================ */
.fin-mod-section { margin-bottom: 26px; }

.fin-mod-head {
    background: var(--fin-azul-escuro);
    color: #fff;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fin-mod-cod {
    background: var(--fin-laranja);
    padding: 2px 9px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    letter-spacing: .5px;
}
.fin-mod-desc { font-weight: 400; opacity: .7; font-size: 11px; }

.fin-mod-grid {
    background: #fff;
    border: 1px solid var(--fin-border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}
.fin-mod-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    border-right: 1px solid #f0f2f5;
    border-bottom: 1px solid #f0f2f5;
    text-decoration: none;
    color: inherit;
    transition: background .1s;
}
.fin-mod-item:hover { background: #f7f9fc; }
.fin-mod-item:hover .mi-cmd { color: var(--fin-laranja); }
.mi-ico {
    width: 30px; height: 30px;
    border-radius: 3px;
    background: #f0f2f5;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.mi-cmd {
    font-size: 10px; font-weight: 800;
    font-family: 'Courier New', monospace;
    color: var(--fin-azul); letter-spacing: .4px; margin-bottom: 2px;
}
.mi-desc { font-size: 12px; color: #444; line-height: 1.3; }
.mi-badge {
    margin-left: auto; align-self: flex-start; flex-shrink: 0;
    font-size: 10px; padding: 2px 6px; border-radius: 2px; font-weight: 700;
}
.b-novo     { background: #dcfce7; color: #15803d; }
.b-alerta   { background: #fef3c7; color: #92400e; }
.b-info     { background: #dbeafe; color: #1d4ed8; }
.b-em-breve { background: #f1f5f9; color: #94a3b8; }

/* ============================================================
   BOXES DA LINHA INFERIOR
============================================================ */
.fin-bottom-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 20px; }

.fin-box {
    background: #fff;
    border: 1px solid var(--fin-border);
    border-radius: 4px;
    overflow: hidden;
}
.fin-box-head {
    background: #f8f9fa;
    border-bottom: 1px solid var(--fin-border);
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #444;
    display: flex; align-items: center; gap: 6px;
}
.fin-ativ-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; border-bottom: 1px solid #f5f6f8; font-size: 12px;
}
.fin-ativ-row:last-child { border-bottom: none; }
.fin-ativ-ico {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 13px;
}
.fin-ativ-txt { flex: 1; line-height: 1.3; }
.fin-ativ-txt strong { display: block; color: #222; font-size: 12px; }
.fin-ativ-txt span   { color: #888; font-size: 11px; }
.fin-ativ-hora { font-size: 10px; color: #bbb; white-space: nowrap; }

.fin-rapido-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px; border-bottom: 1px solid #f0f2f5;
    text-decoration: none; color: #333; font-size: 12.5px;
    transition: background .1s;
}
.fin-rapido-item:last-child { border-bottom: none; }
.fin-rapido-item:hover { background: #f7f9fc; }
.fin-rapido-item .bi { font-size: 15px; color: var(--fin-azul); flex-shrink: 0; }

/* ============================================================
   LOGIN / TOTP — páginas de acesso
============================================================ */
.fin-login-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: calc(var(--fin-header-h) + var(--fin-bc-h) + 30px);
    padding-bottom: 40px;
}
.fin-login-card {
    background: #fff;
    border-top: 5px solid var(--fin-azul);
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    width: 100%;
    max-width: 400px;
    padding: 32px 30px 28px;
}
.fin-login-card.orange-top { border-top-color: var(--fin-laranja); }
.fin-login-logo { text-align: center; margin-bottom: 22px; }
.fin-login-logo .sys-title { font-size: 21px; font-weight: 800; color: var(--fin-azul-escuro); margin-top: 8px; letter-spacing: .5px; }
.fin-login-logo .sys-sub   { font-size: 12px; color: #888; margin-top: 2px; }
.fin-login-logo .sys-badge {
    display: inline-block; background: var(--fin-azul-escuro); color: #fff;
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
    padding: 3px 12px; border-radius: 2px; text-transform: uppercase; margin-top: 8px;
}
.fin-form-label { font-size: 11px; font-weight: 700; color: var(--fin-azul-escuro); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; display: block; }
.fin-form-control {
    width: 100%; border-radius: 3px; font-size: 14px;
    border: 1px solid #c9d0d8; padding: 8px 10px;
    outline: none; transition: border-color .15s;
}
.fin-form-control:focus { border-color: var(--fin-azul); box-shadow: 0 0 0 2px rgba(0,92,153,.15); }
.fin-btn-submit {
    background: var(--fin-azul); color: #fff; border: none;
    border-radius: 3px; font-weight: 700; font-size: 14px;
    padding: 11px; width: 100%; cursor: pointer;
    transition: background .15s;
}
.fin-btn-submit:hover { background: var(--fin-azul-escuro); }

/* Campos OTP */
.fin-otp-grid { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.fin-otp-digit {
    width: 44px; height: 52px; text-align: center;
    font-size: 22px; font-weight: 700;
    border: 2px solid #c9d0d8; border-radius: 4px;
    outline: none;
    font-family: 'Courier New', monospace;
    color: var(--fin-azul-escuro);
    transition: border-color .15s;
}
.fin-otp-digit:focus { border-color: var(--fin-azul); }
.fin-otp-digit.filled { border-color: var(--fin-laranja); background: #fff9f5; }

/* ============================================================
   GOV FOOTER
============================================================ */
.fin-gov-footer {
    background: var(--fin-azul-escuro);
    color: rgba(255,255,255,.45);
    text-align: center;
    font-size: 11px;
    padding: 9px;
}

/* ============================================================
   UTILITÁRIOS
============================================================ */
.fin-sep { border-top: 1px solid var(--fin-border); margin: 18px 0; }
.fin-text-muted  { color: #888; }
.fin-text-laranja { color: var(--fin-laranja); }
.fin-font-mono { font-family: 'Courier New', monospace; }

/* ============================================================
   RESPONSIVO
============================================================ */
@media (max-width: 900px) {
    .fin-sidebar { transform: translateX(calc(-1 * var(--fin-sidebar-w))); }
    .fin-main    { margin-left: 0 !important; width: 100% !important; padding: 16px 24px 40px; }
    .fin-status-grid { grid-template-columns: repeat(2, 1fr); }
    .fin-mod-grid    { grid-template-columns: repeat(2, 1fr); }
    .fin-bottom-grid { grid-template-columns: 1fr; }
    .fin-at-header   { flex-direction: column; align-items: flex-start; gap: 8px; }
    .fin-user-info   { display: none; }
    .fin-topicons    { display: none; }
}
@media (max-width: 500px) {
    .fin-status-grid { grid-template-columns: 1fr; }
    .fin-mod-grid    { grid-template-columns: 1fr; }
}

/* ============================================================
   JS HELPER CLASSES
============================================================ */
.fin-sidebar.aberto { transform: translateX(0); }