/* ============================================
   NiveshIQ Site-Wide Shared Styles
   Includes: Theme CSS Variables, Header, Auth Modal
   ============================================ */

/* ============ CSS Variables for Light/Dark Themes ============ */
:root {
    /* Light theme (default) */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-hover: rgba(0, 0, 0, 0.12);
    --accent: #007AFF;
    --accent-hover: #0051D5;
    --success: #34C759;
    --danger: #FF3B30;
    --warning: #FF9500;
    --card-bg: #ffffff;
    --modal-bg: #ffffff;
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --input-bg: #ffffff;
    --input-border: #d0d0d0;
}

/* Dark theme */
.theme-dark, body.dark-mode {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-color: #333333;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --card-bg: #1a1a1a;
    --modal-bg: #1a1a1a;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --input-bg: #2a2a2a;
    --input-border: #444444;
}

/* ============ Base Document ============ */
html { box-sizing: border-box; }
*, *::before, *::after {
    box-sizing: inherit;
    overflow-wrap: anywhere;
    word-break: break-word;
}
img { max-width: 100%; height: auto; }

/* Horizontal-scroll wrapper for wide tables */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; line-height: 1.2; }
p { margin: 0; }

/* ============ Base Transitions ============ */
body, .site-header, .auth-modal, input, button, .card, .modal-content {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ============ Site Header ============ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

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

.site-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.site-logo:hover {
    color: var(--accent-hover);
}

.site-header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
}

.site-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

.site-nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.site-nav-link.active {
    background: var(--accent);
    color: #fff;
}

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

/* Theme Toggle Switch */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: 16px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--border-color);
}

.theme-toggle-icon {
    font-size: 16px;
}

/* Login/Account Button */
.auth-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-btn:hover {
    background: var(--accent);
    color: #fff;
}

.auth-btn.logged-in {
    background: var(--accent);
    color: #fff;
}

/* ============ Auth Modal ============ */
.auth-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.auth-modal-overlay.active {
    display: flex;
}

.auth-modal {
    background: var(--modal-bg);
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px var(--shadow-hover);
    position: relative;
}

.auth-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-tertiary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.auth-modal-close:hover {
    background: var(--border-color);
    transform: rotate(90deg);
}

.auth-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 24px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab:hover {
    background: var(--border-color);
}

.auth-tab.active {
    background: var(--accent);
    color: #fff;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.auth-field input {
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s;
}

.auth-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.auth-field input::placeholder {
    color: var(--text-tertiary);
}

.auth-field-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ── Phone input with fixed +91 country-code prefix ─────────────────────── */
.phone-input-wrapper {
    display: flex;
    align-items: center;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.phone-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}
.phone-prefix {
    padding: 12px 10px 12px 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    user-select: none;
    border-right: 1px solid var(--input-border);
    background: var(--input-bg);
}
.phone-input-wrapper input {
    flex: 1;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 12px 16px 12px 10px;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    min-width: 0;
}
.phone-input-wrapper input:focus {
    outline: none;
    border: none !important;
    box-shadow: none !important;
}
/* ─────────────────────────────────────────────────────────────────────────── */

.auth-submit {
    padding: 14px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.auth-submit:hover {
    background: var(--accent-hover);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-error {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

.auth-divider {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 12px;
    margin: 8px 0;
}

/* ============ Google & Method Buttons ============ */
.auth-google-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-google-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.auth-google-btn svg {
    flex-shrink: 0;
}

.auth-method-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-method-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.auth-back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 8px;
    transition: color 0.2s;
}

.auth-back-btn:hover {
    color: var(--accent);
}

.auth-resend-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    padding: 12px;
    margin-top: 8px;
    transition: opacity 0.2s;
}

.auth-resend-btn:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Signup steps container */
.signup-step {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#signup-container {
    display: flex;
    flex-direction: column;
}

/* OTP input styling */
#signup-otp {
    font-size: 24px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: 600;
}

/* ============ Gating Overlay for Locked Content ============ */
.gated-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    border-radius: inherit;
    z-index: 10;
}

.gated-overlay-icon {
    font-size: 48px;
}

.gated-overlay-text {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    text-align: center;
}

