/* ============================================================================
   80s Retro-Futuristic Trading Terminal Styles
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Imports & Base Styles
   ---------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: 'Courier New', 'Monaco', monospace;
    background: #000000;
    background-image: 
        linear-gradient(rgba(0, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    color: #00ffff;
    position: relative;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    animation: scanline 8s linear infinite;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Terminal/CRT Border Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid #00ffff;
    box-shadow: 
        inset 0 0 20px rgba(0, 255, 255, 0.3),
        0 0 40px rgba(0, 255, 255, 0.2),
        0 0 80px rgba(0, 255, 255, 0.1);
    pointer-events: none;
    z-index: 0;
}

/* ----------------------------------------------------------------------------
   Animations
   ---------------------------------------------------------------------------- */
@keyframes scanline {
    0% { background-position: 0 0; }
    100% { background-position: 0 20px; }
}

@keyframes pulse {
    0%, 100% { 
        text-shadow: 
            0 0 10px #ff00ff,
            0 0 20px #ff00ff,
            0 0 30px #ff00ff,
            2px 2px 0 #00ffff,
            -2px -2px 0 #ffff00;
    }
    50% { 
        text-shadow: 
            0 0 20px #ff00ff,
            0 0 30px #ff00ff,
            0 0 40px #ff00ff,
            3px 3px 0 #00ffff,
            -3px -3px 0 #ffff00;
    }
}

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

@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes scan {
    0% { left: -100%; }
    100% { left: 100%; }
}

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

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ----------------------------------------------------------------------------
   Typography
   ---------------------------------------------------------------------------- */
h2 {
    font-family: 'Orbitron', monospace;
    font-weight: 900;
    font-size: 1.8em;
    color: #ff00ff;
    text-shadow: 
        0 0 10px #ff00ff,
        0 0 20px #ff00ff,
        0 0 30px #ff00ff,
        2px 2px 0 #00ffff,
        -2px -2px 0 #ffff00;
    margin: 0;
    letter-spacing: 3px;
    text-transform: uppercase;
    animation: pulse 2s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   Color Classes - Neon Styling
   ---------------------------------------------------------------------------- */
.color-buy { 
    color: #00ff00; 
    text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00;
    font-weight: bold;
}

.color-sell { 
    color: #ff0080; 
    text-shadow: 0 0 10px #ff0080, 0 0 20px #ff0080;
    font-weight: bold;
}

.color-total { 
    color: #ff00ff; 
    text-shadow: 0 0 10px #ff00ff, 0 0 20px #ff00ff;
    font-weight: bold;
}

.color-ticker { 
    color: #ff8000; 
    text-shadow: 0 0 10px #ff8000, 0 0 20px #ff8000;
    font-weight: bold;
    letter-spacing: 1px;
}

.color-per-stock { 
    color: #ffff00; 
    font-weight: bold;
    text-shadow: 0 0 10px #ffff00, 0 0 20px #ffff00;
}

/* ----------------------------------------------------------------------------
   Tables - Terminal Aesthetic
   ---------------------------------------------------------------------------- */
table {
    margin-top: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ffff;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.5),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    width: 100%;
    table-layout: fixed;
    position: relative;
    font-size: 0.85em;
}

table::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 255, 0.03) 2px,
        rgba(0, 255, 255, 0.03) 4px
    );
    pointer-events: none;
}

th, td {
    padding: 2px 4px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    position: relative;
    font-size: 0.95em;
}

th:nth-child(1), td:nth-child(1) { width: 5%; min-width: 52px; }    /* Symbol */
th:nth-child(2), td:nth-child(2) { width: 7%; min-width: 60px; }   /* Company */
th:nth-child(3), td:nth-child(3) { width: 8%; min-width: 68px; }   /* Sector */
th:nth-child(4), td:nth-child(4) { width: 6%; min-width: 64px; }   /* Invested */
th:nth-child(5), td:nth-child(5) { width: 22%; min-width: 160px; } /* Today */
th:nth-child(6), td:nth-child(6) { width: 7%; min-width: 68px; }   /* Return today */
th:nth-child(7), td:nth-child(7) { width: 22%; min-width: 160px; } /* Since purchase */
th:nth-child(8), td:nth-child(8) { width: 9%; min-width: 78px; }   /* Return per day */
th:nth-child(9), td:nth-child(9) { width: 7%; min-width: 88px; font-size: 0.95em; } /* Details */

th {
    background: linear-gradient(180deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 255, 255, 0.1) 100%);
    color: #00ffff;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid #00ffff;
    box-shadow: 0 2px 10px rgba(0, 255, 255, 0.3);
}

tr:nth-child(even) {
    background: rgba(0, 255, 255, 0.05);
}

tr:hover {
    background: rgba(0, 255, 255, 0.1);
    box-shadow: inset 0 0 10px rgba(0, 255, 255, 0.2);
}

.row-container {
    position: relative;
    transition: all 0.2s ease;
}

.row-container:hover {
    background: rgba(0, 255, 255, 0.1) !important;
    box-shadow: inset 0 0 15px rgba(0, 255, 255, 0.3);
}

/* ----------------------------------------------------------------------------
   Price chart column
   ---------------------------------------------------------------------------- */
.sector-column {
    vertical-align: middle;
}

.sector-cell {
    font-size: 0.9em;
    color: rgba(0, 255, 255, 0.85);
}

.chart-column {
    width: 120px;
    padding: 0 4px;
    vertical-align: middle;
    background: rgba(0, 0, 0, 0.5);
    border-left: 2px solid rgba(0, 255, 255, 0.5);
}

.today-chart-column {
    width: 200px;
    padding: 0 4px;
    vertical-align: middle;
    background: rgba(0, 0, 0, 0.5);
    border-left: 2px solid rgba(0, 255, 255, 0.5);
}

