/* === TradeRaiserAI Theme System (WCAG AA contrast) ===
   Default = dark. Light via html[data-bs-theme="light"].
   Prefer var(--text-*) / theme utility classes over hardcoded Bootstrap colors.
*/
:root,
[data-bs-theme="dark"] {
    --bg-primary: #0b0e11;
    --bg-secondary: #1e2329;
    --bg-card: #181a20;
    --bg-card-hover: #1e2329;
    --bg-input: #2b3139;
    --bg-sidebar: #0b0e11;
    --bg-elevated: #1a1d24;
    --border-color: #2b3139;
    --border-strong: #3a4149;
    --text-primary: #f3f4f6;      /* gray-100 — body text on dark */
    --text-secondary: #d1d5db;    /* gray-300 — labels */
    --text-muted: #9ca3af;        /* gray-400 — still ≥4.5:1 on #0b0e11 */
    --text-inverse: #111827;
    --accent-green: #0ecb81;
    --accent-red: #f6465d;
    --accent-blue: #3b82f6;
    --accent-yellow: #f0b90b;
    --accent-info: #38bdf8;
    --surface-success: rgba(14, 203, 129, 0.12);
    --surface-danger: rgba(246, 70, 93, 0.12);
    --surface-warning: rgba(240, 185, 11, 0.12);
    --surface-info: rgba(56, 189, 248, 0.12);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --compliance-bg: linear-gradient(135deg, #1a1a2e, #16213e);
    --sidebar-width: 240px;
    --navbar-height: 56px;
}

/* Light theme — high-contrast text on white cards */
[data-bs-theme="light"] {
    --bg-primary: #f3f4f6;        /* gray-100 page canvas */
    --bg-secondary: #e5e7eb;      /* gray-200 */
    --bg-card: #ffffff;
    --bg-card-hover: #f9fafb;
    --bg-input: #ffffff;
    --bg-sidebar: #f0f2f5;
    --bg-elevated: #ffffff;
    --border-color: #d1d5db;      /* gray-300 */
    --border-strong: #9ca3af;
    --text-primary: #111827;      /* gray-900 */
    --text-secondary: #374151;    /* gray-700 */
    --text-muted: #4b5563;        /* gray-600 — AA on white */
    --text-inverse: #f9fafb;
    --accent-green: #059669;
    --accent-red: #dc2626;
    --accent-blue: #2563eb;
    --accent-yellow: #b45309;
    --accent-info: #0284c7;
    --surface-success: rgba(5, 150, 105, 0.1);
    --surface-danger: rgba(220, 38, 38, 0.08);
    --surface-warning: rgba(180, 83, 9, 0.1);
    --surface-info: rgba(2, 132, 199, 0.1);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --compliance-bg: linear-gradient(135deg, #fff7ed, #ffedd5);
}

/* Reset & Base */
* { box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === LAYOUT === */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-navbar {
    height: var(--navbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1030;
    padding: 0;
    flex-shrink: 0;
}
.top-navbar, .top-navbar .navbar-brand, .top-navbar .navbar-brand:hover {
    color: var(--text-primary) !important;
}
.top-navbar .btn-link { color: var(--text-primary) !important; }
.top-navbar .navbar-brand { font-size: 15px; letter-spacing: 0.3px; color: var(--text-primary); }
.top-navbar .navbar-brand img { border: 1px solid var(--border-color); }
.top-navbar .nav-link { color: var(--text-secondary) !important; }
.top-navbar .nav-link:hover { color: var(--text-primary) !important; }
.top-navbar .sidebar-toggle { color: var(--text-primary) !important; }
.top-navbar .nav-user-btn { color: var(--text-primary) !important; }

/* Co-brand lockup — Mirae Asset Partners logo shown first, then TradeRaiserAI.
   The Mirae PNG carries its own light background, so no extra border. */
.top-navbar .navbar-brand .cobrand-mirae {
    height: 26px; width: auto; border: none !important;
    border-radius: 4px; display: block; flex-shrink: 0;
}
.top-navbar .navbar-brand .cobrand-sep {
    width: 1px; height: 22px; background: var(--border-strong);
    display: inline-block; flex-shrink: 0;
}
@media (max-width: 575.98px) {
    .top-navbar .navbar-brand .cobrand-name { display: none !important; }
    .top-navbar .navbar-brand .cobrand-mirae { height: 22px; }
    .top-navbar .navbar-brand img:not(.cobrand-mirae) { height: 24px !important; width: auto !important; }
}

.search-bar {
    position: relative;
    max-width: 360px;
}
.search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    z-index: 5;
}
.search-bar input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px 6px 32px;
    font-size: 13px;
    color: var(--text-primary);
    width: 100%;
    transition: all 0.2s;
}
.search-bar input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(30,128,255,0.15);
    outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    flex-shrink: 0;              /* prevent sidebar from being squished by wide content */
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: all 0.25s ease;
    z-index: 1020;
    color: var(--text-primary);
}
/* Sidebar already uses --bg-sidebar from light theme block */
.sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; }

