/* ============ Money Dashboard - Tema Dark ============ */
:root {
    --bg: #0a0a0c;
    --bg-card: #141417;
    --bg-card-2: #1b1b1f;
    --bg-hover: #222228;
    --border: #26262c;
    --text: #f0f0f2;
    --text-muted: #8b8b94;
    --green: #22c55e;
    --red: #ef4444;
    --radius: 18px;
}

/* Tema EMPRESA (verde) */
body.theme-empresa {
    --accent: #a3e635;
    --accent-soft: rgba(163, 230, 53, 0.12);
    --accent-dark: #65a30d;
    --accent-contrast: #101400;
    --glow: rgba(163, 230, 53, 0.25);
}

/* Tema PESSOAL (azul) */
body.theme-pessoal {
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --accent-dark: #1d4ed8;
    --accent-contrast: #ffffff;
    --glow: rgba(59, 130, 246, 0.3);
}

/* ============ MODO CLARO (sobrescreve só as cores neutras; o accent continua) ============ */
body.claro {
    --bg: #f4f5f7;
    --bg-card: #ffffff;
    --bg-card-2: #f2f3f6;
    --bg-hover: #e9ebef;
    --border: #dfe3e8;
    --text: #15161a;
    --text-muted: #626875;
}
body.claro .card-dark,
body.claro .kpi-card,
body.claro .sidebar,
body.claro .mobile-topbar { box-shadow: 0 1px 3px rgba(16,24,40,.06); }
body.claro .btn-close { filter: none; }
body.claro .table-dark-custom tbody tr:hover td { background: var(--bg-hover); }
body.claro .modal-content { box-shadow: 0 20px 60px rgba(16,24,40,.18); }

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
}

/* ============ Layout ============ */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 28px 32px;
}

/* Barra superior e backdrop só aparecem no mobile */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.hamburger { background: transparent; border: none; color: var(--text); font-size: 1.6rem; cursor: pointer; padding: 2px 8px; line-height: 1; }
.brand-mobile { font-size: 1.2rem; font-weight: 800; }
.brand-mobile span { color: var(--accent); }

@media (max-width: 991px) {
    .sidebar {
        width: 270px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 1100;
        box-shadow: 0 0 40px rgba(0,0,0,.5);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; padding: 72px 16px 24px; }
    .app-wrapper { flex-direction: column; }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 56px;
        padding: 0 14px;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        z-index: 1090;
    }
    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.55);
        z-index: 1095;
    }
}

/* Telas pequenas (celular): reduz fontes dos KPIs para não quebrar */
@media (max-width: 575px) {
    .kpi-value { font-size: 1.45rem; }
    .kpi-value.small { font-size: 1.15rem; }
    .kpi-label { font-size: 0.68rem; letter-spacing: 0.3px; }
    .kpi-sub { font-size: 0.74rem; }
    .kpi-card { padding: 15px; }
    .page-title { font-size: 1.3rem; }
}
@media (max-width: 380px) {
    .kpi-value { font-size: 1.25rem; }
    .kpi-card { padding: 13px; }
}
@media (max-width: 575px) {
    .dash-head .btn-accent { padding: 8px 14px; font-size: .85rem; white-space: nowrap; }
    .dash-head .page-title { margin-bottom: 2px; }
    .month-nav { padding: 5px 8px; }
}

.brand {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    padding: 0 12px 20px;
}
.brand span { color: var(--accent); }

.sidebar .nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 16px 12px 8px;
}

.sidebar .nav-link {
    color: var(--text-muted);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all .15s ease;
}
.sidebar .nav-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar .nav-link.active {
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 700;
    box-shadow: 0 4px 18px var(--glow);
}