.gated-overlay-btn {
    padding: 12px 24px;
    border-radius: 24px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.gated-overlay-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

/* Blurred/Locked rows in table */
.locked-row {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .site-header {
        flex-wrap: wrap;
        padding: 12px 16px;
    }
    
    .site-header-nav {
        margin-left: 0;
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
    
    .site-nav-link {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .auth-modal {
        padding: 24px;
    }
}

/* ============ Utility Classes ============ */
.positive-text { color: var(--success) !important; }
.negative-text { color: var(--danger) !important; }
.text-muted { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }

/* ── Card ── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 4px var(--shadow);
}

/* ── Pill badge ── */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1px;
    cursor: pointer;
    transition: background .2s, box-shadow .2s, opacity .2s;
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover    { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(0,122,255,0.25); }
.btn:active   { opacity: .9; }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }

/* Ghost / secondary button */
.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    box-shadow: none;
}
.btn-secondary:hover {
    background: rgba(0, 122, 255, 0.07);
    box-shadow: none;
    color: var(--accent);
}

/* ── Select / dropdown ── */
.select-styled {
    appearance: none; -webkit-appearance: none;
    padding: 10px 36px 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    box-shadow: 0 2px 8px var(--shadow);
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
}
.select-styled:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* ── Live dot indicator ── */
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: live-pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.85); }
}

/* ── Stat chip (small key-value metric pill) ── */
.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}
.stat-chip-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-tertiary);
}
.stat-chip-value { font-weight: 700; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border-color); margin: 20px 0; }

/* ── Clickable table rows ── */
.clickable-row {
    cursor: pointer;
    transition: background .15s;
}
.clickable-row:hover  { background: rgba(0, 122, 255, 0.06); }
.clickable-row:active { opacity: .92; }

/* ── Skeleton loading ── */
@keyframes skeleton-shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}
.skeleton {
    display: inline-block;
    background: linear-gradient(
        90deg,
        var(--bg-tertiary)   25%,
        var(--border-color)  50%,
        var(--bg-tertiary)   75%
    );
    background-size: 1200px 100%;
    animation: skeleton-shimmer 1.5s infinite linear;
    border-radius: 6px;
}

/* ── Spacing scale helpers ── */
.mt-4  { margin-top:  4px; }
.mt-8  { margin-top:  8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom:  8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* ═══════════════════════════════════════════════════════════════
   PREMIUM DESIGN SYSTEM — Layout & Components
   ═══════════════════════════════════════════════════════════════ */

/* ── Container ── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ── Page Header banner ── */
.page-header {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 22px 28px;
    margin-bottom: 24px;
    box-shadow: 0 1px 4px var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
.page-header-title    { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.page-header-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }

/* ── Section wrappers ── */
.section { margin-bottom: 32px; }
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}
.section-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}
.section-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px 8px;
    margin-left: 2px;
}
.section-controls { margin-left: auto; }

/* ── Grid utilities ── */
.grid      { display: grid; gap: 16px; }
.grid-2    { grid-template-columns: repeat(2, 1fr); }
.grid-3    { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}
.badge-positive { background: rgba(52, 199, 89, 0.15);  color: var(--success); }
.badge-negative { background: rgba(255, 59, 48, 0.15);  color: var(--danger);  }
.badge-neutral  { background: rgba(153,153,153, 0.15);  color: var(--text-secondary); }

/* ── Sentiment / change text helpers ── */
.positive-text, .pos { color: var(--success); }
.negative-text, .neg { color: var(--danger);  }

/* ── Shared loading & empty states ── */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: _spin 1s linear infinite;
    margin: 0 auto 20px;
}
@keyframes _spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
    font-size: 16px;
}

/* ── Hero section ── */
.hero {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: 20px;
    padding: 52px 48px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 4px var(--shadow);
}
.hero::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -60px;
    width: 340px;
    height: 340px;
    background: radial-gradient(circle, rgba(0,122,255,0.07) 0%, transparent 70%);
    pointer-events: none;
}
.hero-eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}
.hero-title {
    font-size: clamp(28px, 6vw, 52px);
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1.12;
    color: var(--text-primary);
    margin-bottom: 16px;
}
.hero-subtitle {
    font-size: clamp(14px, 3.5vw, 18px);
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 28px;
}
.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.hero-actions .btn,
.hero-actions .btn-secondary {
    padding: 13px 28px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 12px;
}

