/* Portfolio v2 - Main Styles */

/* ===== LIGHT THEME (default) ===== */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --primary-light: #5dade2;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    
    /* Backgrounds */
    --bg-app: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f5f5f5;
    --bg-modal: #ffffff;
    
    /* Text */
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-muted: #95a5a6;
    --text-link: #3498db;
    
    /* Borders */
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    
    /* Shadows */
    --shadow: rgba(0,0,0,0.1);
    --shadow-lg: rgba(0,0,0,0.15);
    
    /* Status colors */
    --gain: #27ae60;
    --loss: #c0392b;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    --primary: #5dade2;
    --primary-dark: #3498db;
    --primary-light: #85c1e9;
    
    /* Backgrounds */
    --bg-app: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --bg-card: #1e2a3a;
    --bg-header: #1e2a3a;
    --bg-input: #2d3748;
    --bg-hover: #2d3748;
    --bg-modal: #1e2a3a;
    
    /* Text */
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --text-link: #63b3ed;
    
    /* Borders */
    --border-color: #2d3748;
    --border-light: #3d4a5c;
    
    /* Shadows */
    --shadow: rgba(0,0,0,0.3);
    --shadow-lg: rgba(0,0,0,0.5);
    
    /* Status colors */
    --gain: #48bb78;
    --loss: #fc8181;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-header);
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px var(--shadow);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-row:first-child {
    margin-bottom: 10px;
}

.header-second-row {
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.header h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 0;
}

.header-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap;
}

.header-info > * {
    flex-shrink: 0;
    white-space: nowrap;
}

.header-info span {
    font-weight: 600;
    color: var(--text-primary);
    min-width: fit-content;
}

#portfolio-value {
    font-size: 1.4rem;
    color: var(--primary);
}

#last-update {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: normal;
}

/* Account Selector */
.account-selector {
    position: relative;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.account-selector select {
    padding: 10px 35px 10px 12px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 180px;
    max-width: 250px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233498db' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
}

.account-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.account-selector select:hover {
    background-color: var(--bg-hover);
}

.account-selector select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 10px;
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    background: var(--bg-card);
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px var(--shadow);
    flex-wrap: wrap;
}

.tab {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
    color: var(--text-secondary);
}

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

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

/* Tab Content */
.tab-content {
    display: none;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow);
}

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

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
    border-radius: 12px;
    color: white;
}

.card:nth-child(2) {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.card:nth-child(3) {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.card:nth-child(4) {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.card-title {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Actions */
.actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.filter-bar input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-bar select {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    min-width: 140px;
}

.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

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

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

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

.data-table th {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

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

.data-table td {
    color: var(--text-primary);
}
    text-align: left;
    border-bottom: 1px solid var(--light);
}

.data-table th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
}

.data-table tr:hover {
    background: #f8f9fa;
}

.data-table .positive {
    color: var(--success);
}

.data-table .negative {
    color: var(--danger);
}

/* Price flash animation for auto-updates */
.data-table .price-flash {
    animation: price-flash 2s ease-out;
}

@keyframes price-flash {
    0% {
        background-color: var(--primary);
        color: white;
        transform: scale(1.05);
    }
    30% {
        background-color: var(--primary-light);
        color: white;
    }
    100% {
        background-color: transparent;
        color: inherit;
        transform: scale(1);
    }
}

[data-theme="dark"] .data-table .price-flash {
    animation: price-flash-dark 2s ease-out;
}

@keyframes price-flash-dark {
    0% {
        background-color: var(--primary);
        color: white;
        transform: scale(1.05);
    }
    30% {
        background-color: #1e3a5f;
        color: white;
    }
    100% {
        background-color: transparent;
        color: inherit;
        transform: scale(1);
    }
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-modal);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

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

#modal-body {
    padding: 20px;
}

/* Form */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Action buttons in table */
.action-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
    margin-right: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }

    .header-info {
        flex-direction: column;
        gap: 10px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        flex: 1;
        min-width: 100px;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

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

/* Badge for currency display */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
}

.badge.mxn {
    background: #e67e22;
}

/* Ticker validation styles */
#ticker-validation {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
}

.validation-pending {
    color: #f39c12;
}

.validation-success {
    color: #27ae60;
}

.validation-error {
    color: #e74c3c;
}

/* Auth styles */
.auth-container {
    padding: 20px;
}

.auth-container h2 {
    margin-bottom: 20px;
    text-align: center;
}

.auth-container .form-group {
    margin-bottom: 15px;
}

.auth-container .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.auth-container .form-actions .btn {
    flex: 1;
}

.auth-note {
    margin-top: 15px;
    text-align: center;
    color: var(--gray);
    font-size: 0.85rem;
}

/* User info in header */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info span {
    color: var(--dark);
}

.user-info .btn-logout {
    padding: 5px 15px;
    font-size: 0.85rem;
}

