/* ==========================================================================
   AI COPILOT & HANDS-OFF AUTOPILOT - GLOBAL STYLESHEET
   ========================================================================== */

/* ── GLOBAL FLOATING AI COPILOT WIDGET & DRAWER ─────────────────────── */
.ai-widget-fab-container {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 99990 !important;
    display: block !important;
}

.ai-widget-fab {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #7c3aed 100%) !important;
    border: 1px solid rgba(147, 197, 253, 0.4) !important;
    color: #ffffff !important;
    padding: 10px 18px !important;
    border-radius: 9999px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(37, 99, 235, 0.5) !important;
    cursor: pointer !important;
    font-weight: 700 !important;
    font-size: 0.92rem !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    backdrop-filter: blur(8px) !important;
}

.ai-widget-fab:hover {
    transform: translateY(-3px) scale(1.04) !important;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.7), 0 0 25px rgba(124, 58, 237, 0.6) !important;
}

.ai-fab-icon {
    font-size: 1.25rem !important;
    line-height: 1 !important;
}

.ai-fab-indicator {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    display: inline-block !important;
}

.ai-fab-indicator.active {
    background: #22c55e !important;
    box-shadow: 0 0 8px #22c55e !important;
}

.ai-fab-indicator.standby {
    background: #94a3b8 !important;
}

.ai-drawer-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(3, 7, 18, 0.75) !important;
    backdrop-filter: blur(6px) !important;
    z-index: 99995 !important;
    display: flex !important;
    justify-content: flex-end !important;
}

.ai-drawer-panel {
    background: #09132b !important;
    border-left: 1px solid rgba(59, 130, 246, 0.35) !important;
    width: 100% !important;
    max-width: 440px !important;
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: -15px 0 45px rgba(0, 0, 0, 0.85) !important;
    color: #f8fafc !important;
    animation: aiSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes aiSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.ai-drawer-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1rem 1.25rem !important;
    background: rgba(13, 27, 62, 0.95) !important;
    border-bottom: 1px solid rgba(59, 130, 246, 0.25) !important;
}

.ai-drawer-title {
    display: flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
    color: #ffffff !important;
}

.ai-drawer-autopilot-btn {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #cbd5e1 !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    padding: 0.3rem 0.65rem !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
}

.ai-drawer-autopilot-btn.active {
    background: rgba(34, 197, 94, 0.2) !important;
    border-color: #22c55e !important;
    color: #86efac !important;
}

.ai-drawer-close-btn {
    background: transparent !important;
    border: none !important;
    color: #94a3b8 !important;
    font-size: 1.2rem !important;
    cursor: pointer !important;
    padding: 0.2rem 0.5rem !important;
    border-radius: 4px !important;
    line-height: 1 !important;
}

.ai-drawer-close-btn:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

.ai-drawer-body {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #060d1f !important;
}

.ai-drawer-directive {
    font-size: 0.74rem !important;
    color: #93c5fd !important;
    background: rgba(59, 130, 246, 0.12) !important;
    padding: 0.45rem 0.9rem !important;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2) !important;
    text-align: center !important;
    line-height: 1.35 !important;
}

.ai-drawer-chat-stream {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 1rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.85rem !important;
}

.ai-drawer-msg {
    display: flex !important;
    max-width: 92% !important;
}

.ai-drawer-msg.user {
    align-self: flex-end !important;
}

.ai-drawer-msg.assistant {
    align-self: flex-start !important;
}

.ai-drawer-msg-bubble {
    background: rgba(17, 34, 77, 0.85) !important;
    border: 1px solid rgba(59, 130, 246, 0.25) !important;
    border-radius: 12px !important;
    padding: 0.75rem 0.95rem !important;
    font-size: 0.84rem !important;
    color: #f1f5f9 !important;
    line-height: 1.45 !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3) !important;
}

