:root {
    /* Cores do Sistema (Estilo Modern/Clean) */
    --primary: #3b8b9b;
    --primary-dark: #2d6a77;
    --sidebar-bg: #111827;
    --sidebar-hover: #1f2937;
    --bg-app: #f9fafb;
    --white: #ffffff;

    /* Cores de Feedback (Essencial para Finanças) */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Escala de Cinzas */
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;

    /* Dimensões */
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --radius: 8px;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);

    /* Tipografia */
    --font-family: 'Inter', -apple-system, sans-serif;
}

.p-0 {
    padding: 0 !important;
}

.py-0 {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.m-0 {
    margin: 0 !important;
}

.my-0 {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mt-20 {
    margin-top: 20px;
}

.w-100 {
    width: 100% !important;
}

.bg-dark {
    background-color: var(--sidebar-bg) !important;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-white {
    color: #fff !important;
}

.text-dark {
    color: var(--text-main) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-nowrap {
    text-wrap-mode: nowrap !important;
}

.flex-nowrap {
    flex-wrap: nowrap !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.d-inline {
    display: inline !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

.flex-column {
    flex-direction: column !important;
}

.align-items-center {
    align-items: center !important;
}

.align-items-end {
    align-items: end !important;
}

.btn-loading {
    opacity: 0.6;
    pointer-events: none;
}

* {
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--bg-app);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* Define a largura da barra (fina para não ocupar espaço visual) */
.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

/* O "trilho" por onde a barra corre */
.sidebar-menu::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

/* O "polegar" (a parte que arrasta) */
.sidebar-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    /* Cor suave que combina com as bordas do seu layout */
    border-radius: 10px;
    transition: background 0.3s ease;
}

/* Efeito de hover para indicar interatividade */
.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- Sidebar --- */
.app-sidebar {
    position: fixed;
    width: var(--sidebar-width);
    height: 100%;
    background: var(--sidebar-bg);
    color: var(--white);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 32px;
    padding-left: 12px;
    display: flex;
    align-items: center;
    color: var(--white);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: auto;
}

.sidebar-link {
    color: #9ca3af;
    text-decoration: none;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--white);
}

.sidebar-link.active {
    background: var(--primary);
    color: var(--white);
}

/* Títulos de seção na sidebar */
.sidebar-section-title {
    padding: 20px 12px 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #4b5563;
    /* Cinza médio para não brigar com os links */
    display: block;
}

/* Espaçamento dos ícones nos links */
.sidebar-link i {
    margin-right: 10px;
    font-style: normal;
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Melhoria no estado Ativo */
.sidebar-link.active {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Navbar Layout */
.navbar-right {
    display: flex;
    align-items: center;
}

/* --- Navbar --- */
.app-navbar {
    height: var(--navbar-height);
    margin-left: var(--sidebar-width);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* --- Conteúdo Principal --- */
.app-content {
    margin-left: var(--sidebar-width);
    padding: 32px;
    max-width: calc(100% - var(--sidebar-width));
    /* Evita que o dashboard "estique" demais em telas ultrawide */
}

/* --- Sugestões para Cards de Finanças --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.amount-up {
    color: var(--success);
    font-weight: 600;
}

.amount-down {
    color: var(--danger);
    font-weight: 600;
}

/* --- Cabeçalho de Página --- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px 0;
}

.page-header p {
    margin-bottom: 0px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}

/* --- Cards de Conteúdo --- */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* --- Tabelas de Dados Financeiros --- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    background: #f9fafb;
    /* Sutil destaque no header */
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    color: var(--text-main);
}

.table tr:hover td {
    background-color: #fcfcfd;
    /* Efeito hover na linha */
}

/* --- Botões --- */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f3f4f6;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

/* --- Formulários --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* Espaço entre label e input */
}

.form-group-full {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.875rem;
    color: var(--text-main);
    font-weight: 500;
}

.form-control {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 14px;
    font-size: 14px;
    color: var(--text-main);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control::placeholder {
    color: #9ca3af;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 139, 155, 0.1);
    /* Ring de foco sutil */
}

textarea.form-control {
    height: auto;
    min-height: 100px;
    padding: 12px;
    resize: vertical;
}

.form-actions {
    margin-top: 32px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Permite um grid de 3 colunas bem distribuído no Desktop */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* No mobile, reseta tudo para 1 coluna e anula as expansões de coluna (span) */
@media (max-width: 768px) {

    .form-grid-4,
    .form-grid-3 {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .form-grid .form-group,
    .form-grid-4 .form-group,
    .form-grid-3 .form-group {
        grid-column: auto !important;
    }
}

/* --- Badges (Status de Pagamento) --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary,
.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
    /* Verde mais escuro para acessibilidade */
    border: 1px solid #bbf7d0;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fde68a;
}

/* --- Ações na Tabela --- */
.table-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: end;
}

.btn-table {
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: filter 0.2s;
}

.btn-table:hover {
    filter: brightness(0.95);
}

.btn-edit {
    background: #eff6ff;
    color: #2563eb;
}

.btn-success {
    background: #dcfce7;
    color: #166534;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* --- Dashboard Widgets --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    /* Responsivo */
    gap: 12px 24px;
}

.dashboard-card {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    ;
}

.dashboard-card span {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.dashboard-card strong {
    font-size: 1.75rem;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

/* Income */
.dashboard-card:nth-child(2) strong {
    color: var(--danger);
}

/* Expenses */

/* Layout para as tabelas ficarem lado a lado em telas grandes */
.dashboard-tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* Títulos das Tabelas dentro de Cards */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

/* Estilo para os cards de pendência (menos chamativos que os principais) */
.secondary-card {
    padding: 16px 20px;
    background: #f8fafc;
}

.text-small {
    font-size: 1.25rem !important;
}

/* Bordas coloridas para os cards principais para identificação rápida */
.border-success {
    border-top: 4px solid var(--success);
}

.border-danger {
    border-top: 4px solid var(--danger);
}

.border-primary {
    border-top: 4px solid var(--primary);
}

/* Alinhamento de valores */
.text-right {
    text-align: right;
}

/* --- Navegação por Mês --- */
.month-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border: 1px solid var(--border);
    margin-bottom: 32px;
    margin-top: -16px;
    padding: 5px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    gap: 15px;
    min-width: 12rem;
}

.month-navigation strong {
    font-size: 1.1rem;
    color: var(--text-main);
    text-transform: capitalize;
}

/* --- Filtros --- */
.mb-20 {
    margin-bottom: 20px;
}

/* Container de Filtros */
.filters-wrapper {
    background: #f9fafb;
    /* Fundo levemente diferente do card para destacar */
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.filters-grid {
    display: grid;
    /* Grid dinâmico: se ajusta conforme o tamanho da tela */
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    align-items: flex-end;
    /* Alinha labels e inputs na base */
}

/* Ajuste nos grupos de formulário dentro dos filtros */
.filters-grid .form-group label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.filters-grid .form-control {
    height: 40px;
    /* Um pouco mais compacto */
    background-color: var(--white);
    border-color: #d1d5db;
    font-weight: 500;
}

/* Área de botões alinhada */
.filters-actions {
    display: flex;
    gap: 10px;
    /* Faz com que os botões ocupem o espaço restante ou fiquem alinhados */
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Botão de filtrar com destaque */
.btn-filter {
    background: var(--primary);
    color: white;
    padding: 0 24px;
    height: 40px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-filter:hover {
    background: var(--primary-dark);
}


@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }
}

.btn-clear {
    background: transparent;
    color: var(--text-muted);
    padding: 0 16px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-size: 14px;
    border-radius: 8px;
}

.btn-clear:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

/* --- Alertas de Topo (Inline) --- */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.alert-success {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

/* --- Sistema de Modais --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    /* Backdrop ligeiramente mais escuro e moderno */
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    /* Suaviza o fundo atrás do modal */
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--white);
    width: 100%;
    max-width: 640px;
    /* Reduzido de 820px para um visual de formulário mais elegante */
    border-radius: 12px;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border);
}

.modal-box.modal-box-lg {
    max-width: 920px !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

.modal-box-sm {
    max-width: 460px;
}

/* --- Estados Vazios (Empty State) --- */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    max-width: 420px;
    margin: 0 auto;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: inline-block;
}

.empty-state h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* --- Notificações Flutuantes (Toast) --- */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 320px;
    max-width: 400px;
    padding: 14px 20px;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 500;
    font-size: 0.875rem;
    z-index: 9999;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;

    /* Dispara o Fade In assim que o elemento surge na tela */
    animation: fadeIn 0.3s ease forwards;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast.hide {
    animation: fadeOut 0.3s ease forwards;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 320px;
    max-width: 400px;
    padding: 14px 20px;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 500;
    font-size: 0.875rem;
    z-index: 9999;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;

    /* Dispara o Fade In assim que o elemento surge na tela */
    animation: fadeIn 0.3s ease forwards;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

/* Classe que o JavaScript vai injetar para sumir suavemente */
.toast.hide {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* --- Blocos de Ações Rápidas do Dashboard --- */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    /* Responsivo caso mude o tamanho da tela */
    gap: 16px;
}

/* --- Ajustes nos Cards de Ação Rápida --- */
.quick-action-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.quick-action-card .icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.icon-income {
    background: #eff6ff;
    color: #2563eb;
}

.icon-expense {
    background: #f3e8ff;
    color: #9333ea;
}

.icon-transfer {
    background: #e0f2fe;
    color: #0369a1;
}

.icon-list {
    background: #f1f5f9;
    color: #475569;
}

.quick-action-card strong {
    font-size: 0.875rem;
    font-weight: 600;
}


.quick-action-card .arrow-right {
    margin-left: auto;
    font-style: normal;
    font-weight: bold;
    color: var(--text-muted);
    opacity: 0.4;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.quick-action-card:hover .arrow-right {
    opacity: 1 !important;
    animation: pulse-right 700ms infinite, pulse-fading 700ms infinite;
}

.quick-action-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

i.pulse-right:hover,
.pulse-right:hover i.pulse {
    animation: fade-in 700ms ease-in, pulse-right 700ms infinite;
}

@keyframes pulse-right {
    0% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(3px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes pulse-fading {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes fade-in {
    0% {
        opacity: 0;
    }

    65% {
        opacity: 1;
    }

    100% {
        opacity: 1;
    }
}

/* --- Grid de Atalhos / Widgets inferiores --- */
.dashboard-shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.shortcut-card {
    padding: 0 !important;
    overflow: hidden;
}

.card-header,
.shortcut-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.card-header h2,
.shortcut-header h2 {
    font-size: 0.875rem !important;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0;
}

.card-header a,
.shortcut-header a {
    font-size: 0.8rem !important;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.card-header a:hover,
.shortcut-header a:hover {
    text-decoration: underline;
}

.shortcut-item {
    padding: 14px 20px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-item strong {
    display: block;
    font-size: 0.875rem;
    color: var(--text-main);
    font-weight: 500;
}

.shortcut-item small {
    display: block;
    color: var(--text-muted);
    margin-top: 2px;
    font-size: 0.75rem;
}

.shortcut-item span {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* ==========================================================================
   MELHORIAS DE RESPONSIVIDADE (MOBILE & TABLET)
   ========================================================================== */

/* Botão do Menu Hambúrguer (Escondido por padrão no Desktop) */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    color: var(--text-main);
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .hide-sm {
        display: none;
    }

    /* 1. Esconder a Sidebar e prepará-la como um Drawer/Overlay */
    .app-sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Quando a Sidebar estiver aberta no mobile */
    .app-sidebar.active {
        transform: translateX(0);
    }

    /* 2. Remover os recuos fixos esquerdos para ocupar a tela cheia */
    .app-navbar {
        margin-left: 0 !important;
        padding: 0 16px;
    }

    .app-content {
        margin-left: 0 !important;
        max-width: 100% !important;
        padding: 16px;
        /* Reduz padding para ganhar área útil */
    }

    /* Exibir o botão hambúrguer na Navbar */
    .menu-toggle {
        display: inline-flex;
    }

    /* 3. Ajustar Grids e Formulários para ficarem em 1 coluna */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .form-group-full {
        grid-column: span 1 !important;
    }

    .form-actions {
        flex-direction: column-reverse;
        /* Botão principal fica no topo no mobile */
        gap: 8px;
    }

    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
        /* Botões ocupam largura total para facilitar o clique */
    }

    /* 4. Grids de Widgets do Dashboard */
    .dashboard-tables-grid,
    .dashboard-shortcuts {
        grid-template-columns: 1fr !important;
        gap: 0 16px;
    }

    /* Quick Actions (Atalhos de Receita/Despesa) */
    .quick-actions {
        grid-template-columns: 1fr !important;
        /* Fica em 2 colunas organizadas */
        gap: 10px;
    }

    .quick-action-card {
        padding: 10px;
    }

    .quick-action-card strong {
        font-size: 0.8rem;
    }

    /* 5. Proteção de Tabelas (Scroll Horizontal) */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0;
    }

    /* Garante que os botões de ação na tabela fiquem confortáveis para toque */
    .table-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    table .table-actions {
        flex-wrap: nowrap;
    }

    /* table .table-actions a,
    table .table-actions button {
        padding-top: 20px;
        padding-bottom: 20px;
    } */

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .page-header .table-actions button {
        flex: 1 0 10rem;
    }

    .month-navigation {
        width: 100%;
    }
}

/* Overlay de fundo quando a sidebar mobile estiver ativa */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

.space-switcher {
    min-width: 220px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.space-switcher select {
    height: 38px;
    border-color: var(--sidebar-bg);
}

/* NEW */
.activity-feed {
    padding: 0;
    overflow: hidden;
}

.activity-item {
    display: flex;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.2rem;
}

.activity-item p {
    margin: 4px 0;
    color: var(--text-muted);
    font-size: .9rem;
}

.activity-item small {
    color: var(--text-muted);
    font-size: .8rem;
}

.activity-item-link {
    text-decoration: none;
    color: inherit;
}

.activity-item-link:hover {
    background: var(--bg-app);
}

.activity-feed {
    padding: 0;
    overflow: hidden;
}

.activity-date-label {
    padding: 12px 20px;
    background: var(--bg-app);
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.activity-item {
    display: flex;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item-link {
    text-decoration: none;
    color: inherit;
}

.activity-item-link:hover {
    background: var(--bg-app);
}

.activity-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 999px;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.2rem;
}

.activity-content p {
    margin: 4px 0;
    color: var(--text-main);
    font-size: .9rem;
}

.activity-content small {
    color: var(--text-muted);
    font-size: .8rem;
}


/* Customização Avançada da Navegação de Mês */
.month-selector {
    display: inline-flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    /* Cantos arredondados estilo pílula */
    padding: 4px 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    gap: 4px;
}

.month-selector .btn-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s, color 0.2s;
}

.month-selector .btn-nav:hover {
    background: var(--bg-app);
    color: var(--primary);
}

.month-selector .month-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: capitalize;
    padding: 0 12px;
    min-width: 90px;
    text-align: center;
    user-select: none;
}

/* Garante o empilhamento correto se a tela do celular for muito estreita */
@media (max-width: 576px) {
    .page-header-actions {
        display: flex;
        flex-direction: column-reverse;
        width: 100%;
        gap: 12px;
    }

    .month-selector {
        width: 100%;
        justify-content: space-between;
    }

    .page-header-actions .btn-primary {
        width: 100%;
        text-align: center;
    }
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 139, 155, 0.2);
}

.modal-box {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}