.chart-cell {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.chart-cell-empty {
    color: rgba(0, 255, 255, 0.4);
    font-size: 0.9em;
}

/* Return per day: return percentage on first line, days count bar on second */
.profitperday-cell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
}
.profitperday-cell .profitperday-return {
    flex: 0 0 auto;
}

.chart-cell .rationale-chart-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.chart-cell .rationale-chart-line {
    /* Final: price line in green */
    stroke: #00ff00;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: none;
    filter: drop-shadow(0 0 4px rgba(0, 255, 255, 0.6));
}

.chart-cell .rationale-chart-stop-loss {
    /* Solid magenta stop-loss line (no dashes) */
    stroke: #ff0080;
    stroke-width: 1.5;
    stroke-dasharray: none;
    filter: drop-shadow(0 0 2px rgba(255, 0, 128, 0.8));
}

.chart-cell .rationale-chart-nontrading {
    /* Non–trading hours (outside 9:30–16:00 ET Mon–Fri): darker band so trading hours stand out */
    fill: rgba(40, 40, 60, 0.85);
}

.chart-cell .rationale-chart-day-v {
    /* Vertical line at each trading-day boundary (9:30 AM ET) */
    stroke: rgba(0, 255, 255, 0.35);
    stroke-width: 1;
}

.chart-cell .rationale-chart-day-tick-minor {
    /* Subtle day ticks for "since purchase" chart baseline */
    stroke: rgba(0, 255, 255, 0.22);
    stroke-width: 1;
}

.chart-cell .rationale-chart-day-tick-major {
    /* Match minor ticks exactly (no extra emphasis) */
    stroke: rgba(0, 255, 255, 0.22);
    stroke-width: 1;
}

.chart-cell .rationale-chart-grid-v {
    /* Faint 1-min grid (disabled so background reads as pure black) */
    stroke: rgba(0, 0, 0, 0);
    stroke-width: 1;
}

.chart-cell .rationale-chart-buy-fill-above {
    /* Area between buy price and price line when price is above buy (profit) */
    fill: rgba(0, 255, 0, 0.25);
    stroke: none;
}

.chart-cell .rationale-chart-buy-fill-below {
    /* Area between buy price and price line when price is below buy (loss) */
    fill: rgba(255, 0, 0, 0.25);
    stroke: none;
}

/* ----------------------------------------------------------------------------
   Justification Column
   ---------------------------------------------------------------------------- */
.justification-column {
    width: 100%;
    min-width: 0;
    word-wrap: break-word;
    white-space: normal;
    background: rgba(0, 0, 0, 0.5);
    border-left: 2px solid rgba(0, 255, 255, 0.5);
    padding: 0 6px 0 6px;
    font-size: 0.95em;
}

.justification-wrapper {
    position: relative;
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: stretch;
    margin: -2px -4px -2px -6px;
    padding: 2px 0 2px 6px;
    flex: 1;
    align-self: stretch;
}

.justification-text {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
    color: #ccccff;
    text-shadow: 0 0 5px rgba(204, 204, 255, 0.5);
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding-right: 4px;
}

.justification-text.collapsed {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.justification-text.expanded {
    flex: 1 1 auto;
    overflow-y: auto;
}

.justification-toggle {
    padding: 0 8px;
    margin: 0;
    position: relative;
    z-index: 1;
    background: rgba(0, 255, 255, 0.1);
    border-left: 1px solid rgba(0, 255, 255, 0.5);
    border-top: none;
    border-bottom: none;
    border-right: 2px solid rgba(0, 255, 255, 0.5);
    color: #00ffff;
    cursor: pointer;
    font-size: 0.85em;
    font-family: 'Courier New', monospace;
    transition: all 0.2s ease;
    text-shadow: 0 0 8px rgba(0, 255, 255, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    flex-shrink: 0;
    align-self: stretch;
    flex-grow: 0;
}

/* Details button: match header row height, centered in cell */
.justification-details-btn {
    width: auto;
    height: 28px;
    padding: 0 12px;
    border: 2px solid #00ffff;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5), inset 0 0 10px rgba(0, 255, 255, 0.1);
    font-size: 0.75em;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.justification-details-btn:hover {
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.8), inset 0 0 15px rgba(0, 255, 255, 0.2);
    text-shadow: 0 0 12px #00ffff;
}

.justification-details-btn:active {
    background: rgba(0, 255, 255, 0.15);
}

.justification-toggle:hover {
    background: rgba(0, 255, 255, 0.3);
    border-left-color: #00ffff;
    box-shadow: inset 0 0 10px rgba(0, 255, 255, 0.5);
    text-shadow: 0 0 15px rgba(0, 255, 255, 1.5);
}

.justification-toggle:active {
    background: rgba(0, 255, 255, 0.4);
}

.justification-toggle .toggle-text {
    display: inline-block;
}

/* Main table: rationale only in overlay; Details column shows button only */
.justification-text-hidden {
    display: none !important;
}

.justification-wrapper-button-only {
    flex: none;
    width: auto;
}

.justification-cell {
    max-width: 100%;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
    color: #ccccff;
    text-shadow: 0 0 5px rgba(204, 204, 255, 0.5);
}

.justification-container {
    margin-top: 1em;
}

/* Position details overlay (chart, rationale, position info) */
.justification-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.justification-overlay.justification-overlay-hidden {
    display: none;
}

.justification-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.justification-overlay-box {
    position: relative;
    z-index: 1001;
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #00ffff;
    box-shadow:
        0 0 30px rgba(0, 255, 255, 0.5),
        inset 0 0 20px rgba(0, 255, 255, 0.08);
    font-family: 'Courier New', monospace;
}

.justification-overlay-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 255, 255, 0.06) 100%);
    border-bottom: 2px solid #00ffff;
    color: #00ffff;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
}