.ai-drawer-msg.user .ai-drawer-msg-bubble {
    background: linear-gradient(135deg, #1d4ed8, #2563eb) !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
}

.ai-drawer-gem-card {
    background: rgba(11, 23, 56, 0.95) !important;
    border: 1px solid rgba(59, 130, 246, 0.45) !important;
    border-radius: 8px !important;
    padding: 0.6rem 0.8rem !important;
    margin-top: 0.6rem !important;
}

.ai-drawer-chips {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
    margin-top: 0.6rem !important;
}

.ai-drawer-chip {
    background: rgba(59, 130, 246, 0.18) !important;
    border: 1px solid rgba(59, 130, 246, 0.35) !important;
    color: #93c5fd !important;
    font-size: 0.72rem !important;
    padding: 0.25rem 0.6rem !important;
    border-radius: 9999px !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
}

.ai-drawer-chip:hover {
    background: #2563eb !important;
    color: #ffffff !important;
    border-color: #60a5fa !important;
}

.ai-drawer-footer {
    padding: 0.85rem 1rem !important;
    background: rgba(13, 27, 62, 0.95) !important;
    border-top: 1px solid rgba(59, 130, 246, 0.25) !important;
    display: flex !important;
    gap: 0.5rem !important;
}

.ai-drawer-input {
    flex: 1 !important;
    background: #0b152d !important;
    border: 1px solid rgba(59, 130, 246, 0.35) !important;
    border-radius: 8px !important;
    padding: 0.55rem 0.85rem !important;
    color: #ffffff !important;
    font-size: 0.85rem !important;
    outline: none !important;
}

.ai-drawer-input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4) !important;
}

.ai-drawer-send-btn {
    background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 0.55rem 1rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: opacity 0.15s !important;
}

.ai-drawer-send-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* ── AI COPILOT DEDICATED HUB PAGE (/ai-copilot) ────────────────────────── */
.ai-page {
    padding-bottom: 3rem;
    color: #f1f5f9;
}

.ai-unauthorized-card {
    text-align: center;
    padding: 4rem 2rem;
    background: #0a1635;
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 16px;
    max-width: 500px;
    margin: 4rem auto;
}

.ai-unauthorized-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.ai-badge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.ai-badge {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    letter-spacing: 0.05em;
}

