.dashboard-container {
    padding: 8px 16px;
    max-width: 1600px;
    margin: 0 auto;
    background: transparent;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Two-column layout */
.main-grid {
    display: grid;
    grid-template-columns: 62% 38%;
    gap: 16px;
    align-items: stretch;
    height: calc(100vh - 108px); /* back to fixed viewport height */
    min-height: 500px;
    max-height: 850px; /* clamp fluid height to prevent overly stretched charts on large monitors */
}

.chart-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.timeline-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;    /* needed for child absolute positioning */
}

.filters-bar {
    display: flex;
    justify-content: center;
    gap: 32px;
    background: transparent;
    padding: 4px 0;
    margin-bottom: 8px;
    box-shadow: none;
    border: none;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-muted);
}

.filter-group select {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    min-width: 100px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

.filter-group select:focus {
    outline: none;
    box-shadow: none;
    border-color: var(--border);
}

.chart-card {
    background: var(--card-bg);
    padding: 12px 20px 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px -5px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    position: relative;
    flex: 1;              /* fills remaining height in chart-col */
    min-height: 250px;
    outline: none !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Watermark */
.chart-card::after {
    content: 'rollingstraddle.com';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 26px;
    font-weight: 700;
    font-family: 'Inter', system-ui, sans-serif;
    letter-spacing: 0.04em;
    color: var(--text, #64748b);
    opacity: 0.07;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
    user-select: none;
}

#atmStraddleChart {
    height: 100%;
    width: 100%;
}

/* Aggressive Border/Focus Removal */
#atmStraddleChart, 
#atmStraddleChart *, 
.apexcharts-canvas, 
.apexcharts-canvas *, 
.apexcharts-svg,
.apexcharts-inner,
.apexcharts-series-group {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Aggressive Legend Single-Line Force */
.apexcharts-legend {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 0 !important;
}

.apexcharts-legend-series {
    margin: 2px 8px !important;
    display: flex !important;
    align-items: center !important;
    white-space: nowrap !important;
}

.summary-grid {
    margin-top: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;              /* reduced from 12px */
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 12px;         /* reduced from 16px */
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px;          /* reduced from 6px 4px */
    border-right: 1px solid var(--border);
}

.grid-item:last-child, .item-updated, .item-dte {
    border-right: none;
}

.grid-item .label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    white-space: normal;
    line-height: 1.2;
}

.grid-item .value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

#valStraddlePrice, #valIndexSpot {
    color: var(--text);
}

/* Specific styling for the updated row */
.item-updated {
    grid-column: span 4;
    border-top: none;      /* removed from 1px solid var(--border) */
    padding-top: 4px;      /* reduced from 12px */
    margin-top: 0;         /* reduced from 4px */
    flex-direction: row;
    justify-content: center;
    align-items: baseline;
    gap: 6px;
}

.item-updated .value {
    font-size: 14px;
    font-weight: 600;
}

.update-time {
    display: none;
}

/* Custom Tooltip Styling */
.custom-tooltip {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    overflow: hidden;
    color: var(--text);
}

.tooltip-header {
    background: var(--card-hover);
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.tooltip-body {
    padding: 8px 12px;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
}

.tooltip-row:last-child {
    margin-bottom: 0;
}

.tooltip-row .label {
    color: var(--text-muted);
    font-weight: 500;
}

.tooltip-row .value {
    font-weight: 700;
}

.tooltip-row .val-blue {
    color: #3b82f6;
}

.tooltip-row .val-green {
    color: #10b981;
}

.tooltip-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-container {
        padding: 8px;
    }
    
    .filters-bar {
        gap: 16px;
    }
}

/* Stack columns on narrow screens */
@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr;
        height: auto;
        align-items: start;
    }
    .chart-card {
        flex: none;
        min-height: 280px;
    }
    .timeline-col .timeline-card {
        /* Enough room without bleeding past footer */
        max-height: 55vh;
        min-height: 260px;
    }

    /* Re-enable horizontal scroll on mobile */
    .timeline-col .timeline-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Give table enough room so columns aren't crushed */
    #strikeTimelineTable {
        min-width: 480px;
        table-layout: auto;
    }

    /* Tighter cell padding on mobile to maximise content space */
    #strikeTimelineTable th,
    #strikeTimelineTable td {
        padding: 9px 8px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .filters-bar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 8px;
    }

    .filter-group {
        width: calc(50% - 12px);
        justify-content: center;
    }

    .filter-group select {
        width: 100%;
        min-width: unset;
    }

    .chart-card {
        padding: 8px 12px;
        min-height: 300px;
    }

    .summary-grid {
        grid-template-columns: repeat(4, 1fr);
        padding: 12px;
        gap: 8px;
    }
    
    .grid-item {
        border-right: none; /* Remove borders on mobile for cleaner look */
        padding: 6px;
    }

    /* Mobile grid spans (4-col grid) */
    .item-straddle { grid-column: span 2; }
    .item-spot { grid-column: span 2; }
    
    .item-synth { grid-column: span 2; }
    .item-strike { grid-column: span 2; }
    .item-ce { grid-column: span 2; }
    
    .item-pe { grid-column: span 2; }
    .item-dte { grid-column: span 2; }

    .item-updated {
        grid-column: span 4;
        flex-direction: row;
        justify-content: center;
        align-items: baseline;
        gap: 6px;
    }

    .grid-item .label {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .grid-item .value {
        font-size: 14px;
    }

    .tooltip-row {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .filter-group {
        width: 100%;
    }
}

/* Timeline Table Styling */
.timeline-card {
    margin-top: 0;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px -5px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Timeline Watermark */
.timeline-card::after {
    content: 'rollingstraddle.com';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 22px;
    font-weight: 700;
    font-family: 'Inter', system-ui, sans-serif;
    letter-spacing: 0.04em;
    color: var(--text, #64748b);
    opacity: 0.07;
    pointer-events: none;
    white-space: nowrap;
    z-index: 0;
    user-select: none;
}

.timeline-col .timeline-card {
    max-height: 400px; /* Constrains height on mobile to enable internal scrolling */
    min-height: 300px;
}

@media (min-width: 901px) {
    .timeline-col .timeline-card {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        height: auto;
        max-height: none; /* Removes constraint on desktop where height matches the chart */
    }
}

.timeline-col .timeline-table-wrapper {
    overflow-y: auto;
    flex: 1;
    min-height: 0;         /* allows flex shrink */
}

.timeline-card .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-card h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.timeline-card .header-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.timeline-table-wrapper {
    overflow-x: hidden;
}

#strikeTimelineTable {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 13px;
}

/* Column widths via colgroup — Time:16% | Spot:20% | Synth:24% | Old:20% | New:20% */
#strikeTimelineTable col.col-time        { width: 16%; }
#strikeTimelineTable col.col-spot        { width: 20%; }
#strikeTimelineTable col.col-synth       { width: 24%; }
#strikeTimelineTable col.col-old-strike  { width: 20%; }
#strikeTimelineTable col.col-new-strike  { width: 20%; }

#strikeTimelineTable th {
    background: var(--card-hover);
    padding: 10px 10px;
    text-align: right;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* First column (Time) stays left-aligned */
#strikeTimelineTable th:first-child {
    text-align: left;
}

#strikeTimelineTable td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    font-family: 'JetBrains Mono', 'Fira Mono', monospace;
    font-size: 12.5px;
}

