:root {
    --bg-primary: #FAFAFA; /* Alabaster background */
    --bg-secondary: #F5F5F5;
    --bg-panel: #F5F5F5; /* Mist Grey for light mode distinction */
    --text-primary: #000000;
    --text-secondary: #222222; /* High-contrast charcoal copy */
    --text-tertiary: #999999;
    --accent: #000000;
    --border: #E0E0E0;
    --border-hover: #CCCCCC;
    --bg-hover: #E8E8E8;
    --positive: #008A00;
    --negative: #D32F2F; /* Adjusted for 4.5:1 WCAG AA compliance on white */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --timestamp-color: var(--text-secondary);
    --timestamp-stale: #B45309;
}


.dark-theme {
    --bg-primary: #050505;
    --bg-secondary: #121212;
    --bg-panel: #141414; /* Refined Graphite for dark mode distinction */
    --text-primary: #D1D1D1;
    --text-secondary: #9CA3AF;
    --text-tertiary: #9CA3AF;
    --accent: #FFFFFF;
    --border: #262626;
    --border-hover: #444444;
    --bg-hover: #1C1C1C;
    --positive: #4ADE80;
    --negative: #F87171;
    --timestamp-color: var(--text-secondary);
    --timestamp-stale: #FBBF24;
}

/* Ensure headings and bold treatments stay pure white for high-contrast hierarchy */
.dark-theme h1, 
.dark-theme h2, 
.dark-theme h3, 
.dark-theme h4, 
.dark-theme strong, 
.dark-theme b,
.dark-theme th {
    color: #FFFFFF !important;
}

.dark-theme .ticker-badge {
    background: #FFFFFF;
    color: #050505;
}



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

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden; /* Prevent page-level horizontal scroll */
}

button {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

button:disabled {
    cursor: not-allowed;
    background: var(--border) !important;
    color: var(--text-secondary) !important; /* readable disabled text (was faint tertiary) */
    opacity: 1;
    border-color: transparent !important;
}




/* Header & Nav */
.app-header {
    border-bottom: 1px solid var(--border);
    padding: 24px 0;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    opacity: 0.98;
    backdrop-filter: blur(10px);
    z-index: 100;
}


.header-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.site-logo {
    width: 154px;
    height: 40px;
    display: block;
}

/* Dark theme (default): show white logo, hide black logo */
.site-logo--light { display: none; }
.site-logo--dark  { display: block; }

/* Light theme: show black logo, hide white logo */
body:not(.dark-theme) .site-logo--light { display: block; }
body:not(.dark-theme) .site-logo--dark  { display: none; }

.main-nav {
    display: flex;
    gap: 32px;
    align-items: center;
}


.nav-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}


.nav-btn:hover {
    color: var(--text-primary);
}

.nav-btn.active {
    color: var(--text-primary);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -24px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--text-primary);
}

/* Market Pulse Card */
/* Market Bar Styles moved to .indices-and-analyzer-row section */

.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 48px 40px;
    display: flex;
    justify-content: flex-start;
    position: relative; /* Establish positioning context */
}

.app-layout-wrapper {
    width: fit-content;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent layout from collapsing when panel opens */
}

.controls {
    margin-bottom: 64px;
    width: 100%;
}

.table-container-outer {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.meta-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 24px;
    width: 100%;
}

.data-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    width: fit-content;
    white-space: nowrap; /* Prevents refresh icon from dropping below */
}

.indices-and-analyzer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.data-io-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.io-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-primary);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    letter-spacing: 0.01em;
    transition: var(--transition);
}

.io-btn:hover {
    color: var(--text-primary);
    background: var(--border);
}

.io-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

#market-indices-bar {
    display: flex;
    align-items: stretch;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}

.index-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 18px;
    position: relative;
}

/* Vertical divider between cards */
.index-card + .index-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: var(--border);
}

.index-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.index-name {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 0.06em;
}

.index-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.index-change {
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.index-arrow {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Analysis awareness removed as requested */

.data-info b {
    color: var(--text-primary) !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}

.icon-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%; /* Perfect circle */
    transition: var(--transition);
    height: 36px;
    width: 36px;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

.icon-btn.disabled {
    background: #f0f0f0; /* Light gray for visibility */
    border-color: #e0e0e0;
    color: #a0a0a0;
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.dark-theme .icon-btn.disabled {
    background: #2A2A2A;
    border-color: #333;
    color: #666;
}

.spin {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}

.search-container {
    display: flex;
    gap: 16px;
    max-width: 420px;
}

/* Action label buttons (Report + Similar columns) */
.action-label-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    white-space: nowrap;
}

.action-label-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.action-label-btn i {
    pointer-events: none;
    flex-shrink: 0;
}

/* Report column */
.report-col {
    white-space: nowrap;
}
.report-btn {
    color: var(--text-primary); /* Match sparkle-btn brightness */
}

/* Similar column */
.similar-col {
    white-space: nowrap;
}
.sparkle-btn {
    color: var(--text-primary);
}
.sparkle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
    transform: none;
}

/* Delete column */
.delete-col {
    text-align: center;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    color: var(--negative);
    background: rgba(239, 68, 68, 0.15);
}

.delete-btn svg {
    width: 15px;
    height: 15px;
    pointer-events: none;
}




.input-wrapper {
    position: relative;
    flex-grow: 1;
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-secondary); /* theme-aware + visible (was hardcoded faint white, invisible in light mode) */
}

