/* Core Style System */
:root {
    /* Main HSL Palettes */
    --bg-base: hsl(222, 19%, 6%);
    --bg-surface: hsl(222, 19%, 10%);
    --bg-card: rgba(20, 27, 45, 0.6);
    --bg-card-hover: rgba(28, 38, 61, 0.8);
    
    --border-color: rgba(255, 255, 255, 0.05);
    --border-color-hover: rgba(255, 255, 255, 0.1);
    --border-color-glow: rgba(59, 130, 246, 0.25);
    
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 75%);
    --text-muted: hsl(215, 15%, 50%);
    
    /* System Colors */
    --accent: hsl(217, 91%, 60%);
    --accent-glow: rgba(59, 130, 246, 0.15);
    --bg-tooltip: hsl(222, 19%, 12%);
    
    /* Technical indicators colors */
    --color-ma5: #f59e0b;   /* Yellow */
    --color-ma20: #3b82f6;  /* Blue */
    --color-ma60: #ec4899;  /* Pink */
    --color-ma120: #14b8a6; /* Teal */
    
    /* Layout Constants */
    --sidebar-width: 320px;
    --header-height: 80px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    
    /* Font Stack */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, monospace;
    
    /* Timing */
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stock Themes (Dynamic) */
body.theme-tw {
    --up-color: #ef4444;       /* Taiwan Red Up */
    --down-color: #22c55e;     /* Taiwan Green Down */
    --up-bg: rgba(239, 68, 68, 0.08);
    --down-bg: rgba(34, 197, 94, 0.08);
    --up-border: rgba(239, 68, 68, 0.15);
    --down-border: rgba(34, 197, 94, 0.15);
}

body.theme-global {
    --up-color: #22c55e;       /* Global Green Up */
    --down-color: #ef4444;     /* Global Red Down */
    --up-bg: rgba(34, 197, 94, 0.08);
    --down-bg: rgba(239, 68, 68, 0.08);
    --up-border: rgba(34, 197, 94, 0.15);
    --down-border: rgba(239, 68, 68, 0.15);
}

/* Global Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.font-mono {
    font-family: var(--font-mono);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Container Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 10;
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.logo-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.sub-logo {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Color Mode Toggle Buttons */
.color-mode-toggle {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 3px;
    border-radius: 20px;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-left: 10px;
    padding-right: 6px;
}

.toggle-btn {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.toggle-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.toggle-btn:not(.active):hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.time-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Layout Wrapper */
.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar Styling */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.ticker-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Ticker Card */
.ticker-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticker-card:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    transform: translateY(-1px);
}

.ticker-card.active {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.ticker-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ticker-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.ticker-symbol {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ticker-price-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.ticker-price {
    font-size: 0.95rem;
    font-weight: 600;
}

.ticker-change {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
}

.ticker-change.up {
    color: var(--up-color);
    background-color: var(--up-bg);
    border: 1px solid var(--up-border);
}

.ticker-change.down {
    color: var(--down-color);
    background-color: var(--down-bg);
    border: 1px solid var(--down-border);
}

.ticker-change.neutral {
    color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}

/* Comparison Button */
.compare-btn {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 14px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-smooth);
}

.compare-btn:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.compare-btn.active {
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-icon {
    display: flex;
    align-items: center;
}

/* Industry Info Box */
.info-card {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    margin-top: auto;
}

.info-card h4 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.info-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.info-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.4;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}

.info-meta span {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Area Container */
.app-main {
    flex: 1;
    background-color: var(--bg-base);
    overflow-y: auto;
    padding: 24px;
}

/* Panels */
.view-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.3s ease;
}

.view-panel.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

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

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.stock-title-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stock-title-info h2 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.ticker-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
}

.ticker-badge a,
.sa-symbol-link {
    color: inherit;
    text-decoration: none;
}

.ticker-badge a:hover,
.sa-symbol-link:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* MA Controls */
.ma-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
}

.control-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 4px;
}

/* Custom Checkboxes */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 22px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 14px;
    width: 14px;
    background-color: transparent;
    border: 1.5px solid var(--text-muted);
    border-radius: 3px;
    transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--text-primary);
}

