/* ========================================
   FINANCEIRO CSS
   ======================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --accent-primary: #e74c3c;
    --accent-secondary: #ff6b5b;
    --accent-gradient: linear-gradient(135deg, #e74c3c 0%, #ff6b5b 100%);
    --text-primary: #ffffff;
    --text-secondary: #8a8a9a;
    --text-muted: #5a5a6a;
    --success: #00d4aa;
    --warning: #ffc107;
    --danger: #ff4757;
    --info: #3498db;
    --purple: #a855f7;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(231, 76, 60, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* LOADING */
.loading-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}
.loading-screen.hidden { display: none; }
.loading-spinner {
    width: 50px; height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.loading-text { color: var(--text-secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* LAYOUT */
.dashboard-container { display: flex; min-height: 100vh; }
.dashboard-container.hidden { display: none; }

/* SIDEBAR */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.logo { display: flex; align-items: center; gap: 12px; padding-bottom: 30px; border-bottom: 1px solid var(--border-color); margin-bottom: 30px; }
.logo-icon { width: 45px; height: 45px; background: var(--accent-gradient); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: var(--shadow-glow); }
.logo-text { font-size: 18px; font-weight: 700; }
.logo-text span { color: var(--accent-primary); }

.nav-section { margin-bottom: 30px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 15px; padding-left: 15px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 14px 15px; border-radius: 10px; cursor: pointer; transition: all 0.3s ease; color: var(--text-secondary); font-weight: 500; margin-bottom: 5px; text-decoration: none; }
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-gradient); color: white; box-shadow: var(--shadow-glow); }
.nav-icon { font-size: 20px; width: 24px; text-align: center; }

/* MAIN CONTENT */
.main-content { flex: 1; margin-left: 260px; padding: 30px 40px; width: calc(100% - 260px); }

/* HEADER */
.header { display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.header-left h1 { font-size: 28px; font-weight: 700; margin-bottom: 5px; }
.header-left p { color: var(--text-secondary); font-size: 15px; }
.header-right { display: flex; flex-direction: row; align-items: center; gap: 15px; }

.period-selector { display: flex; flex-direction: row; background: var(--bg-card); border-radius: 10px; padding: 4px; border: 1px solid var(--border-color); }
.period-btn { padding: 10px 18px; border: none; background: none; color: var(--text-secondary); font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 8px; transition: all 0.3s ease; }
.period-btn:hover { color: var(--text-primary); }
.period-btn.active { background: var(--accent-gradient); color: white; }

.btn-primary { background: var(--accent-gradient); border: none; color: white; padding: 12px 24px; border-radius: 10px; font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.3s ease; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.btn-logout { background: rgba(255, 71, 87, 0.1); border: 1px solid rgba(255, 71, 87, 0.3); color: var(--danger); padding: 10px 16px; border-radius: 10px; cursor: pointer; font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 500; transition: all 0.3s ease; display: flex; align-items: center; gap: 8px; }
.btn-logout:hover { background: var(--danger); color: white; }

/* FINANCE HERO */
.finance-hero {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.hero-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.hero-card.main {
    background: var(--accent-gradient);
    border: none;
}

.hero-card.main::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero-label { font-size: 14px; color: var(--text-secondary); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.hero-card.main .hero-label { color: rgba(255,255,255,0.8); }

.hero-value { font-size: 42px; font-weight: 800; font-family: 'Space Mono', monospace; margin-bottom: 15px; }
.hero-card.main .hero-value { color: white; }

.hero-trend { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 20px; }
.hero-trend.up { background: rgba(0, 212, 170, 0.15); color: var(--success); }
.hero-trend.down { background: rgba(255, 71, 87, 0.15); color: var(--danger); }
.hero-card.main .hero-trend.up { background: rgba(255,255,255,0.2); color: white; }

.hero-comparison { margin-top: 15px; font-size: 13px; color: var(--text-muted); }
.hero-card.main .hero-comparison { color: rgba(255,255,255,0.7); }
.hero-comparison span { font-weight: 600; }

/* MINI STATS */
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 30px; }

.mini-stat {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}
.mini-stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }

.mini-stat-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.mini-stat-icon.green { background: rgba(0, 212, 170, 0.15); }
.mini-stat-icon.red { background: rgba(255, 71, 87, 0.15); }
.mini-stat-icon.blue { background: rgba(52, 152, 219, 0.15); }
.mini-stat-icon.purple { background: rgba(168, 85, 247, 0.15); }
.mini-stat-icon.institution { background: rgba(168, 85, 247, 0.15); }
.mini-stat-icon.warning { background: rgba(255, 193, 7, 0.15); }

.mini-stat-info { flex: 1; }
.mini-stat-value { font-size: 24px; font-weight: 700; font-family: 'Space Mono', monospace; }
.mini-stat-value.green { color: var(--success); }
.mini-stat-value.red { color: var(--danger); }
.mini-stat-value.purple { color: var(--purple); }
.mini-stat-value.warning { color: var(--warning); }
.mini-stat-label { font-size: 13px; color: var(--text-muted); }

/* INSTITUTIONS STATS */
.institutions-stats {
    margin-bottom: 30px;
}

.institutions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.institutions-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-all-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.view-all-link:hover {
    opacity: 0.8;
}

.institutions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.breakdown-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.breakdown-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card);
}

.breakdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.breakdown-icon {
    font-size: 24px;
}

.breakdown-label {
    font-size: 12px;
    color: var(--text-muted);
}

.breakdown-count {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
}

.breakdown-value {
    font-size: 14px;
    font-weight: 600;
}

.breakdown-value.info { color: var(--info); }
.breakdown-value.purple { color: var(--purple); }
.breakdown-value.success { color: var(--success); }
.breakdown-value.warning { color: var(--warning); }

/* CHARTS */
.charts-section { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 30px; }

.chart-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 25px;
    border: 1px solid var(--border-color);
}

