:root {
    --bg-color: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent-color: #0066cc;
    --card-radius: 18px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.no-scroll {
    overflow: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(12px, 3vw, 20px);
    padding-top: 100px; /* Account for fixed header */
}

header.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px clamp(15px, 4vw, 40px);
    
    /* Fixed Position */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;

    /* Liquid Glass Effect */
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

h1.gradient-text {
    font-size: clamp(20px, 5vw, 32px);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0;
    background: linear-gradient(135deg, #1a1a1a 0%, #4a4a4a 100%); /* Fallback / Dark */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    /* Apple-like colorful gradient option if preferred, but "Apple gradient" usually refers to text gradients seen in marketing */
    background-image: linear-gradient(90deg, #c744ff 0%, #3eccff 100%); 
}

.navbar-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.navbar-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: -0.01em;
}

.search-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(10px, 2vw, 20px) clamp(10px, 2vw, 20px) clamp(20px, 4vw, 40px) clamp(10px, 2vw, 20px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-box {
    width: 100%;
    max-width: 600px;
    position: relative;
    margin: 0 auto;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); /* Add shadow for floating effect */
    border-radius: 16px; /* Match input radius */
}

input[type="text"], input[type="password"] {
    padding: 16px 24px; /* Larger padding for hero search */
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 18px;
    width: 100%; /* Take full width of wrapper */
    outline: none;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

input[type="text"]:focus {
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.15);
    border-color: var(--accent-color);
}

input[type="text"]:disabled {
    background-color: #e5e5e5;
    cursor: not-allowed;
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--accent-color);
}

button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #004499;
}

