/* Alpha Command Center — design tokens (dark navy, glass surfaces, amber accent). */
:root {
    --primary-color: var(--mg-blue);
    --primary-dark: var(--mg-blue-dim);
    --accent-color: var(--mg-gold);
    --success-color: var(--mg-green-base);
    --danger-color: var(--mg-red-base);
    --warning-color: var(--mg-gold);

    --bg-primary: var(--mg-bg);
    --bg-secondary: var(--mg-surface);
    --bg-tertiary: rgba(30, 41, 59, 0.6);

    /* Glass card surface — semi-transparent so the body gradient shows through */
    --card-bg: linear-gradient(135deg, rgba(30, 41, 59, 0.55), rgba(15, 23, 42, 0.75));
    --card-bg-elevated: linear-gradient(135deg, rgba(30, 41, 59, 0.75), rgba(15, 23, 42, 0.85));

    --text-primary: var(--mg-text);
    --text-secondary: #c3d0e8;
    --text-muted: var(--mg-text-muted);
    --border-color: rgba(148, 163, 184, 0.14);
    --border-color-strong: rgba(148, 163, 184, 0.25);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lift: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(63, 123, 255, 0.10);
}

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

html {
    /* Dot grid + soft top blue glow + base navy gradient — copied from TD Pro globals.css */
    background:
        radial-gradient(circle, rgba(63, 123, 255, 0.07) 1px, transparent 1px),
        radial-gradient(ellipse 110% 45% at 50% 0%, rgba(63, 123, 255, 0.08) 0%, transparent 65%),
        linear-gradient(160deg, #0a0e27 0%, #0d1230 40%, #0a0e27 100%);
    background-size: 28px 28px, 100% 100%, 100% 100%;
    background-color: #0a1430;
    background-attachment: fixed;
    overflow-y: scroll;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: transparent;  /* let html gradient show through */
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.dashboard-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    /* Sticky footer: fill the viewport so .site-footer{margin-top:auto}
       lands at the bottom on short pages. */
    min-height: 100vh;
}

/* Header */
.dashboard-header {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.dashboard-header h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #3f7bff 0%, #3f7bff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.header-subtitle {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sync-status {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
}

.sync-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.data-source-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.last-sync-label {
    color: var(--text-muted);
}

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

/* (.btn-icon visual styling consolidated into the canonical button block
   below — line ~172. The previous duplicate here used a red hover that
   clashed with the rest of the secondary palette.) */

.status-indicator {
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.disconnected {
    background: var(--warning-color);
}

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

/* ── Buttons (canonical) ──────────────────────────────────────────────────
   ONE definition for .btn-primary / .btn-secondary / .btn-icon.
   Previously duplicated 4× across this file. Tokens come from tokens.css.
   tdp-polish.css adds the amber hover ring on top.
   ──────────────────────────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-icon {
    padding: 8px 14px;
    font-size: var(--fs-sm);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
    transition: background var(--motion-fast) var(--ease-out),
                border-color var(--motion-fast) var(--ease-out),
                box-shadow   var(--motion-fast) var(--ease-out),
                transform    var(--motion-fast) var(--ease-out),
                color        var(--motion-fast) var(--ease-out);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-color: rgba(63, 123, 255, 0.5);
    color: #fff;
}
.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(63, 123, 255, 0.35);
    transform: translateY(-1px);
}
.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: var(--primary-soft);
    border-color: rgba(63, 123, 255, 0.4);
    color: #93c5fd;
}
.btn-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-icon {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.btn-icon:hover {
    background: var(--primary-soft);
    border-color: rgba(63, 123, 255, 0.4);
    color: #93c5fd;
}

/* Metrics Overview */

.metric-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.metric-card.primary {
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
    border: none;
}


.metric-card.primary .metric-label {
    color: rgba(255, 255, 255, 0.8);
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.2;
}


.metric-change {
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.metric-change.positive {
    color: var(--success-color);
}

.metric-change.negative {
    color: var(--danger-color);
}

.metric-change.positive::before {
    content: '\25B2';
}

.metric-change.negative::before {
    content: '\25BC';
}

/* Period Selector */


.period-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Charts Section */


.legend-dot.csp {
    background: #e8b54d;
}

.legend-dot.cc {
    background: #3f7bff;
}

.legend-dot.total {
    background: #3f7bff;
}

/* Strategy Section */
.strategy-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.strategy-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.strategy-card h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.strategy-metrics {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.strategy-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.strategy-metric:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.strategy-metric .label {
    font-size: 14px;
    color: var(--text-secondary);
}

.strategy-metric .label-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.strategy-metric .period-hint {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.6;
    font-style: italic;
}

.strategy-metric .value {
    font-size: 18px;
    font-weight: 600;
}

/* Positions Section */
.positions-section, .history-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

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

.section-header h2 {
    font-size: 22px;
    font-weight: 600;
}

.filter-buttons {
    display: flex;
    gap: 8px;
}

.filter-btn {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--bg-primary);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
}


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

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

.positions-table thead {
    background: var(--bg-tertiary);
}

.positions-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.positions-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.positions-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.positions-table td {
    padding: 14px 16px;
    font-size: 14px;
    white-space: nowrap;
}

.stock-cell {
    font-weight: 600;
    font-size: 15px;
    color: var(--primary-color);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.status-open {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

.badge.status-closed {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}

.badge.type-csp {
    background: rgba(232, 181, 77, 0.2);
    color: #e8b54d;
}

.badge.type-cc {
    background: rgba(63, 123, 255, 0.2);
    color: #3f7bff;
}

.badge.outcome-profit {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

.badge.outcome-loss {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.badge.outcome-risk {
    background: rgba(232, 181, 77, 0.2);
    color: var(--warning-color);
}

.badge.outcome-assignment {
    background: rgba(63, 123, 255, 0.2);
    color: #3f7bff;
}

.positive {
    color: var(--success-color);
    font-weight: 600;
}

.negative {
    color: var(--danger-color);
    font-weight: 600;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 16px;
}

/* Analytics Section */


.stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.stock-item .symbol {
    font-weight: 600;
    color: var(--primary-color);
}

.stock-item .roi {
    font-weight: 600;
}

/* Goal Tracker */


.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}


.progress-fill.exceeded {
    background: linear-gradient(90deg, var(--success-color) 0%, #0e9b73 100%);
}


/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1200px) {

}

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

    .dashboard-header {
        padding: 20px;
    }

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


    .strategy-section {
        grid-template-columns: 1fr;
    }


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

    .table-container {
        overflow-x: scroll;
    }

}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Tooltip */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ============ Expiration Calendar ============ */
.calendar-section {
    margin-bottom: 32px;
}

.calendar-summary {
    display: flex;
    gap: 32px;
    font-size: 14px;
    color: var(--text-secondary);
}

.calendar-summary strong {
    color: var(--text-primary);
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 24px;
}


.expiration-card.this-week {
    border-color: var(--primary-color);
}

.expiration-card.high-risk {
    border-color: var(--danger-color);
}


.expiration-date .days-away.urgent {
    color: var(--danger-color);
    font-weight: 600;
}


.expiration-badge.safe {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.expiration-badge.warning {
    background: rgba(232, 181, 77, 0.1);
    color: #e8b54d;
}

.expiration-badge.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef5d60;
}


.expiration-stat .label {
    font-size: 12px;
    color: var(--text-muted);
}

.expiration-stat .value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}


.position-type.csp {
    background: rgba(232, 181, 77, 0.1);
    color: #e8b54d;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.position-type.cc {
    background: rgba(63, 123, 255, 0.1);
    color: #3f7bff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}


.risk-indicator.safe { background: #10b981; }
.risk-indicator.near { background: #e8b54d; }
.risk-indicator.danger { background: #ef5d60; }

/* ===================================
   COLLAPSIBLE SECTIONS
   =================================== */


.section-header.clickable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.section-header.clickable:hover {
    background: rgba(255, 255, 255, 0.05);
}

.section-header h2 {
    margin: 0;
    font-size: 1.5rem;
}


.toggle-icon.rotated {
    transform: rotate(-180deg);
}


.section-content.expanded {
    max-height: 10000px;
    padding: 0 24px 24px 24px;
}


/* Include analytics.css styles inline for single page */
.concentration-risk-panel,
.assignment-risk-panel,
.quality-metrics-panel {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.alert-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.alert-badge.ok {
    background: rgba(46, 213, 115, 0.2);
    color: var(--success-bright);
}

.alert-badge.warning {
    background: rgba(255, 159, 67, 0.2);
    color: var(--warning-bright);
}

/* Treemap */
.treemap-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 200px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.treemap-item {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--treemap-cool-from) 0%, var(--treemap-cool-to) 100%);
    border-radius: 6px;
    padding: 12px;
    transition: all 0.3s ease;
}

.treemap-item.warning {
    background: linear-gradient(135deg, var(--treemap-warn-from) 0%, var(--treemap-warn-to) 100%);
    box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.5);
}

.treemap-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.treemap-label {
    text-align: center;
}

.treemap-label .symbol {
    font-size: 1.1rem;
    font-weight: 700;
}

.treemap-label .percent {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 4px 0;
}

.treemap-label .amount {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Risk Tables */
.risk-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.9rem;
}

.risk-table th {
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: #9fb0cf;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.risk-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.risk-table .itm-row {
    background: rgba(255, 77, 79, 0.1);
}

.risk-section {
    margin-bottom: 24px;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid;
}

.risk-section.critical {
    background: rgba(255, 77, 79, 0.05);
    border-left-color: var(--danger-bright);
}

.risk-section.warning {
    background: rgba(255, 159, 67, 0.05);
    border-left-color: var(--warning-bright);
}

.risk-section h4 {
    margin: 0 0 12px 0;
}

.no-risk {
    color: var(--success-bright);
    padding: 12px;
    text-align: center;
}

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

.metric-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.metric-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.metric-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #9fb0cf;
    text-transform: uppercase;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.metric-value.positive { color: var(--success-bright); }
.metric-value.negative { color: var(--danger-bright); }
.metric-value.warning { color: var(--warning-bright); }

.metric-subtext {
    font-size: 0.875rem;
    color: #9fb0cf;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 1024px) {


}

@media (max-width: 768px) {
    .dashboard-header {
        padding: 16px;
    }

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

    .header-content h1 {
        font-size: 1.5rem;
    }

    .sync-status {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .sync-status button {
        width: 100%;
    }


    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .treemap-container {
        flex-direction: column;
    }

    .treemap-item {
        min-width: 100%;
        min-height: 80px;
    }

    .risk-table {
        font-size: 0.75rem;
    }

    .risk-table th,
    .risk-table td {
        padding: 6px 4px;
    }

    .section-content.expanded {
        padding: 0 16px 16px 16px;
    }

}

@media (max-width: 480px) {

    .metric-card {
        padding: 16px;
    }

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

    .section-header h2 {
        font-size: 1.2rem;
    }

    .dashboard-container {
        padding: 12px;
    }

    table {
        font-size: 0.75rem;
    }

}

/* Loading States */
.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay p {
    margin-top: 16px;
    color: #e9f0fb;
    font-size: 1.1rem;
}

/* ==================== Profit & Loss Section (redesigned) ==================== */

.pl-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}


/* ---- Horizontal stat bar ---- */

.pl-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 20px;
    text-align: center;
}


.pl-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.pl-stat-value.positive { color: var(--success-color); }
.pl-stat-value.negative { color: var(--danger-color); }


/* ---- Strategy pill row ---- */


.pl-strat-chip strong.positive { color: var(--success-color); }
.pl-strat-chip strong.negative { color: var(--danger-color); }


/* ---- Open positions unrealized table ---- */


/* Column alignment helpers used in pl-open-table */
.col-right  { text-align: right !important; }
.col-center { text-align: center !important; }

/* Numeric cells: tabular nums for clean alignment */

/* Right-align numeric td cells that inherit from th class */


/* Strike gets a bit more padding on the right for visual breathing room */

.pl-open-table .stock-cell {
    font-size: 14px;
    letter-spacing: 0.02em;
}


.pl-open-table .dte-expiring { color: var(--danger-color); font-weight: 700; }
.pl-open-table .dte-warning  { color: var(--warning-color); font-weight: 600; }

.pl-open-table .val-na {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85em;
}


/* Keep these for JS-set classes */
.positive { color: var(--success-color); }
.negative { color: var(--danger-color); }

@media (max-width: 900px) {
    .pl-stat { flex: 1 0 40%; padding: 8px 12px; }
}

/* ==================== Weekly Earnings Section ==================== */


/* Weekly Calendar */


.legend-box.low {
    background: rgba(239, 68, 68, 0.3);
}

.legend-box.medium {
    background: rgba(232, 181, 77, 0.3);
}

.legend-box.high {
    background: rgba(16, 185, 129, 0.3);
}


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


.week-card.low {
    border-left-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.05);
}

.week-card.medium {
    border-left-color: var(--warning-color);
    background: rgba(232, 181, 77, 0.05);
}

.week-card.high {
    border-left-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}


.week-card.high .week-income {
    color: var(--success-color);
}

.week-card.medium .week-income {
    color: var(--warning-color);
}

.week-card.low .week-income {
    color: var(--danger-color);
}


/* Recent Weeks Table */


/* Responsive */
@media (max-width: 768px) {
    .calendar-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }


}

/* ==========================================
   Assignment Management Dashboard
   ========================================== */


.assignment-section .section-header {
    margin-bottom: 28px;
}

.assignment-section .section-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Assignment Grid */


.risk-card.critical {
    border-left-color: var(--danger-color);
}

.risk-card.warning {
    border-left-color: var(--warning-color);
}

.risk-card.safe {
    border-left-color: var(--success-color);
}

.risk-card.total {
    border-left-color: var(--accent-color);
}


/* Assignment Stats Grid */


/* Moneyness Breakdown */


.moneyness-item.itm {
    border-left-color: var(--danger-color);
}

.moneyness-item.atm {
    border-left-color: var(--warning-color);
}

.moneyness-item.otm {
    border-left-color: var(--success-color);
}


/* Expiration Breakdown */


.expiration-item.urgent {
    background: rgba(239, 68, 68, 0.1);
}

.expiration-item.warning {
    background: rgba(232, 181, 77, 0.1);
}


/* High Risk Positions Table */


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

.positions-table thead {
    background: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
}

.positions-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.positions-table td {
    padding: 14px 16px;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.positions-table tbody tr:hover {
    background: var(--card-bg);
}

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

/* Risk Badges */
.risk-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.risk-badge.critical-risk {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

.risk-badge.high-risk {
    background: rgba(232, 181, 77, 0.15);
    color: var(--warning-color);
}

.risk-badge.low-risk {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success-color);
}

/* Responsive */
@media (max-width: 768px) {


    .positions-table {
        font-size: 0.85rem;
    }

    .positions-table th,
    .positions-table td {
        padding: 10px 12px;
    }
}

/* Pagination Styles */


.pagination-info .separator {
    color: var(--border-color);
}


.page-number {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.page-number:hover {
    background: var(--primary-dark);
    border-color: var(--primary-color);
}

.page-number.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
}

.page-number.ellipsis {
    cursor: default;
    background: transparent;
    border: none;
}

.page-number.ellipsis:hover {
    background: transparent;
    border: none;
}

@media (max-width: 768px) {


    .page-number {
        padding: 6px 10px;
        font-size: 0.85rem;
        min-width: 36px;
    }
}

/* ============================================================
   SECTION NAVIGATION BAR
   ============================================================ */

.section-nav {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 28px;
    background: var(--bg-secondary);
    padding: 6px 8px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow-x: auto;
    scrollbar-width: none;
}

.section-nav::-webkit-scrollbar {
    display: none;
}

.section-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
}

.section-nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.section-nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* ─── Standardized nav (Jinja base layout) ─────────────────────────────
   Per-group color tinting, divider between groups, accessible active state.
   Replaces the old inline `style="color:#xxxxxx"` overrides scattered across
   pages. */
/* All nav links use a uniform color — the active state is the only visual
   difference. Previous per-group tinting (gold bots, blue tools) made the
   nav appear to "change" per page because the active + group color combo
   shifted. Uniform grey + a subtle active indicator reads as static. */
.section-nav-link.nav-group-analyst,
.section-nav-link.nav-group-core,
.section-nav-link.nav-group-bots,
.section-nav-link.nav-group-tools   { color: #9fb0cf; }

.section-nav-link.is-active {
    background: rgba(63, 123, 255, 0.12);
    color: #e9f0fb;
    border: 1px solid rgba(63, 123, 255, 0.30);
}
.section-nav-link.is-active:hover { background: rgba(63, 123, 255, 0.18); }

.section-nav-divider {
    width: 1px;
    align-self: stretch;
    background: var(--border-color);
    margin: 4px 6px;
    flex-shrink: 0;
}

.section-nav-link .nav-icon  { font-size: 0.95em; }
.section-nav-link .nav-label { letter-spacing: 0.005em; }

/* ============================================================
   WEEK DETAIL MODAL
   ============================================================ */


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


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


/* Modal Summary Stats */

.modal-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    background: var(--bg-tertiary);
}

.modal-stat:first-child { border-radius: 0; }


.modal-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Modal Table */


.modal-table .row-win td:first-child {
    border-left: 3px solid var(--success-color);
}

.modal-table .row-loss td:first-child {
    border-left: 3px solid var(--danger-color);
}

.result-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-badge.win {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.result-badge.loss {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

/* Make week cards explicitly show they're clickable */


/* Section dividers for visual grouping */

/* Responsive modal */
@media (max-width: 768px) {


    .section-nav-link span {
        display: none;
    }

    .sync-info {
        display: none;
    }

    .header-actions {
        gap: 6px;
    }
}

/* ============================================================
   Trade Calendar (monthly day-by-day view)
   ============================================================ */


.tc-legend-chip.win-chip {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-color);
}

.tc-legend-chip.loss-chip {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger-color);
}


/* Month section */
.tc-month {
    display: flex;
    flex-direction: column;
    gap: 3px;
}


/* Column grid: week-label | Mon | Tue | Wed | Thu | Fri | week-summary */
.tc-day-headers,
.tc-week-row {
    display: grid;
    grid-template-columns: 90px repeat(5, 1fr) 140px;
    gap: 4px;
    align-items: stretch;
}

.tc-day-header {
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-muted);
    padding: 4px 0;
    letter-spacing: 0.03em;
}

.tc-day-header.tc-week-col,
.tc-day-header.tc-summary-col {
    text-align: left;
    padding-left: 6px;
}

/* Week rows */
.tc-week-row {
    min-height: 52px;
}

.tc-week-label {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    gap: 2px;
}

.tc-week-label-num {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.tc-week-label-dates {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Day cells */
.tc-day-cell {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 4px;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tc-day-cell.tc-empty {
    background: rgba(255, 255, 255, 0.015);
    border: 1px dashed rgba(255, 255, 255, 0.04);
}

/* Trade chips inside day cells */
.tc-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    transition: filter 0.15s, transform 0.1s;
    gap: 4px;
}

.tc-chip.win-chip {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-color);
}

.tc-chip.loss-chip {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger-color);
}

.tc-chip:hover {
    filter: brightness(1.25);
    transform: translateY(-1px);
}

.tc-chip-ticker {
    font-weight: 700;
    flex-shrink: 0;
}

.tc-chip-pl {
    opacity: 0.9;
    flex-shrink: 0;
}

/* Week summary column */
.tc-week-summary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 3px solid var(--border-color);
    gap: 2px;
}

.tc-week-summary.tc-pos {
    border-left-color: var(--success-color);
    background: rgba(16, 185, 129, 0.04);
}

.tc-week-summary.tc-neg {
    border-left-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.04);
}

