:root {
    --bg-primary: #0b0e14;
    --bg-card: #151a23;
    --bg-card-hover: #1c2330;
    --border-color: #242d3d;
    --text-primary: #f0f4f8;
    --text-muted: #8b98a5;
    
    --accent-cyan: #00f2fe;
    --accent-blue: #4facfe;
    --color-green: #00e676;
    --color-red: #ff5252;
    --color-warning: #ffb300;
    
    --font-main: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-lg: 14px;
    --radius-md: 8px;
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-main);
}

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

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #000;
}

.logo-area h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-guide-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--accent-blue);
    border-radius: 20px;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-guide-link:hover {
    background: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.pair-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-weight: 600;
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--color-green);
    animation: pulse 1.5s infinite;
}

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

.ticker-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ticker-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ticker-price {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-running {
    background: rgba(0, 230, 118, 0.15);
    color: var(--color-green);
    border: 1px solid var(--color-green);
}

.status-stopped {
    background: rgba(255, 82, 82, 0.15);
    color: var(--color-red);
    border: 1px solid var(--color-red);
}

/* CARDS COMMON */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-main);
}

/* METRICS ROW */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.card-icon {
    font-size: 1.1rem;
    opacity: 0.7;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.metric-sub {
    font-size: 0.85rem;
    font-weight: 500;
}

.pnl-positive { color: var(--color-green); }
.pnl-negative { color: var(--color-red); }
.pnl-neutral { color: var(--text-muted); }

/* MIDDLE ROW */
.middle-row {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

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

.control-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;

}

.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: none;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-success {
    background: var(--color-green);
    color: #000;
}
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-danger {
    background: var(--color-red);
    color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-secondary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
}
.btn-secondary:hover { filter: brightness(1.1); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover { background: rgba(255,255,255,0.05); }

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
}

.strategy-desc-box {
    margin-top: 8px;
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ACTIVE POSITION BOX & SPACIOUS MULTI-SLOT CARDS */
.pos-box {
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.pos-card-spacious {
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(21, 26, 35, 0.9), rgba(15, 20, 28, 0.95));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.pos-card-spacious:hover {
    border-color: rgba(0, 242, 254, 0.35);
    transform: translateY(-1px);
}

.pos-card-spacious.active-long {
    border-left: 4px solid var(--color-green);
    background: linear-gradient(135deg, rgba(0, 230, 118, 0.06), var(--bg-card));
}

.pos-card-spacious.active-short {
    border-left: 4px solid var(--color-purple);
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.06), var(--bg-card));
}

.pos-timer-bar-container {
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.pos-timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--color-green));
    width: 0%;
    transition: width 1s linear;
}

.pos-timer-bar-fill.warning {
    background: linear-gradient(90deg, var(--color-warning), var(--color-red));
}

.timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
}

.timer-badge.elapsed {
    color: var(--accent-cyan);
    border-color: rgba(0, 242, 254, 0.25);
}

.timer-badge.countdown {
    color: var(--color-warning);
    border-color: rgba(255, 179, 0, 0.25);
}

.pos-box.active-long {
    border-left: 4px solid var(--color-green);
}

.pos-box.active-short {
    border-left: 4px solid #a855f7;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.05), var(--bg-primary));
}

.pos-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

/* CHART CONTAINER */
.chart-card {
    display: flex;
    flex-direction: column;
}

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

.timeframe-selector {
    display: flex;
    gap: 6px;
}

.tf-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    color: var(--text-muted);
}

.tf-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

.chart-container {
    flex: 1;
    min-height: 380px;
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* TRADES TABLE */
.table-responsive {
    overflow-x: auto;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.trades-table th {
    text-align: left;
    padding: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

.trades-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-family: var(--font-mono);
}

.badge-buy {
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 230, 118, 0.15);
    color: var(--color-green);
    font-weight: 700;
}

.badge-sell {
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 82, 82, 0.15);
    color: var(--color-red);
    font-weight: 700;
}

.badge-short {
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
    font-weight: 700;
}

.badge-cover {
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 242, 254, 0.2);
    color: var(--accent-cyan);
    font-weight: 700;
}