.api-key-config {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-btn {
    background-color: var(--text-primary);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.login-btn:hover {
    opacity: 0.8;
    background-color: var(--text-primary);
}

.navbar-text-btn {
    background: none;
    border: none;
    color: #999999;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.navbar-text-btn:hover {
    color: #666666;
}

.navbar-text-btn:active {
    color: #555555;
}

/* Ensure navbar watchlist buttons don't turn blue on click/tap/focus */
#openWatchlistBtn,
#addToWatchlistBtn,
.navbar-text-btn {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    outline: none !important;
    background: transparent !important;
    color: #999999 !important;
}

#openWatchlistBtn:hover,
#addToWatchlistBtn:hover,
.navbar-text-btn:hover {
    color: #666666 !important;
}

#openWatchlistBtn:active,
#addToWatchlistBtn:active,
#openWatchlistBtn:focus,
#addToWatchlistBtn:focus,
.navbar-text-btn:active,
.navbar-text-btn:focus,
.navbar-text-btn:focus-visible {
    color: #999999 !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

.user-status {
    font-size: 14px;
    color: #34c759;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.user-status::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: #34c759;
    border-radius: 50%;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.72), rgba(242, 249, 255, 0.48));
    padding: 40px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 22px 48px rgba(10, 44, 84, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stronger white glass for View All modal cards */
#profitModal .modal-content,
#revenueModal .modal-content,
#investmentModal .modal-content,
#capitalStructureModal .modal-content,
#costOfCapitalModal .modal-content,
#marketValueModal .modal-content,
#stockPerformanceModal .modal-content,
#balanceModal .modal-content,
#cashModal .modal-content,
#earningsModal .modal-content,
#overviewModal .modal-content {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.9), rgba(246, 251, 255, 0.78));
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 24px 52px rgba(10, 44, 84, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-content h2 {
    margin-bottom: 10px;
    font-size: 24px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 15px;
}

.modal-content input {
    width: 100%;
    margin-bottom: 20px;
    padding: 14px;
    font-size: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
}

.modal-helper {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    color: var(--accent-color);
    cursor: pointer;
}

.link-btn:hover {
    text-decoration: underline;
    background: none;
    color: var(--accent-color);
}

.link-btn:active,
.link-btn:focus,
.link-btn:focus-visible {
    background: none;
    color: var(--accent-color);
    box-shadow: none;
    transform: none;
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
}

.secondary-btn {
    background-color: #f5f5f7;
    color: var(--text-primary);
    border: none;
}

.secondary-btn:hover {
    background-color: #e5e5e5;
}

.modal-content small {
    color: var(--text-secondary);
    font-size: 13px;
}

.modal-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.card-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
}

.chart-container {
    position: relative;
    height: clamp(220px, 40vh, 300px);
    width: 100%;
}

.chart-container canvas {
    max-height: 100% !important;
    height: 100%;
}

.chart-container-small {
    position: relative;
    height: clamp(160px, 30vh, 200px);
    width: 100%;
}

.chart-container-small canvas {
    max-height: 100% !important;
    height: 100%;
    margin-top: 0; /* Remove global margin to fit container */
}

.scrollable {
    max-height: 300px;
    overflow-y: auto;
}

.card {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.62), rgba(242, 248, 255, 0.4));
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: 0 14px 30px rgba(12, 46, 86, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(14px) saturate(128%);
    -webkit-backdrop-filter: blur(14px) saturate(128%);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px rgba(12, 46, 86, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.86);
    filter: brightness(0.985);
}

/* .card.wide is no longer strictly needed for grid span if we use flex rows, 
   but we can keep it for specific styling if needed. */
.card.wide {
    width: 100%;
}

h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.card-content {
    flex: 1;
    font-size: 15px;
    color: var(--text-secondary);
}

.data-point {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
    padding-bottom: 4px;
}

.data-label {
    color: var(--text-secondary);
}

.data-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

.placeholder {
    color: #d2d2d7;
    font-style: italic;
}

canvas {
    margin-top: 15px;
    max-height: 200px;
    width: 100%;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none; /* Hidden by default */
}

.search-dropdown.active {
    display: block;
}

.search-result-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f5f5f7;
}

.item-symbol {
    font-weight: 600;
    color: var(--text-primary);
}

.item-name {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* Footer Styles */
.site-footer {
    background-color: #fdfdfd;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 24px 0;
    margin-top: 40px;
    border-top: 1px solid #fdfdfd;
}

.footer-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.footer-text a {
    color: inherit;
    text-decoration: none;
}

.footer-text a:hover {
    text-decoration: underline;
}

/* Toggle Buttons */
.toggle-btn {
    padding: 8px 16px;
    border: 1px solid #d2d2d7;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.toggle-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.toggle-btn:hover:not(.active) {
    background: #f5f5f7;
}

/* Trend Variable Buttons */
.trend-var-btn {
    padding: 6px 12px;
    border: 1px solid #e5e5ea;
    background: #f5f5f7;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.trend-var-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.trend-var-btn:hover:not(.active) {
    background: #e5e5ea;
    color: var(--text-primary);
}

.scrollable-x::-webkit-scrollbar {
    height: 4px;
}

.scrollable-x::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

/* AI Chat Widget */
.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 10000;
}

.watchlist-sidebar {
    position: fixed;
    right: 0;
    left: calc(100% - 320px);
    top: 0;
    bottom: 0;
    width: 320px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(242, 248, 255, 0.42));
    border-left: 1px solid rgba(255, 255, 255, 0.48);
    border-right: none;
    box-shadow: 0 18px 40px rgba(10, 44, 84, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    display: flex;
    flex-direction: column;
    z-index: 10001;
    transition: left 0.4s ease, right 0.4s ease, width 0.4s ease;
}

.watchlist-sidebar.closed {
    left: 100%;
    right: auto;
}

.watchlist-sidebar.open {
    left: calc(100% - 320px);
    right: 0;
}

.watchlist-sidebar.fullscreen {
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    border-left: none;
    border-right: none;
}

.watchlist-sidebar.fullscreen .watchlist-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px;
}

.log-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}





.watchlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.48);
    flex-shrink: 0;
}

.watchlist-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.watchlist-header-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

/* Watchlist tabs (Watchlist / AI) and divider */
.watchlist-tab-buttons {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.watchlist-tab-buttons .ai-chat-text-btn {
    padding: 8px 10px;
    border-radius: 8px;
}

.watchlist-tab-buttons .ai-chat-text-btn.active {
    color: #111827;
    font-weight: 600;
}

.watchlist-tab-buttons .ai-chat-text-btn.inactive {
    color: #8a8a8f;
    font-weight: 500;
    opacity: 0.95;
}

.tab-divider {
    width: 1px;
    height: 18px;
    background: #e5e7eb;
    border-radius: 1px;
}

/* Subheader for Recent Chats / Key buttons under the main header */
.watchlist-ai-subheader {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
    background: #ffffff;
    flex-shrink: 0;
}

.watchlist-ai-subheader .ai-chat-action-btn.ai-chat-key-action {
    padding: 6px 10px;
}

.watchlist-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Watchlist Content Areas for tab switching */
.watchlist-content-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.watchlist-ai-content-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #f7f7f9;
}