.justification-overlay-title {
    font-weight: bold;
    font-size: 0.95em;
    letter-spacing: 2px;
}

.justification-overlay-close {
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ffff;
    color: #00ffff;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
    transition: all 0.2s ease;
}

.justification-overlay-close:hover {
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.6);
}

/* Position info grid */
.justification-overlay-position {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.justification-overlay-position-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px 20px;
}

.justification-overlay-position-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.justification-overlay-position-label {
    font-size: 0.7em;
    letter-spacing: 1px;
    color: #00ffff;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
    text-transform: uppercase;
}

.justification-overlay-position-value {
    font-size: 0.95em;
    color: #00ffff;
    word-break: break-word;
}

.justification-overlay-position-value.color-ticker { color: #ff8000; text-shadow: 0 0 10px #ff8000, 0 0 20px #ff8000; }
.justification-overlay-position-value.color-total { color: #ff00ff; text-shadow: 0 0 10px #ff00ff, 0 0 20px #ff00ff; }
.justification-overlay-position-value.color-buy { color: #00ff00; text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00; }
.justification-overlay-position-value.color-sell { color: #ff0080; text-shadow: 0 0 10px #ff0080, 0 0 20px #ff0080; }

/* Chart with axes: Y left, chart center, X below; expands to fill space */
/* Side-by-side TODAY + SINCE PURCHASE chart row in the modal */
.justification-overlay-charts-row {
    display: flex;
    flex-direction: row;
    gap: 0;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.justification-overlay-chart-section {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 12px 12px;
    border-right: 1px solid rgba(0, 255, 255, 0.2);
}
.justification-overlay-chart-section:last-child { border-right: none; }

.justification-overlay-chart-section--wide {
    flex: 3 1 0;
}

.justification-overlay-chart-section-label {
    font-size: 0.75em;
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.8);
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 6px;
    font-weight: bold;
}

.justification-overlay-chart-wrap {
    flex: 1;
    min-height: 270px;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr auto;
    gap: 8px 4px;
    padding: 0;
}

.justification-overlay-chart-y {
    grid-column: 1;
    grid-row: 1;
    writing-mode: vertical-rl;
    transform: rotate(-180deg);
    align-self: center;
    font-size: 0.75em;
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.8);
    white-space: nowrap;
    min-height: 1.5em;
}

.justification-overlay-chart-inner {
    grid-column: 2;
    grid-row: 1;
    min-width: 200px;
    min-height: 270px;
    height: 100%;
    background: #000;
    border: 1px solid rgba(0, 255, 255, 0.4);
    display: flex;
    align-items: stretch;
}

.justification-overlay-chart {
    flex: 1;
    display: flex;
    align-items: stretch;
    min-height: 270px;
    width: 100%;
}

/* Today chart inside its section — smaller, fills the section column */
.justification-overlay-chart-section #justification-overlay-today-chart {
    flex: 1;
    min-height: 200px;
    width: 100%;
    background: #000;
    border: 1px solid rgba(0, 255, 255, 0.4);
    display: flex;
    align-items: stretch;
}

.justification-overlay-chart-svg {
    width: 100%;
    height: 100%;
    min-height: 270px;
    display: block;
}

/* Overlay chart: non-trading hour bands (outside 09:30–16:00 ET Mon–Fri) */
.overlay-chart-nt {
    fill: rgba(40, 40, 60, 0.85);
}

/* Overlay chart: filled area above buy price (profit) */
.overlay-chart-fill-above {
    fill: rgba(0, 255, 0, 0.25);
    stroke: none;
}

/* Overlay chart: filled area below buy price (loss) */
.overlay-chart-fill-below {
    fill: rgba(255, 0, 0, 0.25);
    stroke: none;
}

.justification-overlay-chart-x {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 0.75em;
    color: #00ffff;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.8);
    text-align: center;
    padding-top: 4px;
}

.justification-overlay-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #00ffff;
    opacity: 0.7;
    font-size: 0.9em;
    min-height: 120px;
}

.justification-overlay-rationale-label {
    flex: 0 0 auto;
    padding: 10px 16px 4px;
    font-size: 0.75em;
    letter-spacing: 2px;
    color: #00ffff;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
    text-transform: uppercase;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.justification-overlay-body {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 40vh;
    overflow-y: auto;
    padding: 6px 16px 14px;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.92em;
    line-height: 1.55;
    color: #ccccff;
    text-shadow: none;
}

.overlay-rationale-section {
    padding: 10px 0 4px;
    border-top: 1px solid rgba(0, 255, 255, 0.12);
}
.overlay-rationale-section:first-child {
    border-top: none;
    padding-top: 6px;
}

.overlay-rationale-section-label {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.72em;
    letter-spacing: 1.5px;
    color: rgba(0, 255, 255, 0.65);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.overlay-rationale-section-body {
    color: #d8d8f0;
    line-height: 1.6;
    white-space: pre-wrap;
}

.overlay-rationale-section-body--dim {
    color: #9090b8;
    font-style: italic;
}

/* ----------------------------------------------------------------------------
   Layout - Main Structure
   ---------------------------------------------------------------------------- */
.main-container {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    gap: 8px;
    padding: 8px;
    align-items: stretch;
}

.main-content {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: stretch;
}

/* Inside #table-container: sidebar metrics (left) + positions table (right); fixed height so recent events stays on screen */
#table-container .main-content-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 10px;
    flex: 0 0 auto;
    height: 585px;
    max-height: 585px;
}

#table-container .sidebar-metrics {
    flex: 0 0 286px;
    width: 286px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

#table-container .sidebar-metrics .metric-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#table-container .sidebar-metrics .sidebar-metric-fund {
    flex: 1;
    background: rgba(0, 40, 50, 0.4);
    border-radius: 4px;
}

#table-container .sidebar-metrics .metric-card-performance-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-metric-share-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.sidebar-metric-share-value {
    font-size: 1.4em;
    font-weight: bold;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
}

