/* =============================================
   CONTROLE DE GASTOS - DESIGN SYSTEM
   ============================================= */

:root {
    /* Cores Primárias */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;

    /* Cores de Estado */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Neutros */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 60px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* Superfícies */
    --surface: #ffffff;
    --surface-hover: #f8fafc;

    /* Transições */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   RESET & BASE
   ============================================= */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition-slow);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-info-display {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.875rem;
    font-weight: 500;
    overflow: hidden;
    min-width: 0;
}

.user-info-display span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info-display svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.logout-button {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.logout-button:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* =============================================
   MOBILE HEADER
   ============================================= */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 16px;
    align-items: center;
    gap: 12px;
    z-index: 999;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--gray-700);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.menu-toggle:hover {
    background: var(--gray-100);
}

.mobile-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gray-900);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}

/* =============================================
   MAIN CONTENT
   ============================================= */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 28px;
    min-height: 100vh;
    max-width: 100%;
    overflow-x: hidden;
}

/* =============================================
   PAGES
   ============================================= */

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.03em;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* =============================================
   STATS CARDS
   ============================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-total .stat-icon {
    background: var(--primary-50);
    color: var(--primary);
}

.stat-card-fixos .stat-icon {
    background: var(--success-light);
    color: var(--success);
}

.stat-card-parcelados .stat-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card-mensais .stat-icon {
    background: var(--info-light);
    color: var(--info);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    margin-top: 2px;
    word-break: break-word;
}

.stat-count {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 2px;
}

/* =============================================
   CARDS
   ============================================= */

.card {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 24px;
}

.card-body.p-0 {
    padding: 0;
}

.chart-card {
    margin-bottom: 28px;
}

.chart-container {
    max-width: 360px;
    margin: 0 auto;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.chart-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* =============================================
   TABLE
   ============================================= */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.table tbody td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
    vertical-align: middle;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    text-align: right;
}

.table-total {
    font-size: 0.95rem;
    color: var(--gray-600);
}

.table-total strong {
    color: var(--gray-900);
    font-size: 1.1rem;
}

.empty-state {
    text-align: center;
    color: var(--gray-400);
    padding: 48px 20px !important;
    font-size: 0.9rem;
}

/* =============================================
   STATUS BADGES
   ============================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success {
    background: var(--success-light);
    color: #065f46;
}

.badge-warning {
    background: var(--warning-light);
    color: #92400e;
}

.badge-danger {
    background: var(--danger-light);
    color: #991b1b;
}

.badge-info {
    background: var(--info-light);
    color: #1e40af;
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* =============================================
   CATEGORY TAG
   ============================================= */

.category-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--gray-100);
    color: var(--gray-700);
}

.category-tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

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

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-success:hover {
    background: #059669;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--border-radius-sm);
    background: transparent;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-icon.danger:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.btn-icon.success:hover {
    background: var(--success-light);
    color: var(--success);
}

.action-buttons {
    display: flex;
    gap: 4px;
}

/* =============================================
   MONTH SELECTOR
   ============================================= */

.month-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    padding: 4px;
}

.month-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    min-width: 140px;
    text-align: center;
}

/* =============================================
   PARCELADOS CARDS GRID
   ============================================= */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 16px;
}

.parcelado-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    padding: 20px;
    transition: var(--transition);
    overflow: hidden;
}

.parcelado-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.parcelado-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.parcelado-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.parcelado-card-category {
    margin-top: 4px;
}

.parcelado-card-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.parcelado-value-item {
    display: flex;
    flex-direction: column;
}

.parcelado-value-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.parcelado-value-number {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-top: 2px;
    word-break: break-word;
}

.parcelado-progress {
    margin-bottom: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
}

.progress-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
}

.progress-bar {
    height: 8px;
    background: var(--gray-100);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.parcelado-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

.parcelado-card.inactive {
    opacity: 0.6;
}

.parcelado-card.inactive .progress-fill {
    background: var(--success);
}

.empty-state-card {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--gray-400);
    padding: 48px 20px;
    font-size: 0.9rem;
}

/* =============================================
   CHECKBOX TOGGLE
   ============================================= */

