/* =====================================================================
   AKDEVZ AI TRADING TERMINAL — INSTITUTIONAL DESIGN SYSTEM
   Theme: Institutional Dark / Light
   Typography: Plus Jakarta Sans (UI) & JetBrains Mono (Numbers/Quotes)
   Master Spec Section 22A & 25.4
   ===================================================================== */

:root {
    --bg-base: #0B0E14;
    --bg-sidebar: #0F121A;
    --bg-card: #151922;
    --bg-surface: #1E232F;
    --bg-surface-hover: #262D3D;
    --border: #232936;
    --border-light: #2E3648;
    
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-glow: rgba(59, 130, 246, 0.15);
    
    --profit: #10B981;
    --profit-bg: rgba(16, 185, 129, 0.12);
    --loss: #EF4444;
    --loss-bg: rgba(239, 68, 68, 0.12);
    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.12);
    
    --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --sidebar-width: 230px;
    --header-height: 56px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* APP SHELL LAYOUT */
.app-layout {
    display: flex;
    min-height: 100vh;
}

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

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #FFF;
}

.brand-title {
    font-size: 14px;
    font-weight: 700;
    color: #FFF;
    letter-spacing: -0.3px;
}

.brand-tag {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

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

.nav-item.active {
    color: #FFF;
    background: var(--accent);
}

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

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}

/* MAIN CONTENT WORKSPACE */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* TOP STATUS & USAGE BAR */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 90;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.session-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.session-open {
    background: var(--profit-bg);
    color: var(--profit);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.session-closed {
    background: var(--loss-bg);
    color: var(--loss);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.session-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* TOP USAGE & QUOTA MONITORS */
.header-usage-strip {
    display: flex;
    align-items: center;
    gap: 12px;
}

.usage-pill {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.usage-pill:hover {
    border-color: var(--accent);
}

.usage-label {
    color: var(--text-muted);
    font-weight: 600;
}

.usage-val {
    color: var(--text-primary);
}

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

.btn-kill-switch {
    background: rgba(239, 68, 68, 0.15);
    color: var(--loss);
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-mono);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-kill-switch:hover {
    background: var(--loss);
    color: #FFF;
}

/* WORKSPACE VIEW CONTAINER */
.workspace {
    padding: 24px;
    flex: 1;
}

/* CARDS & PANELS */
.terminal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 20px;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #FFF;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* GRID LAYOUTS */
.grid-cols-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.grid-cols-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
}

.stat-widget-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-widget-value {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-mono);
    margin-top: 4px;
}

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

/* RESPONSIVE TABLE WRAPPERS (HORIZONTAL TOUCH SCROLLING) */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x pan-y !important;
    margin-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.04);
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* DATA TABLES */
.terminal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.terminal-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
}

.terminal-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
}

.terminal-table tr:hover td {
    background: var(--bg-surface-hover);
}

/* EXPANDABLE USAGE DRAWER */
.usage-drawer {
    display: none;
    position: fixed;
    top: var(--header-height);
    right: 20px;
    width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    padding: 20px;
    z-index: 200;
}

.usage-drawer.open {
    display: block;
}

/* MOBILE BOTTOM NAVIGATION */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(15, 18, 26, 0.98);
    backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 9px;
    font-weight: 500;
    padding: 4px 2px;
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-nav-item:hover, .mobile-nav-item.active {
    color: var(--accent);
}

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

/* MOBILE SLIDE-OUT NAVIGATION DRAWER */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
}
.mobile-nav-overlay.open {
    display: block;
}

.mobile-nav-drawer {
    position: fixed;
    top: 0;
    left: -290px;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: #0B0E14;
    border-right: 1px solid var(--border);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.mobile-nav-drawer.open {
    transform: translateX(290px);
}
.mobile-drawer-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.mobile-drawer-body {
    padding: 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mobile-drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}
.mobile-drawer-item:hover, .mobile-drawer-item.active {
    color: #FFF;
    background: var(--bg-surface-hover);
}
.mobile-drawer-item.active {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.12);
    font-weight: 600;
}
.mobile-drawer-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.mobile-drawer-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =====================================================================
   SUPER AI DESK, LIVE MONITOR & BACKTESTING STUDIO STYLES
   ===================================================================== */
.aichat-super-workspace {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.ai-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    gap: 12px;
    width: 100%;
    max-width: 100%;
}

.ai-tab-nav-slider {
    display: flex;
    align-items: center;
    position: relative;
    max-width: 100%;
    overflow: hidden;
    gap: 6px;
    flex: 1;
}

.ai-tab-arrow-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.2s ease;
    user-select: none;
    z-index: 5;
}

