/* Alphiq Dashboard Styles */

:root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-hover: #334155;
    --color-border: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-bullish: #22c55e;
    --color-bearish: #ef4444;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);

    /* Reusable alpha variants */
    --color-primary-10: rgba(59, 130, 246, 0.1);
    --color-primary-15: rgba(59, 130, 246, 0.15);
    --color-success-15: rgba(34, 197, 94, 0.15);
    --color-danger-15: rgba(239, 68, 68, 0.15);
    --color-warning-15: rgba(245, 158, 11, 0.15);

    /* Mobile responsive variables */
    --mobile-bottom-nav-height: 56px;
    --mobile-nav-safe-area: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout */
.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
}

.brand-icon {
    display: block;
    height: 40px;
    width: auto;
    max-height: 40px;
    object-fit: contain;
}

.brand-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--color-text);
}

.main-content {
    flex: 1;
    padding: 2rem;
}

.footer {
    padding: 1rem 2rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--color-border);
}

/* Navigation */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-user {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.nav-link {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.nav-link:hover {
    background: var(--color-surface-hover);
}

.nav-logout {
    color: var(--color-danger);
}

/* Login page styles are in Login.razor.css (Blazor scoped CSS) */

/* Dashboard */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 1.5rem;
}

.status-indicators {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
}

.connection-status.connected .status-dot {
    background: var(--color-success);
    animation: pulse 2s infinite;
}

.connection-status.disconnected .status-dot {
    background: var(--color-danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.refresh-button {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.refresh-button:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.refresh-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.last-refresh {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* Symbol Grid */
.symbol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Symbol Card */
.symbol-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.symbol-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.symbol-card.selected {
    border-color: var(--color-primary);
}

.symbol-card.health-good {
    border-left: 4px solid var(--color-success);
}

.symbol-card.health-warning {
    border-left: 4px solid var(--color-warning);
}

.symbol-card.health-critical {
    border-left: 4px solid var(--color-danger);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.symbol-name {
    font-weight: 600;
    font-size: 1.125rem;
}

.symbol-id {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.stat-label {
    color: var(--color-text-muted);
}

.stat-value {
    font-weight: 500;
}

.gap-count {
    color: var(--color-warning);
}

.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.live-indicator {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.live-indicator.live {
    color: var(--color-success);
    background: rgba(34, 197, 94, 0.1);
}

/* Detail Panel */
.detail-panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2rem;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.detail-header h2 {
    font-size: 1.25rem;
}

.close-button {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.close-button:hover {
    background: var(--color-surface-hover);
}

.detail-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.detail-section {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
}

/* Gap Timeline */
.gap-timeline h3,
.spread-chart h3,
.live-candle-feed h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--color-text-muted);
}

.gap-summary {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.gap-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.gap-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--color-surface);
    border-radius: 4px;
    font-size: 0.75rem;
}

.gap-times {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gap-arrow {
    color: var(--color-text-muted);
}

.gap-duration {
    color: var(--color-warning);
    font-weight: 500;
}

.no-gaps {
    color: var(--color-success);
    font-size: 0.875rem;
}

.more-gaps {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    text-align: center;
    padding-top: 0.5rem;
}

/* Spread Chart */
.spread-summary {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.spread-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.spread-stat .stat-label {
    font-size: 0.75rem;
}

.spread-stat .stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.spread-sources h4 {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.source-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.source-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
}

.source-name {
    width: 80px;
    color: var(--color-text-muted);
}

.source-bar-container {
    flex: 1;
    height: 8px;
    background: var(--color-surface);
    border-radius: 4px;
    overflow: hidden;
}

.source-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.source-bar.source-live {
    background: var(--color-success);
}

.source-bar.source-calc {
    background: var(--color-primary);
}

.source-bar.source-default {
    background: var(--color-warning);
}

.source-count {
    width: 120px;
    text-align: right;
    color: var(--color-text-muted);
}

/* Live Candle Feed */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.feed-header h3 {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin: 0;
}

.feed-header .connection-status {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.feed-header .connection-status.connected {
    background-color: rgba(34, 197, 94, 0.2);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.feed-header .connection-status.disconnected {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}

.candle-table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.candle-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.candle-table th {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-weight: 500;
    text-align: left;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.candle-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.candle-table tr:hover {
    background: var(--color-surface-hover);
}

.candle-table .newest-row {
    background: rgba(59, 130, 246, 0.1);
}

.time-cell {
    white-space: nowrap;
}

.price-cell {
    font-family: 'SF Mono', Monaco, monospace;
    text-align: right;
}

.price-cell.high {
    color: var(--color-bullish);
}

.price-cell.low {
    color: var(--color-bearish);
}

.price-cell.bullish {
    color: var(--color-bullish);
}

.price-cell.bearish {
    color: var(--color-bearish);
}

.volume-cell {
    text-align: right;
    color: var(--color-text-muted);
}

.spread-cell {
    text-align: right;
}

.candle-count {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-align: center;
}

/* Loading & Empty States */
.loading, .no-data {
    padding: 3rem;
    text-align: center;
    color: var(--color-text-muted);
}

.loading-text {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Data Range Display */
.data-range-row .stat-value {
    font-size: 0.7rem;
}

.data-range {
    color: var(--color-text-muted);
}

/* Coverage Indicators */
.coverage-excellent {
    color: var(--color-success);
}

.coverage-good {
    color: #4ade80;
}

.coverage-fair {
    color: var(--color-warning);
}

.coverage-poor {
    color: var(--color-danger);
}

/* Gap List Enhancements */
.gap-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gap-summary-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.gap-item-clickable {
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    border-left: 3px solid transparent;
}

.gap-item-clickable:hover {
    background: var(--color-surface-hover);
    transform: translateX(4px);
}

.gap-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.gap-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
}

.gap-day {
    color: var(--color-text-muted);
    min-width: 60px;
}

/* Gap Type Badges */
.gap-badge {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-suspicious {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}

.badge-low-liquidity {
    background: rgba(245, 158, 11, 0.2);
    color: var(--color-warning);
    border: 1px solid var(--color-warning);
}

.badge-holiday {
    background: rgba(59, 130, 246, 0.2);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.badge-weekend {
    background: rgba(148, 163, 184, 0.2);
    color: var(--color-text-muted);
    border: 1px solid var(--color-text-muted);
}

.badge-verified {
    background: rgba(34, 197, 94, 0.2);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.badge-unknown {
    background: rgba(148, 163, 184, 0.1);
    color: var(--color-text-muted);
}

/* Gap Duration Colors */
.duration-short {
    color: var(--color-text-muted);
}

.duration-medium {
    color: var(--color-warning);
}

.duration-long {
    color: var(--color-danger);
}

.duration-critical {
    color: var(--color-danger);
    font-weight: 600;
    border-left-color: var(--color-danger);
}

/* Gap Timeline Header */
.gap-timeline-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.gap-timeline-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--color-text-muted);
}

.btn-clear-selection {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-clear-selection:hover {
    background: var(--color-surface-hover);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 1rem;
    overflow: hidden;
    overscroll-behavior: contain;
}

.modal-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-container-lg {
    max-width: 720px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: 1.125rem;
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Gap Details in Modal */
.gap-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--color-bg);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.detail-label {
    color: var(--color-text-muted);
}

.detail-value {
    color: var(--color-text);
}

/* Action Section */
.action-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.action-description {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Buttons */
.btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
}

.btn-fetch, .btn-save {
    width: 100%;
    justify-content: center;
}

.btn-retry {
    margin-top: 1rem;
    width: 100%;
    justify-content: center;
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* Result Section */
.result-section {
    margin-top: 1rem;
}

.result-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius);
    font-weight: 500;
}

.result-summary.has-data {
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
}

.result-summary.no-data {
    background: rgba(148, 163, 184, 0.1);
    color: var(--color-text-muted);
}

.result-icon {
    font-size: 1.25rem;
}

/* Candle Preview Table */
.candle-preview {
    margin-top: 1.5rem;
}

.candle-preview h4 {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.preview-table-container {
    max-height: 250px;
    overflow-y: auto;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.preview-table th {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-weight: 500;
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.preview-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.preview-table .time-cell {
    white-space: nowrap;
}

.preview-table .price-cell {
    font-family: 'SF Mono', Monaco, monospace;
    text-align: right;
}

.preview-table .volume-cell {
    text-align: right;
    color: var(--color-text-muted);
}

/* Error Message */
.error-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.error-icon {
    font-size: 1rem;
}

/* Data Coverage Timeline */
.coverage-timeline {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.timeline-header h3 {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin: 0;
}

.timeline-controls {
    display: flex;
    gap: 0.5rem;
}

.zoom-select {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.timeline-legend {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-data {
    background: var(--color-success);
}

.legend-gap {
    background: var(--color-danger);
}

.legend-weekend {
    background: var(--color-text-muted);
}

.timeline-container {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.timeline-svg {
    width: 100%;
    height: 40px;
    display: block;
}

.gap-segment {
    cursor: pointer;
    transition: opacity 0.2s;
}

.gap-segment:hover {
    opacity: 1 !important;
}

.timeline-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.timeline-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

/* Gap Bulk Progress */
.bulk-progress-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.bulk-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.bulk-progress-header h4 {
    margin: 0;
    font-size: 1rem;
}

.bulk-progress-bar {
    height: 8px;
    background: var(--color-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.bulk-progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.bulk-progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.bulk-progress-current {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.bulk-stats-summary {
    display: flex;
    gap: 2rem;
    font-size: 0.875rem;
}

.bulk-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bulk-stat.success {
    color: var(--color-success);
}

.bulk-stat.failed {
    color: var(--color-danger);
}

.bulk-stat.skipped {
    color: var(--color-text-muted);
}

/* Gap Statistics */
.gap-statistics {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
}

.gap-statistics h3 {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin: 0 0 1rem 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.stat-card-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.heatmap-container {
    margin-top: 1rem;
}

.heatmap-container h4 {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    min-width: 10px;
}

.heatmap-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.625rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.no-data-text {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem;
}

/* Statistics Breakdown */
.stats-breakdown {
    margin-top: 1.5rem;
}

.stats-breakdown h4,
.day-breakdown h4 {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.type-breakdown,
.day-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.type-row,
.day-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
}

.type-bar-container,
.day-bar-container {
    flex: 1;
    height: 6px;
    background: var(--color-surface);
    border-radius: 3px;
    overflow: hidden;
}

.type-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.day-bar {
    height: 100%;
    background: var(--color-warning);
    border-radius: 3px;
    transition: width 0.3s;
}

.type-count,
.day-count {
    min-width: 30px;
    text-align: right;
    color: var(--color-text-muted);
}

.day-name {
    min-width: 30px;
    color: var(--color-text-muted);
}

.day-breakdown {
    margin-top: 1.5rem;
}

/* Bulk Progress Additions */
.bulk-start {
    text-align: center;
}

.bulk-description {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.btn-cancel {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
}

.bulk-complete {
    text-align: center;
}

.bulk-complete h4 {
    margin: 0 0 1rem 0;
    color: var(--color-success);
}

.bulk-result-message {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin: 1rem 0;
}

/* ===========================================
   Form Elements - Dark Theme
   =========================================== */

.form-input,
.form-select,
.form-textarea {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Date inputs */
input[type="date"] {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius);
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    font-family: inherit;
}

input[type="date"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Select dropdowns */
select {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius);
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.5rem;
}

select:focus {
    outline: none;
    border-color: var(--color-primary);
}

select option {
    background: var(--color-surface);
    color: var(--color-text);
}

/* Textarea */
textarea {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

textarea::placeholder {
    color: var(--color-text-muted);
}

/* Form labels */
.form-label {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

/* Form rows */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.form-row label {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.form-row select,
.form-row textarea {
    width: 100%;
}

/* ===========================================
   Gap Timeline Controls
   =========================================== */

.gap-timeline-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.date-range-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.date-range-picker label {
    color: var(--color-text-muted);
    white-space: nowrap;
}

.date-range-picker input[type="date"] {
    width: 125px;
}

.status-filter {
    display: flex;
    align-items: center;
}

.status-filter select {
    min-width: 110px;
}

.btn-refresh {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-refresh:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.btn-refresh:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Gap Summary Bar */
.gap-summary-bar {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.gap-summary-bar span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.summary-total {
    color: var(--color-text);
    font-weight: 500;
}

.summary-new {
    color: var(--color-warning);
}

.summary-investigated {
    color: var(--color-primary);
}

.summary-expected {
    color: var(--color-success);
}

.summary-resolved {
    color: var(--color-text-muted);
}

/* ===========================================
   Gap Investigation Modal Enhancements
   =========================================== */

.investigation-section {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1.5rem;
}

.investigation-section h4 {
    font-size: 0.875rem;
    color: var(--color-text);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.investigation-section h5 {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0.75rem 0;
}

.status-form {
    display: flex;
    flex-direction: column;
}

.status-form .form-row:last-of-type {
    margin-bottom: 1rem;
}

/* ===========================================
   Enhanced Form Styles (Backtest/Optimization)
   =========================================== */

/* Form Section Cards */
.form-section {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
}

.form-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.form-section-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
    border-radius: 6px;
    font-size: 1rem;
}

.form-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.form-section-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.125rem;
}

/* Enhanced Select Dropdown */
.select-enhanced {
    position: relative;
}

.select-enhanced select {
    appearance: none;
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-enhanced select:hover {
    border-color: var(--color-primary);
}

.select-enhanced select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.select-enhanced::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--color-text-muted);
    pointer-events: none;
    transition: border-color 0.2s;
}

.select-enhanced:hover::after {
    border-top-color: var(--color-primary);
}

.select-enhanced select option {
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.5rem;
}

/* Enhanced Input Field */
.input-enhanced {
    position: relative;
}

.input-enhanced input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-enhanced input:hover {
    border-color: var(--color-primary);
}

.input-enhanced input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input-enhanced input::placeholder {
    color: var(--color-text-muted);
}

.input-enhanced.has-icon input {
    padding-left: 2.75rem;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

.input-enhanced:focus-within .input-icon {
    color: var(--color-primary);
}

/* Enhanced Form Row */
.form-row-enhanced {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-row-enhanced:last-child {
    margin-bottom: 0;
}

.form-label-enhanced {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
}

.form-label-required {
    color: var(--color-danger);
    font-weight: 400;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* Date Range Picker Enhanced */
.date-range-enhanced {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.date-input-wrapper {
    flex: 1;
    min-width: 140px;
    position: relative;
}

.date-input-wrapper input[type="date"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.date-input-wrapper input[type="date"]:hover {
    border-color: var(--color-primary);
}

.date-input-wrapper input[type="date"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.date-separator {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Symbol Input Chips Style */
.symbol-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    min-height: 48px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.symbol-input-container:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.symbol-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-primary);
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.symbol-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: var(--color-primary);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

.symbol-chip-remove:hover {
    opacity: 1;
}

.symbol-input-field {
    flex: 1;
    min-width: 80px;
    border: none;
    background: transparent;
    color: var(--color-text);
    font-size: 0.875rem;
    outline: none;
    padding: 0.375rem;
}

.symbol-input-field::placeholder {
    color: var(--color-text-muted);
}

/* Advanced Settings Toggle */
.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 1rem;
}

.advanced-toggle:hover {
    background: var(--color-border);
}

.toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    transition: transform 0.2s, color 0.2s;
}

.toggle-icon.expanded {
    transform: rotate(90deg);
    color: var(--color-primary);
}

.toggle-text {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
}

.toggle-badge {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.5rem;
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-primary);
    border-radius: 4px;
}

/* Advanced Settings Panel */
.advanced-panel {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.advanced-panel-section {
    margin-bottom: 1.25rem;
}

.advanced-panel-section:last-child {
    margin-bottom: 0;
}

.advanced-panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.advanced-panel-title-icon {
    color: var(--color-primary);
}

/* Number Input with Slider */
.number-slider-input {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.number-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.number-slider-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    min-width: 48px;
    text-align: center;
}

.slider-track {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.slider-track::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.slider-track::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.slider-track::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* Inline Number Input */
.inline-number {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.inline-number input[type="number"] {
    width: 80px;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.875rem;
    text-align: center;
}

.inline-number input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Two Column Form Layout */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 480px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Strategy Preview Card */
.strategy-preview {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius);
    margin-top: 0.75rem;
}

.strategy-preview-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: white;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 700;
}

.strategy-preview-info {
    flex: 1;
}

.strategy-preview-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.strategy-preview-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.strategy-preview-badge {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.25rem 0.5rem;
    background: var(--color-primary);
    color: white;
    border-radius: 4px;
}

/* Textarea Enhanced */
.textarea-enhanced {
    position: relative;
}

.textarea-enhanced textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.8125rem;
    font-family: 'SF Mono', Monaco, 'Consolas', monospace;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.textarea-enhanced textarea:hover {
    border-color: var(--color-primary);
}

.textarea-enhanced textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.textarea-enhanced textarea::placeholder {
    color: var(--color-text-muted);
    font-family: inherit;
}

.textarea-label-right {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
}

/* Loading State for Strategy Dropdown */
.select-loading {
    position: relative;
}

.select-loading::before {
    content: "";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spin 0.8s linear infinite;
}

.select-loading select {
    padding-left: 2.5rem;
    color: var(--color-text-muted);
}

/* Empty State for No Strategies */
.empty-state-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px dashed rgba(245, 158, 11, 0.4);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.empty-state-inline a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.empty-state-inline a:hover {
    text-decoration: underline;
}

.btn-save-status {
    width: 100%;
    justify-content: center;
}

/* Success message */
.success-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--color-success);
    color: var(--color-success);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Danger Zone */
.danger-zone {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.danger-zone h4 {
    color: var(--color-danger);
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.btn-danger {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
    width: 100%;
    justify-content: center;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
}

.btn-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===========================================
   Gap List With Investigations
   =========================================== */

/* Gap status row styling */
.status-new {
    border-left-color: var(--color-warning);
}

.status-investigated {
    border-left-color: var(--color-primary);
}

.status-expected {
    border-left-color: var(--color-success);
}

.status-resolved {
    border-left-color: var(--color-text-muted);
    opacity: 0.7;
}

/* Investigation status badges */
.badge-new {
    background: rgba(245, 158, 11, 0.2);
    color: var(--color-warning);
    border: 1px solid var(--color-warning);
}

.badge-investigated {
    background: rgba(59, 130, 246, 0.2);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.badge-expected {
    background: rgba(34, 197, 94, 0.2);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.badge-resolved {
    background: rgba(148, 163, 184, 0.2);
    color: var(--color-text-muted);
    border: 1px solid var(--color-text-muted);
}

/* Multiple badges container */
.gap-badges {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* Gap reason display */
.gap-reason {
    font-size: 0.625rem;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===========================================
   Symbol Detail Modal
   =========================================== */

.symbol-detail-modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    max-width: 1800px;
    width: 98%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.symbol-detail-modal .modal-header {
    padding: 1.25rem 1.5rem;
}

.symbol-detail-modal .modal-header h2 {
    font-size: 1.25rem;
}

.symbol-detail-modal .modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.detail-grid .detail-section {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 350px;
    display: flex;
    flex-direction: column;
}

.detail-grid .detail-section-wide {
    grid-column: span 1;
}

/* Responsive */
@media (max-width: 1200px) {
    .detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail-grid .detail-section-wide {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .symbol-grid {
        grid-template-columns: 1fr;
    }

    .detail-content {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid .detail-section-wide {
        grid-column: span 1;
    }

    .symbol-detail-modal {
        width: 100%;
        max-height: 95vh;
    }

    .spread-summary {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ====== Backtest Detail Modal ====== */

.backtest-detail-modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    max-width: 1400px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.backtest-detail-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    gap: 1rem;
}

.backtest-detail-modal .modal-header-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.backtest-detail-modal .modal-header-content h2 {
    font-size: 1.25rem;
    margin: 0;
}

.backtest-detail-modal .modal-header-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.backtest-detail-modal .modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.backtest-detail-modal .modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.backtest-detail-modal .trading-card {
    margin-bottom: 1.5rem;
}

.backtest-detail-modal .trading-grid {
    margin-top: 1.5rem;
}

@media (max-width: 1200px) {
    .backtest-detail-modal {
        width: 100%;
        max-width: 100%;
    }

    .backtest-detail-modal .trading-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .backtest-detail-modal .modal-header {
        flex-direction: column;
        align-items: stretch;
    }

    .backtest-detail-modal .modal-header-actions {
        justify-content: flex-end;
    }
}

/* ====== Live Trading Dashboard ====== */

.trading-page {
    max-width: 1400px;
    margin: 0 auto;
}

.trading-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.trading-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.trading-card + .trading-card,
.trading-card + .audit-summary-grid,
.audit-summary-grid + .trading-card {
    margin-top: 1.5rem;
}

.trading-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--color-text-muted);
}

.engine-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.running {
    background: var(--color-success);
}

.dot.stopped {
    background: var(--color-danger);
}

.dot.unknown {
    background: var(--color-warning);
}

.badge-buy {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.badge-sell {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

.badge-version {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-primary);
}

.badge-timeframe {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
}

.badge-running {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-primary);
}

.badge-loading {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
    animation: pulse 1.5s ease-in-out infinite;
}

/* Loading phase for backtest progress */
.loading-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-hint {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
}

.balance-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
}

.balance-currency {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
}

.no-data-message {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
    font-size: 0.875rem;
}

.auto-refresh-indicator {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.strategy-card {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--color-border);
}

/* Trading tables */
.trading-card .table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.trade-list-container {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.trading-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.trading-card th {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-weight: 500;
    text-align: left;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.trading-card td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.trading-card tr:hover {
    background: var(--color-surface-hover);
}

/* Trading stats grid inside card */
.trading-card .stats-grid {
    margin-bottom: 0;
}

.trading-card .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

@media (max-width: 768px) {
    .trading-grid {
        grid-template-columns: 1fr;
    }

    .strategy-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Backtest Results Styles ===== */

/* Backtest Sort Controls */
.backtest-sort-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.sort-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.backtest-sort-controls .select-enhanced {
    min-width: 160px;
}

.backtest-sort-controls .select-enhanced select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.sort-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
}

.backtest-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.backtest-summary-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.backtest-summary-card:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-primary);
}

.backtest-summary-card.selected {
    border-color: var(--color-primary);
    border-width: 2px;
}

.backtest-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.backtest-strategy {
    font-weight: 600;
    font-size: 1rem;
}

.backtest-summary-metrics {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.backtest-summary-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.backtest-detail {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.backtest-detail-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.backtest-detail-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.backtest-detail-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.btn-save-strategy {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
    border: 1px solid var(--color-success);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save-strategy:hover {
    background: rgba(34, 197, 94, 0.2);
}

.btn-save-strategy.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
}

.equity-chart svg {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.filter-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.filter-controls select {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    outline: none;
    cursor: pointer;
}

.filter-controls select:focus {
    border-color: var(--color-primary);
}

.export-btn {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    padding: 0.375rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.2s;
    margin-left: auto;
}

.export-btn:hover {
    background: var(--color-primary-hover);
}

.monthly-breakdown {
    width: 100%;
}

.pnl-positive {
    color: var(--color-success, #22c55e);
}

.pnl-negative {
    color: var(--color-danger, #ef4444);
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--color-primary);
}

@media (max-width: 768px) {
    .backtest-summary-metrics {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .backtest-detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ===== Strategy Configuration ===== */

.strategy-row {
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.strategy-row:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-primary);
}

/* Toggle switch */
.strategy-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    margin-left: auto;
    cursor: pointer;
}

.strategy-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-border);
    border-radius: 20px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--color-text);
    border-radius: 50%;
    transition: transform 0.2s;
}

.strategy-toggle input:checked + .toggle-slider {
    background: var(--color-success);
}

.strategy-toggle input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* Toggle Switch (Generic) - see consolidated definition in Strategy Allocations section */

/* ========================================
   Risk Optimization UI
   ======================================== */

.risk-optimization-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.75rem;
}

.risk-category {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
}

.risk-category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--color-text);
}

.risk-category-icon {
    font-size: 1rem;
}

.risk-param-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.risk-param-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.risk-param-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 160px;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.risk-param-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

.risk-param-checkbox input:checked + span {
    color: var(--color-text);
}

.risk-param-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.risk-param-range input[type="number"] {
    width: 70px;
    padding: 0.375rem 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.8125rem;
    text-align: center;
}

.risk-param-range input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

.risk-param-range span {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
}

.risk-param-step {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    opacity: 0.7;
}

/* ========================================
   Progress Components (PRP-019)
   ======================================== */

/* Progress Bar */
.progress-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.progress-bar-container {
    flex: 1;
    height: 8px;
    background: var(--color-surface-hover);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
    min-width: 50px;
    text-align: right;
}

/* Progress Stats Grid */
.progress-stats {
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
}

.progress-stats .stat-item {
    min-width: 0; /* Allow flex shrink */
}

.progress-stats .stat-item .metric-value {
    white-space: nowrap;
    font-size: 1.25rem; /* Slightly smaller to fit */
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1200px) {
    .progress-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .progress-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Backtest Progress Panel */
.backtest-progress-panel {
    border-left: 3px solid var(--color-primary);
}

.backtest-progress-panel h3 {
    margin-bottom: 1rem;
}

/* Mini Equity Curve */
.mini-equity-curve {
    margin-top: 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.mini-equity-curve svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Recent Trades Section */
.recent-trades-section {
    margin-top: 1.5rem;
}

.recent-trades-section h4 {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.trade-feed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.trade-feed-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface);
    border-radius: 4px;
    font-size: 0.75rem;
    border-left: 3px solid transparent;
}

.trade-feed-item.trade-win {
    border-left-color: var(--color-success);
}

.trade-feed-item.trade-loss {
    border-left-color: var(--color-danger);
}

.trade-symbol {
    font-weight: 600;
    min-width: 60px;
}

.trade-side {
    font-weight: 500;
    min-width: 35px;
}

.trade-side.side-buy {
    color: var(--color-bullish);
}

.trade-side.side-sell {
    color: var(--color-bearish);
}

.trade-pnl {
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

.trade-reason {
    color: var(--color-text-muted);
    font-size: 0.7rem;
}

/* Fitness Convergence Chart */
.fitness-convergence-chart {
    margin-top: 1rem;
}

.fitness-convergence-chart h3 {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.fitness-convergence-chart svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Optimization Progress Panel */
.optimization-progress-panel {
    border-left: 3px solid var(--color-primary);
}

/* Active Backtests */
.active-backtests {
    margin-top: 1.25rem;
}

.active-backtests h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Table layout */
.active-backtest-table {
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.active-backtest-table-header {
    display: grid;
    grid-template-columns: 160px 120px 70px 60px 70px 65px 75px 80px;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    color: var(--color-text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}

.active-backtest-row {
    display: grid;
    grid-template-columns: 160px 120px 70px 60px 70px 65px 75px 80px;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4375rem 0.625rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    transition: background 0.15s ease;
}

.active-backtest-row:hover {
    background: rgba(51, 65, 85, 0.25);
}

.active-backtest-row:last-child {
    border-bottom: none;
}

.abt-col {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.abt-col-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.active-backtest-progress {
    flex: 0 0 300px;
    height: 5px;
    background: var(--color-surface-hover);
    border-radius: 3px;
    overflow: hidden;
}

.active-backtest-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.active-backtest-pct {
    font-weight: 600;
    font-size: 0.75rem;
    min-width: 28px;
    text-align: right;
    color: var(--color-text);
}

.abt-col-bars {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.abt-col-date {
    color: var(--color-text-muted);
}

.abt-col-trades {
    text-align: right;
    color: var(--color-text);
}

.abt-col-wr {
    text-align: right;
}

.abt-col-pf {
    text-align: right;
}

.abt-col-dd {
    text-align: right;
    color: var(--color-text-muted);
}

.abt-col-pnl {
    text-align: right;
    font-weight: 600;
}

.abt-col-pnl.positive {
    color: var(--color-success, #22c55e);
}

.abt-col-pnl.negative {
    color: var(--color-danger, #ef4444);
}

@media (max-width: 900px) {
    .active-backtest-table-header,
    .active-backtest-row {
        grid-template-columns: minmax(100px, 1fr) 90px 60px 50px 60px 70px;
    }
    .abt-col-dd,
    .abt-col-pf {
        display: none;
    }
}

/* Metric Highlight */
.metric-highlight {
    color: var(--color-primary);
    font-weight: 700;
}

/* Badge for Running state */
.badge-running {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-primary);
}

/* Error Text */
.error-text {
    color: var(--color-danger);
}

/* ===========================================
   Spread Statistics Panel
   =========================================== */
.spread-statistics {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.spread-statistics .loading-state,
.spread-statistics .error-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem;
    color: var(--color-text-muted);
}

.spread-statistics .error-state {
    color: var(--color-danger);
}

.spread-statistics .error-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-danger);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.spread-statistics .retry-btn {
    margin-left: 1rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.spread-statistics .retry-btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-primary);
}

.spread-statistics .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Stats sections */
.spread-statistics .stats-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.spread-statistics .stats-section h3 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Overview grid */
.spread-statistics .overview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.spread-statistics .stat-card {
    background: var(--color-bg);
    padding: 0.875rem;
    border-radius: calc(var(--radius) - 2px);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.spread-statistics .stat-card:hover {
    border-color: var(--color-border);
}

.spread-statistics .stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.spread-statistics .stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

/* Quality section */
.spread-statistics .quality-grade {
    padding: 0.25rem 0.625rem;
    border-radius: calc(var(--radius) - 4px);
    font-size: 0.75rem;
    font-weight: 700;
}

.spread-statistics .grade-a { background: var(--color-success); color: white; }
.spread-statistics .grade-b { background: #34d399; color: white; }
.spread-statistics .grade-c { background: var(--color-warning); color: white; }
.spread-statistics .grade-d { background: #f97316; color: white; }
.spread-statistics .grade-f { background: var(--color-danger); color: white; }

.spread-statistics .quality-bar {
    display: flex;
    height: 24px;
    border-radius: calc(var(--radius) - 4px);
    overflow: hidden;
    background: var(--color-bg);
}

.spread-statistics .quality-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    min-width: 0;
    transition: filter 0.15s ease;
}

.spread-statistics .quality-segment:hover {
    filter: brightness(1.1);
}

.spread-statistics .quality-segment.live { background: var(--color-success); }
.spread-statistics .quality-segment.calc { background: var(--color-primary); }
.spread-statistics .quality-segment.def { background: var(--color-text-muted); }

.spread-statistics .quality-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.spread-statistics .legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.spread-statistics .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.spread-statistics .dot.live { background: var(--color-success); }
.spread-statistics .dot.calc { background: var(--color-primary); }
.spread-statistics .dot.def { background: var(--color-text-muted); }

/* Heatmap */
.spread-statistics .heatmap-container {
    overflow-x: auto;
}

.spread-statistics .heatmap-hours,
.spread-statistics .heatmap-row {
    display: grid;
    grid-template-columns: 40px repeat(24, 1fr);
    gap: 2px;
    min-width: 550px;
}

.spread-statistics .heatmap-hours {
    margin-bottom: 4px;
}

.spread-statistics .hour-label {
    font-size: 0.6rem;
    color: var(--color-text-muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.spread-statistics .day-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
}

.spread-statistics .heatmap-cell {
    aspect-ratio: 1;
    min-height: 14px;
    border-radius: 2px;
    cursor: help;
    transition: transform 0.1s ease;
    will-change: transform;
}

.spread-statistics .heatmap-cell:hover {
    transform: scale(1.2);
    z-index: 1;
    position: relative;
}

.spread-statistics .heatmap-cell.intensity-0 { background: var(--color-surface); }
.spread-statistics .heatmap-cell.intensity-1 { background: var(--color-success); }
.spread-statistics .heatmap-cell.intensity-2 { background: #fbbf24; }
.spread-statistics .heatmap-cell.intensity-3 { background: #f97316; }
.spread-statistics .heatmap-cell.intensity-4 { background: var(--color-danger); }

.spread-statistics .heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.spread-statistics .legend-gradient {
    display: flex;
    gap: 2px;
}

.spread-statistics .legend-gradient span {
    width: 20px;
    height: 12px;
    border-radius: 2px;
}

.spread-statistics .legend-gradient .intensity-1 { background: var(--color-success); }
.spread-statistics .legend-gradient .intensity-2 { background: #fbbf24; }
.spread-statistics .legend-gradient .intensity-3 { background: #f97316; }
.spread-statistics .legend-gradient .intensity-4 { background: var(--color-danger); }

/* Sessions table */
.spread-statistics .sessions-table {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.spread-statistics .sessions-header,
.spread-statistics .sessions-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1.5fr;
    gap: 0.5rem;
    padding: 0.625rem;
    align-items: center;
    font-size: 0.8rem;
}

.spread-statistics .sessions-header {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}

.spread-statistics .sessions-row {
    background: var(--color-bg);
    border-radius: calc(var(--radius) - 2px);
    transition: background 0.15s ease;
}

.spread-statistics .sessions-row:hover {
    background: var(--color-surface-hover);
}

.spread-statistics .session-name {
    font-weight: 600;
    color: var(--color-text);
}

.spread-statistics .session-hours,
.spread-statistics .session-avg,
.spread-statistics .session-median,
.spread-statistics .session-best {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.spread-statistics .session-avg {
    color: var(--color-text);
    font-weight: 500;
}

/* Trading windows */
.spread-statistics .windows-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.spread-statistics .windows-column h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.spread-statistics .windows-column.best h4 { color: var(--color-success); }
.spread-statistics .windows-column.avoid h4 { color: var(--color-danger); }

.spread-statistics .window-card {
    background: var(--color-bg);
    padding: 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: background 0.15s ease;
}

.spread-statistics .window-card:hover {
    background: var(--color-surface-hover);
}

.spread-statistics .windows-column.best .window-card {
    border-left: 3px solid var(--color-success);
}

.spread-statistics .windows-column.avoid .window-card {
    border-left: 3px solid var(--color-danger);
}

.spread-statistics .window-time {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text);
}

.spread-statistics .window-spread {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.spread-statistics .window-reason {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    opacity: 0.75;
    font-style: italic;
}

.spread-statistics .no-data {
    color: var(--color-text-muted);
    font-style: italic;
    margin: 0;
    padding: 1rem 0;
}

/* ============================================================================
   Account Selector
   ============================================================================ */

.account-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.account-selector .no-accounts {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

.account-selector .single-account {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.account-selector .account-name {
    font-weight: 500;
    color: var(--color-text);
}

.account-selector .account-type {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.account-selector .account-type.live {
    background: var(--color-success);
    color: white;
}

.account-selector .account-type.demo {
    background: var(--color-warning);
    color: black;
}

.account-selector .account-type.unknown {
    background: var(--color-text-muted);
    color: white;
}

.account-selector .account-dropdown {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-width: 200px;
    cursor: pointer;
}

.account-selector .account-dropdown:focus {
    outline: none;
    border-color: var(--color-primary);
}

.account-selector .sync-btn {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.account-selector .sync-btn:hover:not(:disabled) {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.account-selector .sync-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.account-selector .syncing {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Balance extras */
.trading-card .balance-equity {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.trading-card .balance-sync-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* Account Strategies Component */
.trading-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.trading-card .card-header h3 {
    margin: 0;
}

.allocation-summary-bar {
    display: flex;
    gap: 2rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.allocation-summary-bar .summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.allocation-summary-bar .summary-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.allocation-summary-bar .summary-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.allocation-summary-bar .summary-value.success {
    color: var(--color-success);
}

/* Strategy cards in allocation view */
.strategy-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color 0.2s, opacity 0.2s;
}

.strategy-card:hover {
    border-color: var(--color-primary);
}

.strategy-card.disabled {
    opacity: 0.6;
}

.strategy-card.available {
    border-style: dashed;
    border-color: var(--color-text-muted);
}

.strategy-card.available:hover {
    border-color: var(--color-success);
}

.strategy-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.strategy-card-header .strategy-info {
    flex: 1;
}

.strategy-card-header .strategy-info strong {
    display: block;
    margin-bottom: 0.5rem;
}

.strategy-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.available-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding: 0.25rem 0.5rem;
    border: 1px dashed var(--color-text-muted);
    border-radius: var(--radius);
}

.strategy-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.allocation-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.allocation-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.allocation-input-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.allocation-input {
    width: 60px;
    padding: 0.375rem 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.875rem;
    text-align: right;
}

.allocation-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.allocation-unit {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.effective-balance {
    font-size: 0.875rem;
    color: var(--color-success);
    font-weight: 500;
}

.strategy-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.strategy-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-icon:hover:not(:disabled) {
    transform: scale(1.05);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
}

.btn-icon.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon.btn-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
}

.btn-icon.btn-success:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.2);
}

/* Toggle switch - consolidated definition */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-switch .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-surface-hover);
    border-radius: 24px;
    transition: background 0.2s;
}

.toggle-switch .toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border-radius: 50%;
    transition: transform 0.2s, left 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--color-success);
}

.toggle-switch input:checked + .toggle-slider::before {
    left: 23px;
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Restart notice */
.restart-notice {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--color-warning);
}

.btn-restart-tradenode {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding: 0.35rem 0.75rem;
    background: var(--color-warning);
    color: #0f172a;
    border: none;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.btn-restart-tradenode:hover:not(:disabled) {
    opacity: 0.85;
}

.btn-restart-tradenode:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================
   Symbol Details Dialog (Redesigned)
   =========================================== */

.sd-dialog {
    background: var(--color-surface);
    border-radius: var(--radius);
    max-width: 1800px;
    width: 98%;
    max-height: 98vh;
    height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

/* Header */
.sd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.sd-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sd-header-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.sd-health-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.875rem;
}

.sd-health-badge.grade-a { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.sd-health-badge.grade-b { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.sd-health-badge.grade-c { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.sd-health-badge.grade-d { background: rgba(249, 115, 22, 0.2); color: #f97316; }
.sd-health-badge.grade-f { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.sd-live-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

/* Chart Toolbar */
.sd-chart-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    font-size: 0.8rem;
}

.sd-range-buttons {
    display: flex;
    gap: 2px;
    background: var(--color-surface);
    border-radius: 4px;
    padding: 2px;
}

.sd-range-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    padding: 0.3rem 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}

.sd-range-btn:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.sd-range-btn-active {
    background: var(--color-primary);
    color: #fff;
}

.sd-range-btn-active:hover {
    background: var(--color-primary-hover);
    color: #fff;
}

.sd-overlay-toggles {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
}

.sd-overlay-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}

.sd-overlay-toggle input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 14px;
    height: 14px;
}

.sd-timeframe-label {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-style: italic;
}

/* Chart Area */
.sd-chart-area {
    flex: 0 0 auto;
    height: 50vh;
    min-height: 250px;
    max-height: 500px;
    background: #1e293b;
    border-bottom: 1px solid var(--color-border);
}

.sd-chart-container {
    width: 100%;
    height: 100%;
}

.sd-chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-muted);
    gap: 0.5rem;
    font-size: 0.875rem;
}

/* Quick Insight Strip */
.sd-insight-strip {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
}

.insight-card {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.75rem;
    background: var(--color-bg);
    border-radius: 6px;
    min-width: 110px;
    flex: 1;
}

.insight-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    font-weight: 600;
}

.insight-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
}

.insight-detail {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.grade-card-a .insight-value { color: #22c55e; }
.grade-card-b .insight-value { color: #3b82f6; }
.grade-card-c .insight-value { color: #f59e0b; }
.grade-card-d .insight-value { color: #f97316; }
.grade-card-f .insight-value { color: #ef4444; }

/* Tab Bar */
.sd-tab-bar {
    display: flex;
    gap: 0;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.sd-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sd-tab:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.sd-tab-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.sd-tab-badge {
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--color-danger);
    color: #fff;
    padding: 0.1rem 0.35rem;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
    line-height: 1.3;
}

/* Tab Content */
.sd-tab-content {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.sd-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Overview Tab */
.sd-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.sd-overview-card {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 1rem;
}

.sd-overview-card h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--color-text);
}

.sd-full-width {
    grid-column: 1 / -1;
}

.sd-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.sd-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sd-stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sd-stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

/* Session Table */
.sd-session-table {
    font-size: 0.8rem;
}

.sd-session-header {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1.5fr;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sd-session-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1.5fr;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
    color: var(--color-text);
}

.sd-session-name {
    font-weight: 500;
}

/* Trading Windows */
.sd-windows-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.sd-windows-heading {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: block;
}

.sd-windows-heading.best { color: var(--color-success); }
.sd-windows-heading.avoid { color: var(--color-danger); }

.sd-window-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding: 0.3rem 0;
    color: var(--color-text);
}

.sd-window-spread {
    color: var(--color-text-muted);
    font-weight: 500;
}

.sd-no-data {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Quality Tab */
.sd-quality-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sd-trust-assessment {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sd-trust-grade {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sd-trust-text {
    font-size: 0.9rem;
    color: var(--color-text);
}

.sd-trust-factors {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sd-trust-item {
    font-size: 0.8rem;
    padding: 0.3rem 0;
}

.sd-trust-item.good::before { content: "\\2713 "; color: #22c55e; }
.sd-trust-item.warn::before { content: "\\26A0 "; color: #f59e0b; }
.sd-trust-item.bad::before { content: "\\2717 "; color: #ef4444; }

/* Investigation Panel (inline) */
.sd-investigation-panel {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 0.5rem;
}

.sd-investigation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.sd-investigation-header h4 {
    font-size: 0.9rem;
    margin: 0;
}

.btn-close-sm {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    line-height: 1;
}

.btn-close-sm:hover {
    color: var(--color-text);
}

.gap-details.compact {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.gap-details.compact .detail-row {
    font-size: 0.8rem;
    padding: 0.15rem 0;
}

.sd-investigation-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.sd-investigation-status {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-row.compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.form-row.compact label {
    min-width: 50px;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.form-row.compact select,
.form-row.compact textarea {
    flex: 1;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

.sd-investigation-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 900px) {
    .sd-dialog {
        width: 100%;
        max-height: 98vh;
    }

    .sd-overview-grid {
        grid-template-columns: 1fr;
    }

    .sd-chart-area {
        height: 250px;
    }

    .sd-insight-strip {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .sd-session-header,
    .sd-session-row {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .sd-session-header span:nth-child(n+4),
    .sd-session-row span:nth-child(n+4) {
        display: none;
    }
}

/* ============================================================
   MOBILE RESPONSIVE FOUNDATION (Phase 1 + Phase 2)
   ============================================================ */

/* --- Responsive utility classes --- */

.mobile-only {
    display: none !important;
}

.desktop-only {
    display: initial;
}

/* --- Mobile Bottom Navigation --- */

.mobile-bottom-nav {
    display: none;
}

.mobile-sheet-backdrop {
    display: none;
}

.mobile-sheet {
    display: none;
}

/* ============================================================
   TABLET BREAKPOINT (max-width: 768px)
   ============================================================ */

@media (max-width: 768px) {

    /* --- Utility class overrides --- */

    .mobile-only {
        display: initial !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* --- Layout foundation --- */

    html {
        /* Safe area handling for notched phones */
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    .layout {
        /* Make room for bottom nav */
        padding-bottom: calc(var(--mobile-bottom-nav-height) + var(--mobile-nav-safe-area));
    }

    .main-content {
        padding: 0.75rem;
    }

    /* --- Hide desktop nav, show mobile header --- */

    .header {
        flex-direction: row;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .nav-menu {
        display: none;
    }

    .brand-logo {
        font-size: 1.125rem;
    }

    .brand-icon {
        height: 32px;
    }

    /* --- Footer hidden on mobile --- */

    .footer {
        display: none;
    }

    /* --- Mobile Bottom Tab Bar --- */

    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--mobile-bottom-nav-height) + var(--mobile-nav-safe-area));
        padding-bottom: var(--mobile-nav-safe-area);
        background: var(--color-surface);
        border-top: 1px solid var(--color-border);
        z-index: 1000;
        align-items: stretch;
        justify-content: space-around;
    }

    .mobile-nav-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        gap: 0.2rem;
        padding: 0.4rem 0;
        color: var(--color-text-muted);
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        font-family: inherit;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        min-height: 44px;
        transition: color 0.15s;
    }

    .mobile-nav-tab:active {
        background: var(--color-surface-hover);
    }

    .mobile-nav-tab.active {
        color: var(--color-primary);
    }

    .mobile-nav-icon {
        font-size: 1.25rem;
        line-height: 1;
    }

    .mobile-nav-label {
        font-size: 0.625rem;
        font-weight: 500;
        letter-spacing: 0.01em;
        line-height: 1;
    }

    /* --- Mobile "More" Sheet --- */

    .mobile-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1100;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--color-surface);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        z-index: 1200;
        padding-bottom: var(--mobile-nav-safe-area);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        animation: mobile-sheet-slide-up 0.25s ease-out;
    }

    @keyframes mobile-sheet-slide-up {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .mobile-sheet-handle {
        display: flex;
        justify-content: center;
        padding: 0.75rem 0 0.5rem;
    }

    .mobile-sheet-handle-bar {
        width: 40px;
        height: 4px;
        background: var(--color-border);
        border-radius: 2px;
    }

    .mobile-sheet-nav {
        display: flex;
        flex-direction: column;
        padding: 0 0.5rem 0.75rem;
    }

    .mobile-sheet-item {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0.875rem 1rem;
        color: var(--color-text);
        text-decoration: none;
        border-radius: var(--radius);
        font-size: 0.9375rem;
        min-height: 48px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        transition: background 0.15s;
    }

    .mobile-sheet-item:active {
        background: var(--color-surface-hover);
    }

    .mobile-sheet-item-icon {
        font-size: 1.25rem;
        width: 28px;
        text-align: center;
    }

    .mobile-sheet-item-danger {
        color: var(--color-danger);
    }

    .mobile-sheet-divider {
        height: 1px;
        background: var(--color-border);
        margin: 0.5rem 1rem;
    }

    .mobile-sheet-account {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .mobile-sheet-account-label {
        color: var(--color-text-muted);
    }

    .mobile-sheet-account-id {
        color: var(--color-text);
        font-weight: 500;
        font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
        font-size: 0.8125rem;
    }
}

/* ============================================================
   SMALL MOBILE BREAKPOINT (max-width: 480px)
   ============================================================ */

@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
    }

    .header {
        padding: 0.5rem 0.75rem;
    }

    .symbol-grid {
        gap: 0.5rem;
    }

    .dashboard-header h1 {
        font-size: 1.125rem;
    }
}

/* ============================================================
   GLOBAL TOUCH / MOBILE UX IMPROVEMENTS
   ============================================================ */

@media (pointer: coarse) {
    /* Increase tap targets for touch devices */
    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    /* Prevent double-tap zoom on interactive elements */
    button, a, input, select, textarea {
        touch-action: manipulation;
    }

    /* Remove tap highlight for clean feedback */
    a, button {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ============================================================
   PHASE 3: MODAL → BOTTOM SHEET ON MOBILE
   ============================================================ */

@media (max-width: 768px) {

    /* --- All modal overlays: align to bottom for sheet effect --- */

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    /* --- Standard modals → bottom sheets --- */

    .modal-container,
    .modal-container-lg {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        animation: modal-sheet-up 0.25s ease-out;
    }

    .modal-header {
        padding: 1rem;
        /* Add drag-handle visual hint */
        position: relative;
    }

    .modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--color-border);
        border-radius: 2px;
    }

    .modal-header h2 {
        font-size: 1rem;
        padding-top: 0.5rem;
    }

    .modal-close {
        font-size: 1.75rem;
        padding: 0.5rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        padding-bottom: calc(0.75rem + var(--mobile-bottom-nav-height) + var(--mobile-nav-safe-area));
    }

    .modal-footer .btn-primary,
    .modal-footer .btn-secondary {
        min-height: 44px;
        flex: 1;
    }

    /* --- Backtest detail modal → bottom sheet --- */

    .backtest-detail-modal {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        animation: modal-sheet-up 0.25s ease-out;
    }

    .backtest-detail-modal .modal-header {
        padding: 1rem;
    }

    .backtest-detail-modal .modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--color-border);
        border-radius: 2px;
    }

    .backtest-detail-modal .modal-header-content h2 {
        font-size: 1rem;
        padding-top: 0.25rem;
    }

    .backtest-detail-modal .modal-body {
        padding: 0.75rem;
    }

    /* --- Form input mobile fixes (prevent iOS zoom) --- */

    .form-input,
    .form-select,
    .form-textarea,
    .input-enhanced input,
    .textarea-enhanced textarea,
    .select-enhanced select,
    .date-input-wrapper input,
    .status-form select,
    .status-form textarea,
    .status-form input {
        font-size: 16px;
        min-height: 44px;
    }

    .date-range-enhanced {
        flex-direction: column;
        gap: 0.5rem;
    }

    .date-separator {
        text-align: center;
    }

    /* --- Slider inputs: bigger touch target --- */

    .slider-track {
        height: 6px;
    }

    input[type="range"] {
        min-height: 44px;
    }

    /* --- Form grid: single column on mobile --- */

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    /* --- Risk optimization grid: single column --- */

    .risk-optimization-grid {
        grid-template-columns: 1fr;
    }

    .risk-param-range {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .risk-param-range input[type="number"] {
        font-size: 16px;
        min-height: 44px;
        width: 80px;
    }

    @keyframes modal-sheet-up {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

/* ============================================================
   PHASE 4: SYMBOL DETAILS DIALOG — MOBILE FULL-SCREEN
   ============================================================ */

@media (max-width: 768px) {

    /* --- Full-screen takeover --- */

    .sd-dialog {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    /* Overlay: no padding, sheet from bottom */
    .sd-dialog .modal-overlay,
    div.modal-overlay:has(> .sd-dialog) {
        padding: 0;
        align-items: stretch;
    }

    /* --- Header: compact, 44px close button --- */

    .sd-header {
        padding: 0.5rem 0.75rem;
        min-height: 48px;
    }

    .sd-header-title {
        font-size: 0.95rem;
    }

    .sd-header .modal-close {
        font-size: 1.75rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sd-health-badge {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }

    .sd-live-badge {
        font-size: 0.6rem;
        padding: 0.1rem 0.35rem;
    }

    /* --- Chart: full width, constrained height --- */

    .sd-chart-area {
        min-height: 220px;
        height: 35vh;
        max-height: 280px;
        flex: 0 0 auto;
    }

    /* --- Chart Toolbar: compact, scrollable --- */

    .sd-chart-toolbar {
        padding: 0.4rem 0.75rem;
        gap: 0.5rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sd-chart-toolbar::-webkit-scrollbar {
        display: none;
    }

    .sd-range-buttons {
        flex-shrink: 0;
    }

    .sd-range-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
        min-height: 36px;
        min-width: 36px;
    }

    .sd-overlay-toggles {
        flex-shrink: 0;
        gap: 0.5rem;
    }

    .sd-overlay-toggle {
        font-size: 0.7rem;
        white-space: nowrap;
    }

    .sd-timeframe-label {
        display: none;
    }

    /* --- Insight Strip: scrollable horizontal pills --- */

    .sd-insight-strip {
        padding: 0.4rem 0.75rem;
        gap: 0.4rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sd-insight-strip::-webkit-scrollbar {
        display: none;
    }

    .sd-insight-strip .insight-card {
        flex-shrink: 0;
        min-width: 90px;
    }

    .insight-card {
        padding: 0.3rem 0.6rem;
    }

    .insight-value {
        font-size: 0.875rem;
    }

    /* --- Tab Bar: scrollable, sticky below chart area --- */

    .sd-tab-bar {
        padding: 0 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--color-surface);
    }

    .sd-tab-bar::-webkit-scrollbar {
        display: none;
    }

    .sd-tab {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
        white-space: nowrap;
        min-height: 44px;
    }

    .sd-tab-badge {
        font-size: 0.6rem;
    }

    /* --- Tab Content: scrollable, fills remaining space --- */

    .sd-tab-content {
        padding: 0.75rem;
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Overview: single column --- */

    .sd-overview-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .sd-overview-card {
        padding: 0.75rem;
    }

    .sd-overview-card h4 {
        font-size: 0.8rem;
    }

    .sd-stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }

    .sd-stat-label {
        font-size: 0.65rem;
    }

    .sd-stat-value {
        font-size: 0.825rem;
    }

    /* --- Session table: compact --- */

    .sd-session-header,
    .sd-session-row {
        grid-template-columns: 1fr 1fr 1fr;
        font-size: 0.75rem;
    }

    .sd-session-header span:nth-child(n+4),
    .sd-session-row span:nth-child(n+4) {
        display: none;
    }

    /* --- Trading windows: single column --- */

    .sd-windows-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* --- Investigation panel: compact --- */

    .sd-investigation-panel {
        padding: 0.75rem;
    }

    .sd-investigation-actions {
        flex-direction: column;
    }

    .sd-investigation-actions button {
        width: 100%;
        min-height: 44px;
    }

    /* --- Quality content --- */

    .sd-quality-content {
        gap: 0.75rem;
    }

    .sd-trust-grade {
        flex-wrap: wrap;
    }
}

/* ============================================================
   PHASE 5: DASHBOARD & CARDS — MOBILE OPTIMIZATION
   ============================================================ */

@media (max-width: 768px) {

    /* --- Dashboard header: compact --- */

    .dashboard-header {
        margin-bottom: 1rem;
    }

    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .status-indicators {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .refresh-button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 0.75rem;
    }

    .last-refresh {
        display: none;
    }

    /* --- Symbol grid: 2 columns on tablet, handled below for phone --- */

    .symbol-grid {
        gap: 0.75rem;
    }

    /* --- Symbol cards: compact, touch-friendly --- */

    .symbol-card {
        padding: 0.875rem;
        transition: none; /* Remove hover transform on mobile */
    }

    .symbol-card:hover {
        transform: none;
    }

    .symbol-card:active {
        background: var(--color-surface-hover);
    }

    .card-header {
        margin-bottom: 0.5rem;
    }

    .symbol-name {
        font-size: 1rem;
    }

    .stat-row {
        font-size: 0.8125rem;
    }

    .data-range-row .stat-value.data-range {
        font-size: 0.75rem;
    }

    .card-footer {
        margin-top: 0.625rem;
        padding-top: 0.625rem;
    }

    .live-indicator {
        font-size: 0.6875rem;
    }

    /* Login page mobile overrides are in Login.razor.css */
}

/* Phone-specific: single column cards */
@media (max-width: 480px) {

    .symbol-grid {
        grid-template-columns: 1fr;
    }

    .symbol-card {
        padding: 0.75rem;
    }

    .card-body .stat-row.data-range-row {
        flex-direction: column;
        gap: 0.15rem;
    }
}

/* Tablet: 2 columns */
@media (min-width: 481px) and (max-width: 768px) {
    .symbol-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
