:root {
    --radar-bg: #131722;
    --radar-card: #1e222d;
    --radar-border: #2a2e39;
    --text-primary: #d1d4dc;
    --text-secondary: #787b86;
    --market-up: #26a69a;
    --market-down: #ef5350;
    --market-neutral: #434651;
}

.radar-wrapper {
    background: var(--radar-bg);
    color: var(--text-primary);
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
    border-radius: 4px;
    border: 1px solid var(--radar-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-height: 500px;
}

/* Header */
.radar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--radar-border);
    padding-bottom: 15px;
}

.radar-title h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.live-indicator {
    font-size: 0.7rem;
    color: var(--market-up);
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 12px;
    padding: 2px 6px;
    background: rgba(38, 166, 154, 0.1);
    border-radius: 4px;
}

/* Controls */
.radar-btn-icon {
    background: #2a2e39;
    border: 1px solid var(--radar-border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    text-transform: uppercase;
    font-weight: 600;
}

.radar-btn-icon:hover {
    background: #363a45;
    color: #fff;
    border-color: #50535e;
}

/* Ticker */
.radar-ticker-container {
    background: var(--radar-card);
    border-top: 1px solid var(--radar-border);
    border-bottom: 1px solid var(--radar-border);
    padding: 8px 0;
    margin-bottom: 20px;
    white-space: nowrap;
    overflow: hidden;
    font-family: 'Consolas', 'Monaco', monospace;
}

.radar-ticker {
    display: flex;
    gap: 30px;
    animation: scroll 45s linear infinite;
    padding-left: 20px;
}

.ticker-item {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.t-name { color: var(--text-secondary); }
.t-val { font-weight: 700; }

/* Grid Layout */
.radar-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 20px;
    min-height: 600px;
}

.radar-panel {
    background: var(--radar-card);
    border: 1px solid var(--radar-border);
    border-radius: 4px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Ensure panel itself doesn't stretch */
    min-width: 0; 
}

.panel-header { 
    margin-bottom: 10px; 
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.panel-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.panel-header p {
    margin: 0;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.chart-wrapper {
    flex-grow: 1;
    position: relative;
    width: 100%;
}

/* Legend */
.matrix-legend {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.7rem;
    justify-content: flex-start;
    padding-top: 10px;
    border-top: 1px solid var(--radar-border);
    color: var(--text-secondary);
}

.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }

/* --- SIDE PANEL --- */
.side-panel { min-height: 700px; }

/* 1. Cloud (Top Half) */
.cloud-container {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    overflow-y: auto;
    max-height: 45%; 
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--radar-border);
}

.cloud-tag {
    font-size: 0.8rem;
    background: #2a2e39;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.cloud-tag:hover {
    border-color: var(--market-up);
    color: #fff;
    background: #262a33;
}

/* New: Locked State for clicked tags */
.cloud-tag.active-locked {
    background: #26a69a;
    color: #131722;
    border-color: #26a69a;
    font-weight: 700;
}

/* 2. Details Panel (Bottom Half) */
.details-panel {
    flex-grow: 1;
    overflow-y: auto;
    background: #191c26;
    border-radius: 4px;
    padding: 10px;
    border: 1px solid #2a2e39;
    /* Prevent layout stretching */
    width: 100%; 
    box-sizing: border-box;
}

.placeholder-msg {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 40px;
    line-height: 1.5;
    opacity: 0.5;
}

.panel-msg-header {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #2a2e39;
    padding-bottom: 8px;
    margin-bottom: 10px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    white-space: nowrap;
    overflow: hidden;
}

.header-sub {
    font-size: 0.7rem;
    color: var(--market-up);
    font-weight: 400;
    margin-left: 10px;
}

.movers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual Product Row */
.mover-row {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s;
    background: #232731;
    /* Prevent stretching beyond container */
    max-width: 100%;
    overflow: hidden; 
}

.mover-row:hover {
    background: #2d323e;
}

.mover-img {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    background: #000;
    border: 1px solid #333;
    flex-shrink: 0; /* Never shrink image */
}

.mover-info {
    flex-grow: 1;
    /* CRITICAL: min-width: 0 allows flex child to shrink below content size (enabling ellipsis) */
    min-width: 0; 
}

.mover-title {
    display: block;
    font-size: 0.8rem;
    color: #d1d4dc;
    line-height: 1.2;
    
    /* Truncation Logic */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.panel-loading, .panel-empty, .panel-error {
    font-size: 0.75rem;
    color: #787b86;
    text-align: center;
    padding: 20px 0;
}

/* Stat Footer */
.radar-footer {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background: var(--radar-card);
    padding: 15px;
    border: 1px solid var(--radar-border);
    border-radius: 4px;
}

.stat-card .label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-card .value {
    font-size: 1.2rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-diff {
    display: block;
    font-size: 0.7rem;
    margin-top: 4px;
}

@keyframes scroll { 0% {transform: translateX(0);} 100% {transform: translateX(-50%);} }
@media (max-width: 900px) {
    .radar-grid { grid-template-columns: 1fr; }
    .radar-footer { grid-template-columns: 1fr; }
}