.ai-tab-arrow-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.ai-tab-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    padding: 2px 0;
    touch-action: pan-x;
}

.ai-tab-buttons::-webkit-scrollbar {
    display: none;
}

.ai-tab-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.ai-tab-btn:hover {
    background: var(--bg-surface-hover);
    color: #FFF;
}

.ai-tab-btn.active {
    background: var(--accent);
    color: #FFF;
    border-color: var(--accent);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.tab-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-family: var(--font-mono);
}

.ai-tab-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-badge {
    font-size: 10px;
    font-family: var(--font-mono);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #60A5FA;
    background: rgba(59, 130, 246, 0.08);
}

.live-dot-pulse {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10B981;
    display: inline-block;
    animation: livePulse 1.8s infinite;
}

@keyframes livePulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ai-tab-panel {
    display: none;
}

.ai-tab-panel.active {
    display: block;
    animation: panelFadeIn 0.2s ease;
}

@keyframes panelFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* TAB 1: CHAT STYLES */
.aichat-container {
    display: flex;
    gap: 16px;
    height: calc(100vh - 170px);
    min-height: 520px;
    position: relative;
}

.chat-sidebar-wrapper {
    width: 260px;
    min-width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.chat-history-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 14px 4px 14px;
    letter-spacing: 0.5px;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-conv-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-conv-item:hover {
    background: var(--bg-surface-hover);
}

.chat-conv-item.active {
    background: var(--bg-surface);
    border-left: 2px solid var(--accent);
}

.chat-main-view {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-mobile-bar {
    display: none;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    justify-content: space-between;
    align-items: center;
}

.btn-chat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: #FFF;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
}

.chat-header-bar {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    flex-wrap: wrap;
    gap: 8px;
}

.chat-chips-bar {
    padding: 8px 18px;
    background: rgba(30, 35, 47, 0.5);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-attach-chip {
    background: none;
    border: 1px dashed var(--border-light);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.chat-message-stream {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-msg-welcome {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    border-left: 3px solid var(--accent);
}

.quick-prompts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.quick-prompt-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: #93C5FD;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-ui);
}

.quick-prompt-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent);
    color: #FFF;
}

.chat-status-strip {
    padding: 6px 18px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

.chat-composer-bar {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
}

.chat-bubble-user {
    align-self: flex-end;
    background: var(--accent);
    color: #FFF;
    border-bottom-right-radius: 2px;
}

.chat-bubble-assistant {
    align-self: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chat-bubble-error {
    align-self: flex-start;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--loss);
    color: #FCA5A5;
}

.terminal-select-compact {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: #FFF;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-family: var(--font-mono);
}

/* TAB 2: LIVE MONITOR STYLES */
.monitor-container {
    display: flex;
    flex-direction: column;
}

.monitor-control-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.regime-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.regime-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.candidate-audit-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
}

.candidate-audit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
    margin-bottom: 14px;
}