.sidebar-metric-uninvested {
    font-size: 0.8em;
    opacity: 0.9;
    font-family: 'Courier New', monospace;
    color: #00ffff;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    margin-bottom: 4px;
}

.sidebar-metric-charts {
    flex: 1;
    min-height: 0;
    margin-top: 4px;
    display: flex;
    flex-direction: row;
    gap: 4px;
}

.sidebar-metric-chart-slot {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-metric-chart-label {
    font-size: 0.55em;
    font-family: 'Orbitron', monospace;
    color: rgba(0, 255, 255, 0.5);
    text-shadow: 0 0 4px rgba(0, 255, 255, 0.3);
    letter-spacing: 1px;
    text-transform: uppercase;
    line-height: 1;
    padding-bottom: 2px;
}

.sidebar-metric-chart {
    flex: 1;
    min-height: 0;
    background: #000;
    border: 1px solid rgba(0, 255, 255, 0.25);
    display: flex;
    align-items: stretch;
    overflow: hidden;
    position: relative;
}

/* Fixed height so all sidebar charts (TODAY + SMD) are the same height across cards */
.sidebar-metric-chart.chart-cell {
    height: 88px;
    min-height: 88px;
    flex: 0 0 88px;
}

.sidebar-metric-chart svg {
    width: 100%;
    height: 100%;
    display: block;
}

.sidebar-chart-overlay {
    position: absolute;
    top: 2px;
    left: 4px;
    font-family: 'Orbitron', monospace;
    font-size: 0.95em;
    font-weight: bold;
    letter-spacing: 0.5px;
    line-height: 1;
    pointer-events: none;
    z-index: 1;
}

.sidebar-chart-overlay.color-buy {
    color: #00ff00;
    text-shadow: 0 0 8px #00ff00, 0 0 16px rgba(0, 255, 0, 0.6);
}

.sidebar-chart-overlay.color-sell {
    color: #ff0080;
    text-shadow: 0 0 8px #ff0080, 0 0 16px rgba(255, 0, 128, 0.6);
}

#table-container .positions-section {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.sidebar-content {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 0;
    flex: 1;
    min-height: 0;
}

/* ----------------------------------------------------------------------------
   AJAX Refresh Containers
   ---------------------------------------------------------------------------- */
#table-container {
    transition: opacity 0.3s ease;
    opacity: 1;
    flex: none;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar metrics + table fill the main-content-row */

/* Table: flex column, rows share space; min-width 0 so it can shrink and scale */
#table-container table {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

#table-container thead {
    flex: 0 0 auto;
    display: flex;
}

#table-container thead tr {
    display: flex;
    width: 100%;
}

#table-container tbody {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#table-container tbody tr {
    flex: 1;
    min-height: 0;
    display: flex;
    width: 100%;
}

#table-container tbody td,
#table-container thead th {
    overflow: hidden;
    display: flex;
    align-items: center;
    min-width: 0;
}

/* 9-column layout (pixel-fixed non-chart cols; chart cols grow at 1:3 ratio) */
/* Symbol | Company | Sector | Invested | Today | Return today | Since purchase | Return per day | Details */
#table-container th:nth-child(1),
#table-container td:nth-child(1) { flex: 0 0 60px; }        /* Symbol */
#table-container th:nth-child(2),
#table-container td:nth-child(2) { flex: 0 0 80px; }        /* Company */
#table-container th:nth-child(3),
#table-container td:nth-child(3) { flex: 0 0 92px; }        /* Sector */
#table-container th:nth-child(4),
#table-container td:nth-child(4) { flex: 0 0 76px; }        /* Invested */
#table-container th:nth-child(5),
#table-container td:nth-child(5) { flex: 0.6 1 70px; min-width: 70px; }      /* Today chart (~60% prior width) */
#table-container th:nth-child(6),
#table-container td:nth-child(6) { flex: 0 0 108px; }       /* Return today */
#table-container th:nth-child(7),
#table-container td:nth-child(7) { flex: 3.4 1 150px; min-width: 150px; }    /* Since purchase (expanded) */
#table-container th:nth-child(8),
#table-container td:nth-child(8) { flex: 0 0 120px; }       /* Return per day */
#table-container th:nth-child(9),
#table-container td:nth-child(9) { flex: 0 0 80px; }        /* Details */

/* Center all column headers */
#table-container thead th {
    text-align: center;
    justify-content: center;
    align-items: center;
    white-space: normal;
    line-height: 1.15;
    font-size: 0.82em;
    padding: 2px 2px;
}

/* Chart columns: column flex so SVG fills the cell height */
#table-container td:nth-child(5),
#table-container td:nth-child(7) {
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    padding: 0 4px;
}

/* Return today: center the value text */
#table-container td:nth-child(6) {
    justify-content: center;
    text-align: center;
}

#table-container td.justification-column {
    justify-content: center;
    align-items: center;
    padding: 0;
}

#table-container td.justification-column .justification-wrapper {
    width: auto;
    min-height: 0;
}

#table-container td.justification-column .justification-wrapper-button-only {
    align-self: center;
}

#table-container thead th {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#table-container .chart-cell {
    height: 100%;
    min-height: 0;
}

#cap-table-container {
    transition: opacity 0.3s ease;
    opacity: 1;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#log-table-container {
    transition: opacity 0.3s ease;
    opacity: 1;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#status-indicator {
    transition: color 0.3s ease;
}