.checkbox-container input:checked ~ .checkmark {
    border-color: transparent;
}

/* Individual MA Indicator Colors */
.checkbox-container.ma5 input:checked ~ .checkmark { background-color: var(--color-ma5); }
.checkbox-container.ma20 input:checked ~ .checkmark { background-color: var(--color-ma20); }
.checkbox-container.ma60 input:checked ~ .checkmark { background-color: var(--color-ma60); }
.checkbox-container.ma120 input:checked ~ .checkmark { background-color: var(--color-ma120); }

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 4.5px;
    top: 1.5px;
    width: 3px;
    height: 7px;
    border: solid var(--bg-base);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.checkbox-container.ma5 { color: var(--color-ma5); }
.checkbox-container.ma20 { color: var(--color-ma20); }
.checkbox-container.ma60 { color: var(--color-ma60); }
.checkbox-container.ma120 { color: var(--color-ma120); }

.checkbox-container .label-text {
    opacity: 0.95;
}

/* Stats Grid Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.stat-card.sa-link-card {
    color: var(--text-primary);
    text-decoration: none;
}

.stat-card.sa-link-card:hover {
    border-color: rgba(96, 165, 250, 0.55);
    background: rgba(96, 165, 250, 0.07);
}

.sa-rating-grid {
    margin-top: 14px;
}

.sa-rating-grid .stat-value {
    font-size: 1rem;
    white-space: normal;
    line-height: 1.25;
}

.sa-factor-card .stat-value {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sa-rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 92px;
    justify-content: center;
    border-radius: 5px;
    padding: 4px 7px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.sa-rating-badge span {
    opacity: 0.75;
    font-size: 0.66rem;
}

.sa-rating-badge.sa-strong-buy,
.sa-rating-badge.sa-buy {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.09);
    color: #86efac;
}

.sa-rating-badge.sa-hold {
    border-color: rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.08);
    color: #fde68a;
}

.sa-rating-badge.sa-sell {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
    color: #fca5a5;
}

.sa-rating-badge.sa-empty {
    color: var(--text-muted);
}

.sa-factor-cell {
    min-width: 145px;
}

.sa-factor-chip {
    display: inline-flex;
    align-items: center;
    margin: 1px 3px 1px 0;
    border-radius: 4px;
    padding: 2px 5px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.18);
    color: #bfdbfe;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: transparent;
    transition: var(--transition-smooth);
}

.stat-card:hover::before {
    background: linear-gradient(90deg, var(--accent), transparent);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-top: 2px;
}

.stat-value.compact-value {
    font-size: 1.15rem;
    line-height: 1.8rem;
}

.stat-value.danger-text {
    color: #ef4444;
}

.stat-sub {
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-sub.up {
    color: var(--up-color);
}

.stat-sub.down {
    color: var(--down-color);
}

.stat-sub.neutral {
    color: var(--text-secondary);
}

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

/* Chart Box Styling */
.chart-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow-lg);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.chart-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-legend {
    display: flex;
    gap: 14px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-smooth);
}

.legend-item.hidden {
    opacity: 0.25;
}

.text-ma5 { color: var(--color-ma5); }
.text-ma20 { color: var(--color-ma20); }
.text-ma60 { color: var(--color-ma60); }
.text-ma120 { color: var(--color-ma120); }

/* Chart Drawing Wrappers */
.chart-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

#klineChartContainer {
    width: 100%;
    height: 380px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

#volumeChartContainer {
    width: 100%;
    height: 120px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.chart-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

/* Comparison Line Chart Styling */
.line-chart-wrapper {
    height: 480px;
    width: 100%;
}

#comparisonChart {
    height: 100% !important;
    width: 100% !important;
}

.margin-bottom-lg {
    margin-bottom: 24px;
}

/* Comparison Table Box */
.table-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.table-header {
    margin-bottom: 16px;
}

.table-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.comparison-table th {
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 16px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.comparison-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.comparison-table tbody tr {
    transition: var(--transition-smooth);
}

.comparison-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.015);
}

.comparison-table td.ticker-name-col {
    color: var(--text-primary);
    font-weight: 600;
}

.comparison-table td.up-val {
    color: var(--up-color);
}