#ticker-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid rgba(59, 130, 246, 0.4); /* Subtle neon blue border */
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.15); /* Soft outer glow */
    border-radius: 9999px; /* Pill shape */
    color: var(--text-primary);
    padding: 12px 24px 12px 52px;
    font-size: 16px;
    transition: all 0.3s ease;
}


#ticker-input::placeholder {
    color: var(--text-secondary); /* readable, ADA-friendly (was faint browser default) */
    opacity: 1;
}

#ticker-input:focus {
    outline: none;
    background: var(--bg-tertiary);
    border-color: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.35); /* Stronger glow on focus */
}

#ticker-input.error {
    border: 1px solid red;
    background: rgba(255, 0, 0, 0.05);
}

.error-msg {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    color: red;
    font-size: 15px;
    font-family: var(--font-main);
    font-weight: 500;
    display: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}


.primary-btn {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 12px 28px;
    border-radius: 9999px; /* Pill shape to match search */

    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
}


.primary-btn:hover {
    background: #e0e0e0;
}

/* Autocomplete */
.autocomplete-items {
    position: absolute;
    border: 1px solid var(--border);
    background: var(--bg-panel); /* Consistent with side panels */
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px; /* Slightly more air below the input */
    border-radius: 6px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4); /* Deeper shadow for elevation */
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

/* Custom scrollbar for autocomplete drop-down */
.autocomplete-items::-webkit-scrollbar {
    width: 6px;
}

.autocomplete-items::-webkit-scrollbar-track {
    background: transparent;
}

.autocomplete-items::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}

.autocomplete-items::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.autocomplete-items:empty {
    display: none;
}


.autocomplete-items div {
    padding: 10px 12px; /* Sleeker, less bulky padding */
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.autocomplete-items div:hover {
    background: var(--bg-hover);
}

.autocomplete-item.added:hover {
    background: none;
}

.autocomplete-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    opacity: 0.8;
}
.autocomplete-empty strong {
    color: var(--text-primary);
}
.autocomplete-info {
    display: flex;
    align-items: center;
    gap: 12px; /* Fixed spacing gap between ticker and name */
}

.autocomplete-item.added {
    opacity: 0.5;
    cursor: not-allowed;
}

.added-badge {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-hover); /* Added border for status visibility */
    letter-spacing: 0.05em;
}

.autocomplete-ticker {
    font-weight: 700;
    color: var(--text-primary);
}

.autocomplete-name {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
}

.table-wrapper {
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: none; /* Prevent rubber-banding the main page */
    border: 1px solid var(--border);
    border-radius: 4px;
    padding-bottom: 8px; /* Room for scrollbar */
}

/* Custom Webkit Scrollbar to force visibility on Mac */
.table-wrapper::-webkit-scrollbar {
    height: 10px;
}
.table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-left: 580px; /* Offset for sticky columns */
    margin-right: 4px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.table-wrapper.active-drag {
    cursor: grabbing !important;
}
.table-wrapper.active-drag * {
    cursor: grabbing !important;
    user-select: none;
}

table {
    width: 100%;
    min-width: 1280px;
    table-layout: fixed;
    border-collapse: separate; /* Fixes sticky sub-pixel jitter */
    border-spacing: 0;
    text-align: left;
    white-space: nowrap;
}



th {
    background: var(--bg-secondary);
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.sortable {
    display: table-cell;
    cursor: pointer;
    user-select: none;
}

.sort-icon {
    vertical-align: middle;
    margin-left: 6px;
    opacity: 1; /* Never faded, matches label */
    color: inherit; /* Inherits the var(--text-secondary) from th */
    transition: all 0.2s;
}



th.sort-asc, 
th.sort-desc {
    color: var(--text-primary); /* Bolden the label when active */
    background: var(--border); /* Fill cell with darker shade for strong affordance */
}



th.sortable:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

th.num-col {
    text-align: right;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-secondary);
}

.num-col {
    text-align: right;
    font-weight: 700; /* Bolded for better ADA contrast and glanceability */
    font-variant-numeric: tabular-nums;
    padding-left: 32px;
}

.split-col {
    padding-left: 32px;
}

table.hide-splits .col-split,
table.hide-splits .split-col {
    display: none;
}


.price-cell {
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    padding-left: 12px; /* override .num-col 32px so both sub-columns fit */
}

/* Price value and 1D change each get a fixed, right-aligned slot so all
   dollar amounts align to each other AND all percentages align to each other */