.gates-matrix-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.gates-matrix-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.gate-tile,
.gate-cell {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    font-size: 10px;
    font-family: var(--font-mono);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.gate-tile:hover,
.gate-cell:hover {
    transform: translateY(-1px);
}

.gate-tile.gate-passed,
.gate-cell.pass {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

.gate-tile.gate-failed,
.gate-cell.fail {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.12);
}

.gate-num,
.gate-name {
    font-weight: 700;
    color: #FFF;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
}

.gate-status {
    font-weight: 800;
    font-size: 10px;
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}

.gate-tile.gate-passed .gate-status,
.gate-cell.pass .gate-status {
    color: #34D399;
}

.gate-tile.gate-failed .gate-status,
.gate-cell.fail .gate-status {
    color: #F87171;
}

.gate-detail,
.gate-desc {
    color: var(--text-muted);
    font-size: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.plain-english-audit {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 10px;
}

.empty-stream-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
}

/* TAB 3: LEARNING & BACKTESTING STYLES */
.learning-container {
    display: flex;
    flex-direction: column;
}

.learning-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.learning-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.learning-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.stat-lbl {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-val {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.stat-sub {
    font-size: 10px;
    color: var(--text-secondary);
}

.split-badge-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 260px;
}

/* =====================================================================
   RESPONSIVE BREAKPOINTS (DESKTOP, TABLET, MOBILE)
   ===================================================================== */
@media (max-width: 1024px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .gates-matrix-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .regime-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .learning-stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .chat-sidebar-wrapper {
        width: 220px;
        min-width: 220px;
    }
}

@media (max-width: 768px) {
    .app-sidebar {
        display: none;
    }
    .app-main {
        margin-left: 0;
        margin-bottom: 75px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    .workspace {
        padding: 10px 8px;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .terminal-card {
        padding: 14px 12px;
        margin-bottom: 12px;
    }
    .mobile-menu-btn {
        background: var(--bg-surface);
        border: 1px solid var(--border);
        color: #FFF;
        padding: 5px 8px;
        border-radius: 6px;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-nav {
        display: flex;
        height: 60px;
        background: rgba(15, 18, 26, 0.98);
        backdrop-filter: blur(14px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    }
    .app-header {
        padding: 8px 10px;
        height: auto;
        min-height: 50px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .header-usage-strip {
        display: flex !important;
        order: 3;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        gap: 6px;
        padding-top: 4px;
        padding-bottom: 2px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .header-usage-strip::-webkit-scrollbar {
        display: none;
    }
    .header-usage-strip .usage-pill {
        flex-shrink: 0;
        padding: 4px 8px;
        font-size: 10px;
    }
    .usage-drawer {
        top: auto;
        bottom: 66px;
        left: 8px;
        right: 8px;
        width: auto;
        max-height: 75vh;
        overflow-y: auto;
        z-index: 250;
    }
    .header-actions {
        gap: 6px;
    }
    .header-actions .status-pill {
        padding: 4px 8px;
        font-size: 10px;
    }
    .btn-kill-switch {
        padding: 4px 8px;
        font-size: 10px;
    }
    .grid-cols-4, .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    #benchmarkIndicesGrid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    #benchmarkIndicesGrid .terminal-card {
        padding: 10px 10px;
    }
    #benchmarkIndicesGrid [id^="quote-"] {
        font-size: 15px !important;
    }
    .regime-grid {
        grid-template-columns: 1fr;
    }
    .learning-stat-grid {
        grid-template-columns: 1fr;
    }
    .gates-matrix-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .quick-prompts-grid {
        grid-template-columns: 1fr;
    }

    /* Mobile Chat Drawer */
    .aichat-container {
        height: calc(100vh - 180px);
        min-height: 480px;
        position: relative;
    }
    .chat-sidebar-wrapper {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 270px;
        z-index: 80;
        box-shadow: 8px 0 24px rgba(0,0,0,0.7);
        background: var(--bg-card);
    }
    .chat-sidebar-wrapper.open {
        display: flex;
    }
    .chat-mobile-bar {
        display: flex;
    }
    .chat-message-stream {
        padding: 12px 10px;
    }
    .chat-bubble {
        max-width: 92%;
        font-size: 12px;
        padding: 10px 12px;
    }
    .chat-composer-bar {
        padding: 10px;
    }

    /* Chart viewport on mobile */
    .charts-view .terminal-card {
        padding: 8px;
    }
    .chart-container-wrapper, #chartMainViewport {
        height: calc(100vh - 225px) !important;
        min-height: 380px !important;
    }
    .tv-main-toolbar-inner {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .tv-toolbar-row1, .tv-toolbar-split, .tv-toolbar-actions {
        width: 100%;
        justify-content: space-between;
    }
    #chartSearchContainer {
        flex: 1;
        width: auto !important;
        min-width: 0 !important;
    }
}

/* TRADINGVIEW CHARTS & HORIZONTAL SCROLLBARS */
.tv-scroll-row {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.04);
}
.tv-scroll-row::-webkit-scrollbar {
    height: 4px;
}
.tv-scroll-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
#liveTickerTapeScrollTrack {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
}

/* Small Utilities */
.desktop-only { display: inline; }
.mobile-only { display: none; }

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: inline !important; }
}

@media (max-width: 480px) {
    .workspace {
        padding: 8px 6px;
    }
    .terminal-card {
        padding: 10px 8px;
    }
    .card-header {
        margin-bottom: 10px;
        gap: 6px;
    }
    .session-chip {
        font-size: 10px;
        padding: 3px 6px;
    }
    .header-actions span[style*="●"] {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 10px;
    }
    .gates-matrix-grid {
        grid-template-columns: 1fr;
    }
    .ai-tab-buttons {
        gap: 4px;
    }
    .ai-tab-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    .ai-tab-meta {
        display: none;
    }
    #benchmarkIndicesGrid {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
    #benchmarkIndicesGrid .terminal-card {
        padding: 8px 8px !important;
    }
    #benchmarkIndicesGrid [id^="quote-"] {
        font-size: 13px !important;
    }
}

/* =====================================================================
   BROKER TERMINAL & LIVE PRICE TICK FLUCTUATION ANIMATIONS
   ===================================================================== */
