/* ══════════════════════════════════════════════
   NarrativeRadar – Bloomberg Terminal Intelligence
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ── */
:root {
    --bg-black: #000000;
    --bg-surface: #050505;
    --bg-panel: #0a0a0a;
    --bg-elevated: #111111;
    --bg-hover: #161616;
    --border: rgba(0, 255, 135, 0.12);
    --border-active: rgba(0, 255, 135, 0.35);
    --text: #c8d6c8;
    --text-bright: #e0ffe0;
    --text-muted: #5a6b5a;
    --text-dim: #3a4a3a;
    --accent: #00ff87;
    --accent-dim: rgba(0, 255, 135, 0.6);
    --accent-cyan: #00d4ff;
    --accent-red: #ff3b3b;
    --accent-yellow: #ffd600;
    --gradient-heat: linear-gradient(90deg, #00ff87 0%, #ffd600 50%, #ff3b3b 100%);
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
    --font-body: 'Inter', sans-serif;
    --radius: 4px;
    --radius-md: 6px;
    --transition: all 0.2s ease;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-black);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-size: 13px;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Scanline Overlay ── */
.scanlines {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px);
}

/* ── Container ── */
.terminal-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 12px 24px;
}

/* ── Top Bar ── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.terminal-brand {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
}

.brand-bracket {
    color: var(--text-dim);
}

.brand-name {
    color: var(--text);
}

.brand-accent {
    color: var(--accent);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--border-active);
    border-radius: var(--radius);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-link {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: var(--radius);
    transition: var(--transition);
}

.top-link:hover {
    color: var(--accent);
    border-color: var(--border);
    text-decoration: none;
    background: rgba(0, 255, 135, 0.03);
}

.top-controls {
    display: flex;
    gap: 6px;
    margin-left: 8px;
}

.terminal-select {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.terminal-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.terminal-btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.terminal-btn-primary:hover {
    background: var(--text-bright);
    box-shadow: 0 0 12px rgba(0, 255, 135, 0.3);
}

.terminal-btn-primary:active {
    transform: scale(0.97);
}

.mobile-toggle {
    display: none;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 18px;
    padding: 4px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-mono);
}

/* ── Mobile Controls ── */
.mobile-controls {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-bottom: 12px;
    background: var(--bg-panel);
}

.mobile-nav-links {
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
}

.mobile-nav-link {
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: var(--transition);
}

.mobile-nav-link:hover {
    background: rgba(0, 255, 135, 0.05);
    color: var(--accent);
    text-decoration: none;
}

.mobile-control-row {
    display: flex;
    gap: 8px;
}

.mobile-control-row .terminal-select {
    flex: 1;
}

/* ── Terminal Header ── */
.terminal-header {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 12px;
    background: var(--bg-panel);
    position: relative;
}

.terminal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.header-top-line {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.header-label {
    text-transform: uppercase;
}

.terminal-title {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(0, 255, 135, 0.3);
}

.cursor-blink {
    animation: cursorBlink 1s step-end infinite;
    color: var(--accent);
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.terminal-subtitle {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.header-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.header-metric {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    background: rgba(0, 255, 135, 0.02);
}

.metric-label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.metric-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-bright);
}

/* ── Dashboard Grid ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* ── Terminal Panels ── */
.terminal-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--bg-panel);
    margin-bottom: 12px;
}

.panel-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--accent-dim);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── Sidebar ── */
.sidebar {
    display: grid;
    align-content: start;
    gap: 0;
}

/* ── Watchlist Form ── */
.watchlist-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    margin-bottom: 12px;
}

.input-group {
    display: flex;
    align-items: center;
    background: var(--bg-black);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.input-prefix {
    padding: 0 0 0 8px;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 8px 8px;
    outline: none;
}

.terminal-input::placeholder {
    color: var(--text-dim);
}

/* ── Watchlist Tags ── */
.watchlist-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.watch-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
    background: rgba(0, 255, 135, 0.04);
    transition: var(--transition);
}

.watch-tag:hover {
    border-color: var(--border-active);
}

.watch-tag-remove {
    color: var(--accent-red);
    cursor: pointer;
    font-weight: 700;
}

.watch-tag-remove:hover {
    text-decoration: none;
}

/* ── Watch Hits ── */
.watch-hits-list {
    display: grid;
    gap: 8px;
}

.watch-hit-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    background: rgba(0, 255, 135, 0.02);
    transition: var(--transition);
}

.watch-hit-card:hover {
    border-color: var(--border-active);
    background: rgba(0, 255, 135, 0.04);
}

.watch-hit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.watch-hit-term {
    font-weight: 700;
    color: var(--text-bright);
    font-size: 12px;
}

.watch-hit-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--accent);
}

.watch-hit-item {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.5;
}

.watch-hit-item a {
    color: var(--text);
}

.watch-hit-item a:hover {
    color: var(--accent);
}

/* ── Narratives List ── */
.narratives-list {
    display: grid;
    gap: 8px;
}

.narrative-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--bg-surface);
    transition: var(--transition);
}

.narrative-card:hover {
    border-color: var(--border-active);
    transform: translateX(3px);
    background: var(--bg-elevated);
}

.narrative-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.narrative-rank {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--accent);
    letter-spacing: 0.08em;
}

.narrative-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-bright);
    margin-left: 10px;
    flex: 1;
}

.narrative-score {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

/* Heat map momentum bar */
.momentum-bar-track {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.momentum-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

.heat-green {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(0, 255, 135, 0.4);
}

.heat-yellow {
    background: var(--accent-yellow);
    box-shadow: 0 0 8px rgba(255, 214, 0, 0.4);
}

.heat-red {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(255, 59, 59, 0.4);
}

.narrative-meta {
    font-size: 10px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.narrative-headline {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 6px;
}

.narrative-headline a {
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
}

.narrative-headline a:hover {
    color: var(--accent);
}

.narrative-headline-meta {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 3px;
}

/* ── Headlines List ── */
.headlines-list {}

.headline-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.headline-item:last-child {
    border-bottom: none;
}

.headline-link {
    font-size: 13px;
    color: var(--text);
    line-height: 1.55;
    display: block;
}

.headline-link:hover {
    color: var(--accent);
}

.headline-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
}

.headline-source {
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
}

/* Details/Summary */
details summary {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    padding: 8px 0;
    letter-spacing: 0.04em;
}

details summary:hover {
    text-decoration: underline;
}

/* ── Footer ── */
.terminal-footer {
    text-align: center;
    font-size: 10px;
    color: var(--text-dim);
    padding: 16px 0;
    border-top: 1px solid var(--border);
    letter-spacing: 0.06em;
}

.footer-sep {
    margin: 0 8px;
    opacity: 0.4;
}

/* ── Responsive ── */
.desktop-only {
    display: flex;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .header-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-toggle {
        display: block;
    }

    .terminal-title {
        font-size: 20px;
    }

    .terminal-header {
        padding: 14px;
    }

    .terminal-panel {
        padding: 12px;
    }

    .header-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .watchlist-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .terminal-container {
        padding: 0 8px 20px;
    }

    .header-metrics {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .terminal-title {
        font-size: 17px;
    }
}

/* ── Utilities ── */
.text-empty {
    font-size: 11px;
    color: var(--text-dim);
    padding: 12px 0;
}