.tc-week-summary.tc-empty-week {
    opacity: 0.45;
}

.tc-week-pnl {
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1;
}

.tc-week-pnl.tc-pos { color: var(--success-color); }
.tc-week-pnl.tc-neg { color: var(--danger-color); }
.tc-week-pnl.tc-neutral { color: var(--text-muted); }

.tc-week-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1;
}

.tc-week-summary[data-clickable="true"] {
    cursor: pointer;
}

.tc-week-summary[data-clickable="true"]:hover .tc-week-pnl {
    filter: brightness(1.2);
}

.tc-loading {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 24px 0;
    text-align: center;
}

@media (max-width: 900px) {
    .tc-day-headers,
    .tc-week-row {
        grid-template-columns: 70px repeat(5, 1fr) 110px;
        font-size: 0.7rem;
    }

    .tc-week-label-dates {
        display: none;
    }
}

@media (max-width: 640px) {

    .tc-day-headers,
    .tc-week-row {
        grid-template-columns: 50px repeat(5, 1fr) 90px;
        gap: 2px;
    }

    .tc-chip {
        flex-direction: column;
        gap: 1px;
        font-size: 0.62rem;
        padding: 2px 4px;
    }
}

/* ===== Position Intelligence (TD Pro) ===== */

.intel-section {
    margin-bottom: 2rem;
}