.price-val {
    display: inline-block;
    min-width: 78px;
    text-align: right;
}

.price-change {
    display: inline-block;
    min-width: 72px;
    text-align: right;
    margin-left: 6px;
    font-size: inherit;
    font-weight: 700;
    white-space: nowrap;
}

.company-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* Single line; truncate long names with … (full name shown via #app-tooltip) */
    max-width: 260px;
    line-height: 1.2;
    cursor: default;
}

/* Custom tooltip for truncated company names — anchored to body so the
   table's overflow can't clip it. Themed for light and dark. */
#app-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    max-width: 360px;
    padding: 7px 11px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    white-space: normal;
    opacity: 0;
    transition: opacity 0.12s ease;
    /* Light mode defaults */
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid #e2e2e2;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

#app-tooltip.visible {
    opacity: 1;
}

body.dark-theme #app-tooltip {
    background: #2a2a2e;
    color: #f0f0f0;
    border: 1px solid #44444a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.report-col {
    text-align: left !important;
    padding-left: 40px !important;
}




.ticker-cell {
    font-weight: 500;
}

.pos {
    color: var(--positive);
}

.neg {
    color: var(--negative);
}

.report-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.report-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Empty State */
.empty-state {
    padding: 80px 32px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* Sort indicators removed to favor SVG implementation */

/* Sticky Columns Architecture */
.col-ticker, .col-company, .col-price {
    position: sticky;
    background: var(--bg-primary); /* Needs solid background so text underneath doesn't show */
    z-index: 2; /* Keep above scrolling cells */
}

th.col-ticker, th.col-company, th.col-price {
    background: var(--bg-secondary); /* Headers have different default background */
    z-index: 3; /* Keep above sticky body cells AND scrolling cells */
}

/* Inherit active sort background over sticky default */
th.sort-asc, th.sort-desc {
    background: var(--border) !important;
}

/* Base sticky positions */
.col-ticker { left: 0; min-width: 120px; max-width: 120px; }
.col-company { left: 120px; min-width: 260px; max-width: 260px; }
.col-price { left: 380px; min-width: 180px; max-width: 180px; } /* two right-aligned slots: price + 1D change */
.col-1d { left: 500px; min-width: 100px; max-width: 100px; }

/* Subtle drop shadow to indicate scroll on the last active sticky column */
.col-1d {
    box-shadow: 4px 0 8px -4px rgba(0,0,0,0.1);
}
.dark-theme .col-1d {
    box-shadow: 4px 0 8px -4px rgba(0,0,0,0.5);
}

/* Hover state overrides for sticky body cells */
tr:hover .col-ticker,
tr:hover .col-company,
tr:hover .col-price {
    background: var(--bg-secondary);
}

/* Media Queries for progressive un-sticking */
@media (max-width: 1024px) {
    /* Tablet: un-stick Price */
    .col-price {
        position: static;
        box-shadow: none;
    }
    .col-company {
        box-shadow: 4px 0 8px -4px rgba(0,0,0,0.1);
    }
    .dark-theme .col-company {
        box-shadow: 4px 0 8px -4px rgba(0,0,0,0.5);
    }
    .table-wrapper::-webkit-scrollbar-track {
        margin-left: 380px; /* Ticker + Company */
    }
}

@media (max-width: 767px) {
    .app-header { padding: 8px 0; }
    .header-content { flex-direction: column; gap: 6px; padding: 0 16px; }
    /* Keep nav links + theme toggle on one row, tighter spacing */
    .main-nav { gap: 4px; flex-wrap: nowrap; justify-content: center; align-items: center; }
    .nav-btn { font-size: 14px; padding: 6px 10px; }
    .theme-toggle-btn { margin-left: 8px; }
    .app-container { padding: 20px 16px; }

    /* Tighter gap between controls section and the table below */
    .controls { margin-bottom: 20px; }

    /* Stack search + button, both full width — with more breathing room between them */
    .search-container { flex-direction: column; align-items: stretch; gap: 20px; }
    .input-wrapper { width: 100%; }
    .primary-btn { padding: 16px; width: 100%; }

    /* Market indices: wrap instead of clipping — 2 per row, NASDAQ drops to row 2 */
    .indices-and-analyzer-row { flex-direction: column; align-items: stretch; gap: 12px; }
    #market-indices-bar {
        width: 100%;
        flex-wrap: wrap;
        overflow: visible;
        gap: 1px;
        background: var(--border); /* 1px gaps show as divider lines */
    }
    .index-card {
        flex: 1 1 45%; /* 2 per row; a lone card (NASDAQ) grows to fill row 2 */
        background: var(--bg-secondary);
    }
    .index-card + .index-card::before { display: none; } /* drop side dividers when wrapped */

    /* (Panel sizing handled in a later block so it wins the cascade) */

    /* Denser table on small screens */
    td, th { padding: 10px 8px; }

    /* Mobile: un-stick Company */
    .col-company {
        position: static;
        box-shadow: none;
    }
    .col-ticker {
        box-shadow: 4px 0 8px -4px rgba(0,0,0,0.1);
    }
    .dark-theme .col-ticker {
        box-shadow: 4px 0 8px -4px rgba(0,0,0,0.5);
    }
    .table-wrapper::-webkit-scrollbar-track {
        margin-left: 120px; /* Ticker only */
    }

    /* iOS safe-area insets — notch / home bar clearance */
    .app-header {
        padding-top: max(16px, env(safe-area-inset-top));
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .app-container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(80px, env(safe-area-inset-bottom));
    }

    /* Mobile pagination: label left, controls right, single row */
    .pagination-container {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0;
        margin-top: 16px;
    }
    .pagination-controls {
        position: static;
        transform: none;
        margin-left: auto;
    }
    .pagination-controls .page-prev,
    .pagination-controls .page-next {
        min-width: 36px;
        min-height: 36px;
        font-size: 20px;
        padding: 4px 8px;
        line-height: 1;
    }
    .page-badge {
        font-size: 13px;
        font-weight: 500;
        color: var(--text-secondary);
        padding: 0 4px;
        white-space: nowrap;
    }
    .pagination-info {
        margin-top: 0;
        text-align: left;
    }

    /* Import/Export right-aligned on mobile */
    .indices-and-analyzer-row {
        flex-direction: column;
        align-items: stretch;
    }
    .data-io-btns {
        justify-content: flex-end;
    }
}


