/* ═══════════════════════════════════════════════════
   MarketPulse — Design System & Styles
   ═══════════════════════════════════════════════════ */

:root {
    --bg-primary: #09090b;
    --bg-secondary: #0f0f13;
    --bg-tertiary: #151519;
    --bg-card: rgba(22, 22, 35, 0.8);
    --bg-card-hover: rgba(30, 30, 50, 0.9);
    --bg-sidebar: rgba(13, 13, 18, 0.95);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #5a5a72;
    --accent-green: #00ff88;
    --accent-green-bg: rgba(0, 255, 136, 0.08);
    --accent-green-border: rgba(0, 255, 136, 0.15);
    --accent-red: #ff3366;
    --accent-red-bg: rgba(255, 51, 102, 0.08);
    --accent-red-border: rgba(255, 51, 102, 0.15);
    --accent-purple: #8b5cf6;
    --accent-blue: #3b82f6;
    --accent-yellow: #fbbf24;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.02);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.5);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset & Base ──────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Ambient background ────────────────────────── */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(0, 255, 136, 0.025) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.02) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
    animation: ambientShift 20s ease-in-out infinite alternate;
}

@keyframes ambientShift {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-2%, 1%) scale(1.02); }
}

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ── App Layout ────────────────────────────────── */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 22px;
    color: var(--accent-purple);
    animation: pulseGlow 3s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.4));
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

.logo h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 0%, #c4b5fd 50%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-tagline {
    font-size: 11px;
    color: var(--text-muted);
    padding-left: 12px;
    border-left: 1px solid var(--border-subtle);
    font-weight: 400;
}

.header-stats {
    display: flex;
    gap: 32px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-green .stat-value { color: var(--accent-green); }
.stat-red .stat-value { color: var(--accent-red); }

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 2px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.market-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-red);
}

.market-status.open .status-dot {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
    animation: blink 2s ease infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.date-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Sector Ribbon ─────────────────────────────── */
.sector-ribbon {
    display: flex;
    gap: 8px;
    padding: 10px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    scrollbar-width: none;
}
.sector-ribbon::-webkit-scrollbar { display: none; }
.sector-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
    cursor: pointer;
}
.sector-pill:hover { border-color: var(--border-medium); }
.sector-pill .sector-name { color: var(--text-secondary); }
.sector-pill .sector-change { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.sector-pill.positive { background: rgba(0, 255, 136, 0.06); }
.sector-pill.positive .sector-change { color: var(--accent-green); }
.sector-pill.negative { background: rgba(255, 51, 102, 0.06); }
.sector-pill.negative .sector-change { color: var(--accent-red); }
.sector-pill.active {
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
    background: rgba(139, 92, 246, 0.12);
}
.sector-pill.active .sector-name {
    color: var(--accent-purple);
}

/* ── Market Summary ───────────────────────────── */
.market-summary {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 8px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    scrollbar-width: none;
}
.market-summary::-webkit-scrollbar { display: none; }

.summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    font-size: 11px;
}

.summary-label {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 9px;
}

.summary-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 12px;
}

.summary-value.green { color: var(--accent-green); }
.summary-value.red { color: var(--accent-red); }
.summary-value.purple { color: var(--accent-purple); }

.summary-divider {
    width: 1px;
    height: 16px;
    background: var(--border-subtle);
    flex-shrink: 0;
}

/* ── App Body ──────────────────────────────────── */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    padding: 20px;
    overflow-y: auto;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.search-box {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.search-box:focus-within .search-icon {
    color: var(--accent-purple);
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 34px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    background: rgba(21, 21, 25, 0.9);
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ── Threshold Slider ──────────────────────────── */
.threshold-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.threshold-control input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

.threshold-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.threshold-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.6);
}

.threshold-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-purple);
    min-width: 42px;
    text-align: right;
}

/* ── Tabs ──────────────────────────────────────── */
.tab-group {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-md);
}

.tab-btn {
    flex: 1;
    padding: 7px 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    background: var(--accent-purple);
    color: white;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.35);
}

/* ── Checkboxes ────────────────────────────────── */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 0;
}

.checkbox-item input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-medium);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.checkbox-item input:checked + .checkmark {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.2);
}

.checkbox-item input:checked + .checkmark::after {
    content: '\2713';
    color: white;
    font-size: 10px;
    font-weight: 700;
}

.checkbox-item:hover .checkmark {
    border-color: var(--accent-purple);
}

/* ── Badges ────────────────────────────────────── */
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-high {
    background: rgba(0, 255, 136, 0.12);
    color: var(--accent-green);
}