.text-success { color: var(--color-green); }
.text-danger { color: var(--color-red); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* PAGINATION CONTROLS */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.page-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

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

.btn:disabled, .btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* AI AGENT TELEMETRY SECTION */
.ai-agent-section {
    margin-top: 18px;
    padding: 14px;
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.08), rgba(0, 242, 254, 0.03));
    border: 1px solid rgba(79, 172, 254, 0.2);
    border-radius: var(--radius-md);
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.badge-regime {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.regime-ranging {
    background: rgba(0, 242, 254, 0.15);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
}

.regime-trending {
    background: rgba(0, 230, 118, 0.15);
    color: var(--color-green);
    border: 1px solid var(--color-green);
}

.regime-volatile {
    background: rgba(255, 179, 0, 0.15);
    color: var(--color-warning);
    border: 1px solid var(--color-warning);
}

/* CHART COLUMN & LOCKED CONTROLS */
.chart-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.locked-strategy-box {
    background: rgba(0, 242, 254, 0.04);
    border: 1px dashed var(--accent-cyan);
    border-radius: var(--radius-md);
    padding: 12px;
}

.locked-badge {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.discrete-reset-container {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
}

.btn-subtle-reset {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.btn-subtle-reset:hover {
    opacity: 1;
    color: var(--color-red);
    background: rgba(255, 82, 82, 0.1);
}

/* WIDE PROMINENT AI TELEMETRY PANEL BELOW CHART */
.ai-telemetry-card {
    background: linear-gradient(135deg, #151a23, #1a2230);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

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

.ai-telemetry-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr;
    gap: 16px;
}

.ai-sub-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ai-sub-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-val-large {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-green);
    margin-bottom: 8px;
}

.ai-confidence-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.ai-confidence-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--color-green));
    transition: width 0.3s ease;
}

.ai-sub-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.ai-risk-targets {
    display: flex;
    gap: 12px;
    margin-bottom: 6px;
}

.risk-target-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.risk-target-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.risk-target-item strong {
    font-family: var(--font-mono);
    font-size: 1rem;
}

.top-candidate-badge-large {
    padding: 8px 12px;
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: 8px;
}

.scanned-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.scanned-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.scanned-item.item-high {
    border-color: rgba(0, 230, 118, 0.3);
    background: rgba(0, 230, 118, 0.08);
    color: var(--color-green);
}

.scanned-item .item-sym {
    font-weight: 600;
}

.scanned-item .item-score {
    opacity: 0.8;
}

/* PNL EQUITY GROWTH CHART */
.pnl-chart-card {
    margin-bottom: 20px;
}

.pnl-chart-container {
    height: 220px;
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
}

@media (max-width: 1200px) {
    .ai-telemetry-grid { grid-template-columns: 1fr; }
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
    .middle-row { grid-template-columns: 1fr; }
}

/* INFO BUTTON & MODAL STYLES */
.label-with-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.label-with-info label {
    margin-bottom: 0;
}

.btn-info-icon {
    background: transparent;
    border: none;
    color: var(--accent-cyan);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.btn-info-icon:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* MODAL OVERLAY & CARD */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 580px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.open .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.btn-close-modal:hover {
    color: var(--color-red);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-info-item {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.modal-strat-title {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-strat-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* RESPONSIVE DESIGN OPTIMIZATIONS FOR MOBILE & TABLETS */
@media (max-width: 992px) {
    .metrics-header {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .main-row {
        flex-direction: column;
    }

    .control-column {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .chart-column {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .ai-telemetry-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .bottom-row {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 12px 10px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 14px 16px;
    }

    .logo-area {
        width: 100%;
        justify-content: flex-start;
    }

    .logo-area h1 {
        font-size: 1.15rem;
    }

    .subtitle {
        font-size: 0.78rem;
    }

    .header-right {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 10px;
    }

    .btn-guide-link, .pair-badge, .status-badge {
        font-size: 0.78rem;
        padding: 6px 12px;
    }

    .ticker-price {
        font-size: 1.05rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .metrics-header {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .metric-card {
        padding: 12px 14px;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .timeframe-selector {
        width: 100%;
        justify-content: space-between;
        overflow-x: auto;
    }

    .tf-btn {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .trades-table th, .trades-table td {
        padding: 8px 10px;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .modal-card {
        width: 95%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .metrics-header {
        grid-template-columns: 1fr;
    }

    .header-title h1 {
        font-size: 1.3rem;
    }

    .app-header {
        padding: 12px;
    }

    .logo-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .header-right {
        gap: 8px;
    }

    .ticker-box {
        align-items: flex-start;
    }

    .pos-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