/* Theme Toggle */
.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    margin-left: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    width: 44px; /* 44px touch target */
    height: 44px;
}


.theme-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.theme-toggle-btn svg {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    pointer-events: none;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}



.dark-theme .theme-toggle-btn svg {
    transform: rotate(45deg);
}


/* Hide/Show Icons — show the mode you'll switch INTO.
   Light mode -> moon (click to go dark); Dark mode -> sun (click to go light). */
.theme-toggle-btn .sun-icon { display: none; }
.theme-toggle-btn .moon-icon { display: block; }

.dark-theme .theme-toggle-btn .sun-icon { display: block; }
.dark-theme .theme-toggle-btn .moon-icon { display: none; }
/* --- Slide-in Report Panel --- */
body {
    transition: padding-right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-x: hidden;
}
body.panel-open {
    padding-right: 40vw;
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 40vw;
    height: 100vh;
    height: 100dvh; /* iOS Safari: avoids address-bar resize jump */
    background: var(--bg-panel);
    box-shadow: -10px 0 30px rgba(0,0,0,0.05);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    overflow: hidden; /* Panel itself does not scroll — only panel-content does */
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
.dark-theme .side-panel {
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}
.side-panel.open {
    transform: translateX(0);
}

/* Stock Ideas Specific Styles */
.mini-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.mini-table {
    width: 100% !important;
    min-width: 0 !important; /* Override global table min-width of 1280px */
    border-collapse: collapse;
    font-size: 14px;
    table-layout: auto; /* Changed to auto to prevent truncation */
}
.mini-table th, .mini-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: normal; /* Allow wrapping for company names */
}
.mini-table th:first-child, .mini-table td:first-child { width: 40px; } /* Checkbox/Ticker spacer */
.mini-table .num-col {
    text-align: right;
    font-weight: 700;
    width: 64px; /* Fixed width for numbers to prevent overlap (64px is divisible by 4) */
}
.ideas-divider {
    height: 1px;
    background: var(--border);
    margin: 32px 0;
}
.section-header-group {
    margin-bottom: 24px;
}
.muted-small {
    color: var(--text-tertiary);
    font-size: 12px;
    margin-top: 4px;
}
.rationale-text {
    line-height: 24px;
    color: var(--text-primary);
    font-style: normal;
    margin-top: 8px;
}
.panel-disclaimer {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    margin-top: auto;
    padding-top: 48px;
    padding-bottom: 16px;
    width: 100%;
    font-style: italic;
    line-height: 20px;
}

/* Pinned footer disclaimer — always visible at the bottom of the panel */
.panel-disclaimer--footer {
    flex-shrink: 0;
    margin-top: 0;
    padding: 0 24px 16px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    font-style: italic;
    line-height: 20px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
/* Rows already added to Future Prospects — visually muted */
tr.already-added {
    pointer-events: none;
}

tr.already-added .idea-checkbox {
    opacity: 0.45;
    cursor: not-allowed;
}

.wide-btn {
    width: 100%;
    padding: 16px !important;
    margin-top: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
}
.dev-notice {
    color: var(--text-tertiary);
    padding: 0;
    margin-bottom: 24px;
    font-size: 12px;
    text-align: left;
    font-weight: 500;
    font-style: italic;
    background: var(--bg-primary);
}


input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--text-primary);
}