.badge-medium {
    background: rgba(251, 191, 36, 0.12);
    color: var(--accent-yellow);
}

.badge-low {
    background: rgba(255, 51, 102, 0.12);
    color: var(--accent-red);
}

/* ── Catalyst Filter Tags ──────────────────────── */
.catalyst-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.catalyst-filter-tag {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.catalyst-filter-tag:hover {
    border-color: var(--accent-purple);
    color: var(--text-secondary);
    background: rgba(139, 92, 246, 0.05);
}

.catalyst-filter-tag.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.1);
}

/* ── Sort Select ───────────────────────────────── */
.sort-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.sort-select:focus {
    border-color: var(--accent-purple);
}

.sort-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Sidebar Footer ────────────────────────────── */
.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.api-note {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-muted);
}

.api-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-yellow);
    animation: blink 3s ease infinite;
}

/* ── Main Content ──────────────────────────────── */
.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    height: calc(100vh - 64px);
}

/* ── Stocks Grid ───────────────────────────────── */
.stocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

/* ── Stock Card ────────────────────────────────── */
.stock-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    animation: cardEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.stock-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0.5;
    transition: opacity var(--transition-normal);
}

.stock-card.gainer::before {
    background: linear-gradient(90deg, transparent 0%, var(--accent-green) 50%, transparent 100%);
}

.stock-card.loser::before {
    background: linear-gradient(90deg, transparent 0%, var(--accent-red) 50%, transparent 100%);
}

.stock-card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-3px);
}

.stock-card:hover::before {
    opacity: 1;
}

.stock-card.gainer {
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--accent-green-bg) 100%);
}

.stock-card.gainer:hover {
    border-color: var(--accent-green-border);
}

.stock-card.loser {
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--accent-red-bg) 100%);
}

.stock-card.loser:hover {
    border-color: var(--accent-red-border);
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* stagger animation */
.stock-card:nth-child(1)  { animation-delay: 0.02s; }
.stock-card:nth-child(2)  { animation-delay: 0.05s; }
.stock-card:nth-child(3)  { animation-delay: 0.08s; }
.stock-card:nth-child(4)  { animation-delay: 0.11s; }
.stock-card:nth-child(5)  { animation-delay: 0.14s; }
.stock-card:nth-child(6)  { animation-delay: 0.17s; }
.stock-card:nth-child(7)  { animation-delay: 0.20s; }
.stock-card:nth-child(8)  { animation-delay: 0.23s; }
.stock-card:nth-child(9)  { animation-delay: 0.26s; }
.stock-card:nth-child(10) { animation-delay: 0.29s; }
.stock-card:nth-child(11) { animation-delay: 0.32s; }
.stock-card:nth-child(12) { animation-delay: 0.35s; }
.stock-card:nth-child(13) { animation-delay: 0.38s; }
.stock-card:nth-child(14) { animation-delay: 0.41s; }
.stock-card:nth-child(15) { animation-delay: 0.44s; }
.stock-card:nth-child(16) { animation-delay: 0.47s; }
.stock-card:nth-child(17) { animation-delay: 0.50s; }
.stock-card:nth-child(18) { animation-delay: 0.53s; }

/* ── Card Header ───────────────────────────────── */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.ticker-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ticker-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    letter-spacing: 0.02em;
}

.watchlist-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-muted);
    padding: 0 2px;
    transition: all 0.15s ease;
    line-height: 1;
}
.watchlist-btn:hover { color: var(--accent-yellow); transform: scale(1.2); }
.watchlist-btn.active { color: var(--accent-yellow); }

