/* =============================================================================
   Trading Dashboard - Minimal, Observability-Only UI
   Mode Colors: PAPER = Yellow (#F59E0B), LIVE = Green (#10B981)
============================================================================= */

:root {
    /* Mode Colors */
    --color-paper: #F59E0B;
    --color-paper-bg: rgba(245, 158, 11, 0.15);
    --color-paper-border: rgba(245, 158, 11, 0.3);
    --color-live: #10B981;
    --color-live-bg: rgba(16, 185, 129, 0.15);
    --color-live-border: rgba(16, 185, 129, 0.3);

    /* P&L Colors */
    --color-profit: #10B981;
    --color-loss: #EF4444;

    /* Neutral */
    --color-bg: #0F172A;
    --color-surface: #1E293B;
    --color-surface-hover: #334155;
    --color-border: #334155;
    --color-text: #F8FAFC;
    --color-text-secondary: #94A3B8;
    --color-text-muted: #64748B;

    /* Sizes */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.5;
}

/* =============================================================================
   Top Status Bar
============================================================================= */

.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    color: var(--color-text);
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.status-metrics {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 0.25rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Paper Mode (Yellow) */
.status-badge.paper {
    background: var(--color-paper-bg);
    border: 1px solid var(--color-paper-border);
    color: var(--color-paper);
}

/* Live Mode (Green) */
.status-badge.live {
    background: var(--color-live-bg);
    border: 1px solid var(--color-live-border);
    color: var(--color-live);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-item .label {
    color: var(--color-text-secondary);
}

.status-item .value {
    font-weight: 600;
}

/* P&L Colors */
.pnl-positive {
    color: var(--color-profit) !important;
}

.pnl-negative {
    color: var(--color-loss) !important;
}

/* =============================================================================
   Main Content
============================================================================= */

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* =============================================================================
   Active Trade Panel
============================================================================= */

.active-trade-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.active-trade-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.trade-info {
    display: grid;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .label {
    color: var(--color-text-secondary);
}

.info-row .value {
    font-weight: 500;
}

.info-row .masked {
    color: var(--color-text-muted);
    font-style: italic;
}

.position-states {
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-border);
}

.leg-state {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leg-label {
    color: var(--color-text-secondary);
}

.leg-value.active {
    color: var(--color-profit);
    font-weight: 600;
}

.leg-value.exited {
    color: var(--color-text-muted);
}

.live-pnl-row {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    font-size: 1.1rem;
}

.live-pnl-row .value {
    font-weight: 700;
    font-size: 1.25rem;
}

.highlight-row {
    display: flex;
    justify-content: space-between;
    background: rgba(16, 185, 129, 0.05);
    border-radius: var(--radius-md);
    margin: 1rem -0.5rem 0.5rem -0.5rem;
    padding: 0.75rem 0.5rem;
    border: 1px dashed var(--color-border);
}

.ticker {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text);
}

/* Badge */
.badge-buy {
    background: var(--color-live-bg);
    color: var(--color-live);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-sell {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.product-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(107, 114, 128, 0.15);
    color: #D1D5DB;
    border: 1px solid rgba(107, 114, 128, 0.2);
    text-transform: uppercase;
}

.price-stack {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sub-price {
    font-size: 0.7rem;
    color: #9CA3AF;
    font-weight: 400;
}

/* No Trade Panel */
.no-trade-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.no-trade-content {
    color: var(--color-text-muted);
}

.no-trade-content .icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* =============================================================================
   Order Management Section
============================================================================= */

.orders-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.order-tabs {
    display: flex;
    gap: 0.5rem;
}

.order-tab-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.order-tab-btn:hover {
    background: var(--color-surface-hover);
}

.order-tab-btn.active {
    background: var(--color-bg);
    border-color: var(--color-text-secondary);
    color: var(--color-text);
}

.order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.order-table th,
.order-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.order-table th {
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.order-table tbody tr:hover {
    background: var(--color-surface-hover);
}

/* Status Colors */
.status-badge-green {
    color: var(--color-profit);
    font-weight: 600;
}

.status-badge-red {
    color: var(--color-loss);
    font-weight: 600;
}

.status-badge-yellow {
    color: var(--color-paper);
    font-weight: 600;
}

.status-badge-neutral {
    color: var(--color-text-muted);
}

/* =============================================================================
   Reports Section
============================================================================= */

.reports-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.reports-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.report-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--color-surface-hover);
}

.tab-btn.active.paper {
    background: var(--color-paper-bg);
    border-color: var(--color-paper-border);
    color: var(--color-paper);
}

.tab-btn.active.live {
    background: var(--color-live-bg);
    border-color: var(--color-live-border);
    color: var(--color-live);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.metric-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

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

/* Trade Table */
.table-container {
    overflow-x: auto;
}

.trade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.trade-table th,
.trade-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.trade-table th {
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.trade-table tbody tr:hover {
    background: var(--color-surface-hover);
}

.no-data-row td {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
}

/* Result badges */
.result-win {
    background: var(--color-live-bg);
    color: var(--color-profit);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.result-loss {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-loss);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.result-be {
    background: rgba(148, 163, 184, 0.15);
    color: var(--color-text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Mode badges in table */
.badge-paper {
    color: var(--color-paper);
}

.badge-live {
    color: var(--color-live);
}

/* =============================================================================
   Admin Panel
============================================================================= */

.admin-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    padding: 1.5rem;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 200;
    overflow-y: auto;
}

.admin-panel.visible {
    transform: translateX(0);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.admin-header h3 {
    font-size: 1rem;
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.admin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.admin-section {
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
}

.admin-section label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.capital-input-row {
    display: flex;
    gap: 0.5rem;
}

.capital-input-row input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 1rem;
}

.capital-input-row input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.capital-input-row button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-paper);
    color: #000;
    font-weight: 600;
    cursor: pointer;
}

.capital-input-row button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.warning-text {
    font-size: 0.75rem;
    color: var(--color-paper);
    margin-top: 0.5rem;
}

.danger-btn {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #EF4444;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.secondary-btn {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: var(--color-surface-hover);
}

/* Mode Toggle in Admin */
.mode-toggle-admin {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.mode-btn-admin {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.mode-btn-admin.paper.active {
    background: var(--color-paper-bg);
    border-color: var(--color-paper-border);
    color: var(--color-paper);
}

.mode-btn-admin.live.active {
    background: var(--color-live-bg);
    border-color: var(--color-live-border);
    color: var(--color-live);
}

.mode-btn-admin:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Algo Toggle in Admin */
.algo-toggle-admin {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.algo-btn-admin {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.algo-btn-admin.off.active {
    background: rgba(156, 163, 175, 0.2);
    border-color: #6B7280;
    color: #9CA3AF;
}

.algo-btn-admin.on.active {
    background: var(--color-live-bg);
    border-color: var(--color-live);
    color: var(--color-live);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

.algo-btn-admin:hover:not(.active) {
    background: var(--color-surface-hover);
}

.hint-text {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

/* Logout Button */
.logout-btn {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
    color: #EF4444;
}

/* Admin Toggle */
.admin-toggle {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
    z-index: 150;
}

.admin-toggle:hover {
    background: var(--color-surface-hover);
}

/* =============================================================================
   Utility Classes
============================================================================= */

/* =============================================================================
   Navigation
============================================================================= */

.main-nav {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.nav-btn.active {
    background: var(--color-surface);
    border-color: var(--color-profit);
    color: var(--color-profit);
}

/* =============================================================================
   Reports View
============================================================================= */

.reports-view {
    animation: fadeIn 0.4s ease-out;
}

.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.refresh-btn {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.refresh-btn:hover {
    background: var(--color-surface-hover);
}

.chart-container-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-box {
    height: 300px;
    width: 100%;
    margin-top: 1rem;
}


.home-view {
    animation: fadeIn 0.4s ease-out;
}

.home-header {
    text-align: center;
    margin-bottom: 3rem;
    margin-top: 1rem;
}

.home-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #F8FAFC 0%, #94A3B8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.home-header p {
    color: var(--color-text-secondary);
    font-size: 1.1rem;
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 2rem;
}

.strategy-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.strategy-card:hover {
    transform: translateY(-8px);
    border-color: var(--color-text-secondary);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.strategy-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.strategy-card h3 {
    font-size: 1.25rem;
    margin: 0;
    color: var(--color-text);
}

.strategy-card .status-indicator {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-indicator.on {
    background: var(--color-live-bg);
    color: var(--color-live);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.status-indicator.off {
    background: rgba(148, 163, 184, 0.1);
    color: var(--color-text-secondary);
}

.strategy-card .description {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

.strategy-card .card-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
}

/* =============================================================================
   Detail View
============================================================================= */

.detail-view {
    animation: slideInLeft 0.4s ease-out;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.back-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.detail-header h1 {
    font-size: 1.75rem;
    margin: 0;
}

/* =============================================================================
   Grouped Reports
============================================================================= */

.run-header-row {
    background: rgba(30, 41, 59, 0.8) !important;
    cursor: pointer;
}

.run-header-row td {
    border-bottom: 2px solid var(--color-border);
    padding: 1rem !important;
}

.run-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.run-capital {
    color: var(--color-paper);
    background: var(--color-paper-bg);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.run-metrics {
    margin-left: auto;
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.run-metrics span b {
    color: var(--color-text);
}

.trade-row.nested {
    background: rgba(15, 23, 42, 0.4);
}

.trade-row.nested td:first-child {
    padding-left: 2.5rem;
    position: relative;
}

.trade-row.nested td:first-child::before {
    content: '';
    position: absolute;
    left: 1.25rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .status-bar {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-panel {
        width: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =============================================================================
   Rules Section
============================================================================= */

.rules-section {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.rule-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: transform 0.2s ease;
}

.rule-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-text-secondary);
}

.rule-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

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

.rule-card h3 {
    font-size: 1rem;
    color: var(--color-text);
    margin: 0;
}

.rule-card p {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.rule-list {
    list-style: none;
    padding: 0;
}

.rule-list li {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    padding: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rule-list li::before {
    content: '•';
    color: var(--color-live);
    font-weight: bold;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1.5rem;
}

.active-symbol-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-live);
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.hidden {
    display: none !important;
}

/* Responsive Grid */
@media (max-width: 768px) {
    .strategy-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   System Health Indicator (Status Bar)
============================================================================= */

.health-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.health-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #64748B; /* default: gray */
    flex-shrink: 0;
    transition: background 0.4s ease;
}

.health-dot.connected {
    background: var(--color-profit);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    animation: pulse-green 2.5s ease-in-out infinite;
}

.health-dot.disconnected {
    background: var(--color-loss);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.health-label {
    white-space: nowrap;
}

.status-divider {
    width: 1px;
    height: 1.2rem;
    background: var(--color-border);
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
    50%       { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.05); }
}

/* =============================================================================
   Capital Warning Banner
============================================================================= */

.capital-warning-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(239, 68, 68, 0.12);
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.6rem 1.5rem;
    font-size: 0.875rem;
    color: #FCA5A5;
    font-weight: 500;
    animation: slide-down 0.3s ease;
}

.capital-warning-banner .warning-icon {
    font-size: 1.1rem;
}

@keyframes slide-down {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* =============================================================================
   ORB Strategy Status Panel
============================================================================= */

.orb-status-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: fade-in 0.4s ease;
}

.orb-phase-badge {
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.phase-gray    { background: rgba(100,116,139,0.15); color: #94A3B8; border: 1px solid rgba(100,116,139,0.3); }
.phase-yellow  { background: rgba(245,158,11,0.15);  color: #F59E0B; border: 1px solid rgba(245,158,11,0.3); }
.phase-blue    { background: rgba(59,130,246,0.15);  color: #60A5FA; border: 1px solid rgba(59,130,246,0.3); }
.phase-green   { background: rgba(16,185,129,0.15);  color: #10B981; border: 1px solid rgba(16,185,129,0.3); animation: glow-green 2s ease-in-out infinite; }
.phase-red     { background: rgba(239,68,68,0.15);   color: #EF4444; border: 1px solid rgba(239,68,68,0.3); }

@keyframes glow-green {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
}

.orb-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 1.25rem;
}

.orb-stat {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: border-color 0.3s;
}

.orb-stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.orb-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    transition: color 0.3s ease;
}

/* =============================================================================
   Today's Timeline
============================================================================= */

.timeline-wrapper {
    padding-top: 0.5rem;
    overflow-x: auto;
}

.timeline-track {
    display: flex;
    align-items: flex-start;
    gap: 0;
    min-width: 400px;
    padding: 0.5rem 0.25rem;
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.4s ease, transform 0.3s ease;
}

.timeline-step.tl-done {
    opacity: 1;
}

.timeline-step.tl-current {
    opacity: 1;
    transform: scale(1.08);
}

.timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-border);
    border: 2px solid var(--color-border);
    transition: all 0.4s ease;
    flex-shrink: 0;
}

.timeline-dot.done {
    background: var(--color-profit);
    border-color: var(--color-profit);
}

.timeline-dot.current {
    background: #3B82F6;
    border-color: #3B82F6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
    animation: pulse-blue 1.5s ease-in-out infinite;
}

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 0 4px rgba(59,130,246,0.25); }
    50%       { box-shadow: 0 0 0 8px rgba(59,130,246,0.08); }
}

.timeline-label {
    font-size: 0.65rem;
    color: var(--color-text-secondary);
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
}

.timeline-label small {
    color: var(--color-text-muted);
    font-size: 0.6rem;
}

.timeline-line {
    flex: 1;
    height: 2px;
    background: var(--color-border);
    margin-top: 6px; /* center vertically with dot */
    min-width: 30px;
    transition: background 0.5s ease;
}

.timeline-line.tl-line-done {
    background: var(--color-profit);
}

/* =============================================================================
   Candlestick Chart Section
============================================================================= */

.candle-chart-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
    animation: fade-in 0.4s ease;
}

/* Row 1: symbol info + timeframe buttons */
.chart-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.chart-symbol-info {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.chart-symbol-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: 0.02em;
}

.chart-exchange-badge {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-border);
    padding: 1px 5px;
    border-radius: 3px;
}

.chart-ltp {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-left: 0.25rem;
}

.chart-change {
    font-size: 0.82rem;
    font-weight: 600;
}
.chart-change.positive { color: var(--color-success); }
.chart-change.negative { color: var(--color-danger); }

/* Row 2: OHLC bar */
.chart-ohlc-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.ohlc-item { display: flex; align-items: center; gap: 0.2rem; }
.ohlc-item b { color: var(--color-text-primary); font-weight: 600; }
.ohlc-high  { color: #10B981 !important; }
.ohlc-low   { color: #EF4444 !important; }
.ohlc-sep   { color: var(--color-border); font-size: 0.9rem; }

/* Timeframe buttons */
.chart-timeframes {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.tf-btn {
    padding: 0.28rem 0.65rem;
    border-radius: 5px;
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    line-height: 1;
}

.tf-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: rgba(99, 102, 241, 0.08);
}

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

.refresh-tf-btn {
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    margin-left: 0.2rem;
}

/* Chart canvas box */
.candle-chart-box {
    position: relative;
    height: 420px;
}

.candle-chart-box canvas {
    width: 100% !important;
    height: 100% !important;
}

.candle-chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
}

/* =============================================================================
   Animations & Transitions
============================================================================= */

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Smooth row appear for order rows */
@keyframes row-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.order-row-animate {
    animation: row-in 0.25s ease;
}

/* Metric card hover lift */
.metric-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Rule card hover glow */
.rule-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rule-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.1);
}

/* Strategy card hover */
.strategy-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.strategy-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border-color: rgba(16, 185, 129, 0.35);
}

/* ORB stat hover */
.orb-stat:hover {
    border-color: rgba(16, 185, 129, 0.3);
}

/* Algo status pulse when ON */
.value.pnl-positive {
    animation: none;
}

/* Shimmer loading for strategy cards */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.card-shimmer {
    height: 12px;
    width: 80%;
    margin: 0.5rem 0;
    border-radius: 6px;
    background: linear-gradient(90deg, #1E293B 25%, #334155 50%, #1E293B 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

/* Admin panel slide-in */
.admin-panel {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.admin-panel.hidden {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    display: flex !important; /* override !important hidden for animation */
}

.admin-panel.visible {
    transform: translateX(0);
    opacity: 1;
}

/* Refresh button */
.refresh-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-text-secondary);
}

/* P&L value counter animation */
.live-pnl-row .value {
    transition: color 0.4s ease;
}

/* =============================================================================
   Responsive Additions
============================================================================= */

@media (max-width: 768px) {
    .orb-status-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .status-metrics {
        gap: 0.75rem;
    }
    .health-label {
        display: none; /* Show only dot on mobile */
    }
    .candle-chart-box {
        height: 200px;
    }
    .timeline-track {
        min-width: 320px;
    }
}

/* =============================================================================
   Backtest Tab Styles
   ============================================================================= */

.backtest-controls {
    display: flex;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    margin-bottom: 25px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.control-group input,
.control-group select {
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    min-width: 140px;
}

.btn-run-backtest {
    padding: 10px 30px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.btn-run-backtest:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0,0,0,0.3);
}

.btn-run-backtest:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading-message {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: #888;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Summary Hero Card */
.summary-hero {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: white;
    padding: 35px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.hero-title {
    font-size: 18px;
    margin-bottom: 15px;
    opacity: 0.9;
}

.hero-result {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.hero-result .arrow {
    font-size: 36px;
    opacity: 0.7;
}

.final-cap {
    font-size: 42px;
    font-weight: 900;
    color: #00d2ff;
}

.return-pct {
    font-size: 28px;
    font-weight: 600;
}

.return-pct.pnl-positive {
    color: #00e676;
}

.return-pct.pnl-negative {
    color: #ff5252;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.hero-metrics .metric {
    background: rgba(255,255,255,0.08);
    padding: 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

.hero-metrics .metric label {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-metrics .metric span {
    display: block;
    font-size: 20px;
    font-weight: 700;
}

/* Chart Section */
.bt-chart-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 25px;
}

.bt-chart-section h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: #333;
}

/* Table Section */
.bt-table-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

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

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

.bt-filters select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.bt-data-table {
    width: 100%;
    border-collapse: collapse;
}

.bt-data-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #dee2e6;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bt-data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    color: #333;
}

.bt-data-table tbody tr:hover {
    background: #f8f9fa;
}

.bt-pnl-positive {
    color: #28a745;
    font-weight: 600;
}

.bt-pnl-negative {
    color: #dc3545;
    font-weight: 600;
}

.bt-buy-side {
    color: #007bff;
    font-weight: 600;
}

.bt-sell-side {
    color: #e83e8c;
    font-weight: 600;
}

.btn-bt-export {
    padding: 6px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-bt-export:hover {
    background: #0056b3;
}

/* Backtest tab content wrapper */
#content-backtest {
    padding-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .backtest-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-result {
        flex-direction: column;
        align-items: flex-start;
    }

    .final-cap {
        font-size: 32px;
    }

    .return-pct {
        font-size: 22px;
    }

    .hero-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Backtest View */
.backtest-view {
    animation: fadeIn 0.4s ease-out;
}

.backtest-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.backtest-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-text);
}
