/* ========================================
   VARIÁVEIS E RESET
   ======================================== */
:root {
    /* Cores Base - Tema Sóbrio */
    --bg-primary: #1a1d2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --bg-hover: #1e2a4a;
    
    /* Texto */
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Destaques */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --primary: #6366f1;
    
    /* Neutros */
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    
    /* Transições */
    --transition: all 0.3s ease;
}

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

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    position: relative;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Body para página de login */
body.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ========================================
   LAYOUT PRINCIPAL
   ======================================== */

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.app-container ~ .modal-overlay {
    position: fixed !important;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    padding: 20px;
    border-right: 1px solid var(--gray-800);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 0;
    border-bottom: 1px solid var(--gray-800);
    margin-bottom: 20px;
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 5px;
    list-style: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    font-size: 15px;
}

.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.sidebar-nav .icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    max-width: calc(100vw - 260px);
}

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

.page-header > div {
    flex: 1;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.page-header .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ========================================
   COMPONENTES
   ======================================== */

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-secondary);
}

/* Grid de Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

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

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

.stat-card-icon {
    font-size: 28px;
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon.success { background: rgba(16, 185, 129, 0.15); }
.stat-card-icon.danger { background: rgba(239, 68, 68, 0.15); }
.stat-card-icon.warning { background: rgba(245, 158, 11, 0.15); }
.stat-card-icon.info { background: rgba(59, 130, 246, 0.15); }

.stat-card-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card-change {
    font-size: 13px;
    margin-top: 8px;
}

.stat-card-change.positive { color: var(--success); }
.stat-card-change.negative { color: var(--danger); }

/* Botões */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    background-clip: padding-box;
    width: auto;
    max-width: fit-content;
}

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

.btn-primary:hover {
    background: #4f46e5 !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

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

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

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

.btn-secondary {
    background: var(--gray-700) !important;
    color: white !important;
}

.btn-secondary:hover {
    background: var(--gray-800) !important;
}

.btn-outline {
    background: transparent !important;
    border: 2px solid var(--gray-700);
    color: var(--text-primary) !important;
}

.btn-outline:hover {
    background: var(--gray-800) !important;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Grupo de botões */
.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-group .btn {
    flex-shrink: 0;
}

/* Formulários */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.form-row .form-group {
    margin-bottom: 0;
}

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

.form-label {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-input,
.form-select,
.form-textarea,
.form-control,
input.form-control,
select.form-control,
textarea.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--gray-800);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Tabelas */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    background: var(--bg-card);
}

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

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-800);
}

.table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    color: var(--text-primary);
}

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

.table tr:hover {
    background: var(--bg-hover);
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); }

/* Alertas */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border-left: 4px solid var(--success);
    color: var(--success);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border-left: 4px solid var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border-left: 4px solid var(--warning);
    color: var(--warning);
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border-left: 4px solid var(--info);
    color: var(--info);
}

/* Modal */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10000 !important;
    padding: 20px !important;
    margin: 0 !important;
    overflow: auto !important;
}

/* Garantir que modais com ID específicos também funcionem */
#modalDespesa,
#modalReceita,
#modalCartao,
#modalFatura,
#modalPagarFatura,
#modalLancamentoParcelado,
#modalConta,
#modalCategoria {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10000 !important;
    padding: 20px !important;
    margin: 0 !important;
    overflow: auto !important;
}

.modal-overlay.hidden,
#modalDespesa.hidden,
#modalReceita.hidden,
#modalCartao.hidden,
#modalFatura.hidden,
#modalPagarFatura.hidden,
#modalLancamentoParcelado.hidden,
#modalConta.hidden,
#modalCategoria.hidden {
    display: none !important;
}

.modal {
    background: var(--bg-card);
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative !important;
    z-index: 10001 !important;
    margin: auto !important;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-hover);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-800);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Filtros */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--gray-800);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utilitários */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none; }

/* ========================================
   LOGIN PAGE (mantém o estilo original)
   ======================================== */

.container {
    width: 100%;
    max-width: 450px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 8px;
    text-align: center;
}

h2 {
    color: #333;
    font-size: 22px;
    margin-bottom: 16px;
    text-align: center;
}

.subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
    font-size: 14px;
}

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

label {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

input[type="email"],
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="email"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 14px;
    border-left: 4px solid #c33;
}

.success-message {
    background: #efe;
    color: #3c3;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 14px;
    border-left: 4px solid #3c3;
}

#qrCodeContainer {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.setup-info {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
}

.setup-info code {
    display: block;
    background: white;
    padding: 12px;
    border-radius: 4px;
    margin-top: 8px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    font-size: 14px;
    color: #333;
}

.setup-info p {
    margin-bottom: 4px;
    font-size: 14px;
    color: #666;
}

/* Estilo para a página principal */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.header {
    background: white;
    padding: 20px 40px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-logout {
    padding: 10px 24px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* ========================================
   GRID UTILITIES
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