#status-indicator span[style*="color: #ffaa00"] {
    animation: pulse-warning 2s ease-in-out infinite;
}

#status-indicator span[style*="color: #00ffff"] {
    animation: pulse-connecting 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { 
        opacity: 1;
        text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
    }
    50% { 
        opacity: 0.7;
        text-shadow: 0 0 15px rgba(255, 170, 0, 0.8);
    }
}

@keyframes pulse-connecting {
    0%, 100% { 
        opacity: 1;
        text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    }
    50% { 
        opacity: 0.6;
        text-shadow: 0 0 20px rgba(0, 255, 255, 0.9);
    }
}

/* ----------------------------------------------------------------------------
   Section Wrappers
   ---------------------------------------------------------------------------- */
.status-bar-section {
    flex-shrink: 0;
    margin-top: 5px;
}

.metrics-section {
    flex-shrink: 0;
}

.positions-section {
    flex: none;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: visible;
}

.investor-performance-section {
    --cap-scale: 1;
    padding: 8px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ffff;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.4),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
}

.investor-performance-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent,
        #00ffff,
        transparent
    );
    animation: pulse-border 2s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   Title Bar
   ---------------------------------------------------------------------------- */
.title-bar {
    font-size: 0.9em;
    margin-bottom: 0.3em;
    padding: 6px 2px;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #00ffff;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.4),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    z-index: 20;
}

.title-bar::after {
    content: '█';
    animation: blink-cursor 1s infinite;
    color: #00ffff;
    margin-left: 5px;
}

/* ----------------------------------------------------------------------------
   Summary Dashboard - Metric Cards
   ---------------------------------------------------------------------------- */
.summary-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
    margin-bottom: 0.5em;
}

/* Desktop: Fixed 5-column grid for even spacing */
@media screen and (min-width: 1025px) {
    .summary-dashboard {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
    }
}

.metric-card {
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffff;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.4),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: default;
    user-select: none;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 255, 255, 0.1),
        transparent
    );
    transition: left 0.5s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.6),
        inset 0 0 25px rgba(0, 255, 255, 0.15);
}

.metric-card:hover::before {
    left: 100%;
}

.metric-card-primary {
    border-color: #ff00ff;
    box-shadow: 
        0 0 20px rgba(255, 0, 255, 0.4),
        inset 0 0 20px rgba(255, 0, 255, 0.1);
}

.metric-card-primary:hover {
    box-shadow: 
        0 0 30px rgba(255, 0, 255, 0.6),
        inset 0 0 25px rgba(255, 0, 255, 0.15);
}

.metric-card-gain {
    border-color: #00ff00;
    box-shadow: 
        0 0 20px rgba(0, 255, 0, 0.4),
        inset 0 0 20px rgba(0, 255, 0, 0.1);
}

.metric-card-gain:hover {
    box-shadow: 
        0 0 30px rgba(0, 255, 0, 0.6),
        inset 0 0 25px rgba(0, 255, 0, 0.15);
}

.metric-card-loss {
    border-color: #ff0080;
    box-shadow: 
        0 0 20px rgba(255, 0, 128, 0.4),
        inset 0 0 20px rgba(255, 0, 128, 0.1);
}

.metric-card-loss:hover {
    box-shadow: 
        0 0 30px rgba(255, 0, 128, 0.6),
        inset 0 0 25px rgba(255, 0, 128, 0.15);
}

.metric-card-info {
    border-color: #ffff00;
    box-shadow: 
        0 0 20px rgba(255, 255, 0, 0.4),
        inset 0 0 20px rgba(255, 255, 0, 0.1);
}

.metric-card-info:hover {
    box-shadow: 
        0 0 30px rgba(255, 255, 0, 0.6),
        inset 0 0 25px rgba(255, 255, 0, 0.15);
}

.metric-card-market {
    border-color: #ff8000;
    box-shadow: 
        0 0 20px rgba(255, 128, 0, 0.4),
        inset 0 0 20px rgba(255, 128, 0, 0.1);
}

.metric-card-market:hover {
    box-shadow: 
        0 0 30px rgba(255, 128, 0, 0.6),
        inset 0 0 25px rgba(255, 128, 0, 0.15);
}

.metric-label {
    font-size: 0.6em;
    color: #00ffff;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 2px;
    opacity: 0.9;
}

.metric-value {
    font-size: 1.2em;
    font-weight: bold;
    line-height: 1.1;
    margin-bottom: 1px;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
}

/* Metric cards with label LHS, value RHS (share price, uninvested) */
.metric-card-rhs {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}

/* Performance cards: two tight rows, values right-aligned */
.metric-card-performance .metric-card-performance-inner {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    min-width: 0;
}

.metric-card-performance .metric-card-performance-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.metric-card-performance .metric-card-performance-top .metric-label {
    flex-shrink: 0;
}

.metric-card-performance .metric-card-performance-bottom {
    justify-content: flex-start;
    align-items: center;
}

/* Right side: percentage stacked above "today" as one unit */
.metric-card-performance .metric-today-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    flex-shrink: 0;
    line-height: 1.1;
}

.metric-card-performance .metric-today-block .metric-today-label {
    font-size: 0.7em;
    opacity: 0.9;
    letter-spacing: 0.5px;
    margin-bottom: 1px;
}

.metric-card-performance .metric-today-block .metric-value-today {
    line-height: 1.1;
}

.metric-card-rhs .metric-label {
    flex-shrink: 0;
}

.metric-card-rhs .metric-value-rhs {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    font-size: 1.5em;
    font-weight: bold;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
}