.sidebar-nav { padding: 12px 10px; flex: 1; }
.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 1px;
    position: relative;
}
.sidebar-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.sidebar-item.active {
    background: var(--accent-blue);
    color: #fff;
    font-weight: 600;
}
.sidebar-item i { font-size: 16px; width: 20px; text-align: center; }
.sidebar-badge {
    margin-left: auto;
    background: var(--accent-red);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 11px;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 4px;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    min-width: 0;                /* allow flex item to shrink below content width */
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;          /* no page-level rightward scrollbar; dense tables hide columns */
    padding: 16px 20px;
    background: var(--bg-primary);
    transition: margin-left 0.25s ease;
}
.main-content.expanded { margin-left: 0; }

/* Option Chain page — tighter spacing */
#ocPageArea + .main-content,
.main-content:has(#ocPageArea) {
    padding: 8px 12px !important;
}

.flash-container { margin-bottom: 12px; }
.flash-container .alert {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 6px;
}

/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: none;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    border-radius: 12px 12px 0 0 !important;
}
.card-body { padding: 16px; }
.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 0 0 12px 12px !important;
}

/* === TABLES === */
.table {
    color: var(--text-primary);
    margin-bottom: 0;
    font-size: 13px;
}
.table thead th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 12px;
    white-space: nowrap;
}
.table td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.table tbody tr:hover { background: var(--bg-card-hover); }
.table-responsive { border-radius: 8px; }

/* Colors */
.text-up, .text-success { color: var(--accent-green) !important; }
.text-down, .text-danger { color: var(--accent-red) !important; }
.text-primary { color: var(--accent-blue) !important; }
.text-warning { color: var(--accent-yellow) !important; }
.text-muted { color: var(--text-muted) !important; }

