:root {
    --sidebar-bg: #1a2332;
    --sidebar-width: 240px;
    --content-bg: #f0f2f5;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --accent: #3b82f6;
    --accent-dark: #2563eb;
}

body {
    background: var(--content-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
}

/* Sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

#sidebar .sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

#sidebar .sidebar-brand h5 {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    margin: 0;
    letter-spacing: 0.5px;
}

#sidebar .sidebar-brand small {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
}

#sidebar .nav-section {
    padding: 1rem 0 0.5rem 1rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}

#sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 0;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

#sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.07);
}

#sidebar .nav-link.active {
    color: #fff;
    background: rgba(59,130,246,0.2);
    border-left-color: var(--accent);
}

#sidebar .nav-link .nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.85;
    flex-shrink: 0;
}

#sidebar .sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Main content */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.page-body {
    padding: 1.5rem;
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    padding: 1rem 1.25rem;
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
}

/* KPI Cards */
.kpi-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    border: none;
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 0.4rem;
}

.kpi-card .kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
    line-height: 1;
}

.kpi-card .kpi-sub {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: 0.3rem;
}

.kpi-card .kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Tables */
.table {
    font-size: 0.875rem;
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #6b7280;
    border-bottom: 2px solid #f3f4f6;
    background: #fafafa;
}

.table td {
    vertical-align: middle;
    color: #374151;
}

.table-hover tbody tr:hover {
    background: #f9fafb;
}

/* Badges */
.badge-buy { background: #dcfce7; color: #16a34a; }
.badge-sell { background: #fee2e2; color: #dc2626; }
.badge-dividend { background: #fef9c3; color: #ca8a04; }
.badge-interest { background: #dbeafe; color: #2563eb; }
.badge-transfer_in { background: #e0e7ff; color: #4f46e5; }
.badge-transfer_out { background: #fce7f3; color: #db2777; }
.badge-card { background: #f3f4f6; color: #6b7280; }

.type-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* P&L colors */
.text-profit { color: #16a34a !important; }
.text-loss { color: #dc2626 !important; }
.text-neutral { color: #6b7280 !important; }

.amount-positive { color: #16a34a; font-weight: 500; }
.amount-negative { color: #dc2626; font-weight: 500; }

/* Login */
.login-page {
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-card .login-subtitle {
    font-size: 0.85rem;
    color: #9ca3af;
    text-align: center;
    margin-bottom: 2rem;
}

/* Spinner */
.price-loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Charts */
.chart-container {
    position: relative;
    width: 100%;
}

/* Summary row */
.table tfoot td {
    font-weight: 700;
    border-top: 2px solid #e5e7eb;
    background: #f9fafb;
}

/* Filter bar */
.filter-bar {
    background: #fff;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #main-content {
        margin-left: 0;
    }
}

/* ── Gráficas ─────────────────────────────────────────── */
.graficas-toolbar {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: var(--card-shadow);
}

.period-selector {
    display: flex;
    gap: 4px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 8px;
}
.period-btn {
    border: none;
    background: transparent;
    padding: 5px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all .15s;
}
.period-btn:hover { background: #e5e7eb; color: #374151; }
.period-btn.active { background: #1a2332; color: #fff; }

.chart-card {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1rem 0.75rem;
    box-shadow: var(--card-shadow);
    transition: box-shadow .2s;
    height: 100%;
}
.chart-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.1); }

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}
.chart-asset-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #111827;
    line-height: 1.3;
}
.chart-asset-meta {
    font-size: 0.72rem;
    color: #9ca3af;
    margin-top: 2px;
}
.chart-price {
    font-weight: 700;
    font-size: 1rem;
    color: #111827;
}
.chart-change {
    font-size: 0.78rem;
    font-weight: 600;
    text-align: right;
}
.chart-change.up   { color: #10b981; }
.chart-change.down { color: #ef4444; }
.chart-change.flat { color: #9ca3af; }

.chart-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid #f3f4f6;
    font-size: 0.75rem;
    color: #6b7280;
}
.pnl-badge {
    font-weight: 700;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 20px;
}
.pnl-badge.up   { color: #10b981; background: #ecfdf5; }
.pnl-badge.down { color: #ef4444; background: #fef2f2; }

.spinner-sm {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: #1a2332;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}
