/* ============================================
   Design Tokens
   ============================================ */
:root {
    --sidebar-w: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255,255,255,0.06);
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-active-bg: rgba(99,102,241,0.15);
    --sidebar-active-text: #818cf8;
    --sidebar-hover-bg: rgba(255,255,255,0.05);

    --content-bg: #f1f5f9;
    --card-bg: #ffffff;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-focus: #6366f1;

    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --accent-light: #e0e7ff;

    --positive: #10b981;
    --positive-bg: #d1fae5;
    --negative: #ef4444;
    --negative-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);

    --transition: all 0.18s ease;
}

/* ============================================
   Reset
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--content-bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
img { display: block; max-width: 100%; }

/* ============================================
   App Shell — Sidebar + Content
   ============================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.sidebar-logo svg {
    width: 28px; height: 28px;
    color: var(--sidebar-active-text);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-text);
    padding: 12px 8px 6px;
    opacity: 0.6;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item svg {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

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

.nav-item:hover svg { opacity: 1; }

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.nav-item.active svg { opacity: 1; }

.nav-item.danger { color: #f87171; }
.nav-item.danger:hover { background: rgba(239,68,68,0.1); color: #ef4444; }

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-info { min-width: 0; }

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.72rem;
    color: var(--sidebar-text);
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-content {
    padding: 32px;
    flex: 1;
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
    margin-bottom: 28px;
}

.page-header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { opacity: 0.5; }

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.card-body { padding: 24px; }

.card-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

/* ============================================
   Stat Cards
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stat-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn svg { width: 16px; height: 16px; }

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

.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

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

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

.btn-danger {
    background: white;
    color: var(--negative);
    border-color: #fca5a5;
}

.btn-danger:hover {
    background: var(--negative-bg);
    border-color: var(--negative);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 13px 28px;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   Tables
   ============================================ */
.table-wrap {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table thead th.text-right { text-align: right; }

.data-table thead th.sortable-col {
    cursor: pointer;
    user-select: none;
}

.data-table thead th.sortable-col:hover { color: var(--text-primary); }

.data-table thead th.sortable-col::after {
    content: '\2195';
    display: inline-block;
    margin-left: 4px;
    opacity: 0.35;
    font-size: 0.9em;
}

.data-table thead th.sortable-col.sort-asc::after { content: '\2191'; opacity: 1; }
.data-table thead th.sortable-col.sort-desc::after { content: '\2193'; opacity: 1; }

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
    cursor: pointer;
}

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

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