/* Watchlist AI header (empty, dropdowns positioned absolutely) */
.watchlist-ai-header-bar {
    background: transparent;
    padding: 0;
    border: none;
    position: relative;
    flex-shrink: 0;
    min-height: 0;
}

/* Watchlist AI Key Dropdown - same as Ask AI */
.watchlist-ai-key-dropdown {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 2;
    margin: 12px;
}

.watchlist-ai-key-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.watchlist-ai-key-dropdown input {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    font-size: 13px;
    outline: none;
    background: #ffffff;
    color: #111827;
}

.watchlist-ai-key-dropdown input:focus {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Watchlist AI History Dropdown - same as Ask AI */
.watchlist-ai-history-dropdown {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.82), rgba(247, 247, 249, 0.68));
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 3;
    margin: 12px;
    max-height: 280px;
    overflow-y: auto;
}

.watchlist-ai-history-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.watchlist-ai-history-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
}

.watchlist-ai-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 14px;
    background: #f7f7f9;
}

.watchlist-ai-input-container {
    display: flex;
    padding: 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
}

.watchlist-ai-input-container input {
    flex: 1;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    margin-right: 8px;
    background: #ffffff;
    color: #111827;
}

.watchlist-ai-input-container input:focus {
    border-color: rgba(11, 94, 215, 0.55);
    box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.12);
}

.watchlist-ai-input-container button {
    background: #d1d5db;
    color: #1f2937;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(31, 41, 55, 0.12);
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.watchlist-ai-input-container button:hover:not(:disabled) {
    background: #c4c9d0;
}

.watchlist-ai-input-container button:active:not(:disabled) {
    transform: translateY(1px) scale(0.97);
    box-shadow: 0 4px 10px rgba(31, 41, 55, 0.18), inset 0 2px 4px rgba(0, 0, 0, 0.16);
}

.watchlist-ai-input-container button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Reuse same chat message styles for Watchlist AI */
.watchlist-ai-messages .chat-message {
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    display: inline-block;
    max-width: 85%;
}

.watchlist-ai-messages .chat-message.ai {
    background: #ffffff;
    color: #111827;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    max-width: 95%;
}

.watchlist-ai-messages .chat-message.user {
    background: #2563eb;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.2);
    max-width: 85%;
}

.watchlist-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.watchlist-add-btn {
    background: linear-gradient(135deg, rgba(102, 179, 149, 0.3), rgba(102, 179, 149, 0.15));
    color: #2d5a3d;
    border: 1px solid rgba(102, 179, 149, 0.4);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.watchlist-add-btn:hover {
    background: linear-gradient(135deg, rgba(102, 179, 149, 0.45), rgba(102, 179, 149, 0.25));
    transform: scale(1.05);
}

.watchlist-add-btn:active {
    transform: scale(0.95);
}

.watchlist-list {
    padding: 12px 14px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    flex: 1;
}

.watchlist-card {
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(248, 250, 255, 0.56));
    box-shadow: 0 8px 20px rgba(10, 44, 84, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px) saturate(130%);
    -webkit-backdrop-filter: blur(12px) saturate(130%);
    padding: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.18s ease;
}

.watchlist-card:hover {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.84), rgba(248, 250, 255, 0.72));
    box-shadow: 0 12px 26px rgba(10, 44, 84, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.82);
    border-color: rgba(255, 255, 255, 0.68);
}