.ai-badge-lead {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.ai-badge-active {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.ai-badge-standby {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.ai-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.4rem;
}

.ai-prime-directive {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.6);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    border: 1px dashed rgba(59, 130, 246, 0.3);
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ai-autopilot-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #0f1f4b;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.4rem 0.85rem;
    border-radius: 10px;
}

.ai-autopilot-label {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.ai-autopilot-label strong {
    font-size: 0.82rem;
    color: #ffffff;
}

.ai-autopilot-label small {
    font-size: 0.68rem;
    color: #94a3b8;
}

.ai-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.ai-toggle-btn.active {
    background: #22c55e;
    color: #ffffff;
    border-color: #22c55e;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

/* ── EXECUTIVE GLANCE BANNER ─────────────────────────────────────────── */
.ai-glance-card {
    background: linear-gradient(135deg, rgba(15, 31, 75, 0.9) 0%, rgba(10, 22, 53, 0.98) 100%);
    border: 1px solid rgba(59, 130, 246, 0.35);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.ai-glance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.ai-glance-tag {
    font-size: 0.78rem;
    font-weight: 800;
    color: #93c5fd;
    letter-spacing: 0.05em;
}

.ai-glance-updated {
    font-size: 0.75rem;
    color: #64748b;
}

.ai-glance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.ai-glance-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ai-stat-label {
    font-size: 0.72rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ai-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
}

.ai-stat-value-sm {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    line-height: 1.3;
}

.ai-stat-sub {
    font-size: 0.72rem;
    color: #64748b;
}

/* ── CROWN PICKS SECTION ─────────────────────────────────────────────── */
.ai-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.ai-section-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.25rem;
}

.ai-section-sub {
    font-size: 0.82rem;
    color: #94a3b8;
    margin: 0;
}

.tg-btn-stage-all {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    border: 1px solid rgba(147, 197, 253, 0.4);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    transition: all 0.15s;
}

.tg-btn-stage-all:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.ai-crown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.ai-gem-card {
    background: #0f1f4b;
    border: 1px solid rgba(59, 130, 246, 0.28);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.15s, border-color 0.15s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.ai-gem-card:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

.ai-gem-autonomous {
    border-color: rgba(245, 158, 11, 0.6);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.1) 0%, rgba(15, 31, 75, 0.98) 100%);
}

.ai-gem-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-gem-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-gem-symbol {
    font-size: 1.3rem;
    font-weight: 800;
    color: #ffffff;
}

.ai-gem-score {
    text-align: right;
}

.ai-score-num {
    font-size: 1.25rem;
    font-weight: 800;
    display: block;
}

.ai-score-label {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
}

.ai-gem-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    background: rgba(10, 22, 53, 0.6);
    padding: 0.65rem;
    border-radius: 8px;
    text-align: center;
}

.ai-gem-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ai-gem-lbl {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
}

.ai-gem-val {
    font-family: monospace;
    font-weight: 700;
    font-size: 0.85rem;
}

.ai-gem-thesis {
    background: rgba(10, 22, 53, 0.5);
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
}

.ai-thesis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.ai-verdict-pill {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.ai-sector-tag {
    font-size: 0.72rem;
    color: #94a3b8;
}

.ai-thesis-text {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin: 0;
    line-height: 1.4;
}

.ai-gem-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ai-check-item {
    font-size: 0.76rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-check-icon {
    font-size: 0.82rem;
}

.ai-gem-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.tg-btn-stage {
    flex: 1;
    background: #2563eb;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    text-align: center;
}

.tg-btn-stage:hover {
    background: #1d4ed8;
}

.ai-status-pill {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
}

.ai-status-staged {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.ai-status-bought {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

/* ── CHAT SECTION ────────────────────────────────────────────────────── */
.ai-chat-card {
    background: #0f1f4b;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: rgba(10, 22, 53, 0.7);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.ai-chat-status {
    font-size: 0.75rem;
    color: #86efac;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-pulse-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: ai-pulse 1.5s infinite;
}

@keyframes ai-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.ai-chat-stream {
    padding: 1.25rem 1.25rem 3.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 480px;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.ai-msg-row {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
}

.ai-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ai-msg-bubble {
    background: rgba(10, 22, 53, 0.75);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
    padding: 0.85rem 1.1rem;
    color: #f1f5f9;
    font-size: 0.88rem;
    line-height: 1.45;
}

.ai-msg-row.user .ai-msg-bubble {
    background: #2563eb;
    color: #fff;
    border-color: #3b82f6;
}

.ai-attached-card {
    background: rgba(15, 31, 75, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    margin-top: 0.75rem;
    font-size: 0.82rem;
}

.ai-attached-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}

.ai-attached-actions {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.5rem;
}

.ai-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.ai-chip-btn {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #93c5fd;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-chip-btn:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.ai-chat-input-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    background: rgba(10, 22, 53, 0.75);
    border-top: 1px solid rgba(59, 130, 246, 0.25);
}

.ai-chat-input {
    flex: 1;
    background: rgba(15, 31, 75, 0.85);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 8px;
    padding: 0.65rem 0.95rem;
    color: #ffffff;
    font-size: 0.88rem;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.ai-chat-send-btn {
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    padding: 0.65rem 1.2rem;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-chat-send-btn:hover:not(:disabled) {
    background: #1d4ed8;
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-typing-indicator {
    display: flex;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem;
}

.ai-typing-indicator span {
    width: 6px;
    height: 6px;
    background: #93c5fd;
    border-radius: 50%;
    animation: ai-bounce 1s infinite;
}

.ai-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ── CANDIDATE DISCOVERY POOL & MARKET STUDY SECTION ─────────────────────── */
.ai-study-section {
    margin-bottom: 2.5rem;
}

.ai-study-card {
    background: #0d1b3e;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.45);
}

.ai-study-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.ai-study-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-study-actions {
    display: flex;
    gap: 0.5rem;
}

.ai-candidates-table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    background: rgba(10, 22, 53, 0.6);
}

.ai-candidates-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.ai-candidates-table th {
    background: rgba(13, 27, 62, 0.95);
    color: #94a3b8;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.25);
    white-space: nowrap;
}

.ai-candidates-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
    white-space: nowrap;
}

.ai-candidates-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
}

.ai-cand-winner {
    background: rgba(245, 158, 11, 0.08) !important;
    border-left: 3px solid #f59e0b !important;
}

.ai-cand-score {
    font-weight: 800;
    font-family: monospace;
    font-size: 0.95rem;
}

.ai-study-markdown-wrap {
    background: rgba(10, 22, 53, 0.8);
    border-radius: 10px;
    padding: 1.5rem;
    color: #e2e8f0;
    line-height: 1.65;
    font-size: 0.92rem;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.ai-study-markdown-wrap h3 {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.25);
    padding-bottom: 0.5rem;
}

.ai-study-markdown-wrap h4 {
    color: #93c5fd;
    font-size: 1.05rem;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
}

.ai-study-markdown-wrap ul {
    padding-left: 1.2rem;
    margin-bottom: 1rem;
}

.ai-study-markdown-wrap li {
    margin-bottom: 0.35rem;
}

.tg-btn-xs {
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    border-radius: 6px;
    font-weight: 600;
}

/* ── ACTION TOOLBAR ──────────────────────────────────────────────────────── */
.ai-action-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.85rem 1.2rem;
    background: rgba(13, 27, 62, 0.85);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    align-items: center;
}

.ai-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(30, 58, 138, 0.45);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 0.95rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

.ai-toolbar-btn:hover {
    background: rgba(59, 130, 246, 0.45);
    color: #ffffff;
    border-color: #60a5fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.ai-toolbar-btn.active {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #ffffff;
    border-color: #93c5fd;
    box-shadow: 0 0 14px rgba(59, 130, 246, 0.5);
}

.ai-tb-highlight {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(245, 158, 11, 0.3)) !important;
    border-color: rgba(245, 158, 11, 0.5) !important;
    color: #fef08a !important;
}

.ai-tb-highlight:hover {
    background: linear-gradient(135deg, #eab308, #d97706) !important;
    color: #0f172a !important;
}

/* ── POPUP MODAL OVERLAYS ────────────────────────────────────────────────── */
.ai-popup-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(4, 10, 26, 0.84);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: aiFadeIn 0.2s ease-out;
}

.ai-popup-dialog {
    background: #0b1739;
    border: 1px solid rgba(59, 130, 246, 0.45);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(59, 130, 246, 0.25);
    border-radius: 16px;
    width: 100%;
    max-width: 940px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aiScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.5rem;
    background: rgba(13, 27, 62, 0.95);
    border-bottom: 1px solid rgba(59, 130, 246, 0.25);
}

.ai-popup-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-popup-icon {
    font-size: 1.7rem;
}

.ai-popup-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
}

.ai-popup-sub {
    font-size: 0.8rem;
    color: #94a3b8;
}

.ai-popup-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    transition: all 0.15s;
}

.ai-popup-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.ai-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.4rem;
}

.ai-popup-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: rgba(13, 27, 62, 0.95);
    border-top: 1px solid rgba(59, 130, 246, 0.25);
}