.data-table tbody td {
    padding: 14px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody td.text-right { text-align: right; }
.data-table tbody td.text-muted { color: var(--text-secondary); }

/* ============================================
   Forms
   ============================================ */
.form-group { margin-bottom: 20px; }

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

.form-label .required { color: var(--negative); margin-left: 2px; }

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 0.78rem;
    color: var(--negative);
    margin-top: 4px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-grid-2 .col-full { grid-column: 1 / -1; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check-input {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* ============================================
   Badges & Tags
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--positive-bg); color: #065f46; }
.badge-danger  { background: var(--negative-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-neutral { background: #f1f5f9; color: var(--text-secondary); }
.badge-accent  { background: var(--accent-light); color: var(--accent-dark); }

/* ============================================
   Alerts / Messages
   ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--positive-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--negative-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-bg);  color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: var(--accent-light); color: var(--accent-dark); border: 1px solid #a5b4fc; }

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 32px;
    text-align: center;
}

.empty-state svg {
    width: 52px; height: 52px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 320px;
    margin-bottom: 20px;
}

/* ============================================
   Transaction type tabs
   ============================================ */
.type-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius);
}

.type-tab {
    flex: 1;
    padding: 9px 16px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.type-tab svg { width: 16px; height: 16px; }

.type-tab.active-buy {
    background: white;
    color: var(--positive);
    box-shadow: var(--shadow-sm);
}

.type-tab.active-sell {
    background: white;
    color: var(--negative);
    box-shadow: var(--shadow-sm);
}
.type-tab.active-div  { background: white; color: #14532d;  box-shadow: var(--shadow-sm); }
.type-tab.active-spof { background: white; color: #92400e;  box-shadow: var(--shadow-sm); }
.type-tab.active-int  { background: white; color: #475569;  box-shadow: var(--shadow-sm); }
.type-tab.active-dep  { background: white; color: #4c1d95;  box-shadow: var(--shadow-sm); }
.type-tab.active-wit  { background: white; color: #991b1b;  box-shadow: var(--shadow-sm); }
.type-tab.active-exc  { background: white; color: #0c4a6e;  box-shadow: var(--shadow-sm); }
.type-tab.active-opt_paid { background: white; color: #86198f;  box-shadow: var(--shadow-sm); }
.type-tab.active-opt_rec  { background: white; color: #115e59;  box-shadow: var(--shadow-sm); }

/* ============================================
   Metric boxes (position detail)
   ============================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

.metric-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.metric-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.metric-value.positive { color: var(--positive); }
.metric-value.negative { color: var(--negative); }
.metric-value.sm { font-size: 1rem; }

.metric-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Dividend highlight block */
.dividend-block {
    background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    color: white;
}

.dividend-block .metric-box {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.15);
}

.dividend-block .metric-label { color: rgba(255,255,255,0.7); }
.dividend-block .metric-value { color: white; }
.dividend-block .metric-sub { color: rgba(255,255,255,0.65); }

/* ============================================
   Auth pages (no sidebar)
   ============================================ */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.auth-card-header {
    background: var(--sidebar-bg);
    padding: 28px 32px 24px;
    text-align: center;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-logo svg { width: 28px; height: 28px; color: #818cf8; }

.auth-tagline {
    font-size: 0.82rem;
    color: var(--sidebar-text);
}

.auth-card-body { padding: 28px 32px; }

.auth-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-google:hover {
    border-color: #4285f4;
    background: #f0f4ff;
    color: var(--text-primary);
}

.btn-google svg { width: 18px; height: 18px; }

.auth-footer-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.auth-footer-link a { color: var(--accent); font-weight: 600; }

/* ============================================
   Portfolio cards (list view)
   ============================================ */
.portfolio-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.portfolio-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 26px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 20px;
}

.portfolio-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.portfolio-card-body { flex: 1; min-width: 0; }

.portfolio-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.portfolio-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.portfolio-card-stats {
    display: flex;
    gap: 28px;
    flex-shrink: 0;
}

.pcs-item { text-align: right; }

.pcs-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.pcs-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.pcs-value.positive { color: var(--positive); }
.pcs-value.negative { color: var(--negative); }

.card-menu { position: relative; flex-shrink: 0; }

.card-menu-btn {
    background: none;
    border: none;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    line-height: 1;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    transition: background 0.15s, color 0.15s;
}
.card-menu-btn:hover { background: var(--content-bg); color: var(--text-secondary); }

.card-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.1);
    min-width: 130px;
    z-index: 200;
    overflow: hidden;
}
.card-menu-dropdown.open { display: block; }

.card-menu-dropdown a,
.card-menu-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}
.card-menu-dropdown a:hover,
.card-menu-dropdown button:hover { background: var(--content-bg); }
.card-menu-dropdown .menu-item-delete { color: var(--negative); }
.card-menu-dropdown .menu-item-delete:hover { background: #fef2f2; }

/* ============================================
   Transaction badge
   ============================================ */
.tx-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tx-badge.buy  { background: var(--positive-bg); color: #065f46; }
.tx-badge.sell { background: var(--negative-bg); color: #991b1b; }
.tx-badge.div  { background: #dbeafe; color: #1e40af; }
.tx-badge.spof { background: #fef3c7; color: #92400e; }
.tx-badge.int  { background: #f1f5f9; color: #475569; }
.tx-badge.dep  { background: #ede9fe; color: #4c1d95; }
.tx-badge.wit  { background: #fee2e2; color: #7f1d1d; }
.tx-badge.exc  { background: #e0f2fe; color: #0c4a6e; }
.tx-badge.opt_paid { background: #fae8ff; color: #86198f; }
.tx-badge.opt_rec  { background: #ccfbf1; color: #115e59; }

/* ============================================
   Tab switcher (positions table)
   ============================================ */
.tabs-row {
    display: flex;
    gap: 4px;
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover { background: var(--content-bg); color: var(--text-primary); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tab-summary-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}
.tab-summary-sep { color: var(--border); }

/* ============================================
   Positions table — return pill + row colors
   ============================================ */
.return-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}
.return-pill.positive { background: var(--positive-bg); color: #065f46; }
.return-pill.negative { background: var(--negative-bg); color: #991b1b; }

/* ============================================
   Activity feed
   ============================================ */
.activity-feed {
    display: flex;
    flex-direction: column;
}
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid #f1f5f9;
    border-left: 3px solid transparent;
    transition: background 0.15s;
    min-height: 48px;
}
.activity-item:last-child { border-bottom: none; }

.activity-expandable { cursor: pointer; }
.activity-expandable:hover { background: #f8fafc; }
.activity-item-expanded { background: #f8fafc; }

.activity-item-buy    { border-left-color: var(--positive); }
.activity-item-sell   { border-left-color: var(--negative); }
.activity-item-div    { border-left-color: #22c55e; }
.activity-item-spof   { border-left-color: #f59e0b; }
.activity-item-int    { border-left-color: #94a3b8; }
.activity-item-dep    { border-left-color: #7c3aed; }
.activity-item-wit    { border-left-color: #dc2626; }
.activity-item-exc    { border-left-color: #0284c7; }
.activity-item-opt_paid { border-left-color: #c026d3; }
.activity-item-opt_rec  { border-left-color: #0d9488; }

.activity-date {
    width: 76px;
    flex-shrink: 0;
    font-size: 0.78rem;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}
.activity-est {
    display: block;
    font-size: 0.65rem;
    color: #f59e0b;
    font-weight: 600;
}
.activity-date-flag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-top: 2px;
    padding: 1px 5px;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.4;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 4px;
    white-space: nowrap;
    cursor: help;
}
.activity-desc {
    flex: 1;
    font-size: 0.88rem;
    color: #334155;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.activity-amount {
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    min-width: 110px;
    text-align: right;
}
.activity-amount.positive { color: var(--positive); }
.activity-amount.negative { color: var(--negative); }
.activity-amount.neutral  { color: #334155; }
.activity-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.activity-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 8px;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.65rem;
    transition: transform 0.2s ease, background 0.2s, color 0.2s;
    user-select: none;
    flex-shrink: 0;
}
.activity-chevron-hidden { visibility: hidden; }
.activity-item-expanded .activity-chevron {
    background: var(--accent);
    color: #fff;
    transform: rotate(90deg);
}
.activity-detail {
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    padding: 8px 16px 8px 56px;
}
.activity-detail-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ledger-detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.78rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.ledger-detail-label {
    color: #94a3b8;
    font-weight: 500;
}
.ledger-detail-value {
    color: #0f172a;
    font-weight: 700;
}

.ledger-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.ledger-legend .tx-badge {
    cursor: pointer;
    transition: opacity 0.15s, filter 0.15s, box-shadow 0.15s, transform 0.1s;
    user-select: none;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08) inset;
}
.ledger-legend .tx-badge:hover {
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    transform: translateY(-1px);
}
.ledger-legend .tx-badge:active { transform: translateY(0) scale(0.95); }
.ledger-legend .tx-badge.tx-badge-muted {
    opacity: 0.5;
    filter: grayscale(100%);
    text-decoration: line-through;
    box-shadow: none;
}
.ledger-legend .tx-badge.tx-badge-muted:hover {
    opacity: 0.75;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}

.ledger-legend-sep {
    width: 1px;
    height: 14px;
    background: var(--border);
    margin: 0 2px;
}
.ledger-legend-action {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ledger-legend-action:hover { color: var(--accent); }

/* ============================================
   Yearly summary
   ============================================ */
.yearly-block {
    padding: 14px 16px;
}
.yearly-block-sep {
    border-bottom: 1px solid #f1f5f9;
}
.yearly-header {
    display: flex;
    align-items: baseline;
    gap: 20px;
    flex-wrap: wrap;
}
.yearly-year-num {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    min-width: 40px;
    flex-shrink: 0;
}
.yearly-native-metrics {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}
.yn-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.yn-label {
    font-size: 0.68rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.yn-val {
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.yn-pos { color: var(--positive); }
.yn-neg { color: var(--negative); }

.yearly-cur-section {
    margin-top: 10px;
    padding-left: 60px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.yearly-cur-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.yearly-cur-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 5px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    min-width: 36px;
    flex-shrink: 0;
}
.yearly-cur-items {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.yc-item {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}
.yc-label {
    font-size: 0.68rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.yc-val {
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Portfolio detail two-column grid
   ============================================ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .detail-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Chart container
   ============================================ */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 300px;
}

/* ============================================
   Utilities
   ============================================ */
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-bold   { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-sm     { font-size: 0.82rem; }
.text-xs     { font-size: 0.72rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mt-6 { margin-top: 24px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        transition: left 0.25s ease;
        z-index: 200;
    }

    .sidebar.open { left: 0; }

    .main-content { margin-left: 0; }

    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 14px 20px;
        background: var(--sidebar-bg);
        border-bottom: 1px solid var(--sidebar-border);
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .mobile-header-logo {
        display: flex;
        align-items: center;
        gap: 8px;
        color: white;
        font-weight: 700;
        font-size: 1rem;
    }

    .mobile-header-logo svg { width: 22px; height: 22px; color: var(--sidebar-active-text); }

    .mobile-menu-btn {
        background: none;
        border: none;
        cursor: pointer;
        color: white;
        padding: 4px;
    }

    .mobile-menu-btn svg { width: 24px; height: 24px; }

    .page-content { padding: 20px; }

    .stats-grid { grid-template-columns: 1fr 1fr; }

    .portfolio-card-stats { display: none; }

    .form-grid-2 { grid-template-columns: 1fr; }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 150;
    }

    .sidebar-overlay.visible { display: block; }
}

.mobile-header { display: none; }

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .auth-card-body { padding: 24px 20px; }
    .auth-card-header { padding: 24px 20px 20px; }
    .page-header-inner { flex-direction: column; gap: 12px; }
    .page-header-inner .btn { width: 100%; justify-content: center; }
}
