/* ============================================
   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; }
a, button, input, select, textarea { min-width: 0; }

/* 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;
    min-width: 0;
}

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

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

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

.site-header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
    justify-content: flex-start;
    min-width: 0;
    overflow-anchor: none;          /* prevent auto-scroll to .active item */
    scroll-behavior: auto;
}
/* If the browser tries to scrollIntoView() the active link, this large
   scroll-margin makes the calculation resolve to scrollLeft ~= 0. */
.site-header-nav .site-nav-link.active {
    scroll-margin-inline-start: 100vw;
}

.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;
    white-space: nowrap;
    flex-shrink: 0;
}

.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;
    flex-shrink: 0;
    min-width: 0;
}
.site-header-right .auth-btn,
.site-header-right .theme-toggle { white-space: nowrap; flex-shrink: 0; }

/* 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: flex-start;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .site-header-nav::-webkit-scrollbar { display: none; }
    
    .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 — ≤ 1024px (covers iPad portrait at 1024 too) */
@media (max-width: 1024px) {
    .site-header {
        flex-wrap: wrap;
        padding: 10px 16px;
        gap: 10px;
        row-gap: 6px;
        align-items: center;
    }
    /* Flatten .site-header-left so logo + nav + right become direct
       flex children of .site-header. This lets the nav wrap onto
       its own row while the right-controls stay next to the logo. */
    .site-header-left { display: contents; }
    .site-logo { order: 1; flex: 0 0 auto; }
    .site-header-right { order: 2; margin-left: auto; flex: 0 0 auto; }
    .site-header-nav {
        order: 3;
        flex: 1 0 100%;
        width: 100%;
        margin: 4px 0 0;
        padding: 6px 4px 2px;
        border-top: 1px solid var(--border-color);
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
        justify-content: flex-start;
        scroll-padding-left: 8px;   /* keep first item fully visible if browser auto-scrolls */
    }
    .site-header-nav::-webkit-scrollbar { display: none; }
    .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);
        justify-content: flex-start;
    }
    .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; }
}

.earnings-tracker-promo-wrap {
    margin-bottom: 18px;
}

.earnings-tracker-promo {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: min(100%, 420px);
    padding: 13px 18px;
    border-radius: 16px;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border-color));
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, var(--bg-secondary)) 0%, var(--bg-secondary) 72%);
    box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 8%, transparent);
    text-decoration: none;
    color: var(--text-primary);
    overflow: hidden;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.earnings-tracker-promo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 18%, color-mix(in srgb, #ffffff 40%, transparent) 50%, transparent 82%);
    transform: translateX(-130%);
    animation: trackerPromoSweep 3.4s ease-in-out infinite;
    pointer-events: none;
}

.earnings-tracker-promo:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border-color));
    box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 14%, transparent);
}

.earnings-tracker-promo__icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-tertiary));
    border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border-color));
    flex: 0 0 auto;
}

.earnings-tracker-promo__icon {
    font-size: 19px;
    animation: trackerPromoBounce 1.8s ease-in-out infinite;
}

.earnings-tracker-promo__pulse {
    position: absolute;
    right: -2px;
    top: -2px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--danger);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.55);
    animation: trackerPromoPing 1.4s ease-out infinite;
}

.earnings-tracker-promo__copy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.earnings-tracker-promo__live {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    animation: pulse 1.5s ease-in-out infinite;
}

.earnings-tracker-promo__arrow {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 700;
}

@keyframes trackerPromoSweep {
    0%, 72%, 100% { transform: translateX(-130%); }
    30%, 55% { transform: translateX(130%); }
}

@keyframes trackerPromoBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1.5px); }
}

@keyframes trackerPromoPing {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.5);
        opacity: 1;
    }
    75% {
        transform: scale(1.2);
        box-shadow: 0 0 0 10px rgba(255, 59, 48, 0);
        opacity: 0.95;
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .earnings-tracker-promo {
        width: 100%;
    }

    .earnings-tracker-promo__copy {
        flex-wrap: wrap;
        row-gap: 4px;
    }
}

/* 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;
    min-width: 0;
}

/* The dropdown panel */
.account-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 24px));
    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; }
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL RESPONSIVE LAYER
   Targets: phones (iOS/Android), tablets, laptops, desktops, ultra-wide
   Applied LAST so it overrides per-page styles. Uses the
   meta viewport (width=device-width, initial-scale=1, viewport-fit=cover)
   on every page.
   ═══════════════════════════════════════════════════════════════ */

/* Prevent unwanted horizontal scroll on the document itself.
   Use overflow-x: clip so position: sticky on .site-header still works.
   Older browsers fall back to the previous declaration (no clipping). */
html, body { max-width: 100%; }
@supports (overflow-x: clip) {
    html { overflow-x: clip; }
}