.metric-card-rhs .metric-card-rhs-values {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.metric-card-rhs .metric-uninvested {
    font-size: 0.85em;
    opacity: 0.9;
    font-family: 'Courier New', monospace;
}

.metric-card-performance {
    padding: 8px 10px;
}

.metric-card-performance .metric-card-performance-inner {
    padding: 0;
}

.metric-card-performance .metric-value-sub {
    font-size: 0.85em;
    opacity: 0.85;
    font-family: 'Courier New', monospace;
}

.metric-card-performance .monkey-day-tooltip {
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.metric-card-performance .metric-value-sub-cyan {
    color: #00ffff;
    text-shadow: 0 0 8px #00ffff, 0 0 16px rgba(0, 255, 255, 0.5);
    opacity: 1;
}

.metric-card-performance .metric-value-rhs {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.metric-card-performance .metric-today-label {
    color: #00ffff;
    font-family: 'Orbitron', monospace;
}

.metric-card-performance .metric-value-today {
    font-size: 1.4em;
    font-weight: bold;
    line-height: 1.1;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
}

/* Today box percentages: green for positive, red for negative (match .color-buy / .color-sell) */
.metric-card-performance .metric-value-today.color-buy {
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00;
}
.metric-card-performance .metric-value-today.color-sell {
    color: #ff0080;
    text-shadow: 0 0 10px #ff0080, 0 0 20px #ff0080;
}

/* "Since monkey day" sub line: same green/red by sign */
.metric-card-performance .metric-value-sub.color-buy {
    color: #00ff00;
    text-shadow: 0 0 8px #00ff00, 0 0 16px #00ff00;
    opacity: 1;
}
.metric-card-performance .metric-value-sub.color-sell {
    color: #ff0080;
    text-shadow: 0 0 8px #ff0080, 0 0 16px #ff0080;
    opacity: 1;
}

.metric-subvalue {
    font-size: 0.75em;
    margin-top: 2px;
    opacity: 0.9;
    font-family: 'Courier New', monospace;
}

/* ----------------------------------------------------------------------------
   Loading Message
   ---------------------------------------------------------------------------- */
.loading-message {
    padding: 40px 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #00ffff;
    margin: 20px 0;
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.6),
        inset 0 0 30px rgba(0, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.loading-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 255, 255, 0.2),
        transparent
    );
    animation: scan 2s infinite;
}

.loading-message h1 {
    margin: 20px 0;
    font-size: 64px;
    text-shadow: 
        0 0 20px #ff00ff,
        0 0 40px #ff00ff,
        0 0 60px #ff00ff;
    animation: pulse 1.5s ease-in-out infinite;
}

.loading-message h2 {
    margin: 20px 0;
    font-size: 28px;
    color: #00ffff;
    font-weight: bold;
    text-shadow: 0 0 15px #00ffff, 0 0 30px #00ffff;
    font-family: 'Orbitron', monospace;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* ----------------------------------------------------------------------------
   Cap Table (Investor Performance)
   ---------------------------------------------------------------------------- */
.sidebar-cap-table {
    margin-bottom: 0;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--cap-scale, 1));
    visibility: visible;
    opacity: 1;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: 100%;
}

.sidebar-cap-table b {
    color: #ffff00;
    text-shadow: 0 0 10px #ffff00;
    font-size: clamp(0.72em, calc(1em * var(--cap-scale, 1)), 1em);
    font-family: 'Orbitron', monospace;
    letter-spacing: calc(1px * var(--cap-scale, 1));
    text-transform: uppercase;
    display: block;
    margin-bottom: calc(8px * var(--cap-scale, 1));
    flex-shrink: 0;
    text-align: center;
}

.cap-table-fund-value {
    margin-bottom: 10px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 0, 0.3);
    border-radius: 4px;
    font-size: 0.8em;
    line-height: 1.3;
    flex-shrink: 0;
}

.cap-table-vertical {
    display: flex;
    flex-direction: column;
    gap: calc(1px * var(--cap-scale, 1));
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: calc(6px * var(--cap-scale, 1));
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(0, 255, 255, 0.3);
    position: relative;
}

.cap-table-investors {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: calc(1px * var(--cap-scale, 1));
}

.cap-table-total-wrapper {
    margin-top: auto;
    flex-shrink: 0;
}

.cap-table-total-wrapper .equalizer-bar-wrapper {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    grid-template-columns: none !important;
}

.cap-table-total-wrapper .bar-label-column {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
}

.cap-table-total-wrapper .cap-table-name,
.cap-table-total-wrapper .color-buy,
.cap-table-total-wrapper .color-sell {
    text-align: center !important;
    width: 100% !important;
}

.cap-table-vertical-item {
    padding: 6px 8px;
    background: rgba(0, 255, 255, 0.05);
    border-left: 3px solid #00ffff;
    border-radius: 2px;
    transition: all 0.2s ease;
    font-size: 0.8em;
    flex-shrink: 0;
}

.cap-table-vertical-item:hover {
    background: rgba(0, 255, 255, 0.15);
    border-left-width: 5px;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    transform: translateX(3px);
}

.cap-table-name {
    font-weight: bold;
    color: #00ffff;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
    margin-bottom: calc(5px * var(--cap-scale, 1));
    font-family: 'Orbitron', monospace;
    letter-spacing: calc(1px * var(--cap-scale, 1));
    font-size: clamp(0.8em, calc(1em * var(--cap-scale, 1)), 1em);
    line-height: 1.05;
    display: block;
}

.cap-table-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.95em;
    color: #ffffff;
}

/* ----------------------------------------------------------------------------
   VU Meter Styles
   ---------------------------------------------------------------------------- */