.watchlist-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.watchlist-card-symbol {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.watchlist-card-name {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.watchlist-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.watchlist-metric {
    background: #ffffff;
    border-radius: 8px;
    padding: 6px 8px;
    border: 1px solid rgba(15, 23, 42, 0.04);
}

.watchlist-metric-label {
    display: block;
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.watchlist-metric-value {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
}

.watchlist-card-actions {
    display: flex;
    justify-content: flex-end;
}

.watchlist-remove {
    background: transparent;
    border: none;
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.watchlist-remove:hover {
    color: #b91c1c;
}

.watchlist-remove:active,
.watchlist-remove:focus,
.watchlist-remove:focus-visible {
    color: #dc2626 !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    transform: none !important;
}

/* Stronger, more specific selector to override any global button focus/active rules */
button.watchlist-remove,
.watchlist-list button.watchlist-remove,
.watchlist-card button.watchlist-remove {
    color: #dc2626 !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

button.watchlist-remove:active,
.watchlist-list button.watchlist-remove:active,
.watchlist-card button.watchlist-remove:active,
button.watchlist-remove:focus,
.watchlist-list button.watchlist-remove:focus,
.watchlist-card button.watchlist-remove:focus {
    color: #dc2626 !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

.watchlist-empty {
    grid-column: 1 / -1;
    color: var(--text-secondary);
    text-align: center;
    padding: 20px 0;
}

.log-toggle {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.16));
    color: #0a2b47;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 30px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(0, 38, 77, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(14px) saturate(130%);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.2s ease;
}

.log-toggle:hover {
    background: linear-gradient(135deg, rgba(235, 244, 255, 0.44), rgba(214, 233, 255, 0.28));
    background-color: transparent;
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 16px 34px rgba(0, 38, 77, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    filter: brightness(0.96);
}

.log-toggle:active {
    transform: translateY(1px) scale(0.985);
    box-shadow: 0 6px 14px rgba(0, 38, 77, 0.2), inset 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.log-modal {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: clamp(260px, 60vw, 360px);
    max-height: 420px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8f9fb;
}

.log-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}

.log-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.log-text-btn {
    background: none;
    border: none;
    padding: 0;
    color: #8a8a8f;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.log-text-btn:hover {
    color: #666666;
    background: none;
}

.log-text-btn:active,
.log-text-btn:focus,
.log-text-btn:focus-visible {
    color: #8a8a8f;
    outline: none;
    box-shadow: none;
    background: none;
}

.log-header .ai-chat-action-btn {
    color: #0f172a;
}

.log-header .ai-chat-action-btn.ai-chat-key-action {
    /* Match the pill-style used in the AI header (Recent Chats) */
    padding: 0 8px;
    height: 24px;
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
    background: rgba(17, 24, 39, 0.06);
    border: none;
    border-radius: 8px;
    box-shadow: none;
}

.log-header .ai-chat-action-btn.ai-chat-key-action:hover {
    background: rgba(17, 24, 39, 0.09);
}

.log-list {
    padding: 12px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.log-entry {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.log-entry:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.log-entry strong {
    color: #0f172a;
    font-weight: 600;
}

.ai-chat-toggle {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.16));
    color: #0a2b47;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 30px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(0, 38, 77, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(14px) saturate(130%);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.2s ease;
}

.ai-chat-toggle:hover {
    background: linear-gradient(135deg, rgba(235, 244, 255, 0.44), rgba(214, 233, 255, 0.28));
    background-color: transparent;
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 16px 34px rgba(0, 38, 77, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    filter: brightness(0.96);
}

.ai-chat-toggle:active {
    transform: translateY(1px) scale(0.985);
    box-shadow: 0 6px 14px rgba(0, 38, 77, 0.2), inset 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.ai-chat-toggle.is-pressed {
    transform: translateY(1px) scale(0.985);
    box-shadow: 0 6px 14px rgba(0, 38, 77, 0.2), inset 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.ai-chat-modal {
    position: absolute;
    bottom: 60px;
    left: 0;
    width: clamp(300px, 90vw, 380px);
    height: 500px;
    background: #f7f7f9;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(17, 24, 39, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.ai-chat-header {
    background: #ffffff;
    color: #111827;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.ai-chat-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.ai-chat-text-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    font-weight: 500;
    color: #8a8a8f;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none;
}

.ai-chat-text-btn:hover {
    background: none;
    color: #666666;
}

.ai-chat-text-btn:active,
.ai-chat-text-btn:focus,
.ai-chat-text-btn:focus-visible {
    background: none;
    outline: none;
    box-shadow: none;
    color: #8a8a8f;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 15px;
    color: #111827;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.ai-chat-action-btn {
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: #111827;
    box-shadow: none;
    transition: transform 0.16s ease, opacity 0.2s ease;
}

.ai-chat-action-btn:hover {
    background-color: rgba(17, 24, 39, 0.06);
    opacity: 0.9;
}

.ai-chat-action-btn:active {
    background-color: rgba(17, 24, 39, 0.1);
    transform: translateY(1px) scale(0.96);
    opacity: 0.8;
}

.ai-chat-key-action {
    width: auto;
    height: 24px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.01em;
    background: rgba(17, 24, 39, 0.06);
    border-radius: 8px;
}

.close-chat-btn .close-icon {
    position: relative;
    width: 12px;
    height: 12px;
}

.close-chat-btn .close-icon::before,
.close-chat-btn .close-icon::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 0;
    width: 12px;
    height: 2px;
    background: #0a2b47;
    border-radius: 2px;
    transform-origin: center;
}

.close-chat-btn .close-icon::before {
    transform: rotate(45deg);
}

.close-chat-btn .close-icon::after {
    transform: rotate(-45deg);
}

.close-chat-btn:hover .close-icon {
    transform: rotate(90deg);
    transition: transform 0.2s ease;
}

.fullscreen-icon {
    position: relative;
    width: 12px;
    height: 12px;
    border: 1.5px solid #111827;
    border-radius: 2px;
    box-sizing: border-box;
}

.ai-chat-modal.fullscreen {
    position: fixed;
    left: 20px;
    bottom: 20px;
    right: 20px;
    top: 20px;
    width: auto;
    height: auto;
    border-radius: 20px;
}

.ai-chat-modal.fullscreen .ai-chat-messages {
    font-size: 15px;
}

.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 14px;
    background: #f7f7f9;
}

.chat-message {
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 85%;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    display: inline-block;
}

.chat-message.ai {
    background: #ffffff;
    color: #111827;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.chat-message.user {
    background: #2563eb;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.2);
}

.ai-chat-input-container {
    display: flex;
    padding: 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
}

.ai-chat-input-container input {
    flex: 1;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    margin-right: 8px;
    background: #ffffff;
    color: #111827;
}

.ai-chat-input-container input:focus {
    border-color: rgba(11, 94, 215, 0.55);
    box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.12);
}

.ai-chat-key-dropdown {
    position: absolute;
    top: 52px;
    left: 14px;
    right: 14px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 2;
}

.ai-chat-key-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ai-chat-history-dropdown {
    position: absolute;
    top: 52px;
    left: 14px;
    right: 14px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.82), rgba(247, 247, 249, 0.68));
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 3;
}

.ai-chat-history-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ai-chat-history-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
}

.ai-chat-history-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-history-item {
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.ai-chat-history-item:hover {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(15, 23, 42, 0.14);
    transform: translateY(-1px);
}

.ai-chat-history-item.active {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.24);
}

.ai-chat-history-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

.ai-chat-history-meta {
    margin-top: 3px;
    font-size: 11px;
    color: #6b7280;
}

.ai-chat-history-new {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 0;
    color: #8a8a8f;
    font-size: 12px;
    cursor: pointer;
}

.ai-chat-history-new:hover {
    background: none;
    color: #666666;
}

.ai-chat-key-input {
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    padding: 9px 10px;
    font-size: 13px;
    outline: none;
    background: #ffffff;
    color: #111827;
}

.ai-chat-key-input:focus {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ai-chat-input-container button {
    background: #d1d5db;
    color: #1f2937;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(31, 41, 55, 0.12);
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.ai-chat-input-container button:hover:not(:disabled) {
    background: #c4c9d0;
}

.ai-chat-input-container button:active:not(:disabled) {
    transform: translateY(1px) scale(0.97);
    box-shadow: 0 4px 10px rgba(31, 41, 55, 0.18), inset 0 2px 4px rgba(0, 0, 0, 0.16);
}

.ai-chat-input-container button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .card-row-2, .card-row-3 {
        grid-template-columns: 1fr;
    }

    input[type="text"], input[type="password"] {
        padding: 12px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    button {
        padding: 12px 16px;
    }

    .card {
        padding: 16px;
    }

    h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .card-content {
        font-size: 13px;
    }

    .data-point {
        margin-bottom: 8px;
    }

    /* Modal Mobile Optimizations */
    .modal-content {
        padding: 20px;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

@media (max-width: 375px) {
    .navbar {
        padding: 10px 15px;
    }
    
    .api-key-config {
        gap: 5px;
    }
    
    .login-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Markdown styles for AI Chat */
.chat-message.ai p {
    margin-bottom: 8px;
}
.chat-message.ai p:last-child {
    margin-bottom: 0;
}
.chat-message.ai ul, .chat-message.ai ol {
    margin: 8px 0;
    padding-left: 20px;
    text-align: left;
}
.chat-message.ai strong {
    font-weight: 600;
}
.chat-message.ai code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

/* Rainbow Button for Welcome Modal */
.rainbow-btn {
    background: linear-gradient(90deg, #ff5f6d, #ffc371, #3a7bd5, #00d2ff, #ff5f6d);
    background-size: 400% 400%;
    animation: rainbow-anim 5s ease infinite;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rainbow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

@keyframes rainbow-anim {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