/* Time column stays left-aligned and uses body font */
#strikeTimelineTable td:first-child {
    text-align: left;
    font-family: inherit;
    font-size: 13px;
}

#strikeTimelineTable tbody tr:hover {
    background: var(--card-hover);
}

#strikeTimelineTable tr.active-row {
    background: rgba(59, 130, 246, 0.06);
    box-shadow: inset 3px 0 0 #3b82f6;
}

#strikeTimelineTable .strike-old {
    color: var(--text-muted);
}

#strikeTimelineTable .strike-new {
    color: #3b82f6;
    font-weight: 700;
}

#strikeTimelineTable .time-cell {
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
}

/* Sortable Column Styling */
#strikeTimelineTable th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    white-space: nowrap; /* Forces the icon to stay inline with the text */
}

#strikeTimelineTable th.sortable:hover {
    background: var(--border);
}

#strikeTimelineTable th.sortable i {
    margin-left: 6px;
    color: var(--text-muted);
    font-size: 11px;
    opacity: 0.4;
    transition: all 0.2s ease;
}

#strikeTimelineTable th.sortable.active {
    color: var(--text);
}

#strikeTimelineTable th.sortable.active i {
    color: #3b82f6;
    opacity: 1;
}

/* Enhancements for large and ultra-wide screens */
@media (min-width: 1400px) {
    #strikeTimelineTable {
        font-size: 15px;
    }

    .grid-item .label {
        font-size: 12px;
    }

    .grid-item .value {
        font-size: 16px;
    }

    .item-updated .value {
        font-size: 15px;
    }
}