.chart-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.chart-title { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.chart-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 5px; }

.chart-container { height: 300px; position: relative; }

.chart-legend { display: flex; flex-direction: row; gap: 20px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-dot.green { background: var(--success); }
.legend-dot.red { background: var(--danger); }

/* CASH FLOW */
.cash-flow-list { padding: 10px 0; }
.cash-flow-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}
.cash-flow-item:last-child { border-bottom: none; }

.cash-flow-info { display: flex; flex-direction: row; align-items: center; gap: 12px; }
.cash-flow-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.cash-flow-icon.income { background: rgba(0, 212, 170, 0.15); }
.cash-flow-icon.expense { background: rgba(255, 71, 87, 0.15); }

.cash-flow-details .title { font-weight: 600; font-size: 14px; }
.cash-flow-details .date { font-size: 12px; color: var(--text-muted); }

.cash-flow-value { font-family: 'Space Mono', monospace; font-weight: 600; }
.cash-flow-value.income { color: var(--success); }
.cash-flow-value.expense { color: var(--danger); }

/* TABLES */
.tables-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 30px; }

.table-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
}
.table-header h3 { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; }

.view-all-btn { color: var(--accent-primary); background: none; border: none; font-family: 'Outfit', sans-serif; font-size: 14px; cursor: pointer; transition: opacity 0.3s ease; }
.view-all-btn:hover { opacity: 0.8; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 15px 25px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border-color); font-weight: 600; background: var(--bg-secondary); }
.data-table td { padding: 15px 25px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.data-table tbody tr { transition: background 0.3s ease; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

.transaction-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.transaction-type.income { background: rgba(0, 212, 170, 0.15); color: var(--success); }
.transaction-type.expense { background: rgba(255, 71, 87, 0.15); color: var(--danger); }
.transaction-type.refund { background: rgba(255, 193, 7, 0.15); color: var(--warning); }

.amount { font-family: 'Space Mono', monospace; font-weight: 600; }
.amount.positive { color: var(--success); }
.amount.negative { color: var(--danger); }

/* EXPENSES */
.expense-list {
    padding: 20px 25px;
}

.expense-category {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}
.expense-category:last-child { border-bottom: none; }

.expense-info { display: flex; flex-direction: row; align-items: center; gap: 12px; }
.expense-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.05);
}
.expense-name { font-weight: 500; font-size: 14px; }
.expense-percent { font-size: 12px; color: var(--text-muted); }

.expense-value { text-align: right; }
.expense-amount { font-family: 'Space Mono', monospace; font-weight: 600; font-size: 14px; }
.expense-bar {
    width: 80px;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    margin-top: 5px;
    overflow: hidden;
}
.expense-bar-fill { height: 100%; background: var(--accent-gradient); border-radius: 3px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* RESPONSIVIDADE */
@media (max-width: 1400px) {
    .finance-hero { grid-template-columns: 1fr; }
    .charts-section { grid-template-columns: 1fr; }
    .mini-stats { grid-template-columns: repeat(2, 1fr); }
    .institutions-grid { grid-template-columns: repeat(2, 1fr); }
    .breakdown-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; width: 100%; padding: 20px; }
    .header { flex-direction: column; align-items: flex-start; gap: 15px; }
    .mini-stats { grid-template-columns: 1fr; }
    .institutions-grid { grid-template-columns: 1fr; }
    .breakdown-grid { grid-template-columns: 1fr; }
    .tables-row { grid-template-columns: 1fr; }
}

/* ANIMATIONS */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.hero-card, .mini-stat, .chart-card, .table-card, .breakdown-card { animation: fadeInUp 0.5s ease forwards; }