.comparison-table td.down-val {
    color: var(--down-color);
}

/* Responsive Styles for Mobile */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .main-wrapper {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .app-container {
        height: auto;
        overflow: auto;
    }
    
    .app-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        height: auto;
        overflow-y: visible;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        height: auto;
        padding: 16px;
        gap: 12px;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ma-controls {
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
    }
    
    #klineChartContainer {
        height: 300px;
    }
}

/* Custom Skeleton for Loading State */
.skeleton {
    position: relative;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.03) !important;
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.02) 20%,
        rgba(255, 255, 255, 0.04) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* Thesis Card (Investment Thesis Highlights) */
.thesis-card {
    background: linear-gradient(135deg, rgba(16, 23, 41, 0.7), rgba(28, 38, 61, 0.4));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 4px solid var(--accent);
    border-radius: var(--border-radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 4px;
    animation: fadeIn 0.4s ease;
}

.thesis-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thesis-badge {
    background: var(--accent-glow);
    color: #60a5fa;
    border: 1px solid var(--border-color-glow);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.thesis-badge.cpo-badge {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.thesis-badge.starlink-badge {
    background: rgba(167, 139, 250, 0.1);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.thesis-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.9;
}

.thesis-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Customized role tags on sidebar cards */
.ticker-card-role {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    margin-top: 4px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.ticker-card-role.cpo-role {
    background: rgba(34, 197, 94, 0.08);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.15);
}

.ticker-card-role.starlink-role {
    background: rgba(167, 139, 250, 0.08);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.15);
}

/* Adjust sidebar margin for grouped headers */
.app-sidebar .sidebar-section-title {
    margin-top: 8px;
}

.app-sidebar .sidebar-section-title:first-child {
    margin-top: 0;
}

/* CPO Supply Chain Flow Card */
.supply-chain-card {
    display: none;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    flex-direction: column;
    gap: 18px;
    box-shadow: var(--shadow-lg);
}

.supply-chain-flow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.flow-step {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 230px;
    transition: var(--transition-smooth);
    position: relative;
}

.flow-step:hover {
    border-color: var(--border-color-glow);
    background-color: rgba(255, 255, 255, 0.04);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.step-num {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 2rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.04);
    line-height: 1;
    font-family: var(--font-mono);
    pointer-events: none;
}

.step-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.step-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.step-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.05em;
    margin-top: 4px;
    opacity: 0.95;
}

.step-tickers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.badge-ticker {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    padding: 3px 7px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.badge-ticker:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--text-primary);
}

.arrow-right {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.flow-connector {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    width: 24px;
    flex-shrink: 0;
}

/* Responsive Styles for Supply Chain Flow */
@media (max-width: 1200px) {
    .supply-chain-flow {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .flow-connector {
        transform: rotate(90deg);
        margin: 6px auto;
        height: 20px;
    }
    
    .flow-step {
        min-height: auto;
    }
}

.badge-ticker.active-ticker {
    border-color: #22c55e !important;
    background: rgba(34, 197, 94, 0.08) !important;
    color: #4ade80 !important;
    font-weight: 600;
}

/* Markdown Content Styling inside Thesis Text */
.thesis-text h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 24px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 6px;
}

.thesis-text h2:first-of-type {
    margin-top: 12px;
}

.thesis-text h3 {
    font-size: 1.0rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 18px;
    margin-bottom: 8px;
}

.thesis-text p {
    margin-bottom: 12px;
    line-height: 1.6;
}

.thesis-text ul, .thesis-text ol {
    margin-left: 20px;
    margin-bottom: 16px;
}

.thesis-text li {
    margin-bottom: 6px;
    line-height: 1.5;
}

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

.thesis-text hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 20px 0;
}

/* Pre/Code inside Thesis Text */
.thesis-text pre {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    margin: 14px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.thesis-text code {
    font-family: var(--font-mono);
    background-color: rgba(255, 255, 255, 0.06);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.thesis-text pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Tables in Thesis Text */
.thesis-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.8rem;
}

.thesis-text th, .thesis-text td {
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.thesis-text th {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-weight: 600;
}

.thesis-text tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.01);
}