.company-name {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exchange-badge {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

/* ── Sparkline ─────────────────────────────────── */
.sparkline-container {
    display: flex;
    align-items: flex-end;
    opacity: 0.8;
    transition: opacity var(--transition-normal);
    flex-shrink: 0;
}

.sparkline-container:hover {
    opacity: 1;
}

.price-change {
    text-align: right;
}

.price-change .percentage {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.gainer .percentage { color: var(--accent-green); }
.loser .percentage { color: var(--accent-red); }

.price-change .price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ── Confidence Badge ──────────────────────────── */
.card-confidence {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.card-confidence.high {
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent-green);
    border: 1px solid var(--accent-green-border);
}

.card-confidence.medium {
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-yellow);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.card-confidence.low {
    background: rgba(255, 51, 102, 0.1);
    color: var(--accent-red);
    border: 1px solid var(--accent-red-border);
}

.confidence-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Reason ────────────────────────────────────── */
.card-reason {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ── Catalyst Tags ─────────────────────────────── */
.card-catalysts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.catalyst-tag {
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.15);
}

.catalyst-tag.earnings {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.15);
}

.catalyst-tag.guidance {
    background: rgba(0, 255, 136, 0.08);
    color: var(--accent-green);
    border-color: var(--accent-green-border);
}

.catalyst-tag.fda,
.catalyst-tag.regulatory,
.catalyst-tag.fdaregulatory {
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-yellow);
    border-color: rgba(251, 191, 36, 0.15);
}

.catalyst-tag.ma,
.catalyst-tag.merger,
.catalyst-tag.partnership {
    background: rgba(236, 72, 153, 0.1);
    color: #ec4899;
    border-color: rgba(236, 72, 153, 0.15);
}

.catalyst-tag.downgrade,
.catalyst-tag.fraud,
.catalyst-tag.bankruptcy,
.catalyst-tag.bankruptcydistress,
.catalyst-tag.distress,
.catalyst-tag.debtcrisis,
.catalyst-tag.shortreport,
.catalyst-tag.fraudallegation,
.catalyst-tag.insiderselling,
.catalyst-tag.lockupexpiry {
    background: rgba(255, 51, 102, 0.08);
    color: var(--accent-red);
    border-color: var(--accent-red-border);
}

.catalyst-tag.sympathy,
.catalyst-tag.cryptorally {
    background: rgba(34, 211, 238, 0.1);
    color: #22d3ee;
    border-color: rgba(34, 211, 238, 0.15);
}

.catalyst-tag.clinicaltrial {
    background: rgba(52, 211, 153, 0.1);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.15);
}

.catalyst-tag.productlaunch,
.catalyst-tag.licensing,
.catalyst-tag.contractwin {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
    border-color: rgba(168, 85, 247, 0.15);
}

.catalyst-tag.aidatacenter {
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.15);
}

.catalyst-tag.executivechange,
.catalyst-tag.competition {
    background: rgba(244, 114, 182, 0.1);
    color: #f472b6;
    border-color: rgba(244, 114, 182, 0.15);
}

/* ── Context Stats ─────────────────────────────── */
.card-context {
    display: flex;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.context-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.context-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
}

.context-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Volume Bar ────────────────────────────────── */
.volume-bar-bg {
    width: 50px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.volume-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.gainer .volume-bar-fill { background: var(--accent-green); }
.loser .volume-bar-fill { background: var(--accent-red); }

/* ── Expanded Card ─────────────────────────────── */
.card-expanded-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.stock-card.expanded .card-expanded-content {
    max-height: 300px;
}

.evidence-section {
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}

.evidence-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.evidence-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--transition-fast);
    font-weight: 500;
}

.evidence-link:hover {
    color: var(--accent-purple);
}

.evidence-link .arrow {
    color: var(--text-muted);
    font-size: 10px;
    transition: transform var(--transition-fast);
}

.evidence-link:hover .arrow {
    transform: translateX(3px);
}

.expand-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 12px;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.stock-card:hover .expand-hint {
    opacity: 1;
}

.expand-hint .chevron {
    transition: transform var(--transition-fast);
}

.stock-card.expanded .expand-hint .chevron {
    transform: rotate(180deg);
}

/* ── Empty State ───────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 20px;
    opacity: 0.2;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.empty-state h3 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.empty-state p {
    font-size: 13px;
}

/* ── API Connect Button ───────────────────────── */
.api-connect-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.api-connect-btn:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.api-connect-btn.connected {
    border-color: var(--accent-green-border);
    color: var(--accent-green);
}

/* ── Modal ────────────────────────────────────── */
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    max-width: 480px;
    width: 90%;
    padding: 0;
    overflow: hidden;
    animation: scaleIn 0.2s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-desc a {
    color: var(--accent-purple);
    text-decoration: none;
}

.modal-field {
    margin-bottom: 16px;
}

.modal-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.modal-field input,
.modal-field select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}

.modal-field input:focus,
.modal-field select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-secondary {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
}

.btn-primary {
    padding: 8px 20px;
    background: var(--accent-purple);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    opacity: 0.9;
}

.modal-status {
    margin-top: 16px;
    font-size: 12px;
    text-align: center;
    color: var(--text-muted);
}