/* ── SEARCH BAR & PRESETS ────────────────────────────────────────────────── */
.ai-study-search-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    background: rgba(17, 34, 77, 0.65);
    padding: 0.85rem 1.1rem;
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.ai-study-input {
    flex: 1;
    min-width: 220px;
    background: #09122a;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 8px;
    padding: 0.55rem 0.95rem;
    color: #ffffff;
    font-size: 0.9rem;
    outline: none;
}

.ai-study-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.ai-quick-tickers {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-ticker-chip {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #93c5fd;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-ticker-chip:hover {
    background: #2563eb;
    color: #ffffff;
}

/* ── INVARIANTS & POLICIES ───────────────────────────────────────────────── */
.ai-invariants-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    /* Container & Page */
    .ai-page {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        box-sizing: border-box !important;
    }

    /* Action Toolbar: Horizontal swipeable chips */
    .ai-action-toolbar {
        padding: 0.5rem 0.65rem !important;
        gap: 0.35rem !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    .ai-toolbar-btn {
        flex-shrink: 0 !important;
        padding: 0.35rem 0.65rem !important;
        font-size: 0.76rem !important;
    }

    /* Executive Glance Banner */
    .ai-glance-card {
        padding: 0.85rem 0.75rem !important;
        border-radius: 12px !important;
        margin-bottom: 1.25rem !important;
    }
    .ai-glance-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.35rem !important;
    }
    .ai-glance-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    .ai-glance-stat {
        min-width: 0 !important;
    }
    .ai-stat-value {
        font-size: 1rem !important;
    }
    .ai-stat-value-sm {
        font-size: 0.78rem !important;
    }

    /* Crown Picks Grid & Cards (Fix ANF Card Overflow) */
    .ai-section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.65rem !important;
    }
    .tg-btn-stage-all {
        width: 100% !important;
        text-align: center !important;
        font-size: 0.82rem !important;
        padding: 0.55rem 0.85rem !important;
    }
    .ai-crown-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .ai-gem-card {
        padding: 0.85rem 0.75rem !important;
        border-radius: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    .ai-gem-top {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 0.4rem !important;
        width: 100% !important;
    }
    .ai-gem-left {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
        align-items: center !important;
        min-width: 0 !important;
    }
    .ai-gem-symbol {
        font-size: 1.2rem !important;
    }
    .ai-gem-score {
        text-align: right !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
    }
    .ai-score-num {
        font-size: 1.15rem !important;
    }
    .ai-score-label {
        font-size: 0.62rem !important;
    }

    /* Transform metrics into 2x2 grid for mobile so numbers never clip */
    .ai-gem-metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.45rem !important;
        padding: 0.55rem 0.45rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .ai-gem-stat {
        min-width: 0 !important;
        overflow: hidden !important;
    }
    .ai-gem-lbl {
        font-size: 0.62rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .ai-gem-val {
        font-size: 0.85rem !important;
        white-space: nowrap !important;
    }

    /* Thesis & Checklist */
    .ai-gem-thesis {
        padding: 0.65rem 0.75rem !important;
    }
    .ai-thesis-header {
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
    }
    .ai-thesis-text {
        font-size: 0.78rem !important;
        line-height: 1.35 !important;
    }
    .ai-check-item {
        font-size: 0.72rem !important;
        gap: 0.35rem !important;
        word-break: break-word !important;
    }

    /* Card Footer: Full-width stacked buttons */
    .ai-gem-footer {
        flex-direction: column !important;
        gap: 0.4rem !important;
        width: 100% !important;
    }
    .tg-btn-stage,
    .ai-gem-footer .tg-btn {
        width: 100% !important;
        text-align: center !important;
        padding: 0.55rem 0.65rem !important;
        box-sizing: border-box !important;
    }

    /* Study Section & Candidates */
    .ai-study-section {
        margin-bottom: 1.5rem !important;
    }
    .ai-study-card {
        padding: 0.85rem 0.75rem !important;
        border-radius: 12px !important;
    }
    .ai-study-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.65rem !important;
    }
    .ai-study-actions {
        width: 100% !important;
        display: flex !important;
        gap: 0.4rem !important;
    }
    .ai-study-actions button {
        flex: 1 !important;
        font-size: 0.75rem !important;
        padding: 0.4rem 0.5rem !important;
        text-align: center !important;
    }

    /* Chat Section */
    .ai-chat-card {
        border-radius: 12px !important;
    }
    .ai-chat-header {
        padding: 0.85rem 1rem !important;
    }
    .ai-chat-input-bar {
        padding: 0.65rem 0.75rem !important;
    }

    /* Invariants & Cash Grids */
    .ai-invariants-grid {
        grid-template-columns: 1fr !important;
    }
    .ai-cash-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Popup Dialogs */
    .ai-popup-backdrop {
        padding: 0.5rem !important;
        z-index: 100000 !important;
    }
    .ai-popup-dialog {
        max-height: 94vh !important;
        border-radius: 12px !important;
        width: 100% !important;
    }
    .ai-popup-header {
        padding: 0.75rem 1rem !important;
    }
    .ai-popup-body {
        padding: 0.85rem 0.75rem !important;
    }
    .ai-popup-footer {
        padding: 0.75rem 1rem !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    .ai-popup-tabs {
        overflow-x: auto !important;
        white-space: nowrap !important;
        gap: 0.35rem !important;
        padding-bottom: 0.4rem !important;
    }
    .ai-popup-tab-btn {
        padding: 0.35rem 0.65rem !important;
        font-size: 0.78rem !important;
        flex-shrink: 0 !important;
    }
}

.ai-popup-study-header-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(17, 34, 77, 0.7);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    padding: 1rem 1.3rem;
    margin-bottom: 1.2rem;
}

.ai-popup-markdown-content {
    background: rgba(9, 18, 42, 0.75);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 10px;
    padding: 1.3rem;
    font-size: 0.92rem;
    line-height: 1.65;
    color: #e2e8f0;
}

.ai-popup-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.25);
    margin-bottom: 1.2rem;
    padding-bottom: 0.6rem;
}

.ai-popup-tab-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-popup-tab-btn:hover {
    color: #ffffff;
    background: rgba(59, 130, 246, 0.2);
}

.ai-popup-tab-btn.active {
    color: #ffffff;
    background: #2563eb;
}

@keyframes aiFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes aiScaleUp {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