.checkbox-toggle {
    position: relative;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.checkbox-mark {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-toggle input:checked + .checkbox-mark {
    background: var(--success);
    border-color: var(--success);
}

.checkbox-mark svg {
    display: none;
    color: white;
}

.checkbox-toggle input:checked + .checkbox-mark svg {
    display: block;
}

/* =============================================
   MODAL
   ============================================= */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.confirm-modal {
    max-width: 400px;
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 0 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* =============================================
   FORM
   ============================================= */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Toggle Group (Valor Total / Valor Parcela) */
.toggle-group {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    background: var(--gray-100);
}

.toggle-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.toggle-btn:hover {
    color: var(--gray-700);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

.calculo-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--gray-50);
    border: 1px dashed var(--gray-300);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--gray-600);
}

.calculo-preview strong {
    color: var(--primary);
    font-size: 1rem;
}

/* =============================================
   RESUMO
   ============================================= */

.resumo-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 32px;
    flex-wrap: wrap;
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}

.resumo-stat {
    text-align: center;
    padding: 8px 16px;
}

.resumo-stat-total {
    background: var(--primary-50);
    border-radius: var(--border-radius-sm);
    padding: 12px 24px;
}

.resumo-stat-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.resumo-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-top: 4px;
}

.resumo-stat-total .resumo-stat-value {
    color: var(--primary);
    font-size: 1.5rem;
}

.resumo-stat-divider {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-300);
}

.resumo-sections {
    display: grid;
    gap: 20px;
}

.resumo-list {
    /* container for items */
}

.resumo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid var(--gray-100);
    transition: var(--transition);
}

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

.resumo-item:hover {
    background: var(--gray-50);
}

.resumo-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.resumo-item-info {
    display: flex;
    flex-direction: column;
}

.resumo-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-800);
}

.resumo-item-detail {
    font-size: 0.8rem;
    color: var(--gray-400);
}