.equalizer-bar-wrapper {
    display: grid;
    grid-template-columns: minmax(0, calc(140px * var(--cap-scale, 1))) minmax(0, 1fr);
    gap: calc(12px * var(--cap-scale, 1));
    align-items: start;
    padding: calc(3px * var(--cap-scale, 1)) calc(6px * var(--cap-scale, 1));
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

.equalizer-bar-wrapper:last-child {
    border-bottom: none;
}

.bar-label-column {
    display: flex;
    flex-direction: column;
    gap: calc(2px * var(--cap-scale, 1));
}


.bar-value-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: calc(8px * var(--cap-scale, 1));
}

.bar-return-per-day,
.bar-return-per-year {
    font-size: clamp(0.55em, calc(0.65em * var(--cap-scale, 1)), 0.65em);
    font-family: 'Courier New', monospace;
    line-height: 1;
}

.vu-meter-ownership {
    font-size: clamp(0.72em, calc(0.85em * var(--cap-scale, 1)), 0.85em);
    color: #888;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.vu-meter-profit {
    text-align: center;
    margin-top: calc(4px * var(--cap-scale, 1));
}

.vu-meter-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    flex: 1;
}

.vu-meter-scale {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    padding-bottom: 1px;
    font-size: 0.6em;
    color: #666;
    font-family: 'Courier New', monospace;
}

.vu-meter-scale span {
    line-height: 1;
}

.vu-meter-bar-wrapper {
    position: relative;
    width: 100%;
    height: calc(20px * var(--cap-scale, 1));
    background: linear-gradient(to right, #0a0a0a, #1a1a1a);
    border: 1px solid #333;
    border-top: 1px solid #555;
    border-radius: 2px;
    overflow: hidden;
}

.vu-meter-zero-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.4);
    z-index: 2;
    transform: translateX(-50%);
}

.vu-meter-bar {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    height: 100%;
    transition: width 0.3s ease;
    background: #00ff00;
    box-shadow: 
        0 0 10px rgba(0, 255, 0, 0.6),
        inset 0 0 20px rgba(0, 255, 0, 0.3);
    z-index: 1;
}

.vu-meter-bar.negative {
    background: #ff0080;
    box-shadow: 
        0 0 10px rgba(255, 0, 128, 0.6),
        inset 0 0 20px rgba(255, 0, 128, 0.3);
    right: 50%;
    left: auto;
}

.vu-meter-segments {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    pointer-events: none;
}

.vu-meter-segment {
    height: 100%;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.vu-meter-segment {
    height: 100%;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* ----------------------------------------------------------------------------
   Events Section
   ---------------------------------------------------------------------------- */
.events-section {
    margin-top: 0;
    padding: 6px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffff;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.4),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    z-index: 1;
}

.events-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent,
        #00ffff,
        transparent
    );
    animation: pulse-border 2s ease-in-out infinite;
}

.events-section b,
.events-header {
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
    font-size: 0.85em;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
    padding-bottom: 2px;
}

.events-header {
    flex-shrink: 0;
    border-bottom: 2px solid rgba(0, 255, 255, 0.3);
}

.events-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.events-list li {
    padding: 3px 8px;
    margin: 1px 0;
    background: rgba(0, 255, 255, 0.05);
    border-left: 3px solid #00ffff;
    font-family: 'Courier New', monospace;
    font-size: 0.75em;
    transition: all 0.3s ease;
    word-wrap: break-word;
    line-height: 1.2;
}

.events-list li:hover {
    background: rgba(0, 255, 255, 0.15);
    border-left-width: 5px;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    transform: translateX(3px);
}

/* Buy event styling - blue highlight */
.events-list li.event-buy {
    background: rgba(0, 100, 255, 0.3);
    border-left: 5px solid #0066ff;
    color: #88ccff;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(0, 100, 255, 0.3);
}

.events-list li.event-buy:hover {
    background: rgba(0, 100, 255, 0.4);
    border-left-width: 6px;
    box-shadow: 0 0 15px rgba(0, 100, 255, 0.5);
}

/* Sell event styling - green for profit */
.events-list li.event-sell-profit {
    background: rgba(0, 255, 0, 0.3);
    border-left: 5px solid #00ff00;
    color: #aaffaa;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.3);
}

