/* ===== RESET & ROOT ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: rgba(99,102,241,0.12);
    --success: #10b981;
    --success-light: rgba(16,185,129,0.12);
    --danger: #ef4444;
    --danger-light: rgba(239,68,68,0.12);
    --warning: #f59e0b;
    --warning-light: rgba(245,158,11,0.12);
    --purple: #8b5cf6;
    --purple-light: rgba(139,92,246,0.12);
    --cyan: #06b6d4;
    --cyan-light: rgba(6,182,212,0.12);
    --orange: #f97316;
    --orange-light: rgba(249,115,22,0.12);
    --bg: #000000;
    --card: #0a0a0f;
    --card2: #0f0f18;
    --text: #d4d4d8;
    --text-muted: #52525b;
    --border: #18181b;
    --sidebar-bg: #000000;
    --sidebar-text: #52525b;
    --sidebar-active: #6366f1;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --shadow: 0 1px 4px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 32px rgba(0,0,0,0.6);
    --radius: 10px;
    --radius-sm: 6px;
    --accent: #818cf8;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== LIGHT THEME (must be after :root) ===== */
html.light-theme {
    --bg: #f5f5f7 !important;
    --card: #ffffff !important;
    --card2: #f0f0f5 !important;
    --text: #1a1a2e !important;
    --text-muted: #6b7280 !important;
    --border: #e5e7eb !important;
    --sidebar-bg: #ffffff !important;
    --sidebar-text: #6b7280 !important;
    --sidebar-active: #6366f1 !important;
    --shadow: 0 1px 4px rgba(0,0,0,0.08) !important;
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1) !important;
    --shadow-lg: 0 10px 32px rgba(0,0,0,0.12) !important;
}
html.light-theme body { background: #f5f5f7; color: #1a1a2e; }
html.light-theme .sidebar { background: #ffffff; border-right: 1px solid #e5e7eb; }
html.light-theme .sidebar-header { border-bottom-color: #e5e7eb; }
html.light-theme .topbar { background: #ffffff !important; border-bottom-color: #e5e7eb; }
html.light-theme .logo-text { color: #1a1a2e; }
html.light-theme .nav-item { color: #6b7280; }
html.light-theme .nav-item:hover { background: rgba(0,0,0,0.05); color: #1a1a2e; }
html.light-theme .nav-item.active { background: rgba(99,102,241,0.12); color: #4f46e5; }
html.light-theme .stat-card,
html.light-theme .dash-card,
html.light-theme .form-card,
html.light-theme .trade-item,
html.light-theme .analytics-card,
html.light-theme .chart-card,
html.light-theme .risk-card,
html.light-theme .tax-card,
html.light-theme .tax-summary-card,
html.light-theme .calendar-container,
html.light-theme .cal-stat-card,
html.light-theme .portfolio-item,
html.light-theme .report-content,
html.light-theme .broker-item,
html.light-theme .goal-item,
html.light-theme .index-pill,
html.light-theme .breadth-card,
html.light-theme .sector-card,
html.light-theme .sector-holding-item,
html.light-theme .tip-card,
html.light-theme .portfolio-group-card,
html.light-theme .tags-cloud,
html.light-theme .modal-content,
html.light-theme .mistakes-score-bar,
html.light-theme .mistake-card,
html.light-theme .mistake-date-section,
html.light-theme .history-entry,
html.light-theme .flow-table { background: #ffffff; }
html.light-theme .recent-trade-item,
html.light-theme .strategy-item,
html.light-theme .trade-note,
html.light-theme .risk-result,
html.light-theme .dash-goal-item,
html.light-theme .calendar-day { background: #f9fafb; }
html.light-theme .form-group input,
html.light-theme .form-group select,
html.light-theme .form-group textarea { background: #f9fafb; border-color: #d1d5db; color: #1a1a2e; }
html.light-theme .filters-bar select,
html.light-theme .filters-bar input { background: #ffffff; border-color: #d1d5db; color: #1a1a2e; }
html.light-theme .topbar-icon-btn { background: #f3f4f6; border-color: #e5e7eb; color: #374151; }
html.light-theme .topbar-icon-btn:hover { background: #e5e7eb; }
html.light-theme .btn-outline { border-color: #d1d5db; color: #374151; }
html.light-theme .mf-btn { background: #ffffff; border-color: #d1d5db; color: #6b7280; }
html.light-theme .nav-section-label { color: #9ca3af; }
html.light-theme .flow-table th { background: #f3f4f6; color: #6b7280; }
html.light-theme .flow-table td { border-bottom-color: #e5e7eb; }
html.light-theme .page-title { color: #1a1a2e; }
html.light-theme .stat-value { color: #1a1a2e; }
html.light-theme .hamburger { color: #1a1a2e; }
html.light-theme .btn-icon { background: #ffffff; border-color: #d1d5db; color: #374151; }
html.light-theme .report-btn { background: #ffffff; border-color: #d1d5db; color: #374151; }
html.light-theme .report-table th { background: #f3f4f6; }
html.light-theme .month-cell.neutral { background: #f3f4f6; border-color: #e5e7eb; }
html.light-theme .tag-pill { background: #f3f4f6; border-color: #e5e7eb; color: #6b7280; }
html.light-theme .progress-bar-container { background: #e5e7eb; }
html.light-theme .user-topbar-name { color: #1a1a2e; }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon { font-size: 1.5rem; }

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.3px;
}

.logo-pro {
    color: var(--warning);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--warning-light);
    color: var(--warning);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.sidebar-close:hover { background: rgba(255,255,255,0.1); color: white; }

.sidebar-nav {
    padding: 12px 10px;
    flex: 1;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #475569;
    padding: 12px 10px 6px;
    text-transform: uppercase;
}

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

.nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: white;
}

.nav-item.active {
    background: rgba(37,99,235,0.25);
    color: #60a5fa;
    font-weight: 600;
}

.nav-item.active .nav-icon { filter: none; }
.nav-icon { font-size: 1.1rem; min-width: 22px; }
.nav-text { flex: 1; }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ===== MAIN LAYOUT ===== */
.main-layout {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ===== TOPBAR ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 16px;
    box-shadow: var(--shadow);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: none;
}

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

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.market-indicators {
    display: flex;
    gap: 6px;
}

.market-pill {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.market-pill.stocks { background: var(--success-light); color: var(--success); }
.market-pill.crypto { background: var(--warning-light); color: var(--warning); }
.market-pill.forex { background: var(--cyan-light); color: var(--cyan); }

.topbar-icon-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    color: var(--text);
}

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

/* ===== PAGE CONTENT ===== */
.page-content {
    flex: 1;
    padding: 24px;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--text-muted); color: white; }
.btn-secondary:hover { background: var(--text); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; padding: 7px 14px; font-size: 0.85rem; }
.btn-edit { background: var(--warning); color: white; padding: 7px 14px; font-size: 0.85rem; }

/* ===== DASHBOARD STATS ===== */
.market-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.mf-btn {
    padding: 8px 18px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.25s;
}

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

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

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid transparent;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.accent-blue { border-left-color: var(--primary); }
.accent-green { border-left-color: var(--success); }
.accent-purple { border-left-color: var(--purple); }
.accent-orange { border-left-color: var(--orange); }
.accent-cyan { border-left-color: var(--cyan); }
.accent-yellow { border-left-color: var(--warning); }

.stat-icon { font-size: 2rem; min-width: 40px; text-align: center; }
.stat-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.7rem; font-weight: 800; color: var(--text); margin: 2px 0; }
.stat-sub { font-size: 0.78rem; color: var(--text-muted); }

.profit-loss.pl-up .stat-value { color: var(--success); }
.profit-loss.pl-down .stat-value { color: var(--danger); }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dash-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.dash-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.dash-card-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); }

.recent-trades-list { display: flex; flex-direction: column; gap: 10px; }

.recent-trade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

/* ===== FORM STYLES ===== */
.form-card {
    background: var(--card);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 1000px;
}

.form-card h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; color: var(--text); }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 18px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.form-group textarea { resize: vertical; min-height: 100px; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* ===== SCREENSHOT UPLOAD ===== */
.screenshot-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.screenshot-upload:hover { border-color: var(--primary); background: var(--primary-light); }

.screenshot-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.upload-icon { font-size: 1.5rem; }

.screenshot-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

/* ===== FILTERS BAR ===== */
.filters-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filters-bar select,
.filters-bar input {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text);
    background: var(--card);
    cursor: pointer;
    transition: border-color 0.2s;
}

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

/* ===== TRADES LIST ===== */
.trades-list { display: flex; flex-direction: column; gap: 12px; }

.trade-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
    transition: transform 0.2s;
}

.trade-item:hover { transform: translateX(4px); }
.trade-item.buy { border-left-color: var(--success); }
.trade-item.sell { border-left-color: var(--danger); }

.trade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.trade-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.trade-symbol { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.badge {
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-buy { background: var(--success-light); color: var(--success); }
.badge-sell { background: var(--danger-light); color: var(--danger); }
.badge-intraday { background: var(--primary-light); color: var(--primary); }
.badge-swing { background: var(--purple-light); color: var(--purple); }
.badge-investment { background: var(--warning-light); color: var(--warning); }
.badge-open { background: var(--cyan-light); color: var(--cyan); }
.badge-closed { background: #f1f5f9; color: var(--text-muted); }
.badge-exchange { background: var(--bg); color: var(--text-muted); font-weight: 600; }
.badge-sector { background: var(--purple-light); color: var(--purple); }

.trade-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 10px;
}

.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.detail-value { font-size: 0.95rem; font-weight: 600; color: var(--text); }

.trade-note {
    background: var(--bg);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 10px;
}

.trade-screenshot {
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-height: 120px;
}

.trade-screenshot img {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}

.trade-screenshot img:hover { transform: scale(1.02); }

.trade-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

.tag-pill {
    padding: 3px 9px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tag-pill:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.tag-pill.active { background: var(--primary); color: white; border-color: var(--primary); }

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

/* ===== PORTFOLIO ===== */
.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.portfolio-card {
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s;
}

.portfolio-card:hover { transform: translateY(-3px); }
.blue-card { background: linear-gradient(135deg, #eff6ff, #dbeafe); border: 1px solid #bfdbfe; }
.orange-card { background: linear-gradient(135deg, #fff7ed, #ffedd5); border: 1px solid #fed7aa; }
.cyan-card { background: linear-gradient(135deg, #ecfeff, #cffafe); border: 1px solid #a5f3fc; }

.portfolio-card-icon { font-size: 2rem; margin-bottom: 8px; }
.portfolio-card h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 12px; }
.portfolio-value { font-size: 1.8rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.portfolio-pl { font-size: 0.95rem; font-weight: 600; }

.portfolio-list { display: flex; flex-direction: column; gap: 12px; }

.portfolio-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.portfolio-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.portfolio-item-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ===== MULTIPLE PORTFOLIOS ===== */
.portfolios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.portfolio-group-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
    cursor: pointer;
    transition: transform 0.2s;
}

.portfolio-group-card:hover { transform: translateY(-3px); }

/* ===== CALENDAR ===== */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s;
    color: var(--text);
}

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

.month-year-display {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 160px;
    text-align: center;
}

.calendar-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.cal-stat-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cal-stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.cal-stat-value { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.cal-stat-value.success { color: var(--success); }
.cal-stat-value.danger { color: var(--danger); }

.calendar-container {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 8px;
}

.calendar-day-name {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 0;
    text-transform: uppercase;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 70px;
    background: var(--card);
}

.calendar-day:hover { border-color: var(--primary); background: var(--primary-light); }
.calendar-day.today { border-color: var(--primary); border-width: 2px; }
.calendar-day.other-month { opacity: 0.3; }
.calendar-day.profit-day { background: linear-gradient(135deg, rgba(16,185,129,0.06), rgba(16,185,129,0.14)); border-color: var(--success); }
.calendar-day.loss-day { background: linear-gradient(135deg, rgba(239,68,68,0.06), rgba(239,68,68,0.14)); border-color: var(--danger); }

.cal-day-num { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.cal-trade-count { font-size: 0.65rem; color: var(--text-muted); }
.cal-day-pl { font-size: 0.68rem; font-weight: 700; margin-top: 2px; }
.cal-day-pl.up { color: var(--success); }
.cal-day-pl.down { color: var(--danger); }

.selected-day-details {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.selected-day-details h3 { margin-bottom: 16px; font-size: 1rem; }

/* ===== CHARTS ===== */
.chart-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow-x: auto;
}

.chart-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 20px; color: var(--text); }

.chart-card canvas {
    display: block;
    width: 100% !important;
    height: auto;
    max-height: 400px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.charts-grid .chart-card { margin-bottom: 0; }
.charts-grid canvas { max-height: 260px; }

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
}

.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-muted); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

.monthly-heatmap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    padding: 10px 0;
}

.month-cell {
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    transition: transform 0.2s;
    cursor: pointer;
    border: 1.5px solid transparent;
}

.month-cell:hover { transform: scale(1.05); }
.month-cell.neutral { background: var(--bg); border-color: var(--border); }
.month-cell.positive { background: var(--success-light); border-color: #86efac; }
.month-cell.negative { background: var(--danger-light); border-color: #fca5a5; }
.month-name { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.month-pl { font-size: 0.9rem; font-weight: 700; }
.month-pl.positive { color: var(--success); }
.month-pl.negative { color: var(--danger); }

/* ===== SECTOR ANALYSIS ===== */
.sector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.sector-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}

.sector-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.sector-card.green { border-left-color: var(--success); }
.sector-card.red { border-left-color: var(--danger); }

.sector-name { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.sector-change { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.sector-change.up { color: var(--success); }
.sector-change.down { color: var(--danger); }
.sector-meta { font-size: 0.8rem; color: var(--text-muted); }

.sector-details-container { margin-bottom: 24px; }
.sector-details-container h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.sector-holdings { display: flex; flex-direction: column; gap: 10px; }

.sector-holding-item {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.trading-recommendations h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }

.tips-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.tip-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--border);
}

.green-tip { border-top-color: var(--success); }
.red-tip { border-top-color: var(--danger); }
.yellow-tip { border-top-color: var(--warning); }

.tip-card h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.tip-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.7; }

/* ===== ANALYTICS ===== */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.analytics-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.analytics-card.full-width { grid-column: 1 / -1; }

.analytics-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; color: var(--text); }

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

.metric:last-child { border-bottom: none; }
.metric-label { font-size: 0.85rem; color: var(--text-muted); }
.metric-value { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.metric-value.success { color: var(--success); }
.metric-value.danger { color: var(--danger); }

.strategy-stats { display: flex; flex-direction: column; gap: 10px; }

.strategy-item {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.strategy-name { font-size: 0.9rem; font-weight: 600; }
.strategy-metrics { display: flex; gap: 16px; font-size: 0.82rem; }
.strategy-metric { color: var(--text-muted); }
.strategy-metric.success { color: var(--success); }
.strategy-metric.danger { color: var(--danger); }

/* ===== RISK MANAGEMENT ===== */
.risk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.risk-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.risk-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 20px; }

.risk-result {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.risk-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
}

.risk-metric span { color: var(--text-muted); }
.risk-metric strong { font-size: 1rem; color: var(--text); }

/* ===== GOALS TRACKER ===== */
.goals-list { display: flex; flex-direction: column; gap: 14px; }

.goal-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.goal-title { font-size: 1rem; font-weight: 700; }
.goal-deadline { font-size: 0.8rem; color: var(--text-muted); }

.progress-bar-container {
    background: var(--bg);
    border-radius: 20px;
    height: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 20px;
    background: var(--primary);
    transition: width 0.5s ease;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

.progress-text { font-size: 0.8rem; color: var(--text-muted); }

.dash-goals { display: flex; flex-direction: column; gap: 10px; }
.dash-goal-item {
    padding: 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.dash-goal-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }

/* ===== TAGS ===== */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 16px 0;
}

.tag-cloud-item {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-cloud-item:hover { background: var(--primary); color: white; }

/* ===== TAX CALCULATOR ===== */
.tax-info-bar {
    display: flex;
    gap: 16px;
    padding: 14px 20px;
    background: var(--primary-light);
    border-radius: var(--radius);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tax-info-item { display: flex; gap: 8px; font-size: 0.85rem; color: var(--text); }
.tax-info-item strong { color: var(--primary); }

.tax-year-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.tax-year-selector select {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
}

.tax-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.tax-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.tax-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 6px; }
.tax-note { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 14px; }

.tax-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.tax-metric:last-child { border-bottom: none; }
.tax-metric span { color: var(--text-muted); }
.tax-metric.tax-highlight { background: var(--bg); padding: 10px; border-radius: var(--radius-sm); border: none; margin-top: 4px; }
.tax-metric.tax-highlight strong { font-size: 1rem; color: var(--danger); }

.tax-summary-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
}

.tax-summary-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }

.tax-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.tax-summary-row.highlight {
    background: var(--primary-light);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: none;
    margin-top: 8px;
    font-weight: 700;
}

.tax-summary-row.highlight strong { font-size: 1.1rem; color: var(--danger); }
.tax-disclaimer { font-size: 0.78rem; color: var(--text-muted); margin-top: 14px; font-style: italic; }

/* ===== REPORTS ===== */
.reports-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.report-btn {
    padding: 12px 24px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    color: var(--text);
}

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

.report-content {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.report-section { margin-bottom: 30px; }
.report-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.report-table th, .report-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.report-table th { background: var(--bg); font-weight: 700; color: var(--text-muted); }
.report-table tr:hover { background: var(--bg); }

/* ===== BROKER TRACKER ===== */
.broker-list { display: flex; flex-direction: column; gap: 12px; }

.broker-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.broker-name { font-size: 1rem; font-weight: 700; }
.broker-type { font-size: 0.78rem; color: var(--text-muted); }
.broker-fees { display: flex; gap: 20px; font-size: 0.85rem; }
.broker-fee-item span { color: var(--text-muted); }
.broker-fee-item strong { color: var(--text); }

.broker-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 12px;
}

.broker-summary-item {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px;
    box-shadow: var(--shadow);
}

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

.modal.open { display: flex; }

.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92) translateY(-20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover { background: var(--danger-light); color: var(--danger); }

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

/* ===== UTILITIES ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.empty-state.small { padding: 24px 12px; }

.success { color: var(--success) !important; }
.danger { color: var(--danger) !important; }
.warning { color: var(--warning) !important; }

.section-description {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ===== NOTIFICATIONS ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    font-size: 0.9rem;
    font-weight: 600;
    max-width: 320px;
    animation: notifIn 0.3s ease;
}

@keyframes notifIn {
    from { transform: translateX(350px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== MARKET LIVE & HEATMAP ===== */
.live-dot {
    width: 8px; height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-left: auto;
    animation: livePulse 1.5s infinite;
    flex-shrink: 0;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

.live-badge {
    background: #10b981;
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    animation: livePulse 1.5s infinite;
}

.live-badge-sm {
    background: #10b981;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    margin-left: 6px;
    vertical-align: middle;
    animation: livePulse 1.5s infinite;
}

.market-live-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.market-live-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.market-live-title h2 { font-size: 1.3rem; font-weight: 800; }

.market-live-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-updated {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Indices Bar */
.indices-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    overflow-x: auto;
    padding-bottom: 4px;
}

.index-pill {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 130px;
    border-top: 3px solid var(--border);
    transition: transform 0.2s;
}

.index-pill:hover { transform: translateY(-2px); }
.index-pill.up { border-top-color: var(--success); }
.index-pill.down { border-top-color: var(--danger); }

.index-name { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.index-value { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.index-change { font-size: 0.82rem; font-weight: 700; margin-top: 2px; }
.index-change.up { color: var(--success); }
.index-change.down { color: var(--danger); }
.index-loading { color: var(--text-muted); font-size: 0.9rem; padding: 12px; }

/* Main Heatmap */
.heatmap-section { margin-bottom: 24px; }
.heatmap-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }

.data-source-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(16,185,129,0.15);
    color: #10b981;
    margin-left: 8px;
    vertical-align: middle;
}

/* TradingView Heatmap Widget Wrapper */
.tv-heatmap-wrapper {
    width: 100%;
    height: 600px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.tv-heatmap-wrapper .tradingview-widget-container__widget {
    width: 100% !important;
    height: 100% !important;
}

.tv-heatmap-wrapper iframe {
    width: 100% !important;
    height: 100% !important;
    border: none;
    border-radius: var(--radius);
}

.tradingview-widget-copyright {
    font-size: 0.72rem;
    text-align: center;
    padding: 6px 0;
    color: var(--text-muted);
}

.tradingview-widget-copyright a { color: var(--primary); text-decoration: none; }
.tradingview-widget-copyright a:hover { text-decoration: underline; }

@media (max-width: 768px) {
    .tv-heatmap-wrapper { height: 400px; }
}

@media (max-width: 480px) {
    .tv-heatmap-wrapper { height: 320px; }
}

/* Legacy heatmap styles (kept for mini heatmap) */
.heatmap-legend {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.heatmap-legend-item {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: white;
}

.main-heatmap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.heatmap-tile {
    border-radius: var(--radius);
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    color: white;
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.heatmap-tile:hover { transform: scale(1.04); box-shadow: var(--shadow-lg); }

.heatmap-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius);
}

.tile-sector { font-size: 0.78rem; font-weight: 700; text-align: center; opacity: 0.9; margin-bottom: 4px; }
.tile-value { font-size: 1.2rem; font-weight: 800; }
.tile-change { font-size: 1rem; font-weight: 700; }
.tile-price { font-size: 0.75rem; opacity: 0.85; margin-top: 4px; }

.heatmap-loading, .flow-loading, .breadth-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Mini Heatmap on Dashboard */
.dash-heatmap-card { width: 100%; }

.mini-heatmap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mini-tile {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    min-width: 90px;
    cursor: pointer;
    transition: transform 0.2s;
}

.mini-tile:hover { transform: scale(1.05); }
.mini-tile-name { font-size: 0.68rem; font-weight: 700; opacity: 0.9; }
.mini-tile-change { font-size: 0.88rem; font-weight: 800; margin-top: 2px; }

/* Sectorial Flow Table */
.sectorial-flow-section { margin-bottom: 24px; }
.sectorial-flow-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }

.sectorial-flow-table { overflow-x: auto; }

.flow-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: 0.88rem;
}

.flow-table th {
    background: var(--sidebar-bg);
    color: #94a3b8;
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.flow-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.flow-table tr:last-child td { border-bottom: none; }
.flow-table tr:hover td { background: var(--bg); }

.flow-bar-container {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    width: 120px;
    overflow: hidden;
}

.flow-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.flow-bar.up { background: var(--success); }
.flow-bar.down { background: var(--danger); }

/* Market Breadth */
.market-breadth-section { margin-bottom: 24px; }
.market-breadth-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }

.market-breadth-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.breadth-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.breadth-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.breadth-value { font-size: 1.6rem; font-weight: 800; }
.breadth-value.up { color: var(--success); }
.breadth-value.down { color: var(--danger); }
.breadth-value.neutral { color: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .sidebar-overlay.open { display: block; }
    .main-layout { margin-left: 0; }
    .hamburger { display: block; }
    .market-indicators { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 1.3rem; }
    .form-row { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .topbar-right .btn-sm { display: none; }
    .risk-grid { grid-template-columns: 1fr; }
    .tax-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; }
    .filters-bar select,
    .filters-bar input { width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .portfolio-summary { grid-template-columns: 1fr; }
    .calendar-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===================================================== */
/* ===== SECTOR-WISE STOCK BREAKDOWN (Market Live) ===== */
/* ===================================================== */
.sector-stocks-section {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    border: 1px solid var(--border);
}
.sector-stocks-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.sector-stocks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sector-stocks-card {
    background: var(--card2, var(--bg));
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.sector-stocks-card:hover {
    box-shadow: var(--shadow-md);
}
.sector-stocks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    background: var(--card);
    gap: 12px;
    flex-wrap: wrap;
}
.sector-stocks-header:hover {
    background: var(--card2, var(--bg));
}
.sector-stocks-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
.sector-stocks-title strong {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.sector-stocks-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.sector-stocks-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sector-stocks-change {
    font-size: 0.95rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}
.sector-stocks-change.up {
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
}
.sector-stocks-change.down {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}
.sector-stocks-toggle {
    font-size: 0.85rem;
    color: var(--text-muted);
    width: 18px;
    text-align: center;
}
.sector-stocks-body {
    padding: 0 16px 14px 16px;
    background: var(--card2, var(--bg));
    margin-top: 0;
}
.sector-stocks-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.sector-stocks-table thead th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.sector-stocks-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.sector-stocks-table tbody tr:last-child {
    border-bottom: none;
}
.sector-stocks-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}
.sector-stocks-table td {
    padding: 8px 10px;
    font-size: 0.88rem;
    color: var(--text);
}
.sector-stocks-table td.ss-sym strong {
    font-weight: 700;
    font-size: 0.9rem;
}
.sector-stocks-table td.ss-ltp {
    font-variant-numeric: tabular-nums;
}
.sector-stocks-table td.ss-pct,
.sector-stocks-table td.ss-abs {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

@media (max-width: 768px) {
    .sector-stocks-table td,
    .sector-stocks-table thead th {
        padding: 6px 6px;
        font-size: 0.8rem;
    }
    .sector-stocks-meta {
        display: block;
        margin-top: 2px;
    }
}

/* ===================================================
   AI TOOLS PAGE
   =================================================== */

/* NEW badge on nav item */
.nav-badge-new {
    display: inline-block;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 20px;
    margin-left: auto;
    text-transform: uppercase;
    line-height: 1.6;
    flex-shrink: 0;
}

/* API Key setup banner */
.ai-setup-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid #a855f7;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.ai-setup-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}
.ai-setup-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 180px;
}
.ai-setup-info strong {
    font-size: 0.95rem;
    color: var(--text);
}
.ai-setup-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.ai-key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ai-key-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    padding: 7px 12px;
    width: 230px;
    outline: none;
    transition: border-color 0.2s;
}
.ai-key-input:focus {
    border-color: #a855f7;
}
.ai-key-row button {
    background: #a855f7;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}
.ai-key-row button:hover {
    background: #9333ea;
}
.ai-key-row button:last-child {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.ai-key-row button:last-child:hover {
    border-color: #ef4444;
    color: #ef4444;
}
.ai-key-status {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Grid layout for tool cards */
.ai-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

/* Individual AI tool card */
.ai-tool-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ai-tool-card:hover {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.08);
}
.ai-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.ai-card-icon {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}
.ai-card-title {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.ai-card-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.ai-card-title p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Inputs inside AI cards */
.ai-mini-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}
.ai-mini-input:focus {
    border-color: #a855f7;
}
.ai-select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}
.ai-select:focus {
    border-color: #a855f7;
}

/* Setup scorer two-column grid */
.ai-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.ai-input-grid label,
.ai-card-body label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.03em;
    display: block;
    margin-bottom: 3px;
    text-transform: uppercase;
}

/* Run button */
.ai-run-btn {
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 10px 18px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s, transform 0.1s;
    letter-spacing: 0.03em;
}
.ai-run-btn:hover:not(:disabled) {
    opacity: 0.88;
    transform: translateY(-1px);
}
.ai-run-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* Output box */
.ai-output {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.65;
    min-height: 80px;
    max-height: 340px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    display: none;
}
.ai-output.visible {
    display: block;
}
.ai-output strong {
    color: var(--text);
    font-weight: 700;
}
.ai-output .ai-score-badge {
    display: inline-block;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
    padding: 4px 16px;
    border-radius: 20px;
    margin-bottom: 10px;
}

/* Scrollbar inside output */
.ai-output::-webkit-scrollbar {
    width: 4px;
}
.ai-output::-webkit-scrollbar-track {
    background: transparent;
}
.ai-output::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-tools-grid {
        grid-template-columns: 1fr;
    }
    .ai-setup-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .ai-key-input {
        width: 100%;
    }
    .ai-input-grid {
        grid-template-columns: 1fr;
    }
}