/* Honor iOS safe areas (notch, home indicator) for sticky/fixed UI. */
@supports (padding: max(0px)) {
    .site-header {
        padding-left: max(24px, env(safe-area-inset-left));
        padding-right: max(24px, env(safe-area-inset-right));
        padding-top: max(12px, env(safe-area-inset-top));
    }
    .container,
    .admin-wrap,
    .et-container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Form controls inherit the page font and never zoom Safari on focus
   (font-size must be ≥ 16px on iOS to disable auto-zoom). */
input, select, textarea, button { font-family: inherit; }
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input:not([type]),
select,
textarea {
    font-size: 16px;
    max-width: 100%;
}

/* Anything that includes a wide table should never push the layout. */
table { max-width: 100%; }

/* Media stays fluid by default. */
img, video, canvas, svg, iframe { max-width: 100%; height: auto; }

/* ── Small laptop / large tablet — ≤ 1280px ── */
@media (max-width: 1280px) {
    .container { padding: 18px; }
}

/* ── Tablet landscape — ≤ 1024px ── */
@media (max-width: 1024px) {
    .container { padding: 16px; }
    .hero { padding: 44px 36px; }
    .page-header { padding: 20px 22px; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    /* Stock-comprehensive top bar collapses */
    .top-bar { flex-wrap: wrap; gap: 12px; }
    .search-container { max-width: 100%; flex: 1 1 100%; }
}

/* ── Tablet portrait / small laptop — ≤ 820px ── */
@media (max-width: 820px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .section-header { gap: 8px; }
    .section-controls { margin-left: 0; width: 100%; }
    .hero-title { font-size: clamp(28px, 6vw, 40px); }
    .hero-subtitle { font-size: 14px; }
}

/* ── Phones — ≤ 640px (iOS / Android) ── */
@media (max-width: 640px) {
    body {
        padding: 0 !important;                         /* override per-page padding */
        overflow-x: hidden;
        padding-bottom: max(96px, calc(env(safe-area-inset-bottom, 0px) + 88px)) !important;
    }
    .container { padding: 12px 12px max(112px, calc(env(safe-area-inset-bottom, 0px) + 96px)); max-width: 100%; }
    .admin-wrap { padding: 16px 12px 60px; }
    .et-container { padding: 0 12px 32px; }

    /* Header restructured: row 1 = logo + right controls,
       row 2 = horizontally-scrollable nav. The nav lives inside
       .site-header-left in markup, so we flatten that wrapper with
       `display: contents` so logo / nav / right-controls are all
       direct flex children of .site-header. */
    .site-header {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
        align-items: center;
        row-gap: 6px;
        width: 100%;
    }
    .site-header-left {
        display: contents;
    }
    .site-logo {
        order: 1;
        font-size: 17px;
        white-space: nowrap;
        flex: 0 0 auto;
    }
    .site-logo img {
        height: 24px !important;
        width: 24px !important;
    }
    .site-header-right {
        order: 2;
        flex: 1 1 0;
        margin-left: auto;
        gap: 6px;
        justify-content: flex-end;
        min-width: 0;
    }
    .site-header-nav {
        order: 3;
        flex: 1 0 100%;
        width: 100%;
        max-width: 100%;
        margin: 4px 0 0;
        padding: 6px 0 2px;
        border-top: 1px solid var(--border-color);
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 4px;
        display: flex;
        justify-content: flex-start;
        overscroll-behavior-inline: contain;
    }
    .site-header-nav::-webkit-scrollbar { display: none; }
    .site-nav-link {
        padding: 8px 11px;
        font-size: 13px;
        min-height: 38px;
        display: inline-flex;
        align-items: center;
        flex-shrink: 0;
    }
    .auth-btn {
        padding: 7px 12px;
        font-size: 13px;
        min-height: 36px;
        max-width: 34vw;
    }
    #auth-btn-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .theme-toggle { padding: 5px 8px; }
    .lang-btn {
        padding: 7px 10px !important;
        min-height: 36px;
    }
    /* Hide the language label text on narrow phones — keep just the globe icon */
    .lang-current-label,
    .language-selector .current-label { display: none; }
    .lang-menu,
    .account-dropdown {
        position: fixed !important;
        top: auto !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
        max-width: none !important;
    }
    .lang-menu { top: 58px !important; }
    .account-dropdown { top: 58px !important; }

    /* Hero / page banners */
    .hero { padding: 24px 18px; border-radius: 16px; margin-bottom: 20px; }
    .hero-title { font-size: clamp(24px, 7vw, 30px); }
    .hero-eyebrow { font-size: 11px; }
    .hero-subtitle { font-size: 13px; line-height: 1.55; }
    .page-header { padding: 14px 16px; border-radius: 14px; }
    .page-header-title { font-size: 19px; }
    .page-header-subtitle { font-size: 12px; }

    /* Layout grids collapse to one column */
    .grid-2, .grid-3, .grid-auto { grid-template-columns: 1fr; gap: 12px; }

    /* Cards & section spacing tighter */
    .card { padding: 14px; border-radius: 14px; }
    .section { margin-bottom: 22px; }
    .section-title { font-size: 15px; }
    .section-header > .btn,
    .section-header > .btn-secondary,
    .section-header > button,
    .section-controls {
        margin-left: 0 !important;
    }
    .story-card { padding: 16px; border-radius: 14px; }
    .story-headline { font-size: 16px; }
    .story-brief { font-size: 13px; }
    .story-meta,
    .story-meta > div {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px 10px !important;
        width: 100%;
        min-width: 0;
    }
    .story-meta > div {
        flex-wrap: wrap !important;
    }
    .story-source {
        max-width: 45%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow-wrap: normal;
        word-break: normal;
    }
    .impact-badge,
    .discuss-link,
    .polarity-badge {
        margin-left: 0;
        flex: 0 0 auto;
    }
    .impact-badge {
        margin-left: auto;
    }
    .polarity-badge {
        flex-basis: 100%;
        text-align: center;
        border-radius: 14px;
    }

    /* Buttons reach 44px Apple HIG / Android Material tap target */
    .btn, .btn-secondary, .pulse-tab-btn, .auth-tab, .et-tab {
        min-height: 44px;
        padding: 11px 18px;
        font-size: 14px;
        max-width: 100%;
    }
    .btn { width: auto; }                              /* don't full-width by default */

    /* Search inputs span full width on mobile */
    .search-container, .et-search-wrap, .et-select-wrap { min-width: 0; width: 100%; flex: 1 1 100%; }

    /* Auth modal margin-safe */
    .auth-modal { padding: 22px 18px; max-width: calc(100% - 24px); border-radius: 14px; }
    .auth-modal-title { font-size: 20px; }

    /* Top bar (stock page) */
    .top-bar { padding: 12px 14px; border-radius: 14px; gap: 10px; }

    /* Drivers / heatmap collapse */
    .drivers { grid-template-columns: 1fr 1fr; gap: 10px; }
    .driver-value { font-size: 20px; }
    .heatmap { grid-template-columns: repeat(2, 1fr); gap: 8px; }

    /* Tables → horizontal scroll instead of overflowing */
    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
    table.et-table { display: table; white-space: normal; }   /* already wrapped */
    .table-scroll table { display: table; }                   /* respect explicit wrappers */

    /* Long URLs / numbers shouldn't break layout */
    pre, code { white-space: pre-wrap; word-break: break-word; }
}

/* ── Small phones (iPhone SE / Galaxy A0x) — ≤ 380px ── */
@media (max-width: 380px) {
    .site-logo { font-size: 15px; }
    .site-logo img { height: 22px !important; width: 22px !important; }
    .auth-btn { padding: 6px 10px; font-size: 12px; min-height: 34px; max-width: 30vw; }
    .theme-toggle { padding: 4px 7px; font-size: 13px; }
    .site-header-right { gap: 4px; }
    .site-nav-link { padding: 7px 9px; font-size: 12px; }
    .container { padding: 10px; }
    .hero { padding: 20px 14px; }
    .hero-title { font-size: 22px; }
    .page-header-title { font-size: 17px; }
    .drivers { grid-template-columns: 1fr; }
    .heatmap { grid-template-columns: 1fr; }
    .btn, .btn-secondary { width: 100%; justify-content: center; }
}

/* ── Ultra-wide / large desktop — ≥ 1600px ── */
@media (min-width: 1600px) {
    .container { max-width: 1500px; }
}

/* ── Coarse pointer (touch devices) — bigger tap targets regardless of size ── */
@media (pointer: coarse) {
    .site-nav-link, .auth-btn, .theme-toggle,
    .btn, .btn-secondary, .pulse-tab-btn, .auth-tab,
    .et-tab, .auth-modal-close { min-height: 40px; }
    a, button { touch-action: manipulation; }   /* removes 300ms tap delay */
}

/* ── Landscape phones (low height) — keep sticky header from eating screen ── */
@media (max-height: 480px) and (orientation: landscape) {
    .site-header { position: static; }
    .hero { padding: 18px 22px; }
}

/* ── Reduced motion — honor OS preference ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Print ── */
@media print {
    .site-header, .auth-modal-overlay, .bunny-chat,
    #niq-disclaimer-overlay { display: none !important; }
    body { background: #fff; color: #000; }
    .container { max-width: 100%; padding: 0; }
}