/* ── Mobile Menu Button ───────────────────────── */
.mobile-menu-btn {
    display: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.mobile-menu-btn span,
.mobile-menu-btn span::before,
.mobile-menu-btn span::after {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    position: absolute;
    left: 6px;
    transition: all var(--transition-fast);
}

.mobile-menu-btn span {
    top: 15px;
}

.mobile-menu-btn span::before {
    content: '';
    top: -6px;
}

.mobile-menu-btn span::after {
    content: '';
    top: 6px;
}

/* ── Sidebar Overlay (mobile backdrop) ───────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 199;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ── Toast Notifications ──────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 8px; font-size: 12px; font-weight: 500; color: white; backdrop-filter: blur(10px); animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.toast.info { background: rgba(139, 92, 246, 0.9); }
.toast.success { background: rgba(0, 200, 100, 0.9); }
.toast.error { background: rgba(255, 51, 102, 0.9); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }

/* ── Shortcuts Overlay ────────────────────────── */
.shortcuts-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.shortcuts-modal { background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); padding: 24px; max-width: 360px; width: 90%; }
.shortcuts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.shortcuts-header h3 { font-size: 15px; font-weight: 700; }
.shortcuts-list { display: flex; flex-direction: column; gap: 10px; }
.shortcut-item { display: flex; align-items: center; justify-content: space-between; }
.shortcut-item span { font-size: 12px; color: var(--text-secondary); }
kbd { padding: 3px 8px; background: var(--bg-tertiary); border: 1px solid var(--border-medium); border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-primary); min-width: 28px; text-align: center; }

/* ── Theme Toggle Button ─────────────────────────── */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: var(--glass-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.theme-toggle:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.25);
}

.theme-icon {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Dark theme (default): show sun, hide moon */
.theme-icon.sun {
    opacity: 1;
    transform: rotate(0deg);
}

.theme-icon.moon {
    opacity: 0;
    transform: rotate(-90deg);
}

/* Light theme: show moon, hide sun */
[data-theme="light"] .theme-icon.sun {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="light"] .theme-icon.moon {
    opacity: 1;
    transform: rotate(0deg);
}

/* ── Light Theme Overrides ───────────────────────── */
[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f1f3;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(245, 245, 255, 0.95);
    --bg-sidebar: rgba(250, 250, 255, 0.98);
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8888a0;
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(0, 0, 0, 0.02);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.12);
}

/* Light theme ambient background */
[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(0, 200, 136, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 60%);
}

/* Light theme scrollbar */
[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Light theme search focus adjustment */
[data-theme="light"] .search-box input:focus {
    background: rgba(255, 255, 255, 0.95);
}

/* Light theme logo gradient */
[data-theme="light"] .logo h1 {
    background: linear-gradient(135deg, #1a1a2e 0%, #6d28d9 50%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── News Ticker ──────────────────────────────── */
.news-ticker {
    display: flex;
    align-items: center;
    height: 32px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.ticker-label {
    padding: 0 12px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent-red);
    background: rgba(255, 51, 102, 0.08);
    border-right: 1px solid var(--border-subtle);
    height: 100%;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    animation: tickerPulse 2s ease infinite;
}

@keyframes tickerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ticker-track {
    flex: 1;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
}

.ticker-content {
    display: flex;
    gap: 40px;
    white-space: nowrap;
    animation: tickerScroll 60s linear infinite;
    padding-left: 100%;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.ticker-item .ticker-symbol {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
}

.ticker-item .ticker-change {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.ticker-item .ticker-change.up { color: var(--accent-green); }
.ticker-item .ticker-change.down { color: var(--accent-red); }

.ticker-item .ticker-headline {
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticker-separator {
    color: var(--text-muted);
    opacity: 0.3;
    flex-shrink: 0;
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ── Export Button ─────────────────────────────── */
.export-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.export-btn:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.05);
}

.export-btn:active {
    transform: scale(0.98);
}

/* ── Price Flash Animation ────────────────────── */
.price-flash {
    animation: priceFlash 0.6s ease;
}

@keyframes priceFlash {
    0% { opacity: 1; }
    30% { opacity: 0.4; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 1400px) {
    .stocks-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    }
}

@media (max-width: 1100px) {
    .header-center {
        display: none;
    }
}

@media (max-width: 900px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .stocks-grid {
        grid-template-columns: 1fr;
    }
    .main-content {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 0 12px;
        height: 56px;
    }
    .logo-tagline {
        display: none;
    }
    .header-right {
        gap: 8px;
    }
    .date-display {
        display: none;
    }
    .main-content {
        padding: 12px;
    }
    .stocks-grid {
        gap: 12px;
    }
    .stock-card {
        padding: 16px;
    }
    .price-change .percentage {
        font-size: 20px;
    }
}
