/* ==========================================================================
   LDP Analyzer - Professional Trading Platform Styles
   ========================================================================== */

/* Root Variables - Compact Theme with Red Accents */
:root {
    --color-primary: #2563eb;
    --color-success: #059669;
    --color-danger: #dc2626;
    --color-warning: #d97706;
    --color-info: #2563eb;
    --color-red: #dc2626;
    --color-red-light: #ef4444;
    --color-red-dark: #b91c1c;
    --color-hot: #dc2626;
    --color-cold: #2563eb;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    
    /* Compact spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
}

/* Global Styles */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    font-size: 0.875rem; /* Smaller base font size */
    line-height: 1.4; /* Tighter line height */
}

/* Reduce default padding and margins for compact layout */
main {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

main > * {
    margin-bottom: 0.5rem !important;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.dark ::-webkit-scrollbar-track {
    background: #1e293b;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Toast Notifications */
.toast {
    pointer-events: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 1rem;
    animation: slideIn 0.3s ease-out;
    transition: all 0.3s ease;
}

.dark .toast {
    background: #1e293b;
    border-color: #334155;
}

.toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.toast.removing {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideOut {
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Trade Tabs */
.trade-tab {
    background: transparent;
    color: #64748b;
    transition: all 0.2s ease;
}

.dark .trade-tab {
    color: #94a3b8;
}

.trade-tab.active {
    background: white;
    color: #0ea5e9;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.dark .trade-tab.active {
    background: #334155;
    color: #38bdf8;
}

/* Contract Type Tabs */
.contract-tab {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.dark .contract-tab {
    background: #334155;
    color: #94a3b8;
    border-color: #475569;
}

.contract-tab.active {
    background: #0ea5e9;
    color: white;
    border-color: #0ea5e9;
}

/* Live Digits Stream */
#liveDigitsStream {
    scrollbar-width: thin;
}

#liveDigitsStream::-webkit-scrollbar {
    height: 4px;
}

.digit-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Digit Color Classes - Red theme for hot digits (0, 2, 6) */
.digit-0 { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); color: #991b1b; border: 1px solid #dc2626; }
.digit-1 { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1e40af; border: 1px solid #3b82f6; }
.digit-2 { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); color: #991b1b; border: 1px solid #dc2626; }
.digit-3 { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1e40af; border: 1px solid #3b82f6; }
.digit-4 { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1e40af; border: 1px solid #3b82f6; }
.digit-5 { background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%); color: #374151; border: 1px solid #6b7280; }
.digit-6 { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); color: #991b1b; border: 1px solid #dc2626; }
.digit-7 { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1e40af; border: 1px solid #3b82f6; }
.digit-8 { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1e40af; border: 1px solid #3b82f6; }
.digit-9 { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1e40af; border: 1px solid #3b82f6; }

.dark .digit-0 { background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%); color: #fecaca; border: 1px solid #dc2626; }
.dark .digit-1 { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #bfdbfe; border: 1px solid #3b82f6; }
.dark .digit-2 { background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%); color: #fecaca; border: 1px solid #dc2626; }
.dark .digit-3 { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #bfdbfe; border: 1px solid #3b82f6; }
.dark .digit-4 { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #bfdbfe; border: 1px solid #3b82f6; }
.dark .digit-5 { background: linear-gradient(135deg, #374151 0%, #4b5563 100%); color: #d1d5db; border: 1px solid #6b7280; }
.dark .digit-6 { background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%); color: #fecaca; border: 1px solid #dc2626; }
.dark .digit-7 { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #bfdbfe; border: 1px solid #3b82f6; }
.dark .digit-8 { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #bfdbfe; border: 1px solid #3b82f6; }
.dark .digit-9 { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #bfdbfe; border: 1px solid #3b82f6; }

/* Trade Log Entries */
.trade-entry {
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.dark .trade-entry {
    background: #1e293b;
    border-color: #334155;
}

.trade-entry:hover {
    border-color: #0ea5e9;
    transform: translateX(4px);
}

.trade-entry.win {
    background: #f0fdf4;
    border-color: #22c55e;
}

.dark .trade-entry.win {
    background: #14532d;
    border-color: #16a34a;
}

.trade-entry.loss {
    background: #fef2f2;
    border-color: #ef4444;
}

.dark .trade-entry.loss {
    background: #7f1d1d;
    border-color: #dc2626;
}

/* Chart Containers */
.chart-container {
    transition: opacity 0.3s ease;
}

.chart-container.hidden {
    display: none;
}

/* Custom Input Styles */
input[type="number"],
input[type="text"],
select {
    transition: all 0.2s ease;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.1);
}

/* Button Hover Effects */
button {
    transition: all 0.2s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

button:not(:disabled):hover {
    transform: translateY(-1px);
}

button:not(:disabled):active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Signal Cards Animation */
#signal1Card,
#signal2Card,
#signal3Card {
    animation: fadeInUp 0.5s ease;
}

#signal2Card {
    animation-delay: 0.1s;
}

#signal3Card {
    animation-delay: 0.2s;
}

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

/* Section-Specific Loading Overlays */
#chartLoadingOverlay,
#analyticsLoadingOverlay {
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

#chartLoadingOverlay.hidden,
#analyticsLoadingOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Responsive Adjustments */

/* Header Stats Bar - Always visible, no scrolling */
header .bg-slate-50 {
    overflow: visible;
}

/* Quick Trade Buttons - Clean Style */
.quick-trade-btn {
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    will-change: transform;
}

.quick-trade-btn:not(:disabled) {
    cursor: pointer;
}

.quick-trade-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.2);
}

.quick-trade-btn:not(:disabled):active {
    transform: translateY(0);
}

/* Primary quick trade button (Signal 1) */
#signal1Status.quick-trade-btn {
    border-width: 0;
}

/* Secondary quick trade buttons (Signal 2 & 3) */
#signal2Status.quick-trade-btn,
#signal3Status.quick-trade-btn {
    border-width: 0;
}

/* Extra Compact Mobile Mode (Tablets) */
@media (max-width: 768px) {
    /* More compact padding for all cards */
    .bg-white, .dark\:bg-slate-800 {
        padding: 0.5rem !important;
    }
    
    /* Smaller text */
    h1 { font-size: 1rem !important; }
    h2 { font-size: 0.875rem !important; }
    h3 { font-size: 0.75rem !important; }
    
    /* Tighter spacing */
    .space-y-2 > * + * { margin-top: 0.375rem !important; }
    .space-y-3 > * + * { margin-top: 0.5rem !important; }
    .space-x-2 > * + * { margin-left: 0.375rem !important; }
    .space-x-3 > * + * { margin-left: 0.5rem !important; }
    
    /* Compact buttons */
    button {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
    
    /* Compact inputs */
    input, select {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.75rem !important;
    }
    
    /* Compact cards */
    .rounded-lg {
        border-radius: 0.5rem !important;
    }
    
    /* Reduce gaps */
    .gap-3 { gap: 0.5rem !important; }
    .gap-2 { gap: 0.375rem !important; }
    
    /* Compact signal cards */
    #signal1Card, #signal2Card, #signal3Card {
        padding: 0.5rem !important;
    }
    
    /* Smaller chart heights */
    .h-48 { height: 10rem !important; }
    #priceChart { height: 200px !important; min-height: 200px !important; }
    
    /* Compact stats */
    .text-sm { font-size: 0.75rem !important; }
    .text-xs { font-size: 0.625rem !important; }
}

@media (max-width: 640px) {
    .digit-badge {
        min-width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
    
    .trade-entry {
        font-size: 0.75rem;
    }
}

/* Compact Stake Modify Buttons */
.stake-modify-btn,
.manual-stake-modify {
    transition: all 0.2s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.stake-modify-btn:hover,
.manual-stake-modify:hover {
    transform: scale(1.05);
}

/* Equal Height Containers */
@media (min-width: 1024px) {
    .lg\:col-span-8,
    .lg\:col-span-4 {
        display: flex;
        flex-direction: column;
    }
    
    .lg\:col-span-8 > div,
    .lg\:col-span-4 > div {
        flex: 1;
    }
}

/* Fixed Chart Container Height - Prevents resize on theme toggle */
.chart-container-fixed {
    min-height: 360px;
}

#priceChart {
    height: 240px !important;
    min-height: 240px !important;
    max-height: 240px !important;
}

/* Ensure Chart.js canvas doesn't change on theme toggle */
#priceChart canvas {
    height: 240px !important;
}

/* Pulse Animation for Live Indicators */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Smooth Transitions for Theme Toggle */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Hide elements smoothly */
.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Professional Shadows */
.shadow-professional {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.dark .shadow-professional {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Badge Styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.dark .badge-success {
    background: #064e3b;
    color: #6ee7b7;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.dark .badge-danger {
    background: #7f1d1d;
    color: #fca5a5;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.dark .badge-warning {
    background: #78350f;
    color: #fcd34d;
}

/* Card Hover Effects */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #334155 25%, #1e293b 50%, #334155 75%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Professional Focus Styles */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #0ea5e9;
    outline-offset: 2px;
}

/* Mobile Menu Dropdown */
#mobileMenuDropdown {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

#mobileMenuDropdown a {
    transition: all 0.2s ease;
}

/* Footer Horizontal Scroll for Mobile */
footer .overflow-x-auto {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

footer .overflow-x-auto::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Ensure footer links stay in one line on mobile */
@media (max-width: 640px) {
    footer .flex {
        flex-wrap: nowrap !important;
    }
    
    footer .gap-x-4 {
        gap: 0.75rem;
    }
    
    footer .space-x-2 > * + * {
        margin-left: 0.35rem;
    }
    
    footer .text-xs {
        font-size: 0.65rem;
    }
    
    /* Header stats - ultra compact on mobile */
    header .bg-slate-50 .flex {
        gap: 0.25rem !important;
    }
    
    header .bg-slate-50 .flex > div {
        padding-left: 0.375rem !important;
        padding-right: 0.375rem !important;
        justify-content: center;
    }
    
    /* Center stats values when labels are hidden on mobile */
    header .bg-slate-50 #balanceDisplay,
    header .bg-slate-50 #profitDisplay,
    header .bg-slate-50 #loginIdDisplay {
        text-align: center;
        width: 100%;
    }
}

/* FAQ Modal Styles */
#faqModal {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#faqModal > div {
    animation: slideUp 0.3s ease-out;
}

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

.faq-question i {
    transition: transform 0.3s ease;
}

.faq-answer {
    transition: all 0.3s ease;
}

/* Smooth accordion animation */
.faq-item {
    transition: all 0.2s ease;
}

.faq-item:hover {
    transform: translateX(2px);
}

/* FAQ Modal scrollbar */
#faqModal .overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

#faqModal .overflow-y-auto::-webkit-scrollbar-track {
    background: transparent;
}

#faqModal .overflow-y-auto::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dark #faqModal .overflow-y-auto::-webkit-scrollbar-thumb {
    background: #475569;
}

/* Login/Logout Button Styles - Ensure prominence on mobile */
#loginBtn,
#logoutBtn {
    min-width: 90px;
    white-space: nowrap;
}

@media (max-width: 640px) {
    #loginBtn,
    #logoutBtn {
        padding: 0.625rem 2rem !important; /* py-2.5 px-8 */
        font-size: 0.9rem !important;
        min-width: 100px;
        font-weight: 600 !important;
    }
}

/* LDP Legacy Button - Highlighted and Glowing */
.ldp-legacy-btn {
    position: relative;
    animation: subtleGlow 2s ease-in-out infinite;
    box-shadow: 0 0 5px rgba(5, 150, 105, 0.2);
}

.ldp-legacy-btn:hover {
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.3);
    transform: translateY(-1px);
    animation: none;
}

.dark .ldp-legacy-btn {
    box-shadow: 0 0 5px rgba(5, 150, 105, 0.3);
}

.dark .ldp-legacy-btn:hover {
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.4);
}

@keyframes subtleGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(5, 150, 105, 0.2);
    }
    50% {
        box-shadow: 0 0 8px rgba(5, 150, 105, 0.25);
    }
}

.dark .ldp-legacy-btn {
    animation: subtleGlowDark 2s ease-in-out infinite;
}

@keyframes subtleGlowDark {
    0%, 100% {
        box-shadow: 0 0 5px rgba(5, 150, 105, 0.3);
    }
    50% {
        box-shadow: 0 0 8px rgba(5, 150, 105, 0.35);
    }
}

/* ==========================================================================
   BASE THEME LAYER  —  shared brand look (header + stat-cards + market pills
   + account switcher), ported from /ldp/ and made dark/light aware so ldp-pro
   matches every other bot. Compact + mobile-native refinements at the bottom.
   ========================================================================== */

:root {
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --brand: #2563eb;
    --brand-600: #1d4ed8;
    --hot: #dc2626;   /* over-represented digit */
    --cold: #2563eb;  /* under-represented digit */
    --pos: #059669;
    --neg: #dc2626;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}
/* Android WebViews that already sit between the system bars (our Android app, most in-app
   browsers) can still report the bars' insets, so the gesture-bar gap was added twice.
   A normal browser tab is never under the status bar, so a top inset there means the insets
   are not real: ignore the bottom one too. iOS and installed modes keep the real value. */
@media (display-mode: browser) {
    @supports not (-webkit-touch-callout: none) {
        :root {
            --safe-bottom: max(0px, env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px) * 100);
        }
    }
}
.dark {
    --surface: #1e293b;
    --surface-2: #0f172a;
    --surface-3: #334155;
    --border: #334155;
    --border-strong: #475569;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --hot: #f87171;
    --cold: #60a5fa;
    --pos: #34d399;
    --neg: #f87171;
}

/* ---- Brand wordmark in header ---- */
.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1;
}
.brand-logo {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 9px;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
    flex-shrink: 0;
}
.brand-name { font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
.brand-name .lite { font-weight: 500; opacity: 0.65; }
.brand-tag {
    font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted); font-weight: 700;
}

/* ---- Stat cards row (Account / Balance / Profit) ---- */
.stat-row {
    display: flex;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}
.stat-card {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.stat-card .stat-icon { font-size: 1.15rem; color: var(--brand); flex-shrink: 0; }
.stat-body { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.stat-key {
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--text-muted);
}
.stat-key-short { display: none; }
.stat-val {
    font-size: 0.95rem; font-weight: 800; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}
.stat-val.pos { color: var(--pos); }
.stat-val.neg { color: var(--neg); }
.stat-card.switchable { cursor: pointer; transition: box-shadow .15s ease, border-color .15s ease; }
.stat-card.switchable:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(37, 99, 235, 0.18); }
.stat-caret { margin-left: auto; color: var(--text-muted); font-size: 0.9em; flex-shrink: 0; }
.stat-card.switchable:hover .stat-caret { color: var(--brand); }

/* ---- Market pill menu (base-theme style, mobile-native scroll) ---- */
.market-menu {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.market-menu::-webkit-scrollbar { display: none; }
.market-pill {
    flex: 0 0 auto;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all .12s ease;
    min-height: 30px;
}
.market-pill:hover { color: var(--text); background: var(--surface-3); }
.market-pill.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* ---- Account switcher popup (dark/light aware) ---- */
.acct-sw-overlay { position: fixed; inset: 0; z-index: 10001; background: rgba(15, 23, 32, 0.45); }
.acct-sw-pop {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    animation: acctSwIn .12s ease-out;
}
@keyframes acctSwIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.acct-sw-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 13px; font-size: 0.72rem; font-weight: 800;
    letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-muted); background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.acct-sw-close { cursor: pointer; color: var(--text-muted); padding: 2px 4px; }
.acct-sw-close:hover { color: var(--neg); }
.acct-sw-list { max-height: 280px; overflow-y: auto; padding: 5px; }
.acct-sw-row {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px; border-radius: 9px; cursor: pointer;
    transition: background .12s ease; min-height: 44px;
}
.acct-sw-row:hover { background: var(--surface-2); }
.acct-sw-row.active { background: rgba(37, 99, 235, 0.12); }
.acct-sw-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.acct-sw-dot.real { background: #10b981; }
.acct-sw-dot.demo { background: #f59e0b; }
.acct-sw-id { font-size: 0.8rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.acct-sw-pill {
    font-size: 0.55rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em;
    padding: 2px 6px; border-radius: 8px; color: #fff; flex-shrink: 0;
}
.acct-sw-pill.real { background: #10b981; }
.acct-sw-pill.demo { background: #f59e0b; }
.acct-sw-bal { margin-left: auto; font-size: 0.72rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.acct-sw-bal.muted { opacity: 0.6; }
.acct-sw-check { color: var(--brand); font-size: 0.85rem; flex-shrink: 0; width: 0.9em; text-align: center; }
.acct-sw-check.hidden { visibility: hidden; }
.acct-sw-loading { padding: 22px 16px; text-align: center; font-size: 0.9rem; color: var(--text-muted); }
.acct-sw-loading .fa { margin-right: 6px; color: var(--brand); }

/* ==========================================================================
   DIGIT ANALYSIS PANEL  —  real 0-9 heatmap + DIFFER/MATCH targets + streaks
   ========================================================================== */
.analysis-panel { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
@media (max-width: 860px) { .analysis-panel { grid-template-columns: 1fr; } }

/* --- 0-9 heatmap --- */
.heat-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.heat-cell {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 4px 0 3px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1.5px solid transparent;
    transition: border-color .15s ease, transform .1s ease;
}
.heat-pct { font-size: 0.6rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.heat-bar-wrap {
    position: relative;
    width: 60%; height: 46px;
    display: flex; align-items: flex-end;
    border-radius: 4px; background: rgba(148, 163, 184, 0.16); overflow: hidden;
}
/* 10% "fair share" baseline — bars are scaled so full height = 20%, so 10% sits at 50% */
.heat-bar-wrap::before {
    content: ""; position: absolute; left: 0; right: 0; bottom: 50%;
    border-top: 1px dashed rgba(148, 163, 184, 0.7);
    pointer-events: none; z-index: 1;
}
.heat-bar { width: 100%; border-radius: 4px 4px 0 0; transition: height .35s cubic-bezier(.4,0,.2,1); min-height: 2px; }
.heat-digit {
    font-size: 0.82rem; font-weight: 800; color: var(--text);
    width: 20px; height: 20px; display: grid; place-items: center; border-radius: 6px;
}
.heat-cell.is-hot { border-color: var(--hot); }
.heat-cell.is-cold { border-color: var(--cold); }
.heat-cell.is-last { animation: heatPulse 1s ease; }
.heat-cell.is-last .heat-digit { background: var(--brand); color: #fff; }
@keyframes heatPulse { 0% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* --- target chips (DIFFER / MATCH) --- */
.target-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.target-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 11px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface-2);
}
.target-chip .tc-num {
    width: 38px; height: 38px; flex-shrink: 0;
    display: grid; place-items: center; border-radius: 9px;
    font-size: 1.35rem; font-weight: 800; color: #fff;
}
.target-chip.differ .tc-num { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.target-chip.match  .tc-num { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.tc-label { font-size: 0.58rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.tc-desc  { font-size: 0.66rem; color: var(--text-muted); }
.tc-desc b { color: var(--text); }

/* --- balance bars (even/odd, over/under, rise/fall streak) --- */
.bal-bar { margin-top: 2px; }
.bal-bar + .bal-bar { margin-top: 9px; }
.bal-head { display: flex; justify-content: space-between; font-size: 0.62rem; font-weight: 700; margin-bottom: 3px; }
.bal-head .l { color: var(--brand); }
.bal-head .r { color: var(--hot); }
.bal-track { height: 8px; border-radius: 5px; overflow: hidden; display: flex; background: var(--surface-3); }
.bal-fill-l { background: linear-gradient(90deg, #3b82f6, #2563eb); transition: width .4s ease; }
.bal-fill-r { background: linear-gradient(90deg, #ef4444, #dc2626); transition: width .4s ease; }
.streak-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 9px; border-radius: 999px; font-size: 0.68rem; font-weight: 800;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.streak-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }

/* ==========================================================================
   AI TRADING SIGNALS  —  redesigned to match the base theme (clean cards,
   strategy accent, confidence meter, consistent CTA)
   ========================================================================== */
.sig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 860px) { .sig-grid { grid-template-columns: 1fr; } }

.sig-card {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 7px;
    padding: 11px 11px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.sig-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--sig-accent, var(--brand)); }
.sig-card.s1 { --sig-accent: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.sig-card.s2 { --sig-accent: linear-gradient(90deg, #8b5cf6, #6d28d9); }
.sig-card.s3 { --sig-accent: linear-gradient(90deg, #f59e0b, #d97706); }

.sig-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sig-head-l { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sig-ico { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; color: #fff; font-size: 0.8rem; background: var(--sig-accent, var(--brand)); }
.sig-kicker { font-size: 0.55rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); line-height: 1.15; }
.sig-name { font-size: 0.82rem; font-weight: 800; color: var(--text); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sig-conf { font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; white-space: nowrap; } /* JS adds state bg/text */

.sig-pred {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 54px; padding: 6px 8px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
}
.sig-pred .lab { font-size: 0.55rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.sig-pred-num { font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--text); }
.sig-card.s1 .sig-pred-num { color: #2563eb; }
.dark .sig-card.s1 .sig-pred-num { color: #60a5fa; }
.sig-pred-num.wait { font-size: 0.95rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.sig-meter { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.sig-meter > i { display: block; height: 100%; width: 0%; border-radius: 4px; background: var(--brand); transition: width 0.4s ease, background 0.3s ease; }

.sig-analysis { font-size: 0.66rem; line-height: 1.35; color: var(--text-muted); min-height: 2.6em; }

.sig-stake { display: flex; align-items: center; gap: 4px; }
.sig-stake .amt { font-size: 0.72rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; padding-right: 2px; }
.sig-stake .stake-modify-btn {
    flex: 1; padding: 5px 0; border-radius: 7px; font-size: 0.68rem; font-weight: 700;
    color: #fff; border: none; cursor: pointer; transition: filter 0.12s ease; min-height: 28px;
}
.sig-stake .stake-modify-btn[data-action="double"] { background: #2563eb; }
.sig-stake .stake-modify-btn[data-action="half"]   { background: #64748b; }
.sig-stake .stake-modify-btn[data-action="reset"]  { background: #94a3b8; }
.sig-stake .stake-modify-btn:hover { filter: brightness(1.08); }

.sig-cta {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px; border-radius: 9px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em;
    color: var(--text); border: none; cursor: pointer; transition: filter 0.12s ease; min-height: 38px;
}
.sig-cta:disabled { opacity: 0.6; cursor: not-allowed; }
.sig-cta:not(:disabled):hover { filter: brightness(1.04); }

/* ===== AutoPilot (server-side automation) tab ===== */
.ap-dir {
    background: var(--surface-2); color: var(--text-muted);
    border: 1px solid transparent; cursor: pointer; transition: all 0.12s ease;
}
.ap-dir:hover { color: var(--text); }
.ap-dir.active[data-dir="CALL"] { background: #16a34a; color: #fff; }
.ap-dir.active[data-dir="PUT"] { background: #dc2626; color: #fff; }
.ap-badge {
    font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 2px 9px; border-radius: 999px; color: #fff; background: #94a3b8;
}
.ap-badge.running { background: #16a34a; }
.ap-badge.paused { background: #f59e0b; }
.ap-badge.stopped, .ap-badge.idle { background: #94a3b8; }
.ap-log {
    max-height: 96px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
    padding: 6px 8px; font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; line-height: 1.5;
}
.ap-log-line { color: var(--text-muted); white-space: nowrap; }
.ap-log-line.ok { color: var(--pos); }
.ap-log-line.err { color: var(--neg); }

/* AutoPilot Setup/Activity sub-tabs */
.ap-subtab { background: transparent; color: var(--text-muted); border: none; cursor: pointer; transition: all 0.12s ease; }
.ap-subtab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.dark .ap-subtab.active { background: #0f172a; }

/* AutoPilot trade-history list */
.ap-trades { max-height: 150px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.ap-trades-empty { padding: 14px; text-align: center; font-size: 0.66rem; color: var(--text-muted); }
.ap-trade-row {
    display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px;
    padding: 5px 9px; font-size: 0.66rem; border-bottom: 1px solid var(--border);
}
.ap-trade-row:last-child { border-bottom: none; }
.ap-trade-type { font-weight: 800; padding: 1px 7px; border-radius: 6px; color: #fff; font-size: 0.6rem; }
.ap-trade-type.rise { background: #16a34a; }
.ap-trade-type.fall { background: #dc2626; }
.ap-trade-stake { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.ap-trade-status { text-transform: capitalize; color: var(--text-muted); }
.ap-trade-status.won { color: var(--pos); }
.ap-trade-status.lost { color: var(--neg); }
.ap-trade-pl { font-family: 'JetBrains Mono', monospace; font-weight: 700; text-align: right; }
.ap-trade-pl.pos { color: var(--pos); }
.ap-trade-pl.neg { color: var(--neg); }

/* Desktop: keep the Trading Panel aligned with the Live Price Chart (don't let
   a long trade list / log stretch the row). The active tab body scrolls; the
   Launch/Stop buttons stay pinned at the bottom. */
@media (min-width: 1024px) {
    .trade-panel { max-height: 430px; }
    .trade-panel .trade-content { min-height: 0; }
    .trade-panel #apSetupView,
    .trade-panel #apActivityView,
    .trade-panel #aiTab,
    .trade-panel #manualTab { min-height: 0; }
    .trade-panel #apActivityView { overflow-y: auto; }
    /* single scrollbar on the Activity view — let its inner lists grow inside it */
    .trade-panel #apActivityView .ap-trades,
    .trade-panel #apActivityView .ap-log { max-height: none; overflow: visible; }
}

/* ==========================================================================
   COMPACT + MOBILE-NATIVE REFINEMENTS
   ========================================================================== */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.section-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.72rem; font-weight: 800; color: var(--text);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.section-title i { color: var(--brand); }

/* Section loaders — fade out smoothly instead of popping */
[id$="LoadingOverlay"] { transition: opacity 0.22s ease; }
[id$="LoadingOverlay"].fading { opacity: 0; }

/* Small breathing room around the account/stat-cards row */
.stat-row { margin-top: 2px; }
.app-header-pad { padding-top: 4px; padding-bottom: 8px; }

@media (max-width: 640px) {
    body { font-size: 0.78rem; }
    /* short stat labels so 3 cards never wrap on small phones */
    .stat-key-full { display: none; }
    .stat-key-short { display: inline; }
    .stat-row { gap: 6px; }
    .stat-card { padding: 5px 8px; gap: 6px; }
    .stat-card .stat-icon { font-size: 1rem; }
    .stat-key { font-size: 0.55rem; }
    .stat-val { font-size: 0.8rem; }
    /* Card keeps its row layout at this width, so the caret stays inline —
       just shrink it rather than dropping the "tap to switch" affordance. */
    .stat-caret { font-size: 0.7rem; opacity: 0.8; }

    /* tighter section chrome */
    .section-card { border-radius: 10px; }
    .section-title { font-size: 0.66rem; }

    /* signals: smaller + denser */
    .sig-card { padding: 9px 9px 10px; gap: 6px; border-radius: 10px; }
    .sig-ico { width: 26px; height: 26px; font-size: 0.72rem; }
    .sig-name { font-size: 0.74rem; }
    .sig-kicker { font-size: 0.5rem; }
    .sig-conf { font-size: 0.64rem; padding: 2px 6px; }
    .sig-pred { min-height: 46px; }
    .sig-pred-num { font-size: 1.4rem; }
    .sig-analysis { font-size: 0.62rem; min-height: 3.2em; }

    /* digit analysis: smaller cells + chips */
    .heat-grid { gap: 3px; }
    .heat-cell { padding: 3px 0 2px; }
    .heat-pct { font-size: 0.52rem; }
    .heat-bar-wrap { height: 34px; }
    .heat-digit { font-size: 0.7rem; width: 17px; height: 17px; }
    .target-chip { padding: 7px 9px; gap: 7px; }
    .target-chip .tc-num { width: 32px; height: 32px; font-size: 1.1rem; }
    .tc-label { font-size: 0.54rem; }
    .tc-desc { font-size: 0.6rem; }
    .streak-chip { font-size: 0.62rem; }

    /* trading panel — compact on mobile (override Tailwind utility sizes) */
    .trade-tab, .contract-tab { font-size: 0.64rem !important; padding-top: 5px !important; padding-bottom: 5px !important; }
    #manualTab label, #aiTab label { font-size: 0.62rem !important; }
    #manualTab input, #manualTab select,
    #aiTab input, #aiTab select { font-size: 0.72rem !important; padding: 5px 8px !important; }
    #callBtn, #putBtn, #matchBtn, #differBtn, #evenBtn, #oddBtn, #overBtn, #underBtn,
    #startAiBtn, #stopAiBtn { font-size: 0.7rem !important; }
    .section-card { padding: 7px !important; }

    /* comfortable tap targets for the primary trade actions */
    .quick-trade-btn, .sig-cta, #startAiBtn, #stopAiBtn,
    #callBtn, #putBtn, #matchBtn, #differBtn, #evenBtn, #oddBtn, #overBtn, #underBtn {
        min-height: 42px;
    }
    /* keep the page from ever scrolling sideways on a phone */
    main { overflow-x: hidden; }
    /* bottom breathing room for gesture bars / home indicator */
    footer { padding-bottom: calc(0.75rem + var(--safe-bottom)); }
}

/* very small phones — squeeze a little more */
@media (max-width: 400px) {
    body { font-size: 0.74rem; }
    .stat-card { padding: 4px 7px; }
    .stat-key { font-size: 0.5rem; }
    .stat-val { font-size: 0.74rem; }
    .sig-pred-num { font-size: 1.25rem; }
    .heat-bar-wrap { height: 30px; }
    .heat-pct { font-size: 0.48rem; }
    .heat-digit { font-size: 0.64rem; }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    header,
    button,
    #loadingOverlay,
    #faqModal {
        display: none;
    }
}