/* === BADGES === */
.badge { font-weight: 500; font-size: 11px; padding: 3px 8px; border-radius: 6px; }
.badge.bg-success { background: var(--accent-green) !important; color: #fff !important; }
.badge.bg-danger { background: var(--accent-red) !important; color: #fff !important; }
.badge.bg-primary { background: var(--accent-blue) !important; color: #fff !important; }
.badge.bg-warning { color: var(--text-inverse) !important; background: var(--accent-yellow) !important; }
.badge.bg-info { background: var(--accent-info) !important; color: #fff !important; }
.badge.bg-dark { background: var(--bg-secondary) !important; color: var(--text-primary) !important; }

/* === BUTTONS === */
.btn {
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    transition: all 0.15s;
}
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-primary { background: var(--accent-blue); border-color: var(--accent-blue); }
.btn-primary:hover { background: #1466cc; border-color: #1466cc; }
.btn-success { background: var(--accent-green); border-color: var(--accent-green); color: #0b0e11; }
.btn-success:hover { background: #0bb572; border-color: #0bb572; }
.btn-danger { background: var(--accent-red); border-color: var(--accent-red); }
.btn-danger:hover { background: #d93b4f; border-color: #d93b4f; }
.btn-outline-secondary { border-color: var(--border-color); color: var(--text-secondary); }
.btn-outline-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.btn-outline-success { border-color: var(--accent-green); color: var(--accent-green); }
.btn-outline-danger { border-color: var(--accent-red); color: var(--accent-red); }

/* === FORMS === */
.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(30,128,255,0.15);
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.form-check-input {
    background: var(--bg-input);
    border-color: var(--border-color);
}
.form-check-input:checked { background: var(--accent-blue); border-color: var(--accent-blue); }

/* === DROPDOWN === */
.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown-menu-dark { background: var(--bg-card); }
.dropdown-item {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 7px 12px;
    border-radius: 6px;
}
.dropdown-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.dropdown-item-text { color: var(--text-primary); font-size: 13px; }
.dropdown-divider { border-top-color: var(--border-color); }

/* === PROGRESS === */
.progress {
    background: var(--bg-input);
    border-radius: 8px;
    height: 8px;
}
.progress-bar { border-radius: 8px; }

/* === AI CHAT WIDGET === */
.ai-widget {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 360px;
    max-height: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: aiWidgetIn 0.3s cubic-bezier(0.4,0,0.2,1);
}
.ai-widget.show { display: flex; }
/* "Report a problem" (27 Sep 2026): while the form is open it takes the
   whole widget — chat messages + input are hidden — and scrolls if the
   screen is short, with Cancel/Send pinned so Send is always visible
   (it was cut off on desktop and off-screen on mobile). */
.ai-widget.reporting .ai-widget-body,
.ai-widget.reporting .ai-widget-footer { display: none; }
.ai-report-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    background: var(--bg-card);
}
.ai-report-actions {
    position: sticky;
    bottom: 0;
    padding-top: 6px;
    padding-bottom: 2px;
    background: var(--bg-card);
}
@keyframes aiWidgetIn {
    from { opacity: 0; transform: translateY(16px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.ai-widget-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--accent-blue), #6366f1);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ai-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 360px;
    background: var(--bg-primary);
}
.ai-widget-body::-webkit-scrollbar { width: 3px; }
.ai-widget-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.ai-widget-msg { display: flex; max-width: 90%; animation: fadeIn 0.2s ease; }
.ai-widget-msg.user { margin-left: auto; flex-direction: row-reverse; }
.ai-widget-msg .bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-widget-msg.user .bubble {
    background: var(--accent-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-widget-msg.bot .bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.ai-widget-footer {
    padding: 8px 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 6px;
    align-items: flex-end;
    background: var(--bg-card);
    flex-shrink: 0;
}
.ai-widget-tools .btn {
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.ai-widget-tools .btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}
.ai-widget-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
}
.ai-widget-input:focus { border-color: var(--accent-blue); }
.ai-widget-input::placeholder { color: var(--text-muted); }
.ai-widget-send {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: var(--accent-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.ai-widget-send:hover { background: #1466cc; transform: scale(1.05); }
.ai-widget-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* === AI WIDGET GUIDED STEPS === */
.ai-step { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.ai-step-num {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.ai-step-content { font-size: 12px; line-height: 1.5; color: var(--text-primary); }
.ai-step-content strong { color: var(--accent-blue); }
.ai-divider { height: 1px; background: var(--border-color); margin: 8px 0; }
.ai-highlight {
    display: inline-block;
    background: var(--bg-input);
    border: 1px dashed var(--accent-blue);
    border-radius: 6px;
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--accent-blue);
    animation: aiBlink 1.5s ease-in-out infinite;
}
@keyframes aiBlink {
    0%, 100% { border-color: var(--accent-blue); background: var(--bg-input); }
    50% { border-color: var(--accent-yellow); background: rgba(240,185,11,0.1); }
}

/* === AI FEEDBACK === */
.ai-feedback { margin-top: 6px; display: flex; gap: 4px; align-items: center; padding-top: 4px; border-top: 1px solid var(--border-color); }
.ai-fb-btn {
    width: 26px; height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px;
    transition: all 0.15s;
}
.ai-fb-btn:hover { background: var(--bg-card-hover); }
.ai-fb-up:hover { color: var(--accent-green); border-color: var(--accent-green); }
.ai-fb-down:hover { color: var(--accent-red); border-color: var(--accent-red); }

/* === FLOATING AI BUTTON === */
.ai-float-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(30,128,255,0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: aiFloatIn 0.5s ease, aiPulse 3s ease-in-out infinite 0.5s;
}
.ai-float-btn:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 6px 24px rgba(30,128,255,0.5);
    width: auto;
    border-radius: 24px;
    padding: 0 18px 0 14px;
    gap: 6px;
    animation: none;
}
.ai-float-btn:hover i { font-size: 18px; }
.ai-float-btn:hover .ai-float-msg {
    display: inline;
    white-space: nowrap;
    animation: none;
}
.ai-float-btn i { font-size: 22px; transition: font-size 0.3s; }
.ai-float-msg {
    display: none;
    font-size: 13px;
    font-weight: 500;
    animation: flashMsg 2s ease-in-out infinite;
}
@keyframes aiFloatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.8); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes aiPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(30,128,255,0.4); }
    50% { box-shadow: 0 4px 24px rgba(99,102,241,0.6); }
}
@keyframes flashMsg {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* === AI TRAINER FLOAT (quotes + option chain) — sits above AI assistant === */
.ai-trainer-float {
    position: fixed;
    bottom: 88px; /* above .ai-float-btn (24px + 52px + gap) */
    right: 24px;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px 0 12px;
    border-radius: 22px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.15s ease;
}
.ai-trainer-float:hover,
.ai-trainer-float:focus {
    transform: translateY(-2px);
    outline: none;
    border-color: var(--accent-info);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.25);
    color: var(--text-primary);
}
.ai-trainer-float i {
    font-size: 18px;
    color: var(--accent-info);
}
.ai-trainer-label {
    white-space: nowrap;
}
[data-bs-theme="light"] .ai-trainer-float {
    background: #ffffff;
    border-color: #d1d5db;
    color: #111827;
}
[data-bs-theme="light"] .ai-trainer-float:hover {
    border-color: #0284c7;
    background: #f0f9ff;
}
/* === MOBILE POLISH (Trainer, theme, dashboards) === */
@media (max-width: 991.98px) {
    .main-content {
        padding-bottom: 96px; /* clear floating AI / Trainer buttons */
    }
    #themeToggleVisible {
        min-width: 40px;
        min-height: 40px;
    }
    .top-navbar .nav-user-btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
@media (max-width: 575.98px) {
    .ai-trainer-float {
        bottom: 84px;
        right: 12px;
        padding: 0 12px;
        min-height: 44px; /* a11y tap target */
        font-size: 12px;
        max-width: calc(100vw - 80px);
    }
    .ai-trainer-label {
        max-width: 88px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .ai-float-btn {
        right: 12px;
        bottom: 12px;
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
    /* Avoid hover-expand covering content on touch */
    .ai-float-btn:hover {
        width: 48px;
        border-radius: 50%;
        padding: 0;
    }
    .ai-float-btn:hover .ai-float-msg { display: none; }
    .ai-widget {
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-width: none;
        bottom: 72px !important;
        max-height: min(70vh, 480px);
    }
    .ai-widget-footer {
        flex-wrap: wrap;
    }
    .ai-widget-tools {
        width: 100%;
        order: 3;
        justify-content: flex-start;
        margin-top: 4px;
    }
    .trainer-follow-btn,
    .trainer-quiz-opt {
        min-height: 40px;
        font-size: 12px !important;
        padding: 8px 10px !important;
    }
    .metric-tile .metric-value {
        font-size: 1.05rem;
    }
    /* My Training / dashboard tables: allow horizontal scroll without crushing text */
    .table-theme td,
    .table-theme th {
        white-space: nowrap;
    }
    .backtest-panel .btn {
        width: 100%;
    }
}

/* Trainer progress + completion badges */
.ai-trainer-progress {
    font-size: 10px;
    margin-left: auto;
    margin-right: 8px;
}
.badge-training {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
}
.badge-training-done {
    background: var(--surface-success);
    color: var(--accent-green);
    border: 1px solid var(--accent-green);
}
.ai-widget-header .badge-training-done {
    background: rgba(14, 203, 129, 0.25);
    color: #86efac;
    border-color: #86efac;
}
.ai-trainer-done-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 0 2px var(--bg-card);
}
.trainer-followups {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
.trainer-follow-btn {
    color: var(--accent-info) !important;
    border-color: var(--accent-info) !important;
}
.trainer-quiz {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
.trainer-quiz-opt {
    white-space: normal;
    line-height: 1.35;
}

/* Backtest educational panel */
.backtest-panel {
    background: var(--bg-card);
    color: var(--text-primary);
}
.backtest-panel .metric-value,
.backtest-panel strong {
    font-variant-numeric: tabular-nums;
}

/* === ORDERS TICKET — MOBILE V2 === */
.order-ticket-page .form-control,
.order-ticket-page .form-select {
    min-height: 44px;
    font-size: 16px; /* reduces iOS zoom on focus */
}
.order-ticket-page .form-label {
    margin-bottom: 0.25rem;
}
.order-mode-badge {
    font-size: 0.75rem;
    vertical-align: middle;
}
.order-ticket-actions-mobile {
    /* spacer so last fields clear sticky bar + AI floats */
    height: 72px;
}
.order-ticket-sticky-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040; /* below AI floats (9998+) but above content */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
}
.order-ticket-sticky-bar .btn {
    min-height: 44px;
    font-weight: 600;
}
/* Keep AI floats above sticky bar but not covering primary Place button width */
@media (max-width: 767.98px) {
    .order-ticket-page {
        padding-bottom: 8px;
    }
    body:has(.order-ticket-page) .ai-float-btn {
        bottom: 76px;
        right: 12px;
    }
    body:has(.order-ticket-page) .ai-trainer-float {
        bottom: 132px;
        right: 12px;
    }
    body:has(.order-ticket-page) .ai-widget {
        bottom: 140px !important;
    }
}

/* Dashboard metric accent cards keep white text on solid fills */
.metric-accent-card,
.metric-accent-card .card-title,
.metric-accent-card h3 {
    color: #fff !important;
}
.metric-accent-card .text-warning {
    color: #fef08a !important;
}

/* === UNAUTH LAYOUT === */
.unauth-layout {
    min-height: 100vh;
    background: var(--bg-primary);
}

/* === THEME-SAFE NAVBAR === */
.navbar-dark { --bs-navbar-color: var(--text-secondary); --bs-navbar-hover-color: var(--text-primary); --bs-navbar-active-color: var(--text-primary); }
.navbar-dark .navbar-brand { color: var(--text-primary) !important; }
.btn-outline-light { color: var(--text-primary); border-color: var(--border-color); }
.btn-outline-light:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-muted); }
.btn-primary { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }

/* === RESPONSIVE === */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: var(--navbar-height);
        left: -280px;
        height: calc(100vh - var(--navbar-height));
        width: 260px;
        min-width: 260px;
        z-index: 1040;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
        transition: left 0.25s ease;
    }
    .sidebar.show { left: 0; }
    .sidebar.collapsed { width: 260px; min-width: 260px; }
    .main-content { padding: 12px; }
    .search-bar { max-width: 100%; }
    .d-lg-none { display: block !important; }
    .d-none.d-lg-inline { display: none !important; }
}

@media (max-width: 575.98px) {
    .main-content { padding: 10px; }
    .card-body { padding: 12px; }
    .table { font-size: 12px; }
    .table td, .table th { padding: 6px 8px; }
}

/* === UTILITY === */
.cursor-pointer { cursor: pointer; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* === WATCHLIST DETAIL ROW (theme-aware) === */
.wl-detail-row {
    font-size: 10px;
    background: var(--bg-input);
    color: var(--text-primary);
}
/* Ensure table rows adapt to theme */
[data-bs-theme="light"] #watchlistTable tbody tr {
    color: var(--text-primary);
}
[data-bs-theme="light"] #watchlistTable tbody td {
    color: var(--text-primary);
}
[data-bs-theme="light"] #watchlistTable tbody td .text-muted,
[data-bs-theme="light"] .wl-detail-row .text-muted {
    color: var(--text-secondary) !important;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.25s ease; }

/* === PRICE FLASH === */
.price-flash-up { animation: flashGreen 0.5s ease; }
.price-flash-down { animation: flashRed 0.5s ease; }
@keyframes flashGreen { 0% { background: var(--surface-success); } 100% { background: transparent; } }
@keyframes flashRed { 0% { background: var(--surface-danger); } 100% { background: transparent; } }

/* ============================================================
   THEME-RESILIENT BOOTSTRAP REMAPS
   Templates often hardcode bg-dark / text-light for "dark UI".
   Map those utilities to CSS variables so light mode stays readable
   without rewriting every Jinja template.
   ============================================================ */

/* --- Theme utility classes (prefer these going forward) --- */
.text-theme,
.text-theme-primary { color: var(--text-primary) !important; }
.text-theme-secondary { color: var(--text-secondary) !important; }
.text-theme-muted { color: var(--text-muted) !important; }
.bg-theme,
.bg-theme-page { background-color: var(--bg-primary) !important; color: var(--text-primary) !important; }
.bg-theme-card { background-color: var(--bg-card) !important; color: var(--text-primary) !important; }
.bg-theme-secondary { background-color: var(--bg-secondary) !important; color: var(--text-primary) !important; }
.bg-theme-input { background-color: var(--bg-input) !important; color: var(--text-primary) !important; }
.border-theme { border-color: var(--border-color) !important; }
.card-theme {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}
.card-theme .card-header,
.card-theme .card-footer {
    background: transparent !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* --- Bootstrap utilities that break light mode --- */
.bg-dark,
.card.bg-dark,
.card-header.bg-dark,
.modal-content.bg-dark,
.dropdown-menu-dark,
.table-dark,
.table-dark > :not(caption) > * > * {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
.bg-dark .card-header,
.bg-dark .card-body,
.bg-dark .card-footer,
.card.bg-dark .card-header,
.card.bg-dark .card-body {
    background-color: transparent !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* "text-light" meant "readable on dark cards" → primary text in both themes */
.text-light,
.bg-dark .text-light,
.card.bg-dark .text-light {
    color: var(--text-primary) !important;
}

/* Soft surfaces used as "light cards" in empty states */
.bg-light,
.card.bg-light {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
.bg-light .text-muted,
.card.bg-light .text-muted {
    color: var(--text-muted) !important;
}

/* Muted / secondary labels — strong enough on both canvases */
.text-muted,
small.text-muted,
.small.text-muted {
    color: var(--text-muted) !important;
}
.text-secondary:not(.btn):not(.badge) {
    color: var(--text-secondary) !important;
}

/* Info accent (Bootstrap .text-info is often too dim in light mode) */
.text-info {
    color: var(--accent-info) !important;
}

/* Outline buttons that assume a dark page */
.btn-outline-light {
    color: var(--text-primary) !important;
    border-color: var(--border-strong) !important;
    background: transparent !important;
}
.btn-outline-light:hover,
.btn-outline-light:focus {
    color: var(--text-inverse) !important;
    background: var(--text-primary) !important;
    border-color: var(--text-primary) !important;
}
.btn-outline-info {
    color: var(--accent-info) !important;
    border-color: var(--accent-info) !important;
}
.btn-outline-info:hover {
    color: #fff !important;
    background: var(--accent-info) !important;
}
.btn-outline-warning {
    color: var(--accent-yellow) !important;
    border-color: var(--accent-yellow) !important;
}
.btn-outline-primary {
    color: var(--accent-blue) !important;
    border-color: var(--accent-blue) !important;
}

/* Form controls that hardcode bg-dark text-light */
.form-control.bg-dark,
.form-select.bg-dark,
input.bg-dark,
textarea.bg-dark,
select.bg-dark {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
.form-control.bg-dark:focus,
.form-select.bg-dark:focus {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
}
.form-control.text-light,
.form-select.text-light {
    color: var(--text-primary) !important;
}

/* Tables */
.table-dark,
.table-dark thead th,
.table-dark tbody td,
.table-dark tbody th {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
.table-dark tbody tr:hover > * {
    background-color: var(--bg-card-hover) !important;
    color: var(--text-primary) !important;
}

/* Modal / list-group leftovers */
.list-group-item-dark,
.list-group-item.bg-dark {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Border utilities used as "dark UI chrome" */
.border-secondary {
    border-color: var(--border-color) !important;
}

/* Alerts stay readable on theme canvas */
.alert {
    color: var(--text-primary);
}
.alert-success { background: var(--surface-success); border-color: var(--accent-green); color: var(--text-primary); }
.alert-danger  { background: var(--surface-danger);  border-color: var(--accent-red);   color: var(--text-primary); }
.alert-warning { background: var(--surface-warning); border-color: var(--accent-yellow); color: var(--text-primary); }
.alert-info    { background: var(--surface-info);    border-color: var(--accent-info);   color: var(--text-primary); }
.alert .text-light { color: var(--text-primary) !important; }

/* Education / Compliance banners — visible in both modes */
.compliance-footer .card-header { background: var(--surface-warning) !important; }
.compliance-footer .text-warning { color: var(--text-primary) !important; }

/* Progress text on scan bars */
.progress-bar { color: #fff; font-weight: 600; }

/* ── Dark-mode specific overrides ── */
[data-bs-theme="dark"] .text-warning { color: var(--accent-yellow) !important; }
[data-bs-theme="dark"] .btn-outline-warning:hover { color: #111827 !important; }
[data-bs-theme="dark"] .btn-outline-info:hover { color: #fff !important; }

/* ── Light-mode specific overrides ── */
[data-bs-theme="light"] .text-warning { color: #92400e !important; }
[data-bs-theme="light"] .btn-outline-warning:hover { color: #fff !important; }
[data-bs-theme="light"] .text-success { color: #059669 !important; }
[data-bs-theme="light"] .text-danger { color: #dc2626 !important; }
[data-bs-theme="light"] .text-info { color: #0369a1 !important; }

/* Compliance banner — theme aware (overrides inline gradient when class applied) */
.compliance-banner {
    background: var(--compliance-bg) !important;
    border-left: 4px solid var(--accent-yellow) !important;
    color: var(--text-primary);
}
.compliance-banner .text-light {
    color: var(--text-secondary) !important;
}
.compliance-footer .card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
.compliance-footer .text-light {
    color: var(--text-primary) !important;
}

/* Navbar: keep brand/actions readable; sidebar stays elevated panel */
.top-navbar {
    background: var(--bg-secondary) !important;
}
[data-bs-theme="light"] .top-navbar {
    background: #ffffff !important;
    border-bottom-color: var(--border-color);
}
[data-bs-theme="light"] .navbar-dark .navbar-brand,
[data-bs-theme="light"] .top-navbar .text-light {
    color: var(--text-primary) !important;
}

/* Dropdown menus already themed; ensure dark class doesn't force black text */
.dropdown-menu-dark .dropdown-item {
    color: var(--text-secondary) !important;
}
.dropdown-menu-dark .dropdown-item:hover {
    color: var(--text-primary) !important;
    background: var(--bg-card-hover) !important;
}
.dropdown-menu-dark .dropdown-item-text {
    color: var(--text-primary) !important;
}

/* Dynamic scan / opportunity cards (JS often injects bg-dark text-light) */
#segmentScanResult .card,
#segmentScanResult .card-body,
.scan-result-card,
.opportunity-card {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
#segmentScanResult .text-light,
.scan-result-card .text-light,
.opportunity-card .text-light {
    color: var(--text-primary) !important;
}
#segmentScanResult .text-muted,
.scan-result-card .text-muted {
    color: var(--text-muted) !important;
}
#segmentScanResult strong,
.scan-result-card strong {
    color: var(--text-primary);
}

.quotes-page-row > [class*="col-"] {
    min-width: 0;
}

/* Scanner results: wrap to viewport — no left/right scroll to reach Add */
#segmentScanResult {
    max-width: 100%;
    overflow-x: hidden;
    min-width: 0;
}
#segmentScanResult .card,
#segmentScanResult .card-body,
#segmentScanResult .alert {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.scan-toolbar {
    max-width: 100%;
}
.scan-toolbar .btn,
.scan-toolbar .dropdown {
    flex: 0 1 auto;
}
.scan-hint {
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.4;
    font-size: 10px;
}
.scan-add-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.55rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
}
.scan-add-bar.is-active {
    border-color: var(--bs-success, #198754);
}
.scan-add-bar__all {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 12px;
}
.scan-add-bar #addSelectedBtn {
    min-height: 36px;
    white-space: nowrap;
}
.scan-result-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-width: 0;
}
.scan-row-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
    background: var(--bg-secondary, var(--bg-card));
    min-width: 0;
    max-width: 100%;
}
.scan-row-card--warn {
    border-color: #d9a441;
    background: rgba(217, 164, 65, 0.08);
}
.scan-row-card__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.55rem;
    min-width: 0;
}
.scan-row-card__pick {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    font-size: 12px;
    flex: 0 0 auto;
}
.scan-row-card__id {
    flex: 1 1 8rem;
    min-width: 0;
}
.scan-row-card__sym {
    font-weight: 700;
    overflow-wrap: anywhere;
}
.scan-row-card__rec {
    font-size: 11px;
    color: var(--text-muted);
}
.scan-row-card__conf {
    font-weight: 700;
    font-size: 13px;
    flex: 0 0 auto;
}
.scan-row-card__add {
    flex: 0 0 auto;
    min-height: 36px;
    margin-left: auto;
}
.scan-row-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.35rem;
}
.scan-row-card__badges .badge {
    white-space: normal;
    text-align: left;
    line-height: 1.25;
}
.scan-row-card__px {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin-top: 0.35rem;
    font-size: 12px;
}
.scan-row-card__reason,
.scan-checklist,
.scan-checklist__item,
.scan-checklist__wait {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}
.scan-row-card__reason {
    margin-top: 0.25rem;
    font-size: 11px;
    color: var(--text-secondary, var(--text-muted));
}
.scan-checklist {
    font-size: 10px;
    line-height: 1.4;
}
.scan-checklist__list {
    list-style: none;
}
.scan-checklist__item {
    margin-bottom: 0.15rem;
}
@media (max-width: 767.98px) {
    .scan-row-card__add {
        width: 100%;
        margin-left: 0;
    }
    .scan-add-bar #addSelectedBtn {
        width: 100%;
    }
}

/* Symbol chips / quick quote buttons */
#exchangeOptions .btn,
#instrumentOptions .btn,
#expiryOptions .btn,
#optionTypeOptions .btn,
#strikeOptions .btn {
    color: var(--text-primary);
    border-color: var(--border-color);
}
#symbolResults .list-group-item,
#symbolResults button,
#symbolResults .btn {
    color: var(--text-primary) !important;
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Placeholder / empty states */
.text-body-secondary { color: var(--text-muted) !important; }

/* Light-mode table rows without table-dark class */
[data-bs-theme="light"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-striped-bg: var(--bg-secondary);
    --bs-table-hover-bg: var(--bg-card-hover);
    color: var(--text-primary);
}

/* Inline style rescue: common hard-coded dark hex backgrounds on content */
[data-bs-theme="light"] [style*="background:#0d1117"],
[data-bs-theme="light"] [style*="background: #0d1117"],
[data-bs-theme="light"] [style*="background:#0b0e11"],
[data-bs-theme="light"] [style*="background: #0b0e11"],
[data-bs-theme="light"] [style*="background:#181a20"],
[data-bs-theme="light"] [style*="background: #181a20"] {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
/* Soft-fix pure white / near-white text inside content cards in light mode */
[data-bs-theme="light"] .card [style*="color:#fff"],
[data-bs-theme="light"] .card [style*="color: #fff"],
[data-bs-theme="light"] .card [style*="color:white"],
[data-bs-theme="light"] .main-content > .row [style*="color:#eaecef"],
[data-bs-theme="light"] .main-content > .row [style*="color: #eaecef"] {
    color: var(--text-primary) !important;
}
/* Keep white text on solid accent buttons/badges */
[data-bs-theme="light"] .btn-primary,
[data-bs-theme="light"] .btn-success,
[data-bs-theme="light"] .btn-danger,
[data-bs-theme="light"] .badge.bg-success,
[data-bs-theme="light"] .badge.bg-danger,
[data-bs-theme="light"] .badge.bg-primary,
[data-bs-theme="light"] .card-header.bg-success,
[data-bs-theme="light"] .card-header.bg-danger,
[data-bs-theme="light"] .card-header.bg-primary {
    color: #fff !important;
}

/* Ensure labels in wizards stay visible */
.form-label.text-light,
label.text-light {
    color: var(--text-primary) !important;
}

/* Theme toggle affordance (visible control if un-hidden) */
#themeToggleVisible {
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}
#themeToggleVisible:hover {
    background: var(--bg-card-hover);
}

/* --- Expanded trading utilities (iteration 2) --- */

/* BUY / SELL signal text — stronger in light mode for glanceable dashboards */
.signal-buy,
.text-signal-buy {
    color: var(--accent-green) !important;
    font-weight: 700;
}
.signal-sell,
.text-signal-sell {
    color: var(--accent-red) !important;
    font-weight: 700;
}
[data-bs-theme="light"] .signal-buy,
[data-bs-theme="light"] .text-success.text-signal-buy,
[data-bs-theme="light"] .opportunity-card .text-success {
    color: #047857 !important; /* emerald-700 — higher contrast on white */
}
[data-bs-theme="light"] .signal-sell,
[data-bs-theme="light"] .text-danger.text-signal-sell,
[data-bs-theme="light"] .opportunity-card .text-danger {
    color: #b91c1c !important; /* red-700 */
}
[data-bs-theme="light"] .text-warning {
    color: #92400e !important; /* amber-800 for labels on white */
}

/* Status / signal badges */
.badge-signal {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
}
.badge-signal-buy {
    background: var(--surface-success);
    color: var(--accent-green);
    border-color: var(--accent-green);
}
.badge-signal-sell {
    background: var(--surface-danger);
    color: var(--accent-red);
    border-color: var(--accent-red);
}
.badge-signal-neutral {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.badge-theme-status {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.badge-theme-status.is-light {
    background: #fef3c7;
    color: #92400e;
    border-color: #f59e0b;
}
.badge-theme-status.is-dark {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}
[data-bs-theme="light"] .badge-theme-status.is-dark {
    background: #e2e8f0;
    color: #0f172a;
}

/* Scan / status strip (progress, live feed, connecting…) */
.status-strip {
    font-size: 11px;
    line-height: 1.45;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.status-strip.is-live {
    border-left: 3px solid var(--accent-green);
    background: var(--surface-success);
}
.status-strip.is-warn {
    border-left: 3px solid var(--accent-yellow);
    background: var(--surface-warning);
}
.status-strip.is-error {
    border-left: 3px solid var(--accent-red);
    background: var(--surface-danger);
}
.status-strip .label {
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 4px;
}

/* Compliance / educational callouts */
.banner-compliance {
    background: var(--compliance-bg) !important;
    border-left: 4px solid var(--accent-yellow) !important;
    color: var(--text-primary);
    font-size: 11px;
}
.banner-edu {
    border-left: 3px solid var(--accent-yellow);
    padding: 8px 10px;
    background: var(--surface-warning);
    color: var(--text-primary);
    font-size: 11px;
    border-radius: 0 8px 8px 0;
}

/* Metric tiles (LTP, change, conviction) */
.metric-tile {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-primary);
}
.metric-tile .metric-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.metric-tile .metric-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.metric-tile .metric-value.is-up { color: var(--accent-green); }
.metric-tile .metric-value.is-down { color: var(--accent-red); }

/* Mobile sidebar — ensure contrast when drawer opens over content */
@media (max-width: 991.98px) {
    .sidebar {
        background: var(--bg-sidebar) !important;
        color: var(--text-primary);
        box-shadow: var(--shadow-md);
    }
    [data-bs-theme="light"] .sidebar {
        background: #ffffff !important;
        border-right: 1px solid var(--border-color);
    }
    [data-bs-theme="light"] .sidebar .sidebar-item {
        color: var(--text-secondary);
    }
    [data-bs-theme="light"] .sidebar .sidebar-item:hover,
    [data-bs-theme="light"] .sidebar .sidebar-item.active {
        color: #fff;
    }
}

/* Tabular numbers for prices / P&L everywhere */
.num-tabular,
.table td,
.opportunity-card strong,
.metric-tile .metric-value {
    font-variant-numeric: tabular-nums;
}

/* Option-chain / themed tables (prefer over table-dark) */
.table-theme {
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: var(--bg-secondary);
    --bs-table-hover-bg: var(--bg-card-hover);
}
.table-theme thead th {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
.table-theme tbody td {
    color: var(--text-primary);
    border-color: var(--border-color);
    background: transparent;
}

/* Strategy recommendation cards on option chain */
.strategy-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 10px;
    padding: 12px;
    height: 100%;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.strategy-card:hover {
    border-color: var(--accent-blue) !important;
    box-shadow: var(--shadow-md);
}
.strategy-card .strat-metric {
    font-size: 10px;
    color: var(--text-muted);
}
.strategy-card .strat-metric strong {
    font-size: 12px;
    color: var(--text-primary);
}
.autocomplete-items {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
.autocomplete-item {
    color: var(--text-primary) !important;
}
.autocomplete-item:hover {
    background: var(--bg-card-hover) !important;
}

/* Guest top-nav page links (11 Sep 2026, Session C of LANDING_PAGE_PLAN.md)
   — How you trade / Platform / Tools / Learn on the dark .top-navbar shared
   by every logged-out page. .top-navbar is always navbar-dark regardless of
   the site's light/dark theme toggle, so plain white-based colours (not
   design-system --ds-* tokens) are correct here, same as the existing
   Login/Open-Demat buttons right next to it. */
.guest-nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
}
.guest-nav-link {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.guest-nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}
.guest-nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
}

/* 13 Nov 2026: "Buy Static IP" in the public top menu — highlighted pill (own colour pair, readable on the dark nav) */
.guest-nav-link.guest-nav-cta {
    background: #f59e0b;
    color: #111827 !important;
    border-radius: 999px;
    padding: 4px 12px;
    font-weight: 600;
}
.guest-nav-link.guest-nav-cta:hover,
.guest-nav-link.guest-nav-cta.active {
    background: #fbbf24;
    color: #111827 !important;
}