/* Sticky Nav for Report */
.report-nav {
    position: sticky;
    top: 0; /* Clean lock to top */
    background: var(--bg-primary);
    display: flex;
    align-items: center; /* Centers links vertically to prevent clipping */
    gap: 20px;
    padding: 0 48px; /* Side padding only, vertical handled by min-height */
    min-height: 60px; /* Ensures plenty of headroom for text */
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    z-index: 10;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
.report-nav::-webkit-scrollbar { display: none; }

.report-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    padding: 4px 0;
}

.report-nav a:hover {
    color: var(--text-primary);
}

/* New Content Styles */
.sub-heading {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 24px 0 8px 0;
    font-weight: 600;
}

.watch-for-callout {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--text-primary);
    font-size: 16px;
    border-radius: 4px;
    line-height: 24px;
}

.clean-list {
    list-style: none;
    padding-left: 0 !important;
}

.clean-list li {
    margin-bottom: 12px;
}

.report-source-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.report-source-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.citation-link {
    color: var(--text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
    transition: var(--transition);
}

.citation-link:hover {
    color: var(--text-primary);
}

/* Analyst rating proportion bar */
.analyst-bar {
    display: flex;
    width: 100%;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 12px;
    background: var(--bg-secondary);
}
.analyst-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); /* keep numbers legible on any segment */
}
.analyst-seg.buy { background: #15803d; }
.analyst-seg.hold { background: #4b5563; }  /* darker grey so the count reads */
.analyst-seg.sell { background: #dc2626; }
.analyst-legend {
    display: flex;
    gap: 18px;
    margin-top: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.analyst-legend .dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.analyst-legend .dot.buy { background: #15803d; }
.analyst-legend .dot.hold { background: #4b5563; }
.analyst-legend .dot.sell { background: #dc2626; }

/* Related Articles — richer layout (title + source + summary) */
.related-articles { list-style: none; padding: 0; margin: 0; }
.related-articles .article-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.related-articles .article-item:last-child { border-bottom: none; }
.related-articles .article-title {
    font-weight: 600;
    display: inline;
}
.related-articles .article-source {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}
.related-articles .article-summary {
    margin: 4px 0 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* Inline grounded citations within report prose */
.inline-cite {
    font-size: 0.9em;
    color: #2563eb;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}
.dark-theme .inline-cite { color: #60a5fa; }
.inline-cite::before { content: "["; color: var(--text-secondary); font-weight: 600; }
.inline-cite::after { content: "]"; color: var(--text-secondary); font-weight: 600; }
.inline-cite:hover { text-decoration: underline; }

.back-to-top-container {
    display: flex;
    justify-content: flex-end; /* Right-align to the divider */
    margin-top: 16px;
}

.disclaimer {
    text-align: center;
    max-width: 90%;
    margin: 64px auto 32px auto; /* Deep margin-top for last piece of content */
    font-size: 14px;
    color: var(--text-tertiary);
}

.back-to-top {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.back-to-top:hover {
    color: var(--text-primary);
}

/* Ensure headings don't hide under the sticky nav when scrolling */
.panel-content h3 {
    scroll-margin-top: 90px; /* Adjusted for the new 16px gap */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding: 40px 40px 0 40px; 
    background: var(--bg-panel);
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 40px 40px 40px;
}

/* Custom Scrollbar for Report Panel (Pill Only) */
.panel-content::-webkit-scrollbar {
    width: 8px;
}
.panel-content::-webkit-scrollbar-track {
    background: transparent;
}
.panel-content::-webkit-scrollbar-thumb {
    background: #888888;
    border-radius: 8px;
}
.panel-content::-webkit-scrollbar-thumb:hover {
    background: #666666;
}
.panel-title-group h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 32px;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 700;
}
.report-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}
.report-timestamp {
    font-size: 12px;
    color: var(--timestamp-color);
    font-weight: 500;
}
.report-timestamp.stale {
    color: var(--timestamp-stale);
}
.ticker-badge {
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
}
.date-muted {
    color: var(--text-tertiary);
    font-size: 12px;
}
.report-price-capsule {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px 8px 4px 4px;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.report-price-val {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 16px;
}
.report-price-change {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
}
.panel-actions {
    display: flex;
    gap: 16px;
}
.icon-btn {
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}
.icon-btn:hover {
    background: var(--border);
}

.panel-content h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 20px;
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 600;
}
.panel-content p, .panel-content li {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 16px;
    line-height: 24px;
    color: var(--text-primary);
    margin-bottom: 16px;
}
.panel-content ul {
    padding-left: 24px;
}
.panel-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* Source links — WCAG 2.0 AA compliant in both modes */
.panel-content a {
    color: #0057B8; /* ~5.9:1 contrast on white */
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 500;
    transition: opacity 0.15s ease;
}
.panel-content a:hover {
    opacity: 0.75;
}
.dark-theme .panel-content a {
    color: #74B3FE; /* ~7.2:1 contrast on #050505 — passes WCAG AA */
}
.disclaimer {
    font-size: 12px !important;
    color: var(--text-tertiary) !important;
    margin-top: 48px;
    text-align: center;
}

/* Similar Stocks Styling */
.similar-stocks-container {
    margin-bottom: 40px;
}
.similar-stock-item {
    margin-bottom: 20px;
    line-height: 24px;
}
.similar-stock-item:last-child {
    margin-bottom: 0;
}

/* Report Price Table */
.report-prices-table {
    width: 100% !important;
    min-width: 0 !important; /* Override global table min-width of 1280px */
    table-layout: fixed;
    border-collapse: collapse;
    margin-bottom: 32px;
}
.report-prices-table th,
.report-prices-table td {
    padding: 12px 8px !important;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    background: transparent;
}
.report-prices-table th:first-child,
.report-prices-table td:first-child {
    padding-left: 0 !important;
}
.report-prices-table th:last-child,
.report-prices-table td:last-child {
    padding-right: 0 !important;
}
.report-prices-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.report-prices-table td {
    font-size: 16px;
    font-weight: 700;
}
.report-prices-table .num-col {
    text-align: right;
}
.report-prices-table .price-cell {
    text-align: left;
}
.report-prices-table .price-val {
    color: var(--text-primary);
    font-weight: 700;
}
.report-prices-table .price-change {
    margin-left: 8px;
    font-size: inherit;
    font-weight: 700;
}

/* Loading & Error States */
.panel-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
    color: var(--text-primary);
}
.panel-status .lucide {
    width: 48px;
    height: 48px;
    margin-bottom: 24px;
    color: var(--text-secondary);
}
.panel-status h3 {
    margin-bottom: 8px;
    margin-top: 0;
}
.spinner {
    animation: spin 1.2s linear infinite;
    color: var(--text-primary) !important;
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}
.retry-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: 6px;
    margin-top: 16px;
    font-weight: 600;
}
.retry-btn:hover {
    background: var(--bg-hover);
}

/* --- Skeleton Shimmering --- */
.skeleton-row td {
    position: relative;
    overflow: hidden;
    height: 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
.skeleton-row td::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.05) 20%,
        rgba(255, 255, 255, 0.1) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: shimmer 2s infinite;
}
.dark-theme .skeleton-row td::after {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.02) 20%,
        rgba(255, 255, 255, 0.05) 60%,
        rgba(255, 255, 255, 0)
    );
}
@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

.ideas-loading-ui {
    height: 300px; /* Matching the expected table height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-panel);
    border-radius: 8px;
    margin: 24px 0;
}

.price-cell {
    white-space: nowrap;
}

.ideas-progress {
    width: 80%;
    margin-top: 24px;
    padding: 0; /* Remove old padding */
    background: transparent;
}
/* --- Responsive Tiered Sticky Columns --- */

/* Base Logic: Ticker is always sticky, others depend on space */
.col-ticker { position: sticky; left: 0; z-index: 2; }

/* Small Viewports: Only Ticker is sticky */
@media (max-width: 900px) {
    .col-company, .col-price {
        position: static !important;
        left: auto !important;
        box-shadow: none !important;
    }
}

/* Medium Viewports: Ticker and Company are sticky */
@media (min-width: 901px) and (max-width: 1200px) {
    .col-price {
        position: static !important;
        left: auto !important;
        box-shadow: none !important;
    }
}

/* HIGH-VISIBILITY MODE: When any side panel is open, only Ticker stays sticky */
/* This ensures maximum room for performance data in the compressed layout */
body.panel-open .col-company, 
body.panel-open .col-price {
    position: static !important;
    left: auto !important;
    box-shadow: none !important;
}

/* --- Stock Analyzer Header Styles --- */
.analyzer-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 32px;
    color: var(--text-primary);
    font-weight: 700;
    margin: 0;
}

.analyzer-sub-header {
    margin-top: 24px; /* Precise 24px gap */
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.analyzer-ticker {
    font-weight: 700;
    color: var(--bg-primary);
    background: var(--text-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
}

.dot-separator {
    color: var(--text-tertiary);
    font-weight: 700;
}

.analyzer-company {
    font-weight: 500;
}
/* Pagination */
/* Table top bar — record count sits above the table, always visible */
.table-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 10px 0;
}

.table-record-count {
    font-size: 13px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* Bottom pagination row: label left, controls absolutely centered */
.pagination-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-top: 20px;
    width: 100%;
    padding: 0 4px;
    min-height: 36px;
}

.pagination-controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-tertiary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Pill buttons */
.page-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: var(--transition);
    min-width: 34px;
    text-align: center;
    line-height: 1.2;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Prev/Next chevrons — slightly larger, no border fill */
.page-btn.page-prev,
.page-btn.page-next {
    font-size: 18px;
    padding: 4px 8px;
    border-color: transparent;
    color: var(--text-secondary);
}

.page-btn.page-prev:hover:not(:disabled),
.page-btn.page-next:hover:not(:disabled) {
    border-color: var(--border);
    color: var(--text-primary);
}

.page-ellipsis {
    font-size: 14px;
    color: var(--text-tertiary);
    padding: 0 4px;
    user-select: none;
}

/* Mobile compact badge */
.page-badge {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0 6px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* --- Idle Timeout Modals --- */
body.idle-modal-open {
    overflow: hidden !important;
}

.idle-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: idleFadeIn 0.3s ease;
}

.dark-theme .idle-modal-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.idle-modal-overlay--full {
    background: var(--bg-primary) !important;
    backdrop-filter: blur(30px) brightness(0.2) !important;
    -webkit-backdrop-filter: blur(30px) brightness(0.2) !important;
}

.idle-modal-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
    text-align: center;
    animation: idleScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.dark-theme .idle-modal-card {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.idle-modal-card--full {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
}

.idle-modal-card h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.idle-modal-card p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 24px;
}

.countdown-highlight {
    font-weight: 700;
    color: var(--negative);
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    padding: 0 4px;
}

.idle-modal-actions {
    display: flex;
    justify-content: center;
}

.idle-modal-actions .primary-btn {
    min-width: 180px;
    padding: 14px 32px;
}

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

@keyframes idleScaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- Access Restriction Screen --- */
body.access-restricted .app-header,
body.access-restricted .app-container,
body.access-restricted .side-panel,
body.access-restricted .panel-disclaimer--footer {
    display: none !important;
}

.access-required-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10000;
}

.access-required-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 56px 40px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
    text-align: center;
    animation: idleScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.dark-theme .access-required-card {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.lock-icon-container {
    color: var(--negative);
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.access-required-card h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.access-required-card p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 24px;
    margin: 0;
}

/* ============================================================
   Responsive panel sizing — placed at end of file so it wins
   the cascade over the base .side-panel / .panel-* rules above.
   ============================================================ */
@media (max-width: 1024px) {
    /* Tablet: slide-in panel needs more room than 40vw */
    .side-panel { width: 64vw; }
}
@media (max-width: 767px) {
    /* Phone: panel goes full-screen with tighter padding + iOS safe-area insets */
    .side-panel { width: 100vw; }
    .panel-header {
        padding: max(24px, env(safe-area-inset-top)) 20px 0 20px;
        margin-bottom: 20px;
    }
    .panel-content {
        padding: 0 20px max(24px, env(safe-area-inset-bottom)) 20px;
    }
}


/* ============================================================
   Select + Move columns (Future Prospects only)
   ============================================================ */
table.hide-select .col-select,
table.hide-select .select-col,
table.hide-select .col-move,
table.hide-select .move-col {
    display: none;
}

.select-col {
    text-align: center;
    padding-left: 12px;
    padding-right: 4px;
}

/* The select column sits left of the sticky Ticker column, so it must be
   sticky too — and the existing sticky offsets shift right by its 48px. */
table:not(.hide-select) .select-col {
    position: sticky;
    left: 0;
    background: var(--bg-primary);
    z-index: 2;
}

table:not(.hide-select) th.select-col {
    background: var(--bg-secondary);
    z-index: 3;
}

table:not(.hide-select) tr:hover .select-col {
    background: var(--bg-secondary);
}

table:not(.hide-select) .col-ticker  { left: 48px; }
table:not(.hide-select) .col-company { left: 168px; }
table:not(.hide-select) .col-price   { left: 428px; }
table:not(.hide-select) .col-1d      { left: 548px; }

/* Tablet un-sticks Price, phone also un-sticks Company — keep select aligned */
@media (max-width: 1024px) {
    table:not(.hide-select) .col-price { position: static; }
}
@media (max-width: 767px) {
    table:not(.hide-select) .col-company { position: static; }
    .select-col { padding-left: 8px; }
}

/* 44px hit area via padding, 18px visual box */
.row-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    /* Not --border-hover: that's #CCC, only 1.5:1 on the light bg.
       These two clear the 3:1 UI-component minimum in both themes. */
    border: 2px solid #767676;
    border-radius: 4px;
    background: var(--bg-primary);
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: var(--transition);
    flex-shrink: 0;
}

.dark-theme .row-checkbox {
    border-color: #8C8C8C;
}

.row-checkbox:hover {
    border-color: var(--text-primary);
}

.row-checkbox:checked,
.row-checkbox:indeterminate {
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.row-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 0px;
    width: 5px;
    height: 10px;
    border: solid var(--bg-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.row-checkbox:indeterminate::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 6px;
    width: 10px;
    height: 2px;
    background: var(--bg-primary);
}

.row-checkbox:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* Move button — mirrors .delete-btn, positive intent */
.move-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.move-btn:hover {
    color: var(--positive);
    background: rgba(0, 138, 0, 0.12);
}

.dark-theme .move-btn:hover {
    color: var(--positive);
    background: rgba(34, 197, 94, 0.16);
}

.move-btn:focus-visible,
.delete-btn:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

.move-btn svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}


/* ============================================================
   Confirmation modal
   ============================================================ */
body.modal-open {
    overflow: hidden !important;
}

.confirm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: idleFadeIn 0.2s ease;
}

.confirm-modal-overlay[hidden] {
    display: none;
}

.dark-theme .confirm-modal-overlay {
    background: rgba(0, 0, 0, 0.35);
}

.confirm-modal-card {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 14px;
    padding: 32px;
    max-width: 420px;
    width: 100%;
    /* Layered shadow: tight edge + broad lift, so the card reads as
       floating above the blur rather than sinking into it. */
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 12px 24px rgba(0, 0, 0, 0.10),
        0 32px 64px rgba(0, 0, 0, 0.14);
    animation: idleScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark: a lifted surface, lighter than the page, with a bright top edge */
.dark-theme .confirm-modal-card {
    background: #1E1E1E;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 12px 24px rgba(0, 0, 0, 0.55),
        0 32px 64px rgba(0, 0, 0, 0.65);
}

.confirm-modal-card h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--text-primary);
}

.confirm-modal-card p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 22px;
    margin: 0;
}