/* ── Feature / navigation cards ── */
.feature-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 4px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    text-decoration: none;
    display: block;
    color: var(--text-primary);
}
.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px var(--shadow-hover);
    border-color: rgba(0,122,255,0.4);
    text-decoration: none;
}
.feature-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}
.feature-card-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.feature-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── Responsive breakpoints for grid/layout ── */

/* Tablet — ≤ 980px */
@media (max-width: 980px) {
    .site-header {
        flex-wrap: wrap;
        padding: 10px 16px;
        gap: 10px;
    }
    .site-header-nav {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar visually but keep scrollable */
        scrollbar-width: none;
        margin-left: 0;
    }
    .site-header-nav::-webkit-scrollbar { display: none; }
    .site-header-right {
        margin-left: auto;
        flex-shrink: 0;
    }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .hero { padding: 40px 32px; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* Phone — ≤ 640px */
@media (max-width: 640px) {
    .site-header {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
    }
    .site-header-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin-left: 0;
        padding: 6px 0 4px;
        border-top: 1px solid var(--border-color);
    }
    .site-header-nav::-webkit-scrollbar { display: none; }
    .site-nav-link {
        padding: 7px 10px;
        font-size: 13px;
    }
    .hero { padding: 28px 18px; }
    .hero-actions .btn,
    .hero-actions .btn-secondary { padding: 11px 20px; font-size: 14px; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-auto { grid-template-columns: 1fr; }
    .page-header { padding: 14px 16px; }
    .page-header-title { font-size: 20px; }
    .card { padding: 12px; }
    .container { padding: 12px; }
}

/* Legacy 768px block kept for backward compat */
@media (max-width: 768px) {
    .hero { padding: 36px 24px; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .page-header { padding: 18px 20px; }
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL PULSE — Story feed, Drivers, Tabs
   ═══════════════════════════════════════════════════════════════ */

/* Macro drivers grid */
.drivers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}
.driver-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 18px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 4px var(--shadow);
}
.driver-name  { font-size: 12px; color: var(--text-tertiary); margin-bottom: 8px; }
.driver-value { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.driver-change { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.driver-up    { color: var(--success); }
.driver-down  { color: var(--danger); }
.driver-stable { color: var(--text-tertiary); }
.driver-note  { font-size: 11px; color: var(--text-secondary); }

/* Story card */
.story-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 22px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 4px var(--shadow);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.story-card:hover {
    box-shadow: 0 4px 16px var(--shadow-hover);
    border-color: rgba(0,122,255,0.2);
}
.story-headline { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.story-headline a { color: var(--text-primary); text-decoration: none; }
.story-headline a:hover { color: var(--accent); }
.story-brief {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}
.story-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.story-source { font-size: 12px; color: var(--text-secondary); }

/* Tags row */
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Polarity / impact badges */
.polarity-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.polarity-positive { background: rgba(52,199,89,0.2);  color: var(--success); }
.polarity-negative { background: rgba(255,59,48,0.2);  color: var(--danger); }
.polarity-neutral  { background: rgba(153,153,153,0.2); color: var(--text-tertiary); }
.impact-badge {
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: 12px;
    font-size: 11px;
    color: var(--accent);
}

/* Related articles block */
.related-articles {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.related-title {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.related-link {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    text-decoration: none;
    padding: 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.related-link:hover { color: var(--accent); }

/* Updating / warming label */
.updating-label {
    display: inline-block;
    background: rgba(0,122,255,0.15);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 12px;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* Sector heatmap chips (demo homepage) */
.heatmap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}
.sector-chip {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 12px 16px;
    text-align: center;
    border: 1px solid var(--border-color);
}
.sector-positive { border-color: var(--success); }
.sector-negative { border-color: var(--danger); }
.sector-name   { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.sector-direction { font-size: 12px; color: var(--text-tertiary); }
.last-updated  { text-align: center; color: var(--text-secondary); font-size: 12px; margin-top: 20px; }

/* Pulse tab toggle */
.pulse-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.pulse-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit;
}
.pulse-tab-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pulse-tab-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.tab-count {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
}
.pulse-tab-btn.active .tab-count { background: rgba(255,255,255,0.3); }

/* Discuss CTA link */
.discuss-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(0,122,255,0.12);
    border: 1px solid rgba(0,122,255,0.3);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    margin-left: auto;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.discuss-link:hover {
    background: rgba(0,122,255,0.22);
    border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   ACCOUNT DROPDOWN
   ═══════════════════════════════════════════════════════════════ */

/* Wrapper gives us the relative anchor for absolute dropdown */
.account-menu-wrap {
    position: relative;
    display: inline-flex;
}

/* The dropdown panel */
.account-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 8px 28px var(--shadow-hover);
    z-index: 200;
    padding: 6px 0;
    animation: dropdown-fade-in 0.15s ease;
}

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

@keyframes dropdown-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Links / buttons inside the dropdown */
.account-dropdown-item {
    display: block;
    width: 100%;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    box-sizing: border-box;
}

.account-dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.account-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.account-dropdown-logout {
    color: var(--danger);
}

.account-dropdown-logout:hover {
    background: rgba(255, 59, 48, 0.08);
    color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════
   HERO — no-CTA variant (home page)
   ═══════════════════════════════════════════════════════════════ */

.hero.hero-no-cta {
    padding-bottom: 44px;
}

.hero.hero-no-cta .hero-subtitle {
    margin-bottom: 0;
    font-size: clamp(14px, 3.5vw, 17px);
    line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════════
   LEGAL / INFO PAGE TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════ */

.legal-page {
    max-width: 760px;
    margin: 40px auto;
    padding: 0 20px 60px;
}

.legal-page-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 28px;
    padding: 8px 0;
    transition: opacity 0.2s;
}

.legal-page-back:hover { opacity: 0.75; }

.legal-page h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.legal-page .legal-meta {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 36px;
}

.legal-page h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 36px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.legal-page p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 14px;
}

.legal-page ul, .legal-page ol {
    padding-left: 22px;
    margin-bottom: 14px;
}

.legal-page li {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 6px;
}

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

.legal-page a:hover { text-decoration: underline; }

.legal-contact-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px 28px;
    margin-top: 24px;
    box-shadow: 0 1px 4px var(--shadow);
}

.legal-contact-box h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.legal-contact-box p {
    margin-bottom: 6px;
    font-size: 14px;
}

/* ============ Auth Gate Card (shared across pages) ============ */
.auth-gate {
    max-width: 560px;
    margin: 48px auto;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, #e8eaed);
    border-radius: 20px;
    padding: 48px 40px 40px;
    text-align: center;
    box-shadow: 0 4px 24px var(--shadow, rgba(0,0,0,0.07));
}
.auth-gate-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 20px;
}
.auth-gate-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    margin-bottom: 10px;
}
.auth-gate-subtitle {
    font-size: 15px;
    color: var(--text-secondary, #666);
    line-height: 1.6;
    margin-bottom: 28px;
}
.auth-gate-bullets {
    list-style: none;
    padding: 0;
    margin: 0 0 32px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}
.auth-gate-bullets li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary, #666);
}
.auth-gate-bullets li::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 122, 255, 0.12);
    color: var(--accent, #007AFF);
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.auth-gate-btn {
    display: inline-block;
    padding: 14px 36px;
    border-radius: 12px;
    border: none;
    background: var(--accent, #007AFF);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(0,122,255,0.25);
}
.auth-gate-btn:hover {
    background: var(--accent-hover, #0051D5);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,122,255,0.35);
}
/* Compact version for modals */
.auth-gate.auth-gate--modal {
    margin: 24px auto;
    padding: 36px 28px 28px;
    border: none;
    box-shadow: none;
    background: transparent;
}
@media (max-width: 600px) {
    .auth-gate {
        padding: 32px 20px 28px;
        margin: 24px auto;
        border-radius: 16px;
    }
    .auth-gate-title { font-size: 19px; }
    .auth-gate-btn { width: 100%; text-align: center; }
}
