﻿/* CSS COMPLETO */
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background-color: #f8fafc; color: #374151; line-height: 1.6; }

        /* --- ESTILOS DE AUTENTICAÇÃO --- */
        #auth-section { display: none; align-items: center; justify-content: center; min-height: 100vh; }
        .auth-container { width: 100%; max-width: 400px; padding: 40px; background-color: white; border-radius: 16px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); }
        .auth-title { font-size: 24px; font-weight: 600; text-align: center; margin-bottom: 24px; }
        .auth-form .form-group { margin-bottom: 16px; }
        .auth-form .btn-primary { width: 100%; margin-top: 8px; }
        .auth-link { text-align: center; margin-top: 16px; font-size: 14px; }
        .auth-link a { color: #2563eb; text-decoration: none; font-weight: 500; }
        #signup-view { display: none; }

        /* --- ESTILOS DA APLICAÇÃO --- */
        #app-section { display: none; } /* Começa escondida */

        .header { position: fixed; top: 0; left: 0; right: 0; height: 64px; background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.04); z-index: 100; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
        .header-left { display: flex; align-items: center; gap: 12px; }
        .logo { font-size: 24px; }
        .app-name { font-size: 20px; font-weight: 600; color: #1e40af; }
        .header-right { display: flex; align-items: center; gap: 16px; }
        .user-info { display: flex; align-items: center; gap: 8px; }
        .user-avatar { width: 32px; height: 32px; border-radius: 50%; background: #1e40af; color: white; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
        .user-name { font-size: 14px; font-weight: 500; }
        .main-content { margin-top: 64px; max-width: 1400px; margin-left: auto; margin-right: auto; padding: 40px 20px; }
        .context-selector { display: flex; justify-content: center; margin-bottom: 32px; }
        .segmented-control { background: #e5e7eb; border-radius: 12px; padding: 4px; display: flex; }
        .context-btn { width: 120px; height: 44px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; background: transparent; color: #6b7280; }
        .context-btn.active { background: white; color: #1e40af; font-weight: 600; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
        .dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px; margin-bottom: 40px; }
        .dashboard-card { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
        .card-title { font-size: 14px; color: #6b7280; margin-bottom: 8px; }
        .card-value { font-size: 28px; font-weight: 700; }
        .card-subtitle { font-size: 12px; color: #9ca3af; }
        .card-overdue .card-value { color: #dc2626; } .card-due .card-value { color: #f59e0b; } .card-open .card-value { color: #2563eb; } .card-paid .card-value { color: #10b981; }
        .charts-section { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; margin-bottom: 40px; }
        .charts-section.has-three-charts { grid-template-columns: 1fr 1fr 2fr; }
        .chart-container { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); position: relative; height: 400px; }
        .chart-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #111827; }
        .action-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
        .action-bar-group { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
        .search-input { width: 320px; height: 44px; border: 1px solid #d1d5db; border-radius: 8px; padding: 0 16px 0 44px; font-size: 14px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 16px center; background-size: 16px; }
        .primary-action { background: #10b981; color: white; border: none; height: 44px; padding: 0 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2); transition: all 0.2s; }
        .primary-action:hover { background: #059669; }
        .table-container { background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
        .accounts-table { width: 100%; border-collapse: collapse; }
        .accounts-table th, .accounts-table td { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; text-align: left; }
        .accounts-table th { background: #f8fafc; font-weight: 600; color: #374151; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; position: relative; }
        .accounts-table th[data-sort-by] { cursor: pointer; }
        .accounts-table th[data-sort-by]:hover { background-color: #f3f4f6; }
        .sort-indicator { font-size: 10px; margin-left: 4px; color: #374151; }
        .accounts-table tbody tr { cursor: grab; }
        .accounts-table tbody tr:hover { background: #eff6ff; }
        .creditor-cell .creditor-name { font-weight: 600; color: #111827; } .creditor-cell .creditor-description { font-size: 12px; color: #6b7280; }
        .favorecido-column, .macrocampo-column, .categoria-column { display: none; }
        .is-pessoal .favorecido-column, .is-pessoal .categoria-column { display: table-cell; }
        .is-empresa .macrocampo-column { display: table-cell; }
        .status-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
        .status-badge.open { background: #dbeafe; color: #1e40af; } .status-badge.overdue { background: #fee2e2; color: #dc2626; } .status-badge.partial { background: #fef3c7; color: #d97706; } .status-badge.paid { background: #d1fae5; color: #065f46; }
        .progress-bar { width: 100%; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-bottom: 4px;}
        .progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
        .progress-fill.paid { background: linear-gradient(90deg, #10b981, #059669); }
        .progress-fill.percentage { background: linear-gradient(90deg, #60a5fa, #2563eb); }
        .progress-text { font-size: 12px; color: #6b7280; }
        .balance-amount { font-weight: 700; font-size: 16px; }
        .balance-amount.positive { color: #dc2626; } .balance-amount.zero { color: #10b981; }
        .actions-cell { display: flex; gap: 8px; }
        .action-btn { width: 32px; height: 32px; border: none; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all 0.2s; }
        .action-btn.pay { background: rgba(16, 185, 129, 0.1); color: #10b981; }
        .action-btn.details { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
        .action-btn.edit { background: rgba(107, 114, 128, 0.1); color: #6b7280; }
        .action-btn.delete { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
        .action-btn.manage-template { background: rgba(139, 92, 246, 0.1); color: #7c3aed; }
        .action-btn:hover { filter: brightness(1.2); }
        .action-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }
        .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1000; align-items: center; justify-content: center; }
        .modal.show { display: flex; animation: fadeIn 0.3s ease; }
        .modal-content { background: white; border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); animation: slideIn 0.3s ease; max-height: 90vh; overflow-y: auto; width: 90%; max-width: 500px; }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes slideIn { from { transform: scale(0.95) translateY(-10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
        .modal-header { height: 64px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e7eb; }
        .modal-title { font-size: 20px; font-weight: 600; }
        .modal-close { width: 32px; height: 32px; border: none; border-radius: 6px; background: rgba(107, 114, 128, 0.1); color: #6b7280; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; }
        .modal-body { padding: 24px; }
        .modal-footer { height: 72px; padding: 0 24px; background: #f8fafc; display: flex; align-items: center; justify-content: flex-end; gap: 12px; border-bottom-left-radius: 16px; border-bottom-right-radius: 16px; border-top: 1px solid #e5e7eb; }
        .form-grid { display: grid; gap: 16px; }
        .form-group { display: flex; flex-direction: column; }
        .form-group.hidden { display: none; }
        #recurrent-fields.hidden { display: none; }
        .form-group label, .detail-label { font-size: 12px; font-weight: 500; color: #374151; margin-bottom: 4px; }
        .form-input, .form-select, .form-textarea { width: 100%; height: 44px; border: 1px solid #d1d5db; border-radius: 8px; padding: 0 12px; font-size: 14px; background: #f9fafb; }
        .dynamic-field-wrapper { display: flex; gap: 8px; align-items: flex-end; }
        .btn-add-dynamic { width: 44px; height: 44px; flex-shrink: 0; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 18px; cursor: pointer; }
        .context-radio-group { display: flex; gap: 24px; }
        .radio-label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
        .btn { height: 44px; padding: 0 40px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border: none; gap: 8px; }
        .modal-footer .btn { margin: 0 4px; }
        .btn-outline { background: transparent; border: 1px solid #d1d5db; color: #6b7280; }
        .btn-primary { background: #2563eb; color: white; }
        .toast-container { position: fixed; top: 80px; right: 20px; z-index: 1001; }
        .toast { background: white; border-radius: 8px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); padding: 16px; display: flex; gap: 12px; animation: slideInRight 0.3s ease; min-width: 300px; margin-bottom: 12px;}
        .toast.success { border-left: 4px solid #10b981; } .toast.error { border-left: 4px solid #dc2626; } .toast.info { border-left: 4px solid #2563eb; }
        @keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
        .manager-list { list-style: none; padding: 0; margin: 0; max-height: 250px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; }
        .manager-list li { display: flex; justify-content: space-between; align-items: center; padding: 12px; }
        .manager-list li:not(:last-child) { border-bottom: 1px solid #e5e7eb; }
        .manager-list .actions { display: flex; align-items: center; gap: 8px; }
        .manager-list .actions button {
            background: none; border: none; cursor: pointer;
            font-size: 16px; padding: 0; border-radius: 4px;
            display: inline-flex; align-items: center; justify-content: center;
            width: 28px; height: 28px;
        }
        .manager-list .actions button:hover { background-color: #f3f4f6; }
        .manager-list .actions .edit-btn { color: #2563eb; }
        .manager-list .actions .delete-btn { color: #ef4444; }
        .detail-value { font-size: 16px; font-weight: 600; color: #111827; margin-bottom: 12px; padding: 8px; background-color: #f8fafc; border-radius: 6px; }
        .two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
        .sortable-ghost { opacity: 0.4; background-color: #c8ebfb; }
        hr { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }
        .switch-group { display: flex; align-items: center; gap: 8px; }
        #macrocampo-group, #favorecido-group, #categoria-group { margin-bottom: 16px; }

        /* --- ESTILOS DE TOOLTIP --- */
        [data-tooltip] {
            position: relative;
        }
        [data-tooltip]::before,
        [data-tooltip]::after {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
            z-index: 1000;
            pointer-events: none;
        }
        [data-tooltip]::before {
            content: attr(data-tooltip);
            background-color: #111827;
            color: #ffffff;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            white-space: nowrap;
            bottom: calc(100% + 8px);
        }
        [data-tooltip]::after {
            content: '';
            border: 5px solid transparent;
            border-top-color: #111827;
            bottom: calc(100% + 3px);
        }
        [data-tooltip]:hover::before,
        [data-tooltip]:hover::after {
            opacity: 1;
            visibility: visible;
        }
        
        /* --- ESTILOS SPINNER/LOADER --- */
        .spinner {
            border: 4px solid rgba(0, 0, 0, 0.1);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            border-left-color: #4f46e5;
            margin: 0 auto;
            animation: spin 1s ease infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }


        /* Mobile Adjustments */
        @media (max-width: 768px) {
            .auth-container { box-shadow: none; padding: 20px; }
            .header { padding: 0 16px; height: 56px; }
            .app-name { font-size: 18px; }
            .user-info { display: none; }
            .main-content { padding: 20px 16px; margin-top: 56px; }
            .context-selector { margin-bottom: 24px; }
            .context-btn { width: 100px; height: 40px; font-size: 13px; }
            .dashboard { grid-template-columns: 1fr; gap: 16px; margin-bottom: 24px; }
            .dashboard-card { padding: 20px; }
            .card-value { font-size: 24px; }
            .charts-section { grid-template-columns: 1fr; gap: 20px; margin-bottom: 24px; }
            .charts-section.has-three-charts { grid-template-columns: 1fr; }
            .action-bar { flex-direction: column; align-items: stretch; gap: 16px; }
            .action-bar-group { flex-direction: column; align-items: stretch; gap: 8px; }
            .search-input { width: 100%; }
            .primary-action, .btn { width: 100%; text-align: center; }
            .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
            .accounts-table { min-width: 700px; }
            .accounts-table th, .accounts-table td { padding: 10px 12px; font-size: 13px; }
            .creditor-cell .creditor-name { font-size: 14px; }
            .progress-text, .balance-amount { font-size: 13px; }
            .actions-cell { gap: 4px; flex-wrap: wrap; justify-content: center; }
            .action-btn { width: 28px; height: 28px; }
            .modal-content { max-width: 95%; margin: 16px; }
            .modal-header { padding: 0 16px; height: 56px; }
            .modal-title { font-size: 18px; }
            .modal-body { padding: 16px; }
            .modal-footer { height: 64px; padding: 0 16px; }
            .two-columns { grid-template-columns: 1fr; }
        }



body.is-loading {
    cursor: progress;
}

body.is-loading .btn {
    pointer-events: none;
    opacity: 0.7;
}