.confirm-modal-card p strong {
    color: var(--text-primary);
    font-weight: 600;
}

.confirm-modal-list {
    list-style: none;
    margin: 16px 0 0 0;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.confirm-modal-list[hidden] {
    display: none;
}

.confirm-modal-list li {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 10px;
}

.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 28px;
}

.confirm-cancel-btn,
.confirm-ok-btn {
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 500;
    padding: 11px 22px;
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.confirm-cancel-btn {
    background: transparent;
    border: 1px solid #767676;
    color: var(--text-primary);
}

.dark-theme .confirm-cancel-btn {
    border-color: #8C8C8C;
}

.confirm-cancel-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.confirm-ok-btn {
    background: var(--text-primary);
    border: 1px solid var(--text-primary);
    color: var(--bg-primary);
}

.confirm-ok-btn:hover {
    opacity: 0.85;
}

.confirm-ok-btn.danger {
    background: var(--negative);
    border-color: var(--negative);
    color: #FFFFFF; /* 4.98:1 on #D32F2F */
}

/* Dark theme's --negative is a light red, so white text would only hit
   2.8:1 — flip to near-black for 7.6:1. */
.dark-theme .confirm-ok-btn.danger {
    color: #14161A;
}

.confirm-cancel-btn:focus-visible,
.confirm-ok-btn:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

.dark-theme .confirm-ok-btn.danger:focus-visible {
    outline-color: #FFFFFF;
}


/* ============================================================
   Undo toast — between the search bar and the table
   ============================================================ */
.action-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.action-toast[hidden] {
    display: none;
}

.action-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.action-toast-msg {
    flex: 1;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 20px;
}

.action-toast-msg strong {
    color: var(--text-primary);
    font-weight: 600;
}

.action-toast-undo {
    background: transparent;
    border: 1px solid #767676;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    min-height: 44px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.action-toast-undo:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.action-toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.action-toast-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.action-toast-close svg {
    width: 16px;
    height: 16px;
}

.action-toast-undo:focus-visible,
.action-toast-close:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}


