:root {
    --bg-primary: #0a0e17;
    --bg-card: #111827;
    --bg-card-hover: #1a2332;
    --border: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --green: #10b981;
    --green-dim: #065f46;
    --red: #ef4444;
    --red-dim: #7f1d1d;
    --amber: #f59e0b;
    --amber-dim: #78350f;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --cyan: #06b6d4;
}

* { box-sizing: border-box; }

/* Header layout */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 8px;
    flex-wrap: wrap;
}

.header-brand {
    max-width: 280px;
    flex-shrink: 1;
    min-width: 0;
}

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

@media (max-width: 640px) {
    .header-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .header-brand {
        max-width: 100%;
    }
    .header-controls {
        display: grid !important;
        grid-template-columns: 1fr auto auto;
        gap: 6px;
        width: 100%;
    }
    .header-controls .ticker-select {
        width: 100% !important;
        min-width: 0 !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .header-controls .ticker-input {
        width: 55px !important;
    }
    .header-controls .btn-validate {
        white-space: nowrap;
    }
    .header-controls .auto-validate-wrap {
        display: none;
    }
}

/* Header scrolling text */
.header-scroll-wrap {
    overflow: hidden;
    white-space: nowrap;
    mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}

.header-scroll-text {
    display: inline-block;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: #64748b;
    letter-spacing: 0.05em;
    animation: header-scroll 12s linear infinite;
    padding-right: 3em;
}

.header-scroll-text::after {
    content: "Jenie Finance by WEBSUITE.. Human Being still at work..";
    padding-left: 3em;
}

@keyframes header-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 12px 16px;
    background: linear-gradient(135deg, #111827 0%, #1a2332 100%);
    border-top: 1px solid var(--green);
    box-shadow: 0 -4px 24px rgba(16,185,129,0.15);
    animation: pwa-slide-up 0.4s ease-out;
}

.pwa-install-banner.hidden {
    display: none;
}

.pwa-install-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-install-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}

.pwa-install-text {
    flex: 1;
    min-width: 0;
}

.pwa-install-title {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: #e2e8f0;
}

.pwa-install-desc {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #64748b;
    margin-top: 2px;
}

.pwa-install-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.pwa-install-btn:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    transform: translateY(-1px);
    box-shadow: 0 2px 12px rgba(16,185,129,0.3);
}

.pwa-dismiss-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid #334155;
    border-radius: 50%;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.pwa-dismiss-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

@keyframes pwa-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.card-hover:hover {
    background: var(--bg-card-hover);
    transition: background 0.2s;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--blue); }

.metric-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.metric-value {
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.compression-bar {
    position: relative;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.compression-fill {
    position: absolute;
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.compression-marker {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 16px;
    border-radius: 1px;
    transform: translateX(-50%);
}

#chart-container {
    position: relative;
    width: 100%;
    min-height: 380px;
}

.chart-wrapper {
    display: flex;
    gap: 0;
}

.chart-main {
    flex: 1;
    min-width: 0;
}

.volume-profile {
    width: 60px;
    flex-shrink: 0;
}

.news-marker {
    cursor: pointer;
    padding: 6px 10px;
    border-left: 3px solid transparent;
    transition: background 0.15s;
}

.news-marker:hover {
    background: var(--bg-card-hover);
}

.news-marker.bullish { border-left-color: var(--green); }
.news-marker.bearish { border-left-color: var(--red); }
.news-marker.neutral { border-left-color: var(--amber); }

.decision-banner {
    background: linear-gradient(135deg, rgba(16,185,129,0.08) 0%, rgba(6,182,212,0.08) 100%);
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: 8px;
    padding: 12px 16px;
}

.decision-banner.bearish-setup {
    background: linear-gradient(135deg, rgba(239,68,68,0.08) 0%, rgba(245,158,11,0.08) 100%);
    border-color: rgba(239,68,68,0.25);
}

.decision-banner.momentum-setup {
    background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(139,92,246,0.08) 100%);
    border-color: rgba(59,130,246,0.25);
}

.prob-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
}

.prob-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.ticker-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    outline: none;
    cursor: pointer;
    min-height: 32px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 20px;
}

.ticker-select:focus {
    border-color: var(--blue);
}

.ticker-select optgroup {
    color: var(--text-muted);
    font-style: normal;
    font-size: 9px;
}

.ticker-select option {
    color: var(--text-primary);
    background: var(--bg-card);
    font-size: 9px;
    padding: 1px 4px;
}

.ticker-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    outline: none;
    width: 70px;
    min-height: 32px;
    text-transform: uppercase;
}

.ticker-input::placeholder {
    color: var(--text-muted);
    text-transform: none;
}

.ticker-input:focus {
    border-color: var(--blue);
}

/* Ticker changes bar (always visible, responsive) */
.ticker-changes-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
    margin-bottom: 6px;
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
}

.ticker-changes-bar.hidden { display: none; }

.tcb-ticker {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 11px;
    min-width: 42px;
}

.tcb-val {
    font-size: 10px;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Validate Button ────────────────────────────────── */

.btn-validate {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 32px;
}

.btn-validate:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--green);
}

.btn-validate.validating {
    background: var(--amber-dim);
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.3);
    cursor: wait;
}

.btn-validate.validate-success {
    background: rgba(16, 185, 129, 0.25);
    border-color: var(--green);
    color: var(--green);
}

.btn-validate.validate-error {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ── Spinner ────────────────────────────────────────── */

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}

.validating .spinner {
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Auto-Validate Toggle ───────────────────────────── */

.auto-validate-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-track.active {
    background: var(--green-dim);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}

.toggle-track.active .toggle-thumb {
    left: 18px;
    background: var(--green);
}

.auto-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auto-interval {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ── Validation Status Bar ──────────────────────────── */

.validation-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.mock {
    background: var(--amber);
}

.status-dot.live {
    background: var(--green);
    animation: pulse-dot 2s ease infinite;
}

.status-dot.error {
    background: var(--red);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-label {
    color: var(--text-muted);
}

.status-label.live {
    color: var(--green);
}

.status-label.error {
    color: var(--red);
}

.status-time {
    color: var(--text-muted);
    margin-left: auto;
}

/* ── Key Levels ─────────────────────────────────────── */

.levels-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.level-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 4px;
    transition: background 0.15s;
    font-family: 'JetBrains Mono', monospace;
}

.level-row:hover {
    background: var(--bg-card-hover);
}

.level-row.strongest {
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.level-row.strongest-res {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.level-price {
    font-size: 13px;
    font-weight: 600;
    min-width: 70px;
    font-variant-numeric: tabular-nums;
}

.level-dist {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 48px;
    text-align: right;
}

.level-vol-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.level-vol-bar-bg {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    min-width: 30px;
}

.level-vol-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.level-vol-label {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
}

.level-tag {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}

.level-tag.defended {
    background: var(--green-dim);
    color: var(--green);
}

.level-tag.fragile {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

.level-tag.magnet {
    background: rgba(6, 182, 212, 0.15);
    color: var(--cyan);
}

.level-tag.untested {
    background: rgba(139, 92, 246, 0.12);
    color: var(--purple);
}

.level-touches {
    font-size: 9px;
    color: var(--text-muted);
    min-width: 18px;
    text-align: center;
}

.level-bias {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.levels-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.levels-summary-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.levels-summary-item .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Sentiment no-data overlay */
.sentiment-no-data {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10,14,23,0.7);
    border-radius: 6px;
    gap: 4px;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    pointer-events: none;
    z-index: 2;
}

@media (max-width: 640px) {
    .metric-value { font-size: 14px; }
    .card { padding: 12px; }
    #chart-container { min-height: 300px; }
    .level-vol-wrap { display: none; }
    .level-dist { min-width: 38px; font-size: 9px; }
    .level-tag { font-size: 8px; padding: 1px 3px; }
    .level-touches { display: none; }
}