.events-list li.event-sell-profit:hover {
    background: rgba(0, 255, 0, 0.4);
    border-left-width: 6px;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

/* Sell event styling - red for loss */
.events-list li.event-sell-loss {
    background: rgba(255, 0, 80, 0.3);
    border-left: 5px solid #ff0080;
    color: #ff99cc;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(255, 0, 80, 0.3);
}

.events-list li.event-sell-loss:hover {
    background: rgba(255, 0, 80, 0.4);
    border-left-width: 6px;
    box-shadow: 0 0 15px rgba(255, 0, 80, 0.5);
}

/* Sell event styling - neutral (no profit/loss info) */
.events-list li.event-sell {
    background: rgba(255, 128, 0, 0.3);
    border-left: 5px solid #ff8000;
    color: #ffcc99;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(255, 128, 0, 0.3);
}

.events-list li.event-sell:hover {
    background: rgba(255, 128, 0, 0.4);
    border-left-width: 6px;
    box-shadow: 0 0 15px rgba(255, 128, 0, 0.5);
}

/* Learning note event styling - purple/magenta highlight */
.events-list li.event-learning-note {
    background: rgba(255, 0, 255, 0.2);
    border-left: 5px solid #ff00ff;
    color: #ff88ff;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(255, 0, 255, 0.3);
}

.events-list li.event-learning-note:hover {
    background: rgba(255, 0, 255, 0.3);
    border-left-width: 6px;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
}

/* ----------------------------------------------------------------------------
   Tooltip Styles
   ---------------------------------------------------------------------------- */
.tooltip-emoji {
    cursor: default;
    user-select: none;
    filter: drop-shadow(0 0 5px currentColor);
    animation: float 3s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   Scrollbar Styling
   ---------------------------------------------------------------------------- */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #00ffff;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.5);
    border: 2px solid #000;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 255, 0.8);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Mobile/Tablet (max-width: 1024px)
   ---------------------------------------------------------------------------- */
@media screen and (max-width: 1024px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
        width: 100%;
        max-width: 100vw;
    }
    
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .main-container {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        overflow: visible;
        min-height: auto;
        width: 100%;
        max-width: 100%;
    }
    
    .main-content {
        padding-right: 0;
        width: 100%;
        max-width: 100%;
        overflow: visible;
        flex: none;
        display: contents;
    }
    
    .status-bar-section {
        order: 0;
        width: 100%;
    }
    
    .metrics-section {
        order: 1;
        width: 100%;
    }
    
    #table-container .main-content-row {
        flex-direction: column;
        height: auto;
        max-height: none;
    }
    
    #table-container .sidebar-metrics {
        flex: none;
        width: 100%;
        flex-direction: row;
        height: auto;
        gap: 8px;
    }
    
    #table-container .sidebar-metrics .metric-card {
        flex: 1;
    }
    
    #table-container .sidebar-metrics .sidebar-metric-fund {
        flex: 1;
    }
    
    .positions-section {
        order: 2;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex: none;
        min-height: auto;
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar-content {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        order: 3;
    }
    
    #log-table-container {
        order: 4;
    }
    
    .events-section {
        order: 4;
        flex: none;
        max-height: 300px;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
    }
    
    .investor-performance-section {
        max-height: none;
        overflow: visible;
    }
    
    /* Hide justification column on mobile */
    th:nth-child(7),
    td:nth-child(7) {
        display: none;
    }
    
    .summary-dashboard {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
    }
    
    .metric-card {
        padding: 8px 10px;
    }
    
    .metric-value {
        font-size: 1.2em;
    }
    
    .metric-card-performance .metric-value-today {
        font-size: 1.3em;
    }
    
    .metric-card-rhs .metric-value-rhs {
        font-size: 1.3em;
    }
    
    table {
        font-size: 0.8em;
        min-width: 800px;
        width: 100%;
        max-width: 100%;
    }
    
    th, td {
        padding: 2px 3px;
        font-size: 0.95em;
    }
    
    th:nth-child(7), td:nth-child(7) {
        font-size: 0.95em;
    }
    
    * {
        max-width: 100%;
    }
    
    .terminal-header {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .terminal-header > div {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .metrics-section {
        flex: none;
    }
    
    .status-bar-section {
        flex: none;
    }
}

/* ----------------------------------------------------------------------------
   Small Mobile (max-width: 640px)
   ---------------------------------------------------------------------------- */
@media screen and (max-width: 640px) {
    html, body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }
    
    body {
        overflow-y: auto;
    }
    
    .main-container {
        padding: 6px;
        gap: 6px;
        overflow: visible;
        min-height: auto;
    }
    
    .main-content {
        display: contents;
    }
    
    .status-bar-section {
        order: 0;
    }
    
    .metrics-section {
        order: 1;
    }
    
    #table-container .sidebar-metrics {
        flex-direction: column;
        gap: 6px;
    }
    
    .positions-section {
        order: 2;
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar-content {
        order: 3;
    }
    
    #log-table-container {
        order: 4;
    }
    
    .events-section {
        order: 4;
        flex: none;
        max-height: 250px;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Hide justification column on small mobile */
    th:nth-child(7),
    td:nth-child(7) {
        display: none;
    }
    
    .summary-dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .metric-card {
        padding: 6px 8px;
    }
    
    .metric-label {
        font-size: 0.6em;
    }
    
    .metric-value {
        font-size: 1em;
    }
    
    .metric-card-performance .metric-value-today {
        font-size: 1.2em;
    }
    
    .metric-card-rhs .metric-value-rhs {
        font-size: 1.2em;
    }
    
    .title-bar {
        font-size: 0.85em;
        padding: 6px 8px;
    }
    
    .terminal-header {
        padding: 4px 10px;
    }
    
    .terminal-header h2 {
        font-size: 1.4em;
    }
    
    .terminal-header::before {
        font-size: 0.6em;
        right: 10px;
        top: 3px;
    }
    
    table {
        font-size: 0.7em;
        min-width: 700px;
    }
    
    th, td {
        padding: 2px;
        font-size: 0.85em;
    }
    
    th:nth-child(7), td:nth-child(7) {
        font-size: 0.8em;
    }
    
    .investor-performance-section {
        max-height: none;
        padding: 6px;
        overflow: visible;
    }
    
    .main-content {
        overflow: visible;
        flex: none;
    }
    
    .positions-section {
        order: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar-content {
        order: 1;
    }
    
    .sidebar-cap-table {
        font-size: 0.9em;
    }
    
    .equalizer-bar-wrapper {
        grid-template-columns: 120px 1fr;
        gap: 10px;
        padding: 3px 6px;
    }
    
    .vu-meter-bar-wrapper {
        height: 18px;
    }
    
    .bar-label-column {
        gap: 1px;
    }
}

/* ----------------------------------------------------------------------------
   Large Desktop (min-width: 1400px)
   ---------------------------------------------------------------------------- */
@media screen and (min-width: 1400px) {
    .main-container {
        padding: 8px;
    }
    
    .sidebar-content {
        width: 300px;
        min-width: 300px;
        max-width: 300px;
    }
    
    .summary-dashboard {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

/* ----------------------------------------------------------------------------
   Extra Wide Desktop (min-width: 1920px)
   ---------------------------------------------------------------------------- */
@media screen and (min-width: 1920px) {
    .main-container {
        padding: 8px;
    }
}