.intel-source {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.5rem;
    background: rgba(63, 123, 255, 0.12);
    border: 1px solid rgba(63, 123, 255, 0.3);
    padding: 2px 8px;
    border-radius: 999px;
}

.intel-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.intel-status {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.intel-grid {
    display: grid;
    /* auto-fit + bounded max stops cards from ballooning to 25% viewport when
       the body is mostly empty placeholders. Min 260 keeps them readable; max
       340 keeps them compact. */
    grid-template-columns: repeat(auto-fit, minmax(260px, 340px));
    gap: 1rem;
    justify-content: start;
}

.intel-loading,
.intel-error,
.intel-empty {
    grid-column: 1 / -1;
    padding: 2rem;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
}

.intel-error { color: #ef5d60; }

.intel-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color 0.15s;
}
.intel-card:hover { border-color: rgba(63, 123, 255, 0.5); }

/* Compact placeholder when an intel card has no signals — collapse the
   empty body so the section doesn't look like wasted real estate. */
.intel-card-body:has(> .intel-row.intel-muted:only-child) {
    padding-bottom: 0;
}
.intel-row.intel-muted {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.82rem;
}

.intel-card-head {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.intel-ticker {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 0.5rem;
}

.intel-pos-summary {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.intel-alerts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.alert-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid;
}

.alert-red    { background: rgba(239, 68, 68, 0.15);  color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.alert-orange { background: rgba(249, 115, 22, 0.15); color: #fdba74; border-color: rgba(249, 115, 22, 0.4); }
.alert-yellow { background: rgba(234, 179, 8, 0.15);  color: #fde047; border-color: rgba(234, 179, 8, 0.4); }
.alert-green  { background: rgba(34, 197, 94, 0.15);  color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.alert-blue   { background: rgba(63, 123, 255, 0.15); color: #93c5fd; border-color: rgba(63, 123, 255, 0.4); }
.alert-grey   { background: rgba(148, 163, 184, 0.1); color: #c3d0e8; border-color: rgba(148, 163, 184, 0.3); }

.intel-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.intel-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.intel-label { color: var(--text-muted); }
.intel-val   { color: var(--text-primary); font-family: 'Courier New', monospace; font-weight: 600; }
.intel-muted { color: var(--text-muted); font-style: italic; }

.intel-subhead {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 0.4rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.4rem;
}

.intel-ua-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.78rem;
    padding: 2px 0;
}
.ua-type {
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.7rem;
}
.ua-strike { font-family: 'Courier New', monospace; color: var(--text-primary); }
.ua-meta   { color: var(--text-muted); margin-left: auto; font-size: 0.72rem; }

/* ===== Trade calendar — month nav ===== */
.tc-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}
.tc-nav-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
}
.tc-nav-btn:hover:not(:disabled) {
    background: rgba(63, 123, 255, 0.15);
    color: #93c5fd;
    border-color: rgba(63, 123, 255, 0.4);
}
.tc-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.tc-nav-title {
    text-align: center;
    flex: 1;
}
.tc-nav-month {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}
.tc-nav-stats {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.tc-nav-stats .positive { color: #86efac; font-weight: 600; }
.tc-nav-stats .negative { color: #fca5a5; font-weight: 600; }
.tc-nav-sep { margin: 0 0.5rem; opacity: 0.5; }

/* ===== TD Pro polish overrides ===== */

/* Headers, panels, sections — glass surface */
.dashboard-header,
.metric-card,
.pl-section,
.assignment-section,
.weekly-earnings-section,
.calendar-section,
.strategy-card,
.positions-section,
.history-section,
.intel-section,
.intel-card,
.expiration-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    border-radius: 14px;
    transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

/* Subtle lift on hover — mirrors TD Pro's interactive feel */
.metric-card:hover,
.intel-card:hover,
.expiration-card:hover,
.strategy-card:hover {
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-lift);
    transform: translateY(-1px);
}

/* Headline metric values — bigger, tighter tracking */
.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
}
.metric-value.positive { color: #6ee7b7; }
.metric-value.negative { color: #fca5a5; }


.metric-card.primary {
    border-color: rgba(63, 123, 255, 0.3);
    background: linear-gradient(135deg,
        rgba(63, 123, 255, 0.08),
        rgba(15, 23, 42, 0.85));
}
.metric-card.primary .metric-value {
    background: linear-gradient(135deg, #93c5fd 0%, #9fb0cf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Section header refinement */
.section-header h2 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

/* Filter buttons — share button-ish geometry but distinct visual treatment */
.filter-btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all var(--motion-fast) var(--ease-out);
}
.filter-btn.active,
.filter-btn:hover {
    background: var(--primary-soft);
    color: #93c5fd;
    border-color: rgba(63, 123, 255, 0.4);
}

/* Tables — softer borders, glass background */
.positions-table,
.history-table {
    background: transparent;
}
.positions-table thead,
.history-table thead {
    background: rgba(15, 23, 42, 0.5);
}
.positions-table tbody tr:hover,
.history-table tbody tr:hover {
    background: rgba(63, 123, 255, 0.05);
}

/* Brand title — switch from blue/purple to cleaner blue */
.dashboard-header h1 {
    background: linear-gradient(135deg, #6f9bff 0%, #6f9bff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

/* Container — max width and breathing room matching TD Pro */
.dashboard-container {
    max-width: 1500px;
    padding: 28px;
}

/* Better gap between metric cards */

/* ===== Section ordering (command-center flow) ===== */
/* Make dashboard-container a flex column so we can reorder sections via CSS */
.dashboard-container {
    display: flex;
    flex-direction: column;
}
.dashboard-header     { order: 0; }
#section-intel        { order: 2; }   /* Position Intelligence (TD Pro) */
#section-active       { order: 3; }   /* Active option positions */
.calendar-section     { order: 4; }   /* Expiration calendar */
.strategy-section     { order: 6; }   /* CSP / CC / Assignment Stats */

/* ===== Risk + stats + P&L cards — glass surface ===== */

/* Risk card accents — keep the colored left strip but on glass */
.risk-card.critical { border-left: 3px solid #ef5d60; }
.risk-card.warning  { border-left: 3px solid #e8b54d; }
.risk-card.safe     { border-left: 3px solid #10b981; }
.risk-card.total    { border-left: 3px solid #3f7bff; }

/* Strategy cards inner refinement */
.strategy-card h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.strategy-metric .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.strategy-metric .period-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.strategy-metric .value {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* P&L stat bar — make it match metric cards */
.pl-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}


/* History table — same treatment as positions-table */

/* Risk number readability */

/* ===== Expiration calendar — compact horizontal rows ===== */
/* Override the old grid layout; calendar is now a vertical stack of rows. */
.calendar-grid {
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
}

.exp-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.exp-row:hover {
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-lift);
}
.exp-row.is-risk {
    border-left: 3px solid #ef5d60;
}

.exp-row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.exp-row-date {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.exp-row-datetext {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.exp-day-tag {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid;
}

.exp-row-stats {
    display: flex;
    gap: 1.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.exp-row-stat strong {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin-right: 4px;
}
.exp-row-stat.danger strong { color: #fca5a5; }

.exp-row-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--border-color);
}

.exp-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 4px 9px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    transition: all 0.15s;
    cursor: default;
}
.exp-chip:hover {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(63, 123, 255, 0.4);
}
.exp-chip.risk-danger { border-color: rgba(239, 68, 68, 0.5); }
.exp-chip.risk-near   { border-color: rgba(249, 115, 22, 0.4); }

.exp-chip-ticker {
    font-weight: 700;
    color: var(--text-primary);
}
.exp-chip-type {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.04em;
}
.exp-chip-type.csp,
.exp-chip-type.put { background: rgba(232, 181, 77, 0.18); color: #fcd34d; }
.exp-chip-type.cc,
.exp-chip-type.call { background: rgba(63, 123, 255, 0.18); color: #9fb0cf; }
.exp-chip-strike { color: var(--text-secondary); }
.exp-chip-qty    { color: var(--text-muted); font-size: 0.72rem; }

/* ===== Year filter in header ===== */
.header-year-select {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.header-year-select:hover {
    background: rgba(63, 123, 255, 0.15);
    color: #93c5fd;
    border-color: rgba(63, 123, 255, 0.4);
}
.header-year-select:focus {
    outline: none;
    border-color: rgba(63, 123, 255, 0.6);
}

/* ===== Today's Action card (tabbed) ===== */
.action-section {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), rgba(15, 23, 42, 0.88));
    border: 1px solid rgba(239, 68, 68, 0.28);
    border-radius: 16px;
    padding: 1.25rem 1.5rem 1.4rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(239, 68, 68, 0.08);
    order: 0;  /* render before metrics */
}

.action-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1rem;
}
.action-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    text-transform: uppercase;
}
.action-pulse {
    width: 9px;
    height: 9px;
    background: #ef5d60;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
    animation: action-pulse 2s ease-in-out infinite;
}
@keyframes action-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(1.3); }
}
.action-count {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.action-refresh {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
}
.action-refresh:hover { background: rgba(63, 123, 255, 0.18); color: var(--text-primary); }
.action-refresh.is-spinning { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tabs */
.action-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.action-tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 0.95rem;
    border-radius: 9px;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.action-tab:hover {
    background: rgba(63, 123, 255, 0.08);
    color: var(--text-secondary);
}
.action-tab.is-active {
    background: rgba(63, 123, 255, 0.14);
    border-color: rgba(63, 123, 255, 0.35);
    color: var(--text-primary);
}
.tab-count {
    display: inline-block;
    min-width: 1.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.action-tab.is-active .tab-count {
    background: rgba(63, 123, 255, 0.3);
    color: var(--text-primary);
}
.tab-count.is-zero { opacity: 0.45; }

/* Panels */
.action-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.action-item {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 0.85rem 1rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border-color);
    border-left: 3px solid;
    border-radius: 10px;
    transition: background 0.15s, transform 0.15s;
}
.action-item:hover {
    background: rgba(15, 23, 42, 0.85);
    transform: translateX(2px);
}
.action-item.tone-critical { border-left-color: #ef5d60; }
.action-item.tone-urgent   { border-left-color: #e8b54d; }
.action-item.tone-warning  { border-left-color: #f0c674; }
.action-item.tone-info     { border-left-color: #3f7bff; }

.action-icon {
    font-size: 1.45rem;
    line-height: 1;
    flex-shrink: 0;
}
.action-body { flex: 1; min-width: 0; }
.action-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.94rem;
    line-height: 1.35;
}
.action-detail {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.45;
}
.action-link {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(63, 123, 255, 0.25);
    transition: background 0.15s, border-color 0.15s;
}
.action-link:hover {
    background: rgba(63, 123, 255, 0.15);
    border-color: rgba(63, 123, 255, 0.5);
}

.action-empty {
    padding: 1.5rem 1.25rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.86rem;
    text-align: center;
    line-height: 1.55;
}

.action-more {
    margin-top: 0.4rem;
}
.action-more summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    user-select: none;
    list-style: none;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}
.action-more summary::-webkit-details-marker { display: none; }
.action-more summary:hover {
    background: rgba(63, 123, 255, 0.08);
    color: var(--text-secondary);
}
.action-more[open] summary { margin-bottom: 0.55rem; }
.action-more > .action-item { margin-bottom: 0.55rem; }

/* ===== Active positions: expand row + inline intel ===== */
tr.active-row { cursor: pointer; }
tr.active-row.expanded {
    background: rgba(63, 123, 255, 0.05);
}
.expand-cell { width: 24px; }
.expand-caret {
    display: inline-block;
    color: var(--text-muted);
    transition: transform 0.2s;
    font-size: 0.85rem;
}
tr.active-row.expanded .expand-caret { transform: rotate(90deg); color: #93c5fd; }

.intel-badges {
    display: inline-flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
}
.intel-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.intel-badge.critical { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.intel-badge.urgent   { background: rgba(249, 115, 22, 0.18); color: #fdba74; border-color: rgba(249, 115, 22, 0.4); }
.intel-badge.warn     { background: rgba(234, 179, 8, 0.15);  color: #fde047; border-color: rgba(234, 179, 8, 0.4); }
.intel-badge.ok       { background: rgba(34, 197, 94, 0.15);  color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.intel-badge.info     { background: rgba(63, 123, 255, 0.15); color: #93c5fd; border-color: rgba(63, 123, 255, 0.4); }

tr.intel-detail-row td {
    background: rgba(15, 23, 42, 0.6);
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(63, 123, 255, 0.25);
    border-bottom: 1px solid var(--border-color);
}
.intel-detail-cell {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.intel-detail-block {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
}
.intel-detail-h {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}
.intel-detail-kv {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    padding: 2px 0;
}
.intel-detail-kv span { color: var(--text-muted); }
.intel-detail-kv strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.intel-detail-ua {
    display: grid;
    grid-template-columns: 36px 60px 70px 1fr 80px;
    gap: 0.5rem;
    font-size: 0.78rem;
    padding: 3px 0;
    align-items: center;
}
.ua-mini-type {
    font-weight: 700;
    font-size: 0.66rem;
    padding: 1px 5px;
    border-radius: 3px;
    text-align: center;
}
.ua-mini-type.call { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.ua-mini-type.put  { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.intel-detail-ua .muted { color: var(--text-muted); }
.intel-detail-loading,
.intel-detail-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* ===== AI Advisor floating widget ===== */
.ai-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    background: linear-gradient(135deg, #3f7bff, #3f7bff);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(63, 123, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.18s, box-shadow 0.18s;
    font-family: inherit;
}
.ai-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(63, 123, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
}
.ai-fab-icon { font-size: 1.2rem; }
.ai-fab-label { letter-spacing: 0.02em; }

.ai-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 95vw;
    height: 100vh;
    z-index: 1001;
    background: linear-gradient(160deg, #0a0e27 0%, #0d1230 50%, #0a0e27 100%);
    border-left: 1px solid var(--border-color);
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    transform: translateX(110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-drawer.open { transform: translateX(0); }

.ai-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(63, 123, 255, 0.1), rgba(63, 123, 255, 0.1));
}
.ai-drawer-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #93c5fd, #9fb0cf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.ai-drawer-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.ai-drawer-close {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    transition: all 0.15s;
}
.ai-drawer-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.ai-empty {
    padding: 1rem 0;
    color: var(--text-muted);
}
.ai-empty p { margin-bottom: 0.85rem; font-size: 0.9rem; }
.ai-presets {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.ai-preset {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s;
    font-family: inherit;
}
.ai-preset:hover {
    background: rgba(63, 123, 255, 0.12);
    border-color: rgba(63, 123, 255, 0.4);
    color: #93c5fd;
}

.ai-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 92%;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.ai-bubble.user {
    background: linear-gradient(135deg, #3f7bff, #2f63e0);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.ai-bubble.assistant {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.ai-bubble.error { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }

.ai-activity {
    padding: 0 1.25rem 0.4rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-style: italic;
    display: none;
}

.ai-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.5);
}
#aiInput {
    flex: 1;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.88rem;
    resize: none;
    font-family: inherit;
}
#aiInput:focus {
    outline: none;
    border-color: rgba(63, 123, 255, 0.5);
}
#aiSendBtn { padding: 0 18px; }

/* ===== Dashboard header — tighter, cleaner ===== */
.dashboard-header {
    padding: 18px 24px !important;
    margin-bottom: 1rem !important;
    border-radius: 12px !important;
}
.header-content {
    flex-wrap: wrap;
    gap: 1rem;
}
.dashboard-header h1 {
    font-size: 22px !important;
    letter-spacing: -0.02em !important;
    line-height: 1;
}
.header-subtitle {
    font-size: 10px !important;
    letter-spacing: 0.12em !important;
    margin-top: 2px;
    color: var(--text-muted) !important;
}
.sync-status {
    gap: 12px !important;
}
.sync-info {
    padding: 6px 12px !important;
    font-size: 0.78rem !important;
    background: rgba(15, 23, 42, 0.5) !important;
    border-radius: 6px !important;
}
.status-indicator {
    display: inline-block;
    width: 6px; height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}
/* (canonical .btn-primary / .btn-secondary / .btn-icon block lives near the
   top of this file; duplicate definitions here removed during the 2026-05-05
   token consolidation. The single canonical .section-nav block lives ~L1456.) */

/* ===== History filter bar ===== */

/* Type badges in tables — match the chip styling from intel cards */
.badge.type-csp,
.badge.type-put { background: rgba(232, 181, 77, 0.18); color: #fcd34d; }
.badge.type-cc,
.badge.type-call { background: rgba(63, 123, 255, 0.18); color: #9fb0cf; }
.badge.type-equity { background: rgba(148, 163, 184, 0.15); color: #c3d0e8; }
.badge.type-csp,
.badge.type-cc,
.badge.type-call,
.badge.type-put,
.badge.type-equity {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* Outcome badges */
.badge.outcome-otm { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge.outcome-itm { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge.outcome-expiring { background: rgba(249, 115, 22, 0.15); color: #fdba74; }
.badge.outcome-otm,
.badge.outcome-itm,
.badge.outcome-expiring {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* =====================================================================
   Polish overrides — keep at end of file. Tightens spacing / density,
   unifies card surfaces, makes tables breathe.
   (The duplicate :root with --space-*/--radius-* used to live here;
   it was moved to /css/tokens.css during the 2026-05-05 consolidation.)
   ===================================================================== */

/* Container — a bit more side breathing room on big screens */
.dashboard-container {
    padding: 28px 32px 48px;
}
@media (max-width: 900px) {
    .dashboard-container { padding: 18px; }
}

/* Header — more vertical air, balanced with cards */
.dashboard-header {
    padding: 28px 36px;
    margin-bottom: 28px;
    background: var(--card-bg-elevated);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
}

/* Generic card surface — every dashboard section gets the same glass treatment */

.metric-card {
    background: var(--card-bg);
    backdrop-filter: blur(6px);
    padding: 26px 28px;
    border-radius: var(--radius-md);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.metric-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-lift);
}
.metric-value { font-size: 30px; letter-spacing: -0.02em; }

/* Section blocks — give every <section> a clean rhythm */
.dashboard-section,
.weekly-earnings-section,
.strategy-section,
.positions-section,
.history-section {
    margin-bottom: 36px;
}

.dashboard-section,
.weekly-earnings-section,
.strategy-section {
    padding: 24px 28px;
    background: var(--card-bg);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}
.section-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

/* Tables — more padding, stronger header, alternating rows, sticky head */
.positions-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}
.positions-table thead {
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(6px);
    z-index: 1;
}
.positions-table thead th {
    padding: 14px 18px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color-strong);
    background: transparent;
}
.positions-table tbody td {
    padding: 14px 18px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}
.positions-table tbody tr:nth-child(even) { background: rgba(148, 163, 184, 0.025); }
.positions-table tbody tr:hover {
    background: rgba(63, 123, 255, 0.06);
}
.positions-table tbody tr:last-child td { border-bottom: 0; }
.positions-table tbody tr td:first-child { padding-left: 22px; }
.positions-table tbody tr td:last-child  { padding-right: 22px; }

.table-container,
.table-wrapper {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(15, 23, 42, 0.35);
}

/* Strategy cards — match section card system */
.strategy-card {
    border-radius: var(--radius-md);
    padding: 24px 26px;
}
.strategy-metric {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}
.strategy-metric:last-child { border-bottom: 0; padding-bottom: 0; }

/* (Button radius now baked into the canonical button definition near the
   top of this file. This block was previously a fourth redundant override.) */

/* Empty state — friendlier */
.empty-state {
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
    background: rgba(15, 23, 42, 0.35);
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
}

/* Mobile — collapse the action tabs to wrap and keep tables scrollable */
@media (max-width: 720px) {
    .action-section { padding: 1rem 1.1rem 1.15rem; }
    .action-tabs { flex-wrap: wrap; }
    .action-item { padding: 0.7rem 0.85rem; }
    .action-link { display: none; }
    .dashboard-section,
    .weekly-earnings-section,
    .strategy-section { padding: 18px 18px; }
    .metric-card { padding: 20px; }
    .metric-value { font-size: 26px; }
}

/* ─────────────────────────────────────────────────────────────
   Shared page primitives — used by csp-watch, block-hunter,
   sector-reversal, and any future strategy page.
   ───────────────────────────────────────────────────────────── */

/* Stat strip (5–6 KPIs at the top of a strategy page) */
.csp-summary,
.bh-summary,
.sr-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.csp-stat,
.bh-stat,
.sr-stat {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
    backdrop-filter: blur(6px);
}
.csp-stat-label,
.bh-stat-label,
.sr-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.csp-stat-value,
.bh-stat-value,
.sr-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.bh-stat-value.bullish,
.sr-stat-value.bullish { color: #6ee7b7; }
.bh-stat-value.bearish,
.sr-stat-value.bearish { color: #fca5a5; }
.bh-stat-value.warn,
.sr-stat-value.warn    { color: #fcd34d; }
.csp-stat-sub,
.bh-stat-sub,
.sr-stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Section card wrapper */
.bh-section,
.sr-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 22px 26px;
    margin-bottom: 22px;
    backdrop-filter: blur(6px);
}
.bh-section-head,
.sr-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.bh-section-head h2,
.sr-section-head h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.01em;
}

/* Collapsible "How It Works" panel */
.csp-howto,
.bh-howto,
.sr-howto {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 22px 26px;
    margin-top: 28px;
}
.csp-howto summary,
.bh-howto summary,
.sr-howto summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.csp-howto summary::-webkit-details-marker,
.bh-howto summary::-webkit-details-marker,
.sr-howto summary::-webkit-details-marker { display: none; }
.csp-howto summary::before,
.bh-howto summary::before,
.sr-howto summary::before {
    content: "▸";
    color: var(--text-muted);
    transition: transform 0.15s;
}
.csp-howto[open] summary::before,
.bh-howto[open] summary::before,
.sr-howto[open] summary::before { transform: rotate(90deg); }
.csp-howto-body,
.bh-howto-body,
.sr-howto-body {
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.7;
}
.csp-howto-body code,
.bh-howto-body code,
.sr-howto-body code {
    background: rgba(15, 23, 42, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82em;
    color: var(--accent-color);
}
.csp-howto-body table,
.bh-howto-body table,
.sr-howto-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}
.csp-howto-body th, .csp-howto-body td,
.bh-howto-body th, .bh-howto-body td,
.sr-howto-body th, .sr-howto-body td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}
.csp-howto-body th,
.bh-howto-body th,
.sr-howto-body th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

/* Sortable + zebra tables (block-hunter style — reusable) */
.bh-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.bh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.bh-table thead {
    background: rgba(15, 23, 42, 0.7);
    position: sticky;
    top: 0;
    z-index: 1;
}
.bh-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color-strong);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.bh-table th.sortable:hover { color: var(--text-primary); }
.bh-table th .sort-arrow { color: var(--primary-color); margin-left: 4px; opacity: 0; }
.bh-table th.sort-active .sort-arrow { opacity: 1; }
.bh-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.bh-table tbody tr:nth-child(even) { background: rgba(148, 163, 184, 0.02); }
.bh-table tbody tr:hover { background: rgba(63, 123, 255, 0.06); }
.bh-table tbody tr:last-child td { border-bottom: 0; }
.bh-table .ticker { font-weight: 700; color: var(--text-primary); }
.bh-table .bullish { color: #6ee7b7; font-weight: 600; }
.bh-table .bearish { color: #fca5a5; font-weight: 600; }

/* ──────────────────────────────────────────────────────────────────────────
   Strategy Ladder — shared visual stage tracker (frontend/strategy-ladder.js)
   ────────────────────────────────────────────────────────────────────────── */

.sl-compact {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 6px 0;
}
.sl-pipe {
    display: inline-flex;
    align-items: center;
    gap: 0;
}
.sl-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 0.95rem;
    line-height: 1;
    border-radius: 999px;
    border: 1.5px solid transparent;
    cursor: help;
    transition: transform 0.1s;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}
.sl-dot:hover { transform: scale(1.18); }
.sl-line {
    flex: 0 0 14px;
    height: 1.5px;
    background: rgba(148, 163, 184, 0.25);
    margin: 0 1px;
}
.sl-passed   { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.sl-failed   { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.sl-watching { background: rgba(232, 181, 77, 0.18); color: #fcd34d; border-color: rgba(232, 181, 77, 0.45); animation: sl-pulse 1.6s ease-in-out infinite; }
.sl-pending  { background: rgba(148, 163, 184, 0.10); color: #9fb0cf; border-color: rgba(148, 163, 184, 0.28); }
.sl-skipped  { background: rgba(148, 163, 184, 0.06); color: #6b7a99; border-color: rgba(148, 163, 184, 0.18); }
.sl-na       { background: rgba(91, 141, 239, 0.10);  color: #9fb0cf; border-color: rgba(91, 141, 239, 0.3); }

@keyframes sl-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 181, 77, 0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(232, 181, 77, 0); }
}

.sl-tail {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.sl-final {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: 'Outfit', sans-serif;
}
.sl-final-idle        { background: rgba(148, 163, 184, 0.12); color: #c3d0e8; border-color: rgba(148, 163, 184, 0.25); }
.sl-final-watching    { background: rgba(232, 181, 77, 0.16); color: #fcd34d; border-color: rgba(232, 181, 77, 0.35); }
.sl-final-triggered   { background: rgba(16, 185, 129, 0.20); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.45); }
.sl-final-invalidated { background: rgba(239, 68, 68, 0.20);  color: #fca5a5; border-color: rgba(239, 68, 68, 0.45); }

.sl-grade {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}
.sl-counts {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Detailed vertical list */
.sl-detailed {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 10px 0;
}
.sl-detailed .sl-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.sl-strategy {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}
.sl-ticker {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1rem;
    letter-spacing: 0.01em;
}
.sl-summary {
    color: var(--text-secondary);
    font-size: 0.84rem;
    margin: 4px 0 8px;
    font-style: italic;
}
.sl-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.sl-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 0;
}
.sl-row-icon {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    border: 1.5px solid transparent;
}
.sl-row.sl-passed  .sl-row-icon { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.sl-row.sl-failed  .sl-row-icon { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.sl-row.sl-watching .sl-row-icon{ background: rgba(232, 181, 77, 0.18); color: #fcd34d; border-color: rgba(232, 181, 77, 0.45); }
.sl-row.sl-pending .sl-row-icon { background: rgba(148, 163, 184, 0.10); color: #9fb0cf; border-color: rgba(148, 163, 184, 0.28); }
.sl-row.sl-skipped .sl-row-icon { background: rgba(148, 163, 184, 0.06); color: #6b7a99; }
.sl-row.sl-na      .sl-row-icon { background: rgba(91, 141, 239, 0.10); color: #9fb0cf; border-color: rgba(91, 141, 239, 0.3); }

.sl-row-body { min-width: 0; }
.sl-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
.sl-row-label { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.sl-row-status {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.sl-row-detail {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 2px;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
}
.sl-row-meta { font-size: 0.7rem; color: var(--text-muted); align-self: flex-start; }
.sl-ts { font-family: 'JetBrains Mono', 'Consolas', monospace; }
.sl-row-rail {
    height: 8px;
    margin-left: 13px;
    border-left: 1.5px dashed rgba(148, 163, 184, 0.25);
    width: 1.5px;
}

/* Card variant — used on /strategies-live.html */
.sl-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.sl-card:hover {
    border-color: var(--border-color-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lift);
}
.sl-card.sl-final-triggered { border-left: 3px solid #10b981; }
.sl-card.sl-final-watching  { border-left: 3px solid #e8b54d; }
.sl-card.sl-final-invalidated { border-left: 3px solid #ef5d60; }
.sl-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.sl-card-title {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}
.sl-strategy-tag {
    font-size: 0.66rem;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.1);
    padding: 2px 7px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.sl-card-link {
    font-size: 0.78rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.sl-card-link:hover { text-decoration: underline; }
.sl-detail-toggle {
    margin-top: 8px;
    font-size: 0.78rem;
}
.sl-detail-toggle summary {
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
    padding: 4px 0;
}
.sl-detail-toggle summary:hover { color: var(--text-secondary); }
.sl-detail-toggle .sl-detailed {
    background: transparent;
    border: 0;
    padding: 4px 0 0;
    margin: 0;
}

/* ───────────────────────────────────────────────────────────────────────────
   Global market-status banner — rendered by _base.html on every page,
   visible only when the market is closed (weekend, holiday, off-hours).
   ─────────────────────────────────────────────────────────────────────────── */
.market-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 18px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(239,68,68,0.10), rgba(239,68,68,0.04));
    border: 1px solid rgba(239,68,68,0.30);
    border-left: 4px solid #ef5d60;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #fca5a5;
}
.market-banner-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #ef5d60;
    flex-shrink: 0;
    animation: market-banner-pulse 2.4s ease-in-out infinite;
}
.market-banner-text {
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #fca5a5;
}
.market-banner-meta {
    font-size: 0.78rem;
    color: rgba(252,165,165,0.75);
    margin-left: auto;
}
@keyframes market-banner-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ───────────────────────────────────────────────────────────────────────────
   Strategy card grid — used by /csp-watch.html, /gap-continuation.html,
   /block-hunter.html, /sector-reversal.html. Was previously inline in each
   page's <style> block; restored here when pages were templated.
   ─────────────────────────────────────────────────────────────────────────── */

.csp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 18px;
}

.csp-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color-strong, var(--border-color));
    border-radius: 12px;
    padding: 18px 20px 16px;
    position: relative;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.csp-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-color-strong, var(--border-color));
    box-shadow: var(--shadow-lift, 0 8px 30px rgba(0,0,0,0.25));
}

.csp-card-rm {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #6b7a99;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.csp-card-rm:hover { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

.csp-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding-right: 24px;
    margin-bottom: 12px;
}
.csp-card-ticker {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}
.csp-card-spot {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.csp-card-score {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.csp-card-score-num {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}
.csp-card-grade {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin-top: 4px;
}

.csp-card-suggest {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-size: 0.92rem;
    color: var(--text-primary);
}
.csp-card-suggest .strike { font-weight: 700; }
.csp-card-suggest .otm {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-left: 6px;
}

.csp-card-walls { font-size: 0.78rem; line-height: 1.6; }
.csp-card-walls .pw { color: #93c5fd; }
.csp-card-walls .cw { color: #fca5a5; }
.csp-card-walls .muted { color: #6b7a99; }

.csp-card-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.csp-tag {
    padding: 3px 8px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}
.csp-tag.long-gamma   { color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
.csp-tag.short-gamma  { color: #f0c674; border-color: rgba(232,181,77,0.3); }
.csp-tag.earnings-soon{ color: #fca5a5; border-color: rgba(239,68,68,0.3); }

.csp-card-warn {
    margin-top: 8px;
    font-size: 0.74rem;
    color: #fca5a5;
}
.csp-card-rationale {
    margin-top: 8px;
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.csp-card-rationale > div::before { content: "• "; color: var(--text-muted); }

/* Filter / sort / search bar above the card grid */
.csp-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    backdrop-filter: blur(6px);
}
.csp-controls .csp-control-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}
.csp-controls select,
.csp-controls input[type="text"],
.csp-controls input:not([type]) {
    background: rgba(15,23,42,0.6);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
}
.csp-controls .spacer { flex: 1; }
.csp-controls-spacer { flex: 1; }

/* csp-button — strategy page controls. Tokens match btn-primary/secondary. */
.csp-button {
    padding: 8px 14px;
    font-size: var(--fs-sm, 0.82rem);
    border-radius: var(--radius-sm, 8px);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary, rgba(30,41,59,0.7));
    color: var(--text-secondary, #9fb0cf);
    transition: background 0.15s, border-color 0.15s, color 0.15s,
                box-shadow 0.15s, transform 0.15s;
    white-space: nowrap;
}
.csp-button:hover {
    background: var(--primary-soft, rgba(63,123,255,0.12));
    border-color: rgba(63,123,255,0.4);
    color: #93c5fd;
}
.csp-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}
.csp-button-primary {
    background: linear-gradient(135deg, var(--primary-color, #3f7bff), var(--primary-dark, #2f63e0));
    border-color: rgba(63,123,255,0.5);
    color: #fff;
}
.csp-button-primary:hover {
    box-shadow: 0 4px 12px rgba(63,123,255,0.35);
    transform: translateY(-1px);
}
.csp-button-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* csp-select — strategy page dropdowns */
.csp-select {
    background: rgba(15,23,42,0.6);
    border: 1px solid var(--border-color);
    color: var(--text-primary, #e9f0fb);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}
.csp-select:hover {
    border-color: rgba(63,123,255,0.4);
}
.csp-select:focus {
    outline: none;
    border-color: var(--primary-color, #3f7bff);
    box-shadow: 0 0 0 2px rgba(63,123,255,0.15);
}

/* Detail drawer (csp-watch.html slide-in) */
.csp-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.csp-drawer-overlay.is-open { opacity: 1; pointer-events: auto; }
.csp-drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 480px;
    background: linear-gradient(160deg, #0d1230 0%, #0a0e27 100%);
    border-left: 1px solid var(--border-color-strong, var(--border-color));
    box-shadow: -8px 0 40px rgba(0,0,0,0.4);
    z-index: 91;
    padding: 28px 26px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.csp-drawer.is-open { transform: translateX(0); }
.csp-drawer-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.csp-drawer-close:hover { color: var(--text-primary); }

/* ───── How-It-Works (collapsible, applied to every bot page) ───── */
.bot-howto {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.55), rgba(15, 23, 42, 0.35));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 22px;
    overflow: hidden;
}
.bot-howto > summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.bot-howto > summary::-webkit-details-marker { display: none; }
.bot-howto > summary::after {
    content: '▾';
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}
.bot-howto[open] > summary::after { transform: rotate(180deg); }
.bot-howto > summary:hover { background: rgba(63, 123, 255, 0.06); }
.bot-howto-body {
    padding: 4px 24px 22px 24px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.bot-howto-body h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 18px 0 8px 0;
    font-weight: 700;
}
.bot-howto-body h3:first-child { margin-top: 0; }
.bot-howto-body ol, .bot-howto-body ul {
    margin: 6px 0 6px 22px;
    padding: 0;
}
.bot-howto-body li { margin-bottom: 4px; }
.bot-howto-body code {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.78rem;
    color: #93c5fd;
    font-variant-numeric: tabular-nums;
}
.bot-howto-body table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
    font-size: 0.8rem;
}
.bot-howto-body th, .bot-howto-body td {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}
.bot-howto-body th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}
.bot-howto-body .pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(63, 123, 255, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(63, 123, 255, 0.3);
}
.bot-howto-body .pill.danger  { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.bot-howto-body .pill.success { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.bot-howto-body .pill.warn    { background: rgba(232, 181, 77, 0.15); color: #fcd34d; border-color: rgba(232, 181, 77, 0.3); }

/* ───── Bot settings (editable inputs grid) ───── */
.bot-settings h4 {
    margin: 18px 0 10px 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
}
.bot-settings h4:first-child { margin-top: 0; }
.bot-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px 16px;
    margin-bottom: 8px;
}
.bot-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
}
.bot-field-wide { grid-column: span 2; }
.bot-field > span:first-child {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}
.bot-field input[type="number"],
.bot-field input[type="text"],
.bot-field input[type="time"],
.bot-field select {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.92rem;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    width: 100%;
    box-sizing: border-box;
}
.bot-field input:focus, .bot-field select:focus {
    outline: none;
    border-color: rgba(63, 123, 255, 0.6);
    background: rgba(15, 23, 42, 0.9);
}
.bot-field .bot-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}
.bot-checkrow {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 4px 0;
}
.bot-checkrow label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.bot-checkrow input[type="checkbox"] { accent-color: #6f9bff; cursor: pointer; }
.bot-settings-status-ok    { color: #6ee7b7; }
.bot-settings-status-error { color: #fca5a5; }
.bot-settings-status-saving { color: #fcd34d; }

/* ───── Dialog base (broker connection modals, etc.) ───── */
dialog {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color-strong);
    border-radius: 14px;
    padding: 0;
    max-width: 540px;
    width: calc(100% - 32px);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    font-family: inherit;
}
dialog::backdrop {
    background: rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(2px);
}
dialog > .dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border-color);
}
dialog > .dialog-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
dialog > *:not(.dialog-header) {
    padding-left: 22px;
    padding-right: 22px;
}
dialog > *:last-child {
    padding-bottom: 22px;
}
dialog .close-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
dialog .close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--border-color-strong);
}

/* ───── Connections list (existing connections inside #connectionsDialog) ───── */
#connectionsList {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    min-height: 24px;
}
#connectionsList p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 8px 0;
}
.connection-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    transition: border-color 0.15s, background 0.15s;
}
.connection-row:hover {
    border-color: var(--border-color-strong);
    background: rgba(30, 41, 59, 0.55);
}
.connection-row.status-error,
.connection-row.status-disabled {
    opacity: 0.65;
}
.connection-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.connection-info strong {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}
.connection-info small {
    font-size: 0.74rem;
    color: var(--text-muted);
}
.connection-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.connection-actions button {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.connection-actions button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--border-color-strong);
}
.connection-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* "+ Add Connection" button inside the connections dialog */
#addConnectionBtn {
    width: 100%;
    margin-top: 4px;
}

/* ───── Broker picker ───── */
#tradierForm h3 {
    margin: 4px 0 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
#brokerList {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 8px;
    padding-right: 4px;
}
.broker-pick {
    text-align: left;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.broker-pick:hover {
    border-color: rgba(63, 123, 255, 0.55);
    background: rgba(30, 41, 59, 0.7);
}

/* ───── Add-connection adapter cards & Tradier form ───── */
#adapterPicker {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0;
}
.adapter-card {
    text-align: left;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 18px;
    cursor: pointer;
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}
.adapter-card:hover { border-color: rgba(63, 123, 255, 0.6); background: rgba(30, 41, 59, 0.7); }
.adapter-card[disabled] { opacity: 0.5; cursor: not-allowed; }
.adapter-card h3 { margin: 0 0 4px; font-size: 0.95rem; }
.adapter-card p { margin: 0; font-size: 0.8rem; color: var(--text-muted); }

#tradierForm h3 { margin: 0 0 8px; font-size: 0.95rem; }
.dialog-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 14px; }
.dialog-hint a { color: #6f9bff; text-decoration: none; }
.dialog-hint a:hover { text-decoration: underline; }
.tradier-form { display: flex; flex-direction: column; gap: 10px; }
.tradier-form label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 0.78rem; color: var(--text-muted);
}
.tradier-form input {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}
.tradier-form input:focus {
    outline: none; border-color: rgba(63, 123, 255, 0.6);
}
.tradier-form details { margin-top: 4px; }
.tradier-form summary {
    cursor: pointer; font-size: 0.78rem; color: var(--text-muted);
    padding: 4px 0;
}
.tradier-form details[open] { padding-top: 4px; }
.tradier-form details > label { margin-top: 8px; }
.tradier-form-actions {
    display: flex; gap: 10px; margin-top: 8px;
}
.tradier-form-result {
    font-size: 0.82rem;
    padding: 8px 0;
    color: var(--text-muted);
    word-break: break-word;
}
.tradier-form-result.ok  { color: #6ee7b7; }
.tradier-form-result.err { color: #fca5a5; }
