:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --secondary: #0891b2;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --sidebar-width: 240px;
    --header-height: 64px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

/* ===== SETUP SCREEN ===== */
.setup-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.setup-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 3rem;
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.setup-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.allocation-inputs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.input-group .icon {
    font-size: 1.25rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.125rem;
    transition: all 0.2s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-wrapper .suffix {
    position: absolute;
    right: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1.125rem;
}

.total-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    font-weight: 600;
}

.total-value {
    color: var(--primary);
}

.total-value.error {
    color: var(--danger);
}

.error-message {
    padding: 0.75rem;
    background: #fee;
    color: var(--danger);
    border-radius: var(--radius-sm);
    text-align: center;
}

/* ===== APP LAYOUT ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

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

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

.nav-icon {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.btn-icon-sidebar {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

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

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    width: calc(100vw - var(--sidebar-width));
    box-sizing: border-box;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5rem !important;
    margin-bottom: 1.5rem !important;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.2s;
    min-height: 140px;
}

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

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-icon {
    font-size: 1.5rem;
    opacity: 0.5;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.stat-change {
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

.stat-change.positive {
    color: var(--success);
    background: #f0fdf4;
}

.stat-change.negative {
    color: var(--danger);
    background: #fef2f2;
}

.stat-meta {
    color: var(--text-muted);
}

/* ===== CHARTS ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 100%;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    min-width: 0;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chart-body {
    position: relative;
    height: 300px;
}

.select-sm {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

/* ===== CATEGORIES SUMMARY ===== */
.categories-summary {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.category-cards {
    display: grid;
    gap: 1rem;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.category-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.category-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.category-details h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.category-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.category-stats {
    text-align: right;
}

.category-value {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.category-percent {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== TABLE ===== */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

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

.ativos-table th,
.ativos-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.ativos-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.ativos-table tbody tr {
    transition: background 0.2s;
}

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

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

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

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

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

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

.empty-state {
    text-align: center;
    padding: 4rem 2rem !important;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-text {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-subtext {
    color: var(--text-secondary);
}

/* ===== BUTTONS ===== */
.btn-primary, .btn-secondary {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-icon {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 1.125rem;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100vw;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===== EDIÇÃO INLINE ===== */
.editable-price {
    cursor: pointer;
    transition: background 0.2s;
}

.editable-price:hover {
    background: var(--bg-tertiary);
}

/* ===== RESUMO POR CATEGORIA ===== */
.categories-overview {
    margin-bottom: 2rem;
}

.category-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.category-summary-card:hover {
    box-shadow: var(--shadow-sm);
}

.category-header-row {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.category-col {
    text-align: center;
    padding: 0 0.5rem;
}

.category-col:first-child {
    text-align: left;
}

.category-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.category-icon.acoes { background: #dbeafe; }
.category-icon.fiis { background: #dcfce7; }
.category-icon.renda_fixa { background: #fed7aa; }
.category-icon.cripto { background: #e9d5ff; }

.category-title-group h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
}

.category-stat-label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.category-stat-value {
    font-size: 0.9375rem;
    font-weight: 600;
}

.category-stat-value.positive {
    color: var(--success);
}

.category-stat-value.negative {
    color: var(--danger);
}

.category-toggle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.category-table-wrapper {
    margin: 1rem -1.5rem 0 -1.5rem;
    padding: 1rem 1.5rem 0 1.5rem;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    background: var(--bg-secondary);
}

.category-table-wrapper .table {
    margin-bottom: 0;
    width: 100%;
    table-layout: fixed;
}

.category-table-wrapper .table thead {
    background: #f1f5f9;
}

.category-table-wrapper .table thead th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 0.8125rem;
    padding: 0.875rem 0.5rem;
    vertical-align: middle;
    border-bottom: 2px solid #e2e8f0;
}

.category-table-wrapper .table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s;
}

.category-table-wrapper .table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.category-table-wrapper .table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.category-table-wrapper .table tbody tr:hover {
    background: #f1f5f9;
}

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

.category-table-wrapper .table td {
    padding: 1rem 0.5rem;
    vertical-align: middle;
    font-size: 0.875rem;
}

.category-table-wrapper .table .action-buttons {
    white-space: nowrap;
}

.category-table-wrapper .table .action-buttons .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 2px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.category-table-wrapper .table .action-buttons .btn-icon:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

@media (max-width: 1200px) {
    .category-stats-right {
        gap: 1.5rem;
    }
    
    .category-stat-item {
        min-width: 80px;
    }
}

@media (max-width: 1024px) {
    .category-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .category-stats-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .category-stat-item {
        min-width: auto;
    }
}

/* ===== CALCULADORA ===== */
.calc-info {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    text-align: center;
}

.calc-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.calc-result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 2px solid var(--primary);
}

.calc-result h4 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.result-item span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.result-item strong {
    font-size: 1.125rem;
}
/* ==================================
   ANÁLISE DE AÇÕES - ESTILOS
   ================================== */

.analise-container {
    max-width: 900px;
    margin: 0 auto;
}

.analise-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.analise-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.analise-card-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

.analise-card-body {
    padding: 1.5rem;
}

.analise-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.analise-strategy-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    border: 2px solid #e2e8f0;
    overflow: hidden;
}

.strategy-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    color: white;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.analise-results {
    background: linear-gradient(135deg, #f6f9fc 0%, #eef2f7 100%);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.result-label {
    font-weight: 500;
    color: #4a5568;
    font-size: 0.9375rem;
}

.result-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: #667eea;
}

.result-value.positive {
    color: #48bb78;
}

.result-value.negative {
    color: #f56565;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.alert-info {
    background: #dbeafe;
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

.alert-success {
    background: #d1fae5;
    border-left: 4px solid #10b981;
    color: #065f46;
}

.alert-warning {
    background: #fed7aa;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

/* Responsivo */
@media (max-width: 768px) {
    .analise-form-grid {
        grid-template-columns: 1fr;
    }
    
    .analise-container {
        padding: 0 1rem;
    }
}

/* Alertas adicionais para análise */
.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    font-size: 0.9em;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #bee5eb;
    font-size: 0.9em;
}

.metodo-info {
    background: #f1f8ff;
    padding: 15px;
    border-radius: 8px;
    border-left: 5px solid #3498db;
}

.badge {
    display: inline-block;
    padding: 8px 15px;
    border-radius: 50px;
    color: white;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8em;
}