/* Seletor de contexto Empresa/Pessoal */
.context-switch {
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px;
    margin: 0 4px 8px;
}
.context-switch a {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-muted);
    transition: all .15s ease;
}
.context-switch a.active-empresa { background: #a3e635; color: #101400; }
.context-switch a.active-pessoal { background: #3b82f6; color: #fff; }

/* Aviso de fatura fechada em aberto (dashboard) */
.aviso-fatura {
    background: rgba(234,179,8,.08);
    border: 1px solid rgba(234,179,8,.35);
    border-radius: 14px;
    padding: 16px 18px;
}
.aviso-fatura-ic {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 11px; background: rgba(234,179,8,.16); color: #facc15;
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.aviso-fatura-lista { display: flex; flex-direction: column; margin-top: 6px; }
.aviso-fatura-linha {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 10px 0; border-bottom: 1px solid rgba(234,179,8,.18); font-size: .88rem;
}
.aviso-fatura-linha:last-child { border-bottom: 0; }
.aviso-fatura-nome { color: var(--text-muted); flex: 1; min-width: 160px; }
.aviso-fatura-valor { white-space: nowrap; }
.aviso-fatura-btn { padding: 5px 14px !important; font-size: .78rem !important; flex-shrink: 0; }
@media (max-width: 575px) {
    .aviso-fatura { padding: 14px; }
    .aviso-fatura-linha { gap: 8px; }
    .aviso-fatura-nome { min-width: 100%; }
}

/* Fatura do mês em destaque (Contas & Cartões) */
.fatura-atual {
    background: radial-gradient(120% 160% at 0% 0%, var(--accent-soft) 0%, var(--bg-card-2) 65%);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
}
.fatura-itens { display: flex; flex-direction: column; }
.fatura-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 2px; border-bottom: 1px solid var(--border); font-size: .88rem;
}
.fatura-item:last-child { border-bottom: 0; }
.fatura-item-data { color: var(--text-muted); font-size: .8rem; flex-shrink: 0; min-width: 42px; }
.fatura-item-desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fatura-item-valor { font-weight: 700; white-space: nowrap; margin-left: auto; }
.fatura-item-total { border-top: 2px solid var(--border); border-bottom: 0; margin-top: 4px; padding-top: 12px; }

/* Filtro de dias (7d/14d/30d) do gráfico de entradas x saídas */
.dia-filtro { display: flex; background: var(--bg-card-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; flex-shrink: 0; }
.dia-filtro a { padding: 5px 12px; border-radius: 7px; font-size: .78rem; font-weight: 700; color: var(--text-muted); text-decoration: none; transition: all .15s ease; }
.dia-filtro a:hover:not(.active) { color: var(--text); }
.dia-filtro a.active { background: var(--accent); color: var(--accent-contrast); }

/* ============ Cards ============ */
.card-dark {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    height: 100%;
    transition: border-color .2s ease, transform .15s ease;
}
.kpi-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.kpi-card.kpi-destaque {
    background: radial-gradient(120% 160% at 0% 0%, var(--accent-soft) 0%, var(--bg-card) 60%);
    border-color: var(--accent);
}
.kpi-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.kpi-icon {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; white-space: nowrap; max-width: 100%; }
.kpi-value.small { font-size: 1.35rem; }
.kpi-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
.kpi-sub.d-flex { flex-wrap: wrap; row-gap: 4px; }

.badge-var {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    line-height: 1;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 20px;
}
.badge-var i { font-size: 0.8rem; }
.badge-var.up   { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-var.down { background: rgba(239,68,68,.15);  color: var(--red); }
.badge-var.flat { background: var(--bg-hover); color: var(--text-muted); }

.text-positivo { color: var(--green) !important; }
.text-negativo { color: var(--red) !important; }
.text-accent { color: var(--accent) !important; }

/* ============ Cabeçalho da página ============ */
.page-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: 0.88rem; }

/* ============ Tabelas ============ */
.table-dark-custom { color: var(--text); margin: 0; }
.table-dark-custom th {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    border-bottom: 1px solid var(--border) !important;
    background: transparent;
    padding: 12px 14px;
    white-space: nowrap;
}
.table-dark-custom td {
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    padding: 13px 14px;
    font-size: 0.9rem;
    vertical-align: middle;
}
.table-dark-custom tbody tr:hover td { background: var(--bg-hover); }
.table-dark-custom tbody tr:last-child td { border-bottom: 0; }

.cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: 20px;
}

.status-badge { font-size: 0.74rem; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.status-aprovada    { background: rgba(34,197,94,.15);  color: #4ade80; }
.status-pendente    { background: rgba(234,179,8,.15);  color: #facc15; }
.status-reembolsada { background: rgba(239,68,68,.15);  color: #f87171; }
.status-cancelada   { background: rgba(148,163,184,.15);color: #94a3b8; }
.status-chargeback  { background: rgba(239,68,68,.25);  color: #ef4444; }

/* ============ Formulários ============ */
.form-control, .form-select {
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 9px 14px;
}
.form-control:focus, .form-select:focus {
    background: var(--bg-card-2);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: #5a5a64; }
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.form-select option { background: var(--bg-card-2); color: var(--text); }

.btn-accent {
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 700;
    border-radius: 12px;
    border: none;
    padding: 9px 20px;
}
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

.btn-ghost {
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    font-weight: 600;
    padding: 9px 16px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--accent); }

.btn-icon-sm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 8px;
}
.btn-icon-sm:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ============ Modais ============ */
/* Sempre acima da topbar/sidebar mobile (1090/1095/1100), pra nao ficar cortado */
.modal-backdrop { z-index: 1150; }
.modal { z-index: 1160; }
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
}
.modal-header, .modal-footer { border-color: var(--border); flex-shrink: 0; }
.modal-body { overflow-y: auto; }
.btn-close { filter: invert(1); }

/* ============ Filtro de mês ============ */
.month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px 10px;
}
.month-nav a { color: var(--text-muted); text-decoration: none; padding: 4px 8px; border-radius: 8px; }
.month-nav a:hover { color: var(--accent); background: var(--bg-hover); }
.month-nav .month-label { font-weight: 700; font-size: 0.9rem; min-width: 150px; text-align: center; }
@media (max-width: 575px) {
    .month-nav .month-label { min-width: 0; font-size: .82rem; padding: 0 2px; }
}

/* ============ Misc ============ */
.section-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.chart-container { position: relative; width: 100%; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: 10px; opacity: .5; }

.alert-dark-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #4ade80; border-radius: 12px; }
.alert-dark-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #f87171; border-radius: 12px; }

/* ============ Caixa de usuário ============ */
.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 12px;
}
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-contrast);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}
.user-name { font-weight: 700; font-size: 0.88rem; }
.user-plan { font-size: 0.72rem; color: var(--text-muted); }

/* ============ Aviso de nova versão (PWA) ============ */
.pwa-update-toast {
    position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
    z-index: 2000; display: flex; align-items: center; gap: 14px;
    background: var(--bg-card); border: 1px solid var(--accent); color: var(--text);
    padding: 12px 14px 12px 18px; border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0,0,0,.4); font-size: .9rem; font-weight: 600;
    animation: pwaToastIn .3s ease; max-width: calc(100vw - 32px);
}
.pwa-update-toast button {
    background: var(--accent); color: var(--accent-contrast); border: none;
    border-radius: 10px; padding: 8px 16px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
@keyframes pwaToastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ Interruptor de tema (claro/escuro) ============ */
.theme-switch {
    --w: 52px; --h: 28px;
    position: relative;
    width: var(--w); height: var(--h);
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background .3s ease, border-color .3s ease;
    overflow: hidden;
}
.theme-switch .knob {
    position: absolute;
    top: 50%; left: 3px;
    width: calc(var(--h) - 8px); height: calc(var(--h) - 8px);
    border-radius: 50%;
    background: #fff;
    transform: translate(0, -50%);
    transition: transform .32s cubic-bezier(.34,1.56,.64,1), background .3s ease;
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; line-height: 1;
    box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
/* Estado CLARO: knob vai para a direita, trilho fica azul */
body.claro .theme-switch { background: var(--accent); border-color: var(--accent); }
body.claro .theme-switch .knob { transform: translate(calc(var(--w) - var(--h) - 0px), -50%); background: #fff; color: #f59e0b; }
.theme-switch .knob .bi-moon-stars { color: #4b5563; }
.theme-switch:hover { filter: brightness(1.08); }

/* ============ Login ============ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 36px 32px;
}
.auth-brand { font-size: 1.8rem; font-weight: 800; text-align: center; margin-bottom: 4px; }
.auth-brand span { color: var(--accent); }

/* ============ Seletor de emoji/ícone ============ */
.picker-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.picker-tab {
    flex: 1; text-align: center; padding: 7px; border-radius: 10px; cursor: pointer;
    background: var(--bg-card-2); border: 1px solid var(--border); color: var(--text-muted);
    font-size: 0.82rem; font-weight: 600;
}
.picker-tab.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
}
.picker-item {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer; font-size: 1.15rem;
    background: transparent; border: 1px solid transparent; color: var(--text);
}
.picker-item:hover { background: var(--bg-hover); }
.picker-item.sel { background: var(--accent-soft); border-color: var(--accent); }
.picker-preview {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; flex-shrink: 0;
}

/* ============ Lançamento rápido (FAB) ============ */
.fab {
    position: fixed; right: 26px; bottom: 26px;
    width: 62px; height: 62px; border-radius: 50%;
    border: none; background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff; font-size: 1.7rem; cursor: pointer; z-index: 1045;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 28px var(--glow);
    transition: transform .15s ease;
}
.fab:hover { transform: translateY(-3px) scale(1.03); }
.fab:active { transform: scale(.97); }
@media (max-width: 991px) { .fab { right: 18px; bottom: 18px; width: 58px; height: 58px; } }

.rap-toggle { display: flex; background: var(--bg-card-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.rap-toggle button {
    flex: 1; padding: 9px; border: none; background: transparent; color: var(--text-muted);
    font-weight: 700; border-radius: 9px; cursor: pointer; font-size: .9rem;
}
.rap-toggle button.on-saida { background: var(--red); color: #fff; }
.rap-toggle button.on-entrada { background: var(--green); color: #fff; }

.rap-value-wrap { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0 18px; }
.rap-value-wrap span { font-size: 1.6rem; font-weight: 700; color: var(--text-muted); }
.rap-value {
    width: 60%; background: transparent; border: none; outline: none;
    color: var(--text); font-size: 2.6rem; font-weight: 800; text-align: center;
    border-bottom: 2px solid var(--border); padding: 4px 0;
}
.rap-value:focus { border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 168px; overflow-y: auto; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 13px; border-radius: 22px; cursor: pointer;
    background: var(--bg-card-2); border: 1.5px solid var(--border); color: var(--text);
    font-size: .86rem; font-weight: 600; transition: all .12s ease;
}
.chip:hover { border-color: var(--accent); }
.chip.sel { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rap-mais { color: var(--text-muted); cursor: pointer; font-size: .85rem; font-weight: 600; user-select: none; }
.rap-mais:hover { color: var(--accent); }

/* ============ Barras de progresso (limite/orçamento) ============ */
.barra-fina { height: 8px; background: var(--bg-card-2); border-radius: 20px; overflow: hidden; }
.barra-fina > div { height: 100%; border-radius: 20px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }
