:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --border: #2a3042;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-green: #22c55e;
    --accent-green-dim: rgba(34, 197, 94, 0.15);
    --accent-blue: #60a5fa;
    --accent-blue-bright: #3b82f6;
    --accent-blue-dim: rgba(59, 130, 246, 0.15);
    --line-color: #60a5fa;
    --point-color: #93c5fd;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent-blue), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timeframe-badge {
    padding: 4px 12px;
    background: var(--accent-blue-dim);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-blue);
}

.reset-zoom-btn {
    padding: 4px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.reset-zoom-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.controls-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── Ticker search ── */

.ticker-search {
    position: relative;
    flex-shrink: 0;
}

.ticker-input {
    width: 110px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.15s ease;
}

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

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

.ticker-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.ticker-dropdown.open {
    display: block;
}

.ticker-dropdown-item {
    padding: 7px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.1s ease;
}

.ticker-dropdown-item:hover,
.ticker-dropdown-item.highlighted {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
}

.ticker-dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.ticker-dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.ticker-dropdown-empty {
    padding: 7px 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Timeframe toggle ── */

.timeframe-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
    flex-shrink: 0;
}

.tf-btn {
    padding: 5px 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tf-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.tf-btn.active {
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
}

/* ── Ticker buttons ── */

.ticker-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex: 1;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ticker-buttons::-webkit-scrollbar {
    display: none;
}

.ticker-btn {
    padding: 6px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}

.ticker-btn:hover {
    border-color: var(--accent-blue-bright);
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
}

.ticker-btn.active {
    background: var(--accent-blue-dim);
    border-color: var(--accent-blue-bright);
    color: var(--accent-blue);
}

/* ── Chart type toggle ── */

.chart-type-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
    flex-shrink: 0;
    margin-left: auto;
}

.type-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.type-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.type-btn.active {
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
}

/* ── Chart ── */

.chart-wrapper {
    flex: 1;
    padding: 12px 16px 8px;
    position: relative;
    min-height: 0;
}

.chart-wrapper canvas {
    display: block;
}

/* ── Loading overlay ── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Paywall ── */

.paywall-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
}

.paywall-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 36px 40px;
    text-align: center;
}

.paywall-icon {
    color: var(--accent-blue);
    margin-bottom: 20px;
}

.paywall-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--accent-blue), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.paywall-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 28px;
}

.paywall-btn {
    display: inline-block;
    padding: 12px 32px;
    background: var(--accent-blue-bright);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.paywall-btn:hover {
    background: #2563eb;
}

/* ── Login modal ── */

.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
}

.login-modal {
    width: 100%;
    max-width: 380px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 32px 32px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--accent-blue), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-field {
    margin-bottom: 18px;
}

.login-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}

.login-input::placeholder {
    color: var(--text-muted);
}

.login-input:focus {
    border-color: var(--accent-blue-bright);
}

.login-error {
    color: #f87171;
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 8px;
    text-align: center;
}

.login-btn {
    width: 100%;
    padding: 11px;
    background: var(--accent-blue-bright);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.login-btn:hover {
    background: #2563eb;
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .header {
        padding: 10px 14px;
    }

    .logo {
        font-size: 15px;
    }

    .controls-bar {
        padding: 8px 14px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .ticker-input {
        width: 90px;
        padding: 5px 10px;
        font-size: 12px;
    }

    .ticker-btn {
        padding: 5px 14px;
        font-size: 12px;
    }

    .chart-wrapper {
        padding: 8px 8px 4px;
    }

    .timeframe-badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    .reset-zoom-btn {
        font-size: 11px;
        padding: 3px 8px;
    }
}