.resumo-item-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.resumo-empty {
    padding: 32px 24px;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* =============================================
   TOAST
   ============================================= */

.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface);
    border-radius: var(--border-radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastIn 0.3s ease;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* =============================================
   RESPONSIVE
   ============================================= */

/* Tablets e telas menores */
@media (max-width: 1024px) {
    .main-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 14px;
        padding-top: calc(var(--header-height) + 14px);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
        gap: 10px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-icon svg {
        width: 18px;
        height: 18px;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-count {
        font-size: 0.7rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        margin-bottom: 20px;
        gap: 12px;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .page-subtitle {
        font-size: 0.8rem;
    }

    .page-actions {
        width: 100%;
    }

    .month-selector {
        flex: 1;
    }

    .btn-primary {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .resumo-stats {
        flex-direction: column;
        gap: 8px;
        padding: 16px;
    }

    .resumo-stat-divider {
        display: none;
    }

    .resumo-stat-total {
        width: 100%;
    }

    .table thead th,
    .table tbody td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .modal {
        margin: 10px;
        max-height: 85vh;
        border-radius: var(--border-radius);
    }

    .modal-overlay {
        padding: 10px;
    }

    .modal-header {
        padding: 18px 18px 0;
    }

    .modal-body {
        padding: 18px;
    }

    .modal-footer {
        padding: 0 18px 18px;
    }

    .card-header {
        padding: 14px 16px;
    }

    .card-body {
        padding: 16px;
    }

    .parcelado-card {
        padding: 16px;
    }

    .parcelado-card-header {
        flex-direction: column;
        gap: 8px;
    }

    .resumo-item {
        padding: 12px 16px;
    }

    .chart-container {
        max-width: 280px;
    }

    .theme-fab {
        bottom: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
    }

    .toggle-group {
        font-size: 0.8rem;
    }

    .toggle-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .calculo-preview {
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    .calculo-preview strong {
        font-size: 0.9rem;
    }

    .categoria-card {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 10px;
        padding-top: calc(var(--header-height) + 10px);
    }

    .stats-grid {
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
        gap: 8px;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
    }

    .stat-icon svg {
        width: 16px;
        height: 16px;
    }

    .stat-value {
        font-size: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .parcelado-value-number {
        font-size: 0.95rem;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    .form-input,
    .form-select {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .form-label {
        font-size: 0.8rem;
    }

    .category-tag {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    .badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .month-label {
        font-size: 0.8rem;
        min-width: 110px;
    }

    .table thead th,
    .table tbody td {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .parcelado-card {
        padding: 14px;
    }
}

/* =============================================
   SCROLLBAR
   ============================================= */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* =============================================
   UTILITIES
   ============================================= */

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-400); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* Linha riscada para gastos pagos */
.row-paid td {
    text-decoration: line-through;
    opacity: 0.6;
}

/* =============================================
   CATEGORIAS
   ============================================= */

.categorias-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.categoria-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: var(--transition);
}

.categoria-card:last-child {
    border-bottom: none;
}

.categoria-card:hover {
    background: var(--gray-50);
}

.categoria-card-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.categoria-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,0.08);
}

.categoria-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--gray-800);
}

.categoria-card-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.categoria-card:hover .categoria-card-actions {
    opacity: 1;
}

/* Color picker */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-color {
    width: 48px;
    height: 40px;
    padding: 2px;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    background: var(--white, #fff);
    cursor: pointer;
}

.form-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.form-color::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-preview {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-family: monospace;
}

@media (max-width: 768px) {
    .categoria-card-actions {
        opacity: 1;
    }
}

/* =============================================
   THEME TOGGLE - FLOATING BUTTON
   ============================================= */

.theme-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1500;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--gray-200);
    background: var(--surface);
    color: var(--gray-500);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-fab:hover {
    background: var(--gray-100);
    color: var(--gray-700);
    box-shadow: var(--shadow-lg);
    transform: scale(1.08);
}

/* Light mode: show moon icon */
.theme-fab .icon-moon { display: block; }
.theme-fab .icon-sun  { display: none; }

/* Dark mode: show sun icon */
[data-theme="dark"] .theme-fab .icon-moon { display: none; }
[data-theme="dark"] .theme-fab .icon-sun  { display: block; }

[data-theme="dark"] .theme-fab {
    border-color: var(--gray-300);
}

/* =============================================
   DARK MODE
   ============================================= */

[data-theme="dark"] {
    /* Neutros invertidos */
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #94a3b8;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;

    /* Superfícies escuras */
    --surface: #1e293b;
    --surface-hover: #334155;

    /* Cores primárias (levemente ajustadas para dark) */
    --primary: #818cf8;
    --primary-light: #a5b4fc;
    --primary-dark: #6366f1;
    --primary-50: rgba(99, 102, 241, 0.15);
    --primary-100: rgba(99, 102, 241, 0.2);

    /* Estados - versões light mais escuras */
    --success-light: rgba(16, 185, 129, 0.15);
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger-light: rgba(239, 68, 68, 0.15);
    --info-light: rgba(59, 130, 246, 0.15);

    /* Sombras mais sutis */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);

    color-scheme: dark;
}

/* Sidebar já é escura, mas precisa ficar mais escura no dark mode */
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #070b14, #0c1322);
}

/* Botões com cor white no texto devem manter */
[data-theme="dark"] .btn-primary {
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .btn-danger {
    color: white;
}

[data-theme="dark"] .btn-success {
    color: white;
}

/* Badge com fundo claro */
[data-theme="dark"] .badge {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Table header styling */
[data-theme="dark"] .table thead th {
    background: #0f172a;
    color: var(--gray-600);
}

/* Category tag */
[data-theme="dark"] .category-tag {
    background: rgba(255, 255, 255, 0.08);
}

/* Toast */
[data-theme="dark"] .toast {
    border: 1px solid var(--gray-200);
}

/* Confirm dialog text */
[data-theme="dark"] .confirm-text {
    color: var(--gray-600);
}

/* Scrollbar dark */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--gray-300);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Chart.js canvas - invert grid/tick colors handled via JS */
[data-theme="dark"] .form-color {
    background: var(--surface);
    border-color: var(--gray-200);
}

/* Categoria color dot border */
[data-theme="dark"] .categoria-color-dot {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Mobile header dark */
[data-theme="dark"] .mobile-header {
    border-bottom-color: var(--gray-200);
}

/* Toggle group */
[data-theme="dark"] .toggle-group {
    background: var(--gray-100);
    border-color: var(--gray-200);
}

[data-theme="dark"] .toggle-btn.active {
    color: white;
}

/* Calculo preview */
[data-theme="dark"] .calculo-preview {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

/* Progress bar bg */
[data-theme="dark"] .progress-bar {
    background: rgba(255, 255, 255, 0.1);
}

/* Checkbox */
[data-theme="dark"] .checkbox-toggle input:checked + .checkbox-mark svg {
    color: white;
}

/* Modal overlay */
[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}