/* Account Tab */
.account-container {
    display: grid;
    gap: 20px;
    max-width: 600px;
}

.account-card {
    background: var(--light);
    padding: 20px;
    border-radius: 12px;
}

.account-card h3 {
    margin-bottom: 15px;
    color: var(--dark);
    font-size: 1.1rem;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
}

.profile-row:last-child {
    border-bottom: none;
}

.profile-row label {
    font-weight: 600;
    min-width: 120px;
    color: var(--gray);
}

.profile-row span {
    flex: 1;
    color: var(--dark);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.85rem;
}

.danger-zone {
    border: 1px solid var(--danger);
    background: #fdf2f2;
}

.danger-zone h3 {
    color: var(--danger);
}

.danger-zone .btn {
    width: 100%;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin: 1rem 0;
}

.gainers-chart-container,
.losers-chart-container {
    height: 150px;
    margin-top: 1rem;
}

/* Chart buttons for temporal evolution */
.chart-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: #f3f4f6;
}

.btn-small.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* No data message */
.no-data {
    text-align: center;
    color: var(--gray);
    padding: 2rem;
    font-style: italic;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.dashboard-card.main-card {
    grid-column: span 2;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.dashboard-card.main-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.dashboard-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.dashboard-card.main-card h2 {
    margin: 0;
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 500;
}

.big-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1f2937;
}

.stat-detail {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

.gain-loss {
    font-size: 1rem;
}

.gain-loss .gain-value { 
    color: #10b981; 
    font-weight: 600; 
}

.gain-loss .loss-value { 
    color: #ef4444; 
    font-weight: 600; 
}

.gain-loss.negative .gain-value {
    color: #ef4444;
}

.gain-loss.negative .gain-pct {
    color: #ef4444;
}

.mini-chart-container { 
    height: 100px; 
    position: relative;
}

.sector-mini-list {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.sector-mini-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid #f3f4f6;
}

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

.sector-mini-item .sector-name {
    color: #4b5563;
}

.sector-mini-item .sector-pct {
    color: #9ca3af;
    font-weight: 500;
}

.dashboard-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
}

.dashboard-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: #374151;
}

.activity-list { 
    max-height: 300px; 
    overflow-y: auto; 
}

.activity-item { 
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem; 
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.activity-item:hover {
    background: #f9fafb;
}

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

.activity-icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 8px;
}

.activity-details {
    flex: 1;
}

.activity-title {
    font-weight: 500;
    color: #1f2937;
}

.activity-date {
    font-size: 0.75rem;
    color: #9ca3af;
}

.activity-amount {
    font-weight: 600;
    font-size: 0.9rem;
}

.activity-amount.positive {
    color: #10b981;
}

.activity-amount.negative {
    color: #ef4444;
}

/* Responsive adjustments for dashboard */
@media (max-width: 768px) {
    .dashboard-card.main-card {
        grid-column: span 1;
    }
    
    .big-value {
        font-size: 2rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
}

/* Dashboard Charts */
.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.chart-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.chart-card .chart-container {
    height: 250px;
    position: relative;
}
/* ============ IA INSIGHTS TAB ============ */
.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.credits-label {
    font-weight: 600;
    color: #6b7280;
}

.credits-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #10b981;
}

.credits-limit {
    color: #9ca3af;
    font-size: 1rem;
}

.credits-month {
    color: #6b7280;
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.insights-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.insights-content {
    margin-top: 1rem;
}

.insights-empty {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    color: var(--text-muted);
}

/* Account Tab - Theme Preferences */
.preference-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

.preference-row label {
    font-weight: 500;
    color: var(--text-primary);
}

.theme-options {
    display: flex;
    gap: 10px;
}

.theme-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.theme-btn:hover {
    border-color: var(--primary);
}

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

/* Broker badge */
.broker-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-hover);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* Accounts List */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.account-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-hover);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.account-item.default {
    border-color: var(--primary);
    background: rgba(52, 152, 219, 0.1);
}