/* ============================================================
   Sticky bulk-action bar
   ============================================================ */
.selection-bar {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(12px);
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border-hover);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.selection-bar[hidden] {
    display: none;
}

/* Keep the floating bar from covering the last table row */
body.selection-active .app-container {
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

.selection-bar.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.dark-theme .selection-bar {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
}

.dark-theme .selection-clear-btn,
.dark-theme .action-toast-undo {
    border-color: #8C8C8C;
}

.selection-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.selection-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-clear-btn {
    background: transparent;
    border: 1px solid #767676;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.selection-clear-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.selection-move-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--text-primary);
    border: 1px solid var(--text-primary);
    color: var(--bg-primary);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.selection-move-btn:hover {
    opacity: 0.85;
}

.selection-move-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.selection-clear-btn:focus-visible,
.selection-move-btn:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

@media (max-width: 767px) {
    .selection-bar {
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(12px);
        justify-content: space-between;
        gap: 12px;
        padding: 12px;
    }
    .selection-bar.visible {
        transform: translateX(0) translateY(0);
    }
    .selection-count {
        font-size: 13px;
    }
    .selection-move-btn span {
        display: none; /* icon-only on phone to keep the bar compact */
    }
    .selection-move-btn {
        padding: 10px 14px;
    }

    .action-toast {
        flex-wrap: wrap;
        gap: 8px;
    }
    .action-toast-msg {
        flex: 1 1 60%;
    }

    .confirm-modal-card {
        padding: 24px;
    }
    .confirm-modal-actions {
        flex-direction: column-reverse;
    }
    .confirm-cancel-btn,
    .confirm-ok-btn {
        width: 100%;
    }
}