@keyframes tickUpGlow {
    0% { background-color: rgba(16, 185, 129, 0.45); color: #34D399; }
    50% { background-color: rgba(16, 185, 129, 0.25); }
    100% { background-color: transparent; }
}

@keyframes tickDownGlow {
    0% { background-color: rgba(239, 68, 68, 0.45); color: #F87171; }
    50% { background-color: rgba(239, 68, 68, 0.25); }
    100% { background-color: transparent; }
}

.tick-flash-up {
    animation: tickUpGlow 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border-radius: 4px;
}

.tick-flash-down {
    animation: tickDownGlow 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border-radius: 4px;
}

.live-pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: livePulse 1.8s infinite;
}

.live-pulse-dot-paper {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #60A5FA;
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.7);
    animation: livePulsePaper 1.8s infinite;
}

@keyframes livePulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes livePulsePaper {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 7px rgba(96, 165, 250, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(96, 165, 250, 0); }
}

/* Broker Watchlist Table */
.broker-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x pan-y !important;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.04);
}
.broker-table-wrapper::-webkit-scrollbar {
    height: 6px;
}
.broker-table-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
}
.broker-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.broker-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.broker-table th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.broker-table th.num-col, .broker-table td.num-col {
    text-align: right;
    font-family: var(--font-mono);
}

.broker-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    vertical-align: middle;
}

.broker-table tr:hover td {
    background: var(--bg-surface-hover);
}

.broker-table tr:last-child td {
    border-bottom: none;
}

.stock-sym-badge {
    font-weight: 700;
    color: #FFF;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stock-exch-tag {
    font-size: 9px;
    padding: 1px 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Action button micro pills */
.btn-micro-action {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-ui);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.btn-micro-buy {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
    color: #34D399;
}
.btn-micro-buy:hover {
    background: #10B981;
    color: #FFF;
}

.btn-micro-sell {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #F87171;
}
.btn-micro-sell:hover {
    background: #EF4444;
    color: #FFF;
}

.btn-micro-test {
    background: rgba(96, 165, 250, 0.15);
    border-color: rgba(96, 165, 250, 0.35);
    color: #60A5FA;
}
.btn-micro-test:hover {
    background: #3B82F6;
    color: #FFF;
}

/* Smart Bot Banner */
.bot-command-banner {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid rgba(96, 165, 250, 0.25);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.bot-command-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #60A5FA 0%, #34D399 100%);
}

.strategy-metric-pill {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
}

.strategy-metric-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.strategy-metric-val {
    font-size: 14px;
    font-weight: 700;
    color: #FFF;
    font-family: var(--font-mono);
    margin-top: 2px;
}

/* Quick Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    width: 92%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* =====================================================================
   BROKER TERMINAL & MOBILE RESPONSIVE ENHANCEMENTS
   ===================================================================== */
.broker-terminal-layout {
    display: grid;
    grid-template-columns: 1.65fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .broker-terminal-layout {
        grid-template-columns: 1fr;
    }
}

.market-status-banner {
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.market-status-banner.closed {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.market-status-banner.open {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.broker-funds-ribbon {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.funds-ribbon-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.funds-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 20px;
    align-items: center;
}

.funds-metric-card {
    display: flex;
    flex-direction: column;
}

@media (max-width: 992px) {
    .funds-ribbon-content {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }
    .funds-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        width: 100%;
    }
    .funds-metric-card {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 8px;
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .funds-metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .funds-metric-card {
        padding: 8px 10px;
    }
}

@media (max-width: 768px) {
    .broker-funds-ribbon {
        padding: 12px 14px;
    }
    .ai-tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
        max-width: 100%;
    }
    .ai-tab-nav-slider {
        width: 100%;
        max-width: 100%;
    }
    .ai-tab-buttons {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
        display: flex;
        gap: 6px;
    }
    .ai-tab-btn {
        flex-shrink: 0;
        font-size: 11px;
        padding: 7px 11px;
    }
    .ai-tab-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        font-size: 10px;
        width: 100%;
    }
    .broker-table th, .broker-table td {
        padding: 8px 10px;
        font-size: 11px;
    }
    .terminal-table th, .terminal-table td {
        padding: 8px 10px;
        font-size: 11px;
    }
    .btn-micro-action {
        padding: 4px 8px;
        font-size: 10px;
    }
    .aichat-container {
        height: calc(100vh - 190px);
        min-height: 480px;
    }
    .chat-header-bar {
        padding: 10px 12px;
    }
    .chat-chips-bar {
        padding: 8px 12px;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .chat-composer-bar {
        padding: 8px 10px;
    }
}