.account-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.account-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.account-item-details {
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.account-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.account-badge.default {
    background: var(--primary);
    color: white;
}

.account-badge.currency {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.insights-empty p:first-child {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.insights-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.insights-meta {
    background: #f9fafb;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 0.875rem;
}

.insights-text {
    padding: 1.5rem;
    line-height: 1.6;
}

.insights-text h2 {
    color: #1f2937;
    margin: 1.25rem 0 0.75rem;
    font-size: 1.5rem;
}

.insights-text h3 {
    color: #374151;
    margin: 1rem 0 0.5rem;
    font-size: 1.25rem;
}

.insights-text h4 {
    color: #4b5563;
    margin: 0.75rem 0 0.5rem;
    font-size: 1.1rem;
}

.insights-text p {
    margin: 0 0 0.75rem 0;
    color: #4b5563;
}

.insights-text ul {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

.insights-text li {
    margin-bottom: 0.25rem;
    color: #4b5563;
}

.insights-text strong {
    color: #1f2937;
}

/* ============ INSIGHTS HISTORY DROPDOWN ============ */
.insights-history-dropdown {
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
}

.history-dropdown-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.history-dropdown-header:hover {
    background: var(--bg-hover);
}

.history-dropdown-header .history-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.history-dropdown-header .history-count {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.history-dropdown-header .history-arrow {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.history-dropdown-header.expanded .history-arrow {
    transform: rotate(180deg);
}

.history-dropdown-content {
    display: none;
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.history-dropdown-content.show {
    display: block;
}

#insights-history-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    margin-top: 1rem;
}

#insights-history-select:focus {
    outline: none;
    border-color: var(--primary);
}

#insights-history-select option {
    padding: 0.5rem;
}

/* History item styling in dropdown */
#insights-history-select option[value]:not([value=""]) {
    font-weight: 500;
}

/* Dark mode adjustments */
[data-theme="dark"] .insights-history-dropdown {
    background: var(--bg-hover);
}

[data-theme="dark"] #insights-history-select {
    background: var(--bg-card);
}

/* Legacy list styles (kept for compatibility) */
.insights-history-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.insights-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.insight-history-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
}

.insight-history-item.current {
    border-color: var(--primary);
    background: rgba(52, 152, 219, 0.08);
}

.insight-history-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.insight-history-date {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.insight-history-summary {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    gap: 1rem;
}

.insight-history-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.insight-history-value {
    font-weight: 600;
    font-size: 0.95rem;
}

.insight-history-value.positive {
    color: var(--gain-color);
}

.insight-history-value.negative {
    color: var(--loss-color);
}

.insight-history-pct {
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 6px;
}

.insight-history-pct.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--gain-color);
}

.insight-history-pct.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--loss-color);
}

.insight-history-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.insight-history-actions .btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.no-history {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
}

/* ============ SORTABLE TABLES ============ */
.data-table.sortable th[data-sort] {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.data-table.sortable th[data-sort]:hover {
    background: var(--bg-hover);
}

.sort-arrow {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-left: 4px;
}

.data-table.sortable th.sort-asc .sort-arrow,
.data-table.sortable th.sort-desc .sort-arrow {
    opacity: 1;
    color: var(--primary);
}

.data-table.sortable th.sort-asc,
.data-table.sortable th.sort-desc {
    background: var(--bg-hover);
    font-weight: 600;
}

/* View Toggle Buttons */
.view-toggle {
    margin-bottom: 16px;
}

.btn-toggle {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

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

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

/* Footer */
.app-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-brand strong {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.footer-version {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.footer-credits {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.credit-line {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.credit-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.credit-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .credit-line {
        align-items: center;
    }
    
    .footer-credits {
        justify-content: center;
    }
}

/* Export Menu */
.export-menu {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0;
}

.export-menu .btn-flat {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

.export-menu .btn-flat:hover {
    background: var(--bg-hover);
}

/* Credit name emphasis */
.credit-name em {
    font-style: normal;
    font-size: 0.75em;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Alerts Button and Badge */
.alerts-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 50%;
    position: relative;
    transition: background 0.2s;
}

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

.alerts-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 0.1rem 0.35rem;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Alerts Modal Tabs */
.alerts-tabs {
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

/* Alert Item */
.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 10px;
}

.alert-item.triggered {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--danger);
}

.alert-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-ticker {
    font-weight: bold;
    font-size: 1.1rem;
}

.alert-condition {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.alert-status {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
}

.alert-status.active {
    background: var(--success);
    color: white;
}

.alert-status.triggered {
    background: var(--danger);
    color: white;
}

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

.alert-actions button {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* Calendar Tab Styles */
.calendar-section {
    margin: 20px 0;
}

.calendar-section h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.calendar-upcoming {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.calendar-upcoming-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calendar-upcoming-item.ex-soon {
    border-left: 3px solid var(--warning);
}

.calendar-upcoming-item.ex-imminent {
    border-left: 3px solid var(--danger);
}

.calendar-upcoming-item .ticker {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-primary);
}

.calendar-upcoming-item .name {
    font-size: 0.85em;
    color: var(--text-muted);
}

.calendar-upcoming-item .date-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.calendar-upcoming-item .ex-date {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.calendar-upcoming-item .days-until {
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

.calendar-upcoming-item .days-until.soon {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.calendar-upcoming-item .amount {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--success);
}

.calendar-upcoming-item .yield {
    font-size: 0.85em;
    color: var(--text-muted);
}

/* Calendar table */
#calendar-table {
    margin-top: 15px;
}

#calendar-table th,
#calendar-table td {
    text-align: left;
    padding: 12px;
}

#calendar-table .positive {
    color: var(--success);
}

#calendar-table .negative {
    color: var(--danger);
}

/* Dividend FWD in dashboard */
.stat-detail strong {
    color: var(--success);
    font-weight: 600;
}
