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

:root {
    /* UI surfaces — Slate Glass (Palette 6). Chart hues: chart-theme.js / Palette 5. */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #94a3b8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    /* Ocean Luminous — charts only (see .cursor/skills/design-system/references/color-palettes.md) */
    --chart-positive: #34d399;
    --chart-negative: #fb7185;
    --chart-series-1: #38bdf8;
    --chart-series-2: #a78bfa;
    --chart-series-3: #2dd4bf;
    --chart-series-4: #fbbf24;
    --chart-series-5: #fb7185;
    --chart-cash: #cbd5e1;
    --bg-color: rgba(15, 23, 42, 0.85);
    /* Surfaces: same slate hue as page gradient, slightly lifted + translucent for a soft blend */
    --surface-mid: #1a2538;
    --surface-raised: #243044;
    --card-bg: rgba(38, 50, 68, 0.62);
    --card-bg-hover: rgba(48, 62, 82, 0.78);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: rgba(148, 163, 184, 0.14);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.28);

    /* Legacy alias — muted accent, not rainbow */
    --rainbow-gradient: linear-gradient(90deg, #374151 0%, #4b5563 100%);
    --rainbow-gradient-45: linear-gradient(45deg, #374151 0%, #4b5563 100%);

    /* Layout (overridden by layout.css / layout preferences) */
    --sidebar-width-collapsed: 80px;
    --sidebar-width-expanded: 260px;
    --layout-max-width: 1400px;
    --layout-container-padding: 20px;
    --layout-section-gap: 30px;
    --layout-font-scale: 1;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(
        145deg,
        #0f172a 0%,
        #151f32 22%,
        #1a2538 50%,
        #151f32 78%,
        #0f172a 100%
    );
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow-x: clip;
    position: relative;
}

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width-collapsed);
    background: linear-gradient(
        180deg,
        rgba(26, 36, 52, 0.92) 0%,
        rgba(20, 28, 42, 0.88) 100%
    );
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    border-right: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 100vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    /* Hide scrollbar */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.sidebar::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.sidebar:hover {
    width: var(--sidebar-width-expanded);
}

/* Sidebar starts collapsed, expands on hover */

.sidebar-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 24px 16px;
    gap: 32px;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-anchor: none;
    /* Hide scrollbar - comprehensive approach */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    position: relative;
}

/* Hide scrollbar for WebKit browsers (Chrome, Safari, Opera, Edge) */
.sidebar-body::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background: transparent;
    display: none;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: transparent;
    display: none;
}

.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
    display: none;
}

.sidebar-body::before,
.sidebar-body::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 30px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-body::before {
    top: 0;
    background: linear-gradient(to bottom, var(--card-bg) 0%, transparent 100%);
}

.sidebar-body::after {
    bottom: 0;
    background: linear-gradient(to top, var(--card-bg) 0%, transparent 100%);
}

.sidebar-body.scrollable-top::before {
    opacity: 1;
}

.sidebar-body.scrollable-bottom::after {
    opacity: 1;
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
    overflow-y: visible;
    overflow-x: hidden;
    /* Hide scrollbar if any */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.sidebar-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Sidebar Header with Logo */
.sidebar-header {
    padding: 16px 0 24px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 0;
}

.sidebar-logo {
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    transition: all 0.3s;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
    transition: width 0.3s, height 0.3s;
}

.sidebar:hover .logo-icon {
    width: 67px;
    height: 67px;
}

.logo-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s, max-height 0.3s;
}

.sidebar:hover .logo-text {
    opacity: 1;
    max-height: 100px;
}

.logo-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    margin: 0;
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

/* Sidebar Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav-group {
    margin: 0;
}

.sidebar-nav-group > summary {
    list-style: none;
    cursor: pointer;
}

.sidebar-nav-group > summary::-webkit-details-marker {
    display: none;
}

.sidebar-nav-group > summary.sidebar-link {
    width: 100%;
    box-sizing: border-box;
}

.sidebar:not(:hover) .sidebar-nav-group-toggle::after {
    display: none;
}

.sidebar-nav-group-toggle::after {
    content: '▾';
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.55;
    transition: transform 0.15s ease;
}

.sidebar-nav-group[open] .sidebar-nav-group-toggle::after {
    transform: rotate(180deg);
}

.sidebar-nav-sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 4px 0;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

.sidebar-link-sub {
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.sidebar-link-sub .sidebar-link-text {
    font-size: 0.875rem;
}

.sidebar:not(:hover) .sidebar-nav-sub {
    display: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(37, 99, 235, 0.1) 100%);
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 0 4px 4px 0;
}

/* Login-gated nav: visible but greyed out and non-interactive for guests */
.sidebar-link.sidebar-link--login-required,
.footer-extras .login-required-nav {
    opacity: 0.45;
    color: var(--text-secondary);
    filter: grayscale(0.55);
    pointer-events: none;
    cursor: not-allowed;
    user-select: none;
}

.sidebar-link.sidebar-link--login-required:hover,
.footer-extras .login-required-nav:hover {
    opacity: 0.45;
    color: var(--text-secondary);
    background: transparent;
    transform: none;
}

.sidebar-link.sidebar-link--login-required.active {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar-link.sidebar-link--login-required.active::before {
    background: rgba(148, 163, 184, 0.45);
}

button.sidebar-link.sidebar-nav-action.sidebar-link--login-required:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar-link-icon {
    font-size: 1.25rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-link-text {
    flex: 1;
    transition: opacity 0.2s;
}

.sidebar:not(:hover) .sidebar-link-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar:not(:hover) .sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar:hover .sidebar-link-text {
    opacity: 1;
    width: auto;
}

.sidebar:hover .sidebar-link {
    justify-content: flex-start;
    padding: 12px 16px;
}

/* Sidebar Footer (alerts + account): same rhythm as .sidebar-nav links */
.sidebar-footer {
    padding-top: 8px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}

/* Full width wrapper for analysis page */
body:has(.analysis-page) .main-wrapper,
.main-wrapper:has(.analysis-page) {
    max-width: 100%;
}

.container {
    flex: 1;
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: var(--layout-container-padding);
    width: 100%;
    box-sizing: border-box;
}

/* Ensure container doesn't constrain sections within main-content */
.main-content section .container,
.main-content .container {
    max-width: 100%;
    width: 100%;
    padding-left: var(--layout-container-padding);
    padding-right: var(--layout-container-padding);
    box-sizing: border-box;
}

/* REMOVE CONTAINER MAX-WIDTH FOR ANALYSIS PAGE */
body:has(.analysis-page) .container,
.container:has(.analysis-page) {
    max-width: none !important;
    width: 100% !important;
}

/* FORCE EVERYTHING TO MATCH HEADER - NO CONSTRAINTS */
.main-content.analysis-page {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ALL SECTIONS FULL WIDTH - SAME AS HEADER */
.analysis-page section,
.analysis-page .control-panel,
.analysis-page .results-section {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* FORCE FULL WIDTH FOR ANALYSIS PAGE */
/* Make container full width when it contains analysis page */
.container:has(.analysis-page) {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
}

/* Make main-content full width */
.main-content.analysis-page {
    max-width: 100% !important;
    width: 100% !important;
}

/* Make all sections full width */
.analysis-page .control-panel,
.analysis-page .results-section,
.analysis-page section {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Per-ticker digest: one main column so the centered article is not split by grid gaps */
.main-content:has(> article.journal-digest-page) {
    grid-template-columns: 1fr;
}

/*
 * Journal digest shell — mirrors analysis-page “full rail” behavior.
 * Article typography and components live in `static/css/journal-digest.css`.
 * `.container { max-width: var(--layout-max-width) }` from visually shrinking the digest
 * next to wide layouts and survives stale caches / specificity quirks.
 */
body:has(article.journal-digest-page) .container,
.container:has(> .main-content > article.journal-digest-page) {
    max-width: 100% !important;
    width: 100% !important;
}

body:has(article.journal-digest-page) .main-wrapper,
.main-wrapper:has(article.journal-digest-page) {
    max-width: 100%;
}

article.journal-digest-page.digest-article-layout,
.main-content > article.journal-digest-page.digest-article-layout {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

article.journal-digest-page .digest-page-unit {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Main Header removed - moved to sidebar */

/*
 * Default: dashboard-style grid for multi-panel pages (analysis, portfolio, …).
 * Long-form / bespoke pages: opt out via body.layout-self-directed or .main-content.layout-freeform
 * (see layout-scope.css + {% block body_class %} / {% block main_content_class %} in base.html).
 */
.main-content {
    display: grid;
    grid-template-columns: var(--layout-main-columns, 1fr 1fr);
    gap: var(--layout-section-gap);
    margin-bottom: 40px;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure all direct children sections within main-content span full width */
.main-content > section {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Ensure all section types span full width */
.main-content > .portfolio-section,
.main-content > .analytics-section,
.main-content > .watchlists-section,
.main-content > .compare-section,
.main-content > .data-panel,
.main-content > .control-panel,
.main-content > .charts-section,
.main-content > .currencies-section,
.main-content > .watchlists-grid,
.main-content > section.portfolio-section,
.main-content > section.analytics-section,
.main-content > section.watchlists-section,
.main-content > section.compare-section,
.main-content > section.charts-section,
.main-content > section.currencies-section {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
}

/* Ensure all content within sections spans full width */
.main-content section {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure nested containers and dashboards within sections span full width */
.main-content section .portfolio-dashboard,
.main-content section .analytics-dashboard,
.main-content section .watchlists-grid,
.main-content section .compare-section,
.main-content section .charts-section-header,
.main-content section .currencies-section > *,
.main-content section > div:first-child {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure all direct div children of main-content that should span full width */
.main-content > div[class*="section"],
.main-content > div[class*="dashboard"],
.main-content > div[class*="wrapper"] {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure page-header and tabs always span full width */
.main-content .page-header,
.main-content .tabs-navigation-wrapper {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
}

/* Ensure common section containers span full width */
.main-content section > div.dashboard,
.main-content section > div.content-wrapper,
.main-content section > div.container,
.main-content section > div[class*="dashboard"],
.main-content section > div[class*="wrapper"] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
}

/* Override any max-width constraints on section content */
.main-content section > * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure any nested sections within main-content also span full width */
.main-content section section,
.main-content section.help-section,
.main-content section.settings-section {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
}

/* Override any max-width constraints on sections within main-content */
.main-content section[style*="max-width"],
.main-content > section[style*="max-width"] {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Ensure help-section and settings-section span full width */
.main-content .help-section,
.main-content .settings-section,
.main-content > .help-section,
.main-content > .settings-section {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
}

/* Global rule: All sections within main-content should span full width */
.main-content section,
.main-content > section {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Override max-width constraints on sections within main-content (except intentionally centered content like error pages) */
.main-content > section[style*="max-width"] {
    max-width: 100% !important;
    width: 100% !important;
}

/* Ensure all direct div children that are content containers span full width */
.main-content > div:not(.dashboard-quick-stats):not(.dashboard-grid):not(.dashboard-widget):not([class*="modal"]):not([id*="modal"]) {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Stock digest (/insights/<ticker>): article must span the full main grid (same as sections/divs) */
.main-content > article.digest-article-layout {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Digest runs live inside the article; avoid chaining section grid rules onto them */
.main-content article.journal-digest-page section.digest-run {
    grid-column: unset;
    width: auto;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Common section classes - ensure they span full width */
.currencies-section,
.compare-section,
.help-section,
.portfolio-section,
.analytics-section,
.watchlists-section,
.charts-section,
.settings-section {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
}

/* Ensure minimum padding on all boxes/cards/containers */
.stat-card {
    padding: 20px !important;
    box-sizing: border-box;
}

/* Ensure dashboard-widget has proper padding if not specified inline */
.dashboard-widget:not([style*="padding"]) {
    padding: 24px;
    box-sizing: border-box;
}

/* Ensure dashboard-widget with inline padding has at least 20px */
.dashboard-widget[style*="padding"] {
    padding: max(20px, var(--min-padding, 20px)) !important;
}

/* Ensure table containers have proper padding */
.yearly-returns-table-container {
    padding: 24px !important;
    box-sizing: border-box;
}

/* Ensure table cells have proper padding — compact in analytics */
.analytics-section #yearly-returns-table td,
.analytics-section #yearly-returns-table th {
    padding: 10px 8px !important;
    box-sizing: border-box;
}

/* Ensure chart containers have proper padding */
.chart-container {
    padding: 24px !important;
    box-sizing: border-box;
}

/* Chart wrappers inside containers should fill container without padding */
.chart-wrapper {
    padding: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

/* Portfolio Analytics: headings and labels next to charts — white for readability */
.analytics-section .analytics-header h2,
.analytics-section .portfolio-charts-section h3,
.analytics-section .yearly-returns-section h3,
.analytics-section .analytics-header .currency-selector-label {
    color: #ffffff;
}

.analytics-section #yearly-returns-table thead th {
    color: #ffffff;
}

.analytics-section #yearly-returns-table tbody td {
    color: rgba(255, 255, 255, 0.92);
}

/* Ensure portfolio and analytics dashboards have proper padding */
.portfolio-dashboard,
.analytics-dashboard {
    padding: 24px !important;
    box-sizing: border-box;
}

/* Ensure currency containers have proper padding */
.currency-hover-grid:not([style*="padding"]),
.currency-filter-wrapper:not([style*="padding"]) {
    padding: 20px;
    box-sizing: border-box;
}

/* Ensure data-status boxes have proper padding */
.data-status {
    padding: 20px !important;
    box-sizing: border-box;
}

/* Ensure all boxes with background/border in templates have minimum padding */
div[style*="background"][style*="rgba"]:not([style*="padding"]):not(.modal-content):not([class*="overlay"]) {
    padding: 20px;
    box-sizing: border-box;
}

/* Ensure help section content boxes have proper padding */
.help-section div[style*="background"]:not([style*="padding"]) {
    padding: 20px !important;
}

/* Ensure form inputs and selects have proper padding */
.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px !important;
    margin: 0;
    box-sizing: border-box;
}

/* Ensure small text elements have proper margins */
.form-group small,
.control-panel small,
section.control-panel small {
    display: block;
    margin: 6px 0 0 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure date grid has proper margins */
.form-group > div[style*="grid"] {
    margin: 12px 0 0 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Ensure nested labels in date grid have proper margins */
.form-group > div[style*="grid"] label {
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Ensure flex containers have proper spacing */
.form-group > div[style*="flex"] {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    gap: 10px !important;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

/* Ensure currencies-section and compare-section span full width when in main-content */
.main-content .currencies-section,
.main-content .compare-section,
.main-content > .currencies-section,
.main-content > .compare-section {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Compare page: same glass + animated rainbow treatment as Charts tab / EPS-style previews */
.main-content > .compare-page-shell {
    grid-column: 1 / -1;
}

.compare-page-shell {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 40px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 28px;
    padding: 28px 28px 32px;
    box-shadow:
        0 12px 48px 0 rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.18);
    position: relative;
    overflow: hidden;
}

.compare-page-shell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--rainbow-gradient);
    background-size: 300% 100%;
    animation: rainbowBorder 3s linear infinite;
    z-index: 1;
    border-radius: 28px 28px 0 0;
}

.compare-page-shell::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(59, 130, 246, 0.1) 0%,
        rgba(16, 185, 129, 0.08) 30%,
        rgba(255, 0, 128, 0.06) 60%,
        transparent 100%);
    opacity: 0.4;
    animation: glassShimmer 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.compare-page-shell > * {
    position: relative;
    z-index: 2;
}

/* When page-header is present, adjust main-content */
.page-header + .main-content,
.page-header + .dashboard-grid,
.page-header + .dashboard-quick-stats {
    margin-top: 0;
}

/* Ensure page-header is full width */
.page-header {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure dashboard-grid matches page-header width exactly */
.page-header + .dashboard-grid,
.page-header + .analysis-page-grid {
    grid-column: 1 / -1; /* Span all columns like page-header */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Ensure tabs navigation and related sections span full width */
.main-content .tabs-navigation-wrapper {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1001;
        width: 80px;
        transform: translateX(0);
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar:hover {
        width: 260px;
    }

    .main-wrapper {
        width: 100%;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .data-panel,
    .control-panel,
    .results-section {
        grid-column: 1;
    }
    
    /* Analysis page responsive - stack on mobile */
    .analysis-page .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .analysis-page .control-panel {
        grid-column: 1;
    }
    
    .analysis-page .results-section {
        grid-column: 1;
    }
    
    .analysis-page #output-container {
        max-height: 600px;
    }
}

section {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 12px;
    padding: 30px !important;
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.37),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

/* History Section Specific Styling */
.history-section,
section.history-section {
    padding: 30px !important;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.history-section-header,
.history-header-content {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.history-title {
    margin: 0 0 10px 0 !important;
    padding: 0 !important;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.history-actions {
    margin: 0;
    padding: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.history-list {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.history-item {
    margin: 0 0 15px 0;
    padding: 24px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.history-item > * {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.history-item h3 {
    margin: 0 0 5px 0 !important;
    padding: 0 !important;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.history-item > div {
    margin: 0 0 10px 0;
    padding: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Company selector wrapper in history actions */
.history-actions .company-selector-wrapper {
    margin: 0;
    padding: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.history-actions input[type="text"],
.history-actions input[type="date"],
.history-actions select {
    padding: 10px 12px !important;
    margin: 0;
    box-sizing: border-box;
}

section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%,
        rgba(255, 255, 255, 0.3) 20%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0.3) 80%,
        transparent 100%);
    opacity: 0.6;
    z-index: 1;
}

section::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, 
        rgba(59, 130, 246, 0.1) 0%,
        rgba(16, 185, 129, 0.08) 30%,
        rgba(255, 0, 128, 0.06) 60%,
        transparent 100%);
    opacity: 0.4;
    animation: glassShimmer 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

section > * {
    position: relative;
    z-index: 2;
}

section:hover {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 12px 48px 0 rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 30px rgba(59, 130, 246, 0.2);
}

@keyframes glassShimmer {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.3;
    }
    33% {
        transform: translate(30%, 30%) scale(1.1);
        opacity: 0.5;
    }
    66% {
        transform: translate(-20%, 20%) scale(0.9);
        opacity: 0.4;
    }
}

section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding: 0 0 10px 0;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

/* Ensure all sections have proper padding for content */
section > *:first-child {
    margin-top: 0;
}

section > *:last-child {
    margin-bottom: 0;
}

/* Data Panel */
.data-panel {
    grid-column: 1;
    margin-bottom: 30px;
    padding: 24px;
    box-sizing: border-box;
}

.data-status {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.data-status h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    border: none;
    padding: 0;
}

.data-status-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.data-status-item:last-child {
    border-bottom: none;
}

.data-status-item .status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge.available {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.unavailable {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.checkbox-label:hover {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    width: auto;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"]:checked + span {
    font-weight: 500;
    color: var(--primary-color);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

/* Control Panel */
.control-panel,
section.control-panel {
    grid-column: 1;
    max-width: 100%;
    width: 100%;
    padding: 24px !important;
    box-sizing: border-box;
}

/* Ensure h2 in control-panel has proper margins */
.control-panel h2,
section.control-panel h2 {
    margin: 0 0 20px 0;
    padding: 0 0 10px 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure form and form-group elements respect parent padding */
.control-panel form,
section.control-panel form {
    margin: 0;
    padding: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.control-panel .form-group,
section.control-panel .form-group {
    margin: 0 0 20px 0;
    padding: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure labels and inputs have proper margins and respect padding */
.control-panel .form-group label,
section.control-panel .form-group label {
    margin: 0 0 8px 0;
    padding: 0;
    display: block;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.control-panel .form-group input,
.control-panel .form-group select,
.control-panel .form-group textarea,
section.control-panel .form-group input,
section.control-panel .form-group select,
section.control-panel .form-group textarea {
    margin: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Analysis page specific layout - side by side */
.analysis-page .main-content {
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
    width: 100%;
    max-width: 100%;
}

.analysis-page .control-panel {
    grid-column: 1;
    width: 100%;
    max-width: 100%;
    position: relative;
    max-height: none;
    overflow-y: visible;
    overflow-x: visible;
    padding: 24px !important;
    box-sizing: border-box;
}

.analysis-page .results-section {
    grid-column: 2;
    min-height: 500px;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.analysis-page .results-section > div:first-child {
    flex-shrink: 0;
}

.analysis-page #output-container {
    flex: 1;
    min-height: 500px;
}

.form-group {
    margin: 0 0 20px 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin: 0 0 8px 0;
    padding: 0;
    color: var(--text-primary);
    width: 100%;
    box-sizing: border-box;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    background-color: rgba(15, 23, 42, 0.6);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s, background-color 0.2s;
}

.form-group select {
    padding-right: 2.5rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-group select option {
    background-color: rgb(15, 23, 42);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    margin-top: 15px;
}

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

/* Results Section */
.results-section {
    grid-column: 1 / -1; /* Span full width across all columns */
    min-height: 400px;
    width: 100%;
    position: relative;
    overflow: visible;
    padding: 24px;
    box-sizing: border-box;
}


#output-container {
    position: relative;
    z-index: 1;
}

@media (max-width: 1024px) {
    .results-section {
        grid-column: 1 / -1; /* Still full width on mobile */
    }
    
    /* Keep side by side on tablets for analysis page if space allows */
    .analysis-page .dashboard-grid,
    .analysis-page-grid,
    .dashboard-grid:has(.control-panel):has(.results-section) {
        grid-template-columns: 1fr 1fr;
    }
    
    .analysis-page .dashboard-grid .control-panel,
    .analysis-page-grid .control-panel,
    .dashboard-grid:has(.control-panel):has(.results-section) .control-panel {
        grid-column: 1;
    }
    
    .analysis-page .dashboard-grid .results-section,
    .analysis-page-grid .results-section,
    .dashboard-grid:has(.control-panel):has(.results-section) .results-section {
        grid-column: 2;
        grid-column-end: auto;
    }
    
    #output-container {
        max-height: 600px;
        min-height: 400px;
    }
}

#output-container {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    padding: 30px;
    border-radius: 12px;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
    max-height: calc(100vh - 200px);
    min-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 2px 4px -1px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow-anchor: none;
}

#output-container > * {
    overflow-anchor: none;
}

#output-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        var(--primary-color) 0%, 
        #3b82f6 50%, 
        var(--primary-color) 100%);
    border-radius: 12px 12px 0 0;
}

.output-placeholder {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 40px;
    font-style: italic;
    font-size: 1.1rem;
    opacity: 0.8;
}

.output-success {
    color: #10b981;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid #10b981;
    border-radius: 6px;
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

.output-error {
    color: #ef4444;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
    border-radius: 6px;
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

/* Enhanced output formatting */
#output-container > div {
    margin-bottom: 16px;
}

#output-container pre {
    background: rgba(15, 23, 42, 0.6);
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    margin: 12px 0;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: auto;
}

/* Style section headers in output */
#output-container div:has-text("=") {
    color: #60a5fa;
    font-weight: 600;
    margin: 24px 0 16px 0;
    letter-spacing: 0.5px;
}

/* Style markers like [OK], [ERROR], [INFO], etc. */
#output-container div:contains("[") {
    font-weight: 600;
}

/* Better line spacing for structured output */
#output-container {
    letter-spacing: 0.01em;
}

/* Style for metrics and numbers */
#output-container {
    font-variant-numeric: tabular-nums;
}

/* Custom scrollbar for output container */
#output-container::-webkit-scrollbar {
    width: 10px;
}

#output-container::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
}

#output-container::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    border: 2px solid rgba(15, 23, 42, 0.5);
}

#output-container::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Enhanced output content styling */
.output-content {
    color: #cbd5e1;
    line-height: 1.8;
    font-size: 0.95rem;
}

.output-error-content {
    color: #fca5a5;
}

/* Style markers in output */
.output-marker-success {
    color: #10b981;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.output-marker-error {
    color: #ef4444;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.output-marker-info {
    color: #60a5fa;
    font-weight: 600;
    background: rgba(96, 165, 250, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.output-marker-warning {
    color: #f59e0b;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Style section headers */
.output-section-header {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(147, 197, 253, 0.88);
    margin: 1rem 0 0.35rem;
    padding: 0;
    background: none;
    border-radius: 0;
}

/* Formatted analysis parts live directly in #output-container */
#output-container:has(.analysis-output-part),
.output-content:has(.analysis-output-part),
#modal-results-content:has(.analysis-output-part) {
    white-space: normal;
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: 0.9rem;
    line-height: 1.65;
    color: rgba(226, 232, 240, 0.95);
}

.analysis-output-part {
    padding: 0 0 0.25rem;
}

.analysis-output-part + .analysis-output-part {
    margin-top: 1.5cm;
}

.analysis-output-part + .analysis-output-part--sub {
    margin-top: 0.8cm;
}

.analysis-output-part--major:has(.analysis-output-part-body:empty) + .analysis-output-part--sub {
    margin-top: 0.8cm;
}

.analysis-output-part:last-child {
    padding-bottom: 0.15rem;
}

.analysis-output-part-head {
    font-size: 0.84rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    color: rgba(186, 230, 253, 0.95);
    margin: 0 0 0.6rem;
    padding: 0;
    line-height: 1.35;
}

.analysis-output-part--major .analysis-output-part-head {
    font-size: 1.08rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0.015em;
    color: #ffffff;
    padding-bottom: 0.5rem;
    margin-bottom: 0.6rem;
    border-bottom: 2px solid rgba(96, 165, 250, 0.5);
}

.analysis-output-part--major .analysis-output-part-body:empty {
    display: none;
}

.analysis-output-part--major:has(.analysis-output-part-body:empty) .analysis-output-part-head {
    margin-bottom: 0;
    padding-bottom: 0.35rem;
}

.analysis-output-part--sub .analysis-output-part-head {
    font-size: 0.96rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #7dd3fc;
    margin-bottom: 0.5rem;
    padding: 0.15rem 0 0.15rem 0.65rem;
    border-left: 3px solid rgba(56, 189, 248, 0.65);
}

.analysis-output-part--intro .analysis-output-part-head {
    display: none;
}

.analysis-output-part-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.analysis-output-meta {
    margin-bottom: 0.85rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 0.84rem;
    color: rgba(148, 163, 184, 0.92);
}

.analysis-output-ticker {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 0.1rem;
}

.analysis-output-heading {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(147, 197, 253, 0.88);
    margin: 1rem 0 0.35rem;
    padding: 0;
}

.analysis-output-heading--major {
    font-size: 0.82rem;
    color: rgba(226, 232, 240, 0.95);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    padding-bottom: 0.3rem;
}

.analysis-output-meta + .analysis-output-heading,
.analysis-output-heading:first-child {
    margin-top: 0;
}

.analysis-output-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.18rem 0;
    font-size: 0.88rem;
}

.analysis-output-kv--sub {
    padding-left: 0.75rem;
    opacity: 0.92;
}

.analysis-output-kv-label {
    color: rgba(203, 213, 225, 0.82);
    flex-shrink: 0;
}

.analysis-output-tip {
    position: relative;
    border-bottom: 1px dotted rgba(148, 163, 184, 0.55);
    cursor: help;
}

.analysis-output-tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 120;
    min-width: 220px;
    max-width: min(380px, 92vw);
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(125, 211, 252, 0.35);
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    text-align: left;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.analysis-output-tip:hover::after,
.analysis-output-tip:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.analysis-output-part-head .analysis-output-tip {
    border-bottom-color: rgba(125, 211, 252, 0.55);
}

.analysis-output-part-head .analysis-output-tip::after {
    max-width: min(420px, 94vw);
}

.analysis-output-kv-value {
    color: #f1f5f9;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.analysis-output-line {
    font-size: 0.88rem;
    color: rgba(226, 232, 240, 0.9);
    padding: 0.12rem 0;
}

.analysis-output-line--strong {
    font-weight: 600;
    color: rgba(248, 250, 252, 0.95);
}

.analysis-output-line--bullet,
.analysis-output-line--indent {
    padding-left: 1.1rem;
}

.analysis-output-hint {
    font-size: 0.78rem;
    color: rgba(148, 163, 184, 0.72);
    padding: 0 0 0.2rem 0.35rem;
    margin-bottom: 0.15rem;
}

#output-container:has(.analysis-output-part) {
    padding: 1.25rem 1.5rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: none;
}

#output-container:has(.analysis-output-part)::before {
    display: none;
}

/* Better spacing for structured content */
#output-container br {
    line-height: 1.6;
}

/* Highlight numbers and percentages */
#output-container {
    font-feature-settings: "tnum";
}

/* Charts Section - Dashboard Style */
.charts-section {
    grid-column: 1 / -1;
    margin-top: 50px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 28px;
    padding: 45px;
    box-shadow: 
        0 12px 48px 0 rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.18);
    position: relative;
    overflow: hidden;
}

.charts-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--rainbow-gradient);
    background-size: 300% 100%;
    animation: rainbowBorder 3s linear infinite;
    z-index: 1;
    border-radius: 28px 28px 0 0;
}

.charts-section::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, 
        rgba(59, 130, 246, 0.1) 0%,
        rgba(16, 185, 129, 0.08) 30%,
        rgba(255, 0, 128, 0.06) 60%,
        transparent 100%);
    opacity: 0.4;
    animation: glassShimmer 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.charts-section > * {
    position: relative;
    z-index: 2;
}

.charts-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
    padding: 30px 35px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.37),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
    overflow: hidden;
}

.charts-section-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%,
        rgba(255, 255, 255, 0.3) 20%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0.3) 80%,
        transparent 100%);
    opacity: 0.6;
    z-index: 1;
}

.charts-section-header > * {
    position: relative;
    z-index: 2;
}

.charts-section-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 35px;
    right: 35px;
    height: 3px;
    background: var(--rainbow-gradient);
    background-size: 200% 100%;
    opacity: 0.8;
    border-radius: 2px;
    animation: rainbowBorder 3s linear infinite;
}

.charts-header-content {
    display: flex;
    align-items: flex-start;
    gap: 30px;
    flex-wrap: wrap;
    flex: 1;
}

.charts-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    border: none;
    padding: 0;
    letter-spacing: -0.03em;
}

.charts-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.charts-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-badge {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
}

.stat-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.stat-badge-interactive {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.stat-badge-interactive:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.charts-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 15px;
    align-items: flex-end;
    justify-content: flex-start;
    min-width: min(100%, 200px);
}

.company-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.company-selector-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    margin: 0;
    padding: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.company-selector {
    background-color: rgba(15, 23, 42, 0.6);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 36px 10px 16px !important;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s, background-color 0.3s, box-shadow 0.3s;
    min-width: 150px;
    max-width: 100%;
    box-shadow: var(--shadow);
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.company-selector option {
    background-color: rgb(15, 23, 42);
    color: var(--text-primary);
    font-weight: 500;
}

.company-selector:hover {
    border-color: var(--primary-color);
    background-color: rgba(15, 23, 42, 0.8);
    box-shadow: var(--shadow-lg);
}

.company-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-refresh-charts {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-refresh-charts:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3);
}

.btn-refresh-charts:active {
    transform: translateY(0);
}

.refresh-icon {
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.btn-refresh-charts:hover .refresh-icon {
    transform: rotate(180deg);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: 32px;
    margin-bottom: 30px;
    padding: 10px 5px;
    position: relative;
    z-index: 1;
}

@media (min-width: 1600px) {
    .charts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    }
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .charts-title {
        font-size: 1.5rem;
    }
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.chart-card::before {
    display: none;
}

.chart-card:hover {
    transform: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    background: var(--card-bg-hover);
}

.chart-card:hover::before {
    display: none;
}

.chart-card:hover .chart-overlay {
    display: none;
}

.chart-card-interactive::before {
    display: none;
}

.chart-badge-interactive {
    display: none;
}

.chart-overlay {
    display: none;
}

.chart-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.chart-footer .chart-name {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-icon {
    font-size: 0.9rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.badge-text {
    font-size: 0.7rem;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 560px;
    min-height: 560px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 20px 20px 0 0;
    border-bottom: 1px solid var(--border-color);
}

.chart-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(30, 41, 59, 0.5) 0%, 
        rgba(15, 23, 42, 0.3) 50%, 
        rgba(30, 41, 59, 0.6) 100%);
    pointer-events: none;
    z-index: 2;
    mix-blend-mode: multiply;
    border-radius: 20px 20px 0 0;
}

.chart-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), filter 0.4s;
    background: rgba(15, 23, 42, 0.5);
    filter: grayscale(35%) brightness(0.8) contrast(0.85);
    position: relative;
    border-radius: 20px 20px 0 0;
}

.chart-card-interactive {
    min-height: 620px;
}

.chart-iframe {
    width: 100%;
    height: 100%;
    min-height: 550px;
    border: none;
    display: block;
    background: rgba(15, 23, 42, 0.5);
    transition: all 0.3s;
    filter: grayscale(30%) brightness(0.85) contrast(0.9);
    position: relative;
    border-radius: 20px 20px 0 0;
}

.chart-card:hover .chart-iframe {
    transform: scale(1.02);
    filter: grayscale(20%) brightness(0.9) contrast(0.95);
}

.chart-card:hover img {
    filter: grayscale(25%) brightness(0.88) contrast(0.92);
}

.chart-card:hover .chart-wrapper::after {
    background: linear-gradient(180deg, 
        rgba(30, 41, 59, 0.4) 0%, 
        rgba(15, 23, 42, 0.25) 50%, 
        rgba(30, 41, 59, 0.5) 100%);
}

/* Loading state for iframes */
.chart-iframe[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes rainbowBorder {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

.chart-card:hover img {
    transform: scale(1.05);
}

.chart-footer {
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 20px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 2;
}

.chart-name-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.chart-type-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 600;
    width: fit-content;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.chart-type-badge-static {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 0 2px 6px rgba(71, 85, 105, 0.3);
}

.chart-actions-mini {
    display: flex;
    gap: 8px;
}

.chart-action-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-action-btn:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.action-icon {
    display: inline-block;
    transition: transform 0.2s;
}

.chart-action-btn:hover .action-icon {
    transform: scale(1.2);
}

.chart-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.78) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}

.chart-card:hover .chart-overlay {
    pointer-events: all;
}

.overlay-content {
    transform: translateY(10px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-card:hover .overlay-content {
    transform: translateY(0);
}

.chart-view-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border: none;
    padding: 18px 36px;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 0.3px;
}

.chart-view-btn:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
}

.chart-view-btn:active {
    transform: translateY(-1px) scale(1.05);
}

.btn-icon {
    font-size: 1.2rem;
}

/* Chart Modal */
.chart-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: auto;
    animation: fadeIn 0.3s;
}

.chart-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.chart-modal-content {
    position: relative;
    background: var(--card-bg);
    margin: 1% auto;
    padding: 0;
    width: 98%;
    max-width: 1600px;
    max-height: 98vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s;
    overflow: hidden;
}

.chart-modal-content.fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 70px 24px 30px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    position: sticky;
    top: 0;
    z-index: 10001;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chart-modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    border: none;
    padding: 0;
    letter-spacing: -0.02em;
    flex: 1;
    min-width: 0;
}

.chart-modal-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 10004;
    margin-right: 60px;
    padding-right: 10px;
}

.chart-zoom-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border: none;
    min-width: 44px;
    height: 44px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10003;
    position: relative;
    visibility: visible;
    opacity: 1;
}

.chart-zoom-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chart-zoom-btn:active {
    transform: translateY(0) scale(1);
}

#download-btn {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

#download-btn:hover {
    background: linear-gradient(135deg, #059669 0%, var(--success-color) 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

#zoom-reset-btn {
    min-width: 90px;
}

.chart-modal-close {
    position: absolute;
    top: 20px;
    right: 15px;
    color: var(--text-secondary);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10025;
    pointer-events: auto;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    transition: all 0.3s;
    line-height: 1;
}

.chart-modal-close:hover {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border-color: rgba(239, 68, 68, 1);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.chart-modal-body {
    padding: 0;
    overflow: hidden;
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    min-height: 700px;
    position: relative;
}

.modal-chart-image {
    max-width: 100%;
    max-height: calc(95vh - 150px);
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s;
    cursor: grab;
}

.modal-chart-image:active {
    cursor: grabbing;
}

.modal-chart-image.zoomed {
    cursor: zoom-out;
}

#chart-modal-iframe {
    background: white;
    width: 100%;
    height: calc(100vh - 180px);
    min-height: 700px;
    max-height: 90vh;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

#chart-modal-iframe.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10010;
    border-radius: 0;
    max-height: 100vh;
}

.chart-name {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    word-break: break-word;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.no-charts-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 100px 40px;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 2px dashed var(--border-color);
    box-shadow: var(--shadow);
}

.no-charts-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
    filter: grayscale(0.3);
}

.no-charts-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-weight: 600;
}

.no-charts-state p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0;
}

/* Loading state text inside primary buttons (static; no rotation) */
.btn-loader {
    display: inline-block;
    animation: none !important;
    transform: none !important;
}

/* Portfolio Section Styles */
.portfolio-section {
    grid-column: 1 / -1;
    margin-bottom: 30px;
}

.portfolio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.portfolio-header h2 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

.portfolio-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
    overflow: visible;
}

.portfolio-dashboard > div:first-child {
    margin-bottom: 0;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
    gap: 12px;
    margin-bottom: 20px;
    overflow-anchor: none;
}

.stat-card {
    background: linear-gradient(
        165deg,
        rgba(42, 55, 74, 0.72) 0%,
        rgba(30, 41, 59, 0.48) 100%
    );
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.3s;
    box-sizing: border-box;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-value {
    font-size: 1.25rem;
    overflow-anchor: none;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stat-value.positive {
    color: var(--success-color);
}

.stat-value.negative {
    color: var(--error-color);
}

.portfolio-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-anchor: none;
    overflow: visible;
}

.portfolio-card {
    background: linear-gradient(
        165deg,
        rgba(42, 55, 74, 0.72) 0%,
        rgba(30, 41, 59, 0.48) 100%
    );
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    transition: all 0.3s;
    box-sizing: border-box;
    overflow: visible;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.portfolio-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.portfolio-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.portfolio-card-header h3 {
    margin: 0 0 4px 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.portfolio-description {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.portfolio-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.portfolio-actions .btn-small {
    padding: 6px 10px;
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
}

.portfolio-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
    gap: 10px 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 8px;
    box-sizing: border-box;
}

.portfolio-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.portfolio-stat .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portfolio-stat .stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.portfolio-stat .stat-value.positive,
.portfolio-stat .stat-value.negative {
    white-space: normal;
    line-height: 1.15;
}

.portfolio-investments {
    margin-top: 16px;
    overflow-x: visible;
    -webkit-overflow-scrolling: touch;
}

.portfolio-investments h4 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
}

.investments-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
    box-sizing: border-box;
}

.investments-table thead {
    background: rgba(15, 23, 42, 0.5);
}

.investments-table th {
    padding: 6px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.investments-table td {
    padding: 5px 6px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.7rem;
    line-height: 1.15;
    word-wrap: break-word;
    overflow-wrap: break-word;
    vertical-align: middle;
    box-sizing: border-box;
    overflow: hidden;
}

/* Column widths — tuned to header + typical cell content */
.investments-table th:nth-child(1),
.investments-table .investment-company {
    width: 24%;
}

.investments-table th:nth-child(2),
.investments-table .investment-trend {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    padding-left: 2px;
    padding-right: 2px;
    text-align: center;
}

.investments-table th:nth-child(3),
.investments-table .investment-value {
    width: 10%;
}

.investments-table th:nth-child(4),
.investments-table .investment-gain-loss {
    width: 14%;
}

.investments-table th:nth-child(5),
.investments-table .investment-quantity {
    width: 5%;
    padding-left: 6px;
    padding-right: 6px;
    text-align: center;
}

.investments-table th:nth-child(6),
.investments-table .investment-bought {
    width: 10%;
}

.investments-table th:nth-child(7),
.investments-table .investment-now {
    width: 10%;
}

.investments-table th:nth-child(8),
.investments-table .investment-dividends {
    width: 15%;
}

.investments-table .investment-company {
    overflow: hidden;
}

.investments-table .investment-th-qty {
    text-align: center;
}

.investments-table .investment-value,
.investments-table .investment-gain-loss,
.investments-table .investment-bought,
.investments-table .investment-now {
    white-space: nowrap;
    text-overflow: ellipsis;
}

.investments-table .investment-dividends {
    line-height: 1.2;
    white-space: normal;
}

.investment-company-main {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.investment-company-link {
    display: block;
    min-width: 0;
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.investment-company-link strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--primary-color, #007bff);
    font-size: 0.75rem;
    line-height: 1.15;
    margin-bottom: 2px;
}

.investment-company-link small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary, #999);
    font-size: 0.7rem;
    line-height: 1.1;
}

.investment-expand-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 4px;
    min-width: 22px;
    min-height: 22px;
}

.investment-expand-btn:hover,
.investment-expand-btn:focus-visible {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.12);
    outline: none;
}

.investment-expand-btn.is-expanded i {
    transform: rotate(90deg);
}

.investment-expand-btn i {
    display: inline-block;
    font-size: 0.68rem;
    transition: transform 0.15s ease;
}

.investment-row {
    cursor: pointer;
}

.investment-row.is-expanded {
    background: rgba(59, 130, 246, 0.06);
}

.investment-dividend-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 2px;
}

.investment-dividend-meta .investment-detail-sub {
    margin-top: 0;
}

.investment-detail-sub {
    color: var(--text-secondary);
    font-size: 0.62rem;
    margin-top: 2px;
    line-height: 1.2;
    word-break: break-word;
}

.investment-details-row td {
    padding: 0;
    background: rgba(15, 23, 42, 0.45);
    border-bottom: 1px solid var(--border-color);
    cursor: default;
}

.investment-details-panel {
    display: grid;
    grid-template-columns: minmax(180px, 1.1fr) minmax(140px, 1.4fr);
    gap: 12px 24px;
    align-items: start;
    padding: 10px 12px 12px 34px;
}

.investment-details-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.investment-detail-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
}

.investment-detail-value {
    font-size: 0.75rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.investment-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-investment-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.55);
    color: var(--text-primary);
    font-size: 0.72rem;
    line-height: 1.2;
    cursor: pointer;
    min-height: 32px;
    white-space: nowrap;
}

.btn-investment-action i {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.btn-investment-action:hover,
.btn-investment-action:focus-visible {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.35);
    outline: none;
}

.btn-investment-action.btn-delete-inv {
    color: var(--error-color);
    border-color: rgba(239, 68, 68, 0.35);
}

.btn-investment-action.btn-delete-inv i {
    color: var(--error-color);
}

.btn-investment-action.btn-delete-inv:hover,
.btn-investment-action.btn-delete-inv:focus-visible {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.5);
}

.investments-table .trend-indicator {
    text-align: center;
    vertical-align: middle;
    padding: 5px 4px;
    white-space: nowrap;
}

.investments-table .trend-icon {
    display: inline-block;
    font-size: 0.95rem;
    cursor: help;
    transition: opacity 0.2s ease, transform 0.2s ease;
    user-select: none;
    line-height: 1;
}

.investments-table .trend-icon:hover {
    opacity: 0.85;
    transform: scale(1.1);
}

.investments-table tbody tr.investment-row:hover {
    background: rgba(59, 130, 246, 0.1);
}

.investments-table tbody tr:last-child td {
    border-bottom: none;
}

.investments-table .positive {
    color: var(--success-color);
    font-weight: 600;
}

.investments-table .negative {
    color: var(--error-color);
    font-weight: 600;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-small:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error-color);
    color: var(--error-color);
}

.btn-danger:hover {
    background: var(--error-color);
    color: white;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 0.9rem;
    line-height: 1;
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
    transition: transform 0.2s;
    box-sizing: border-box;
}

.btn-icon:hover {
    transform: scale(1.1);
}

/* Instrument disambiguation badge & subtitle (shown when a ticker maps to
   multiple Borsdata instruments, e.g. EVO = Evolution AB / Evotec SE). */
.instrument-subtitle {
    display: block;
    color: var(--text-secondary, #888);
    font-size: 0.7em;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22ch;
}
.btn-instrument-picker {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    font-size: 0.72em;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.4;
    background: transparent;
}
.btn-instrument-warn {
    color: #8a4b00;
    background: rgba(255, 196, 0, 0.18);
    border-color: rgba(255, 152, 0, 0.55);
}
.btn-instrument-warn:hover {
    background: rgba(255, 196, 0, 0.32);
}
.btn-instrument-pinned {
    color: var(--text-secondary, #777);
    background: transparent;
    border-color: var(--border-color, #ddd);
}
.btn-instrument-pinned:hover {
    background: var(--bg-secondary, rgba(0, 0, 0, 0.04));
}
.instrument-candidate button[disabled] {
    opacity: 0.6;
    cursor: default;
}

/* Instrument picker modal layout
   ---------------------------------------------------------------------------
   The candidate list lives inside .modal-content, which sets word-break:
   break-word. The "Use this one" button uses .btn-primary which globally has
   width:100% — without these overrides it stretches inside the flex row and
   squashes the meta column to ~0px wide, which makes each character of
   "Nasdaq · Hälsovård" wrap onto its own line. */
#instrument-picker-modal .modal-content {
    width: min(92vw, 720px);
    max-width: 720px;
}
#instrument-picker-modal .instrument-candidate {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    overflow-wrap: anywhere;
}
#instrument-picker-modal .instrument-candidate.is-current {
    background: rgba(59, 130, 246, 0.10);
    border-color: var(--primary-color, #3b82f6);
}
#instrument-picker-modal .instrument-candidate .ic-info {
    flex: 1 1 auto;
    min-width: 0;
}
#instrument-picker-modal .instrument-candidate .ic-name {
    font-weight: 600;
}
#instrument-picker-modal .instrument-candidate .ic-meta,
#instrument-picker-modal .instrument-candidate .ic-price {
    color: var(--text-secondary, #777);
    font-size: 0.85em;
    word-break: normal;
    overflow-wrap: anywhere;
}
#instrument-picker-modal .instrument-candidate .ic-price {
    font-size: 0.8em;
    margin-top: 2px;
}
#instrument-picker-modal .instrument-candidate .ic-pick {
    flex: 0 0 auto;
    width: auto;
    min-width: 130px;
    margin: 0;
    padding: 8px 14px;
    font-size: 0.9rem;
    white-space: nowrap;
}
#instrument-picker-modal .instrument-candidate .ic-tag {
    font-size: 0.78em;
    font-weight: 500;
    margin-left: 6px;
}
#instrument-picker-modal .ic-tag-current { color: var(--primary-color, #3b82f6); }
#instrument-picker-modal .ic-tag-default { color: var(--text-secondary, #888); }
#instrument-picker-modal .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}
#instrument-picker-modal .form-actions .btn-secondary {
    width: auto;
    min-width: 100px;
    padding: 8px 16px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    overflow: auto;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: slideDown 0.3s;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: var(--text-secondary);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-close:hover {
    color: var(--error-color);
    transform: rotate(90deg) scale(1.1);
}

.modal-content h2 {
    margin: 0 0 24px 0;
    font-size: 1.8rem;
    font-weight: 700;
}

.modal-content textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
}

.modal-content textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Form Row Layout for Side-by-Side Fields */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.form-group-half {
    flex: 1;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Form Row Inline - for side-by-side inputs (e.g., amount + currency) */
.form-row-inline {
    display: flex;
    gap: 12px;
    align-items: stretch;
    width: 100%;
}

.form-row-inline input[type="number"],
.form-row-inline input[type="text"] {
    flex: 1;
    min-width: 0;
}

.form-select-currency {
    min-width: 100px;
    max-width: 120px;
    flex-shrink: 0;
}

.form-help-text {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 6px;
    line-height: 1.4;
}

/* Modal form improvements */
.modal-content form {
    margin: 0;
    padding: 0;
}

.modal-content .form-group {
    margin-bottom: 20px;
}

.modal-content .form-group:last-of-type {
    margin-bottom: 0;
}

.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.modal-content input[type="text"]:focus,
.modal-content input[type="number"]:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-content input::placeholder,
.modal-content textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-actions .btn-primary,
.form-actions .btn-secondary {
    width: auto;
    min-width: 100px;
    margin-top: 0;
}

/* Liquidity Transaction Modal */
.liquidity-modal-content {
    max-width: 460px;
}

.liquidity-modal-header {
    margin-bottom: 4px;
}

.liquidity-modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 4px 0 0 0;
}

.liquidity-type-options {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.liquidity-type-option {
    flex: 1;
    justify-content: center;
    text-align: center;
    padding: 12px 16px;
}

.liquidity-type-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.liquidity-type-icon {
    font-size: 1.25rem;
}

.liquidity-type-option input[type="radio"] {
    margin-right: 6px;
}

.liquidity-type-option:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.12);
}

.liquidity-type-deposit:has(input:checked) {
    border-color: var(--success-color, #22c55e);
    background: rgba(34, 197, 94, 0.1);
}

.liquidity-type-withdrawal:has(input:checked) {
    border-color: var(--error-color, #ef4444);
    background: rgba(239, 68, 68, 0.08);
}

.liquidity-amount-group {
    margin-bottom: 20px;
}

.liquidity-amount-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    margin-top: 8px;
}

.liquidity-amount-input {
    flex: 1;
    min-width: 120px;
    font-size: 1.1rem;
    font-weight: 500;
}

.liquidity-currency-select {
    width: auto;
    min-width: 85px;
    max-width: 100px;
    flex-shrink: 0;
}

/* Investment Modal Specific Styles */
.investment-modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

.investment-modal-content .form-group {
    margin-bottom: 20px;
}

.investment-modal-content .form-group:last-child {
    margin-bottom: 0;
}

.investment-modal-content textarea {
    resize: vertical;
    min-height: 60px;
}

/* Responsive adjustments for investment modal */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group-half {
        margin-bottom: 20px;
    }
    
    .investment-modal-content {
        max-height: 95vh;
        padding: 20px;
    }
}

/* Analysis Types Container - Inside Control Panel */
.analysis-types-container {
    margin: 0 0 10px 0;
    padding: 0 0 10px 0;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

/* Reduce spacing for Analysis Type form group */
.form-group:has(.analysis-types-container) {
    margin-bottom: 10px;
}

.form-group:has(.analysis-types-container) label {
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.analysis-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.analysis-type-card {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 70px;
    box-sizing: border-box;
    /* Buttons default to `buttontext` color; children (FA icons) must read as light on dark cards */
    color: var(--text-primary);
}

.analysis-type-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--rainbow-gradient);
    background-size: 200% 100%;
    opacity: 0;
    transition: opacity 0.3s;
    animation: rainbowBorder 3s linear infinite;
}

.analysis-type-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: 
        0 12px 48px 0 rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 30px rgba(59, 130, 246, 0.2);
    background: rgba(15, 23, 42, 0.5);
}

.analysis-type-card:hover::before {
    opacity: 1;
}

.analysis-type-card.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    box-shadow: 
        0 8px 32px 0 rgba(37, 99, 235, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.analysis-type-card.active::before {
    opacity: 1;
}

.analysis-type-icon {
    font-size: 1.1rem;
    margin-bottom: 2px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.analysis-type-content {
    flex: 1;
}

.analysis-type-content h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px 0;
    border: none;
    padding: 0;
    line-height: 1.15;
}

.analysis-type-content p {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.2;
}

.analysis-type-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.analysis-type-card.active .analysis-type-badge {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Date Presets */
.date-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.date-preset-btn {
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.date-preset-btn:hover {
    background: rgba(15, 23, 42, 0.7);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.date-preset-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Enhanced Results Section */
.results-section .btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .analysis-types-grid {
        grid-template-columns: 1fr;
    }
    
    .date-presets {
        justify-content: center;
    }
    
    .analysis-type-card {
        min-height: 65px;
        padding: 8px;
    }
    
    .analysis-type-icon {
        font-size: 1rem;
    }
    
    .analysis-type-content h3 {
        font-size: 0.75rem;
    }
    
    .analysis-type-content p {
        font-size: 0.65rem;
    }
    
    /* Mobile modal improvements */
    .modal {
        padding: 10px !important;
    }
    
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px auto !important;
        padding: 15px !important;
    }
    
    /* Mobile touch targets */
    button, a.btn-primary, a.btn-small, .btn-small, .btn-primary {
        min-height: 44px;
        padding: 12px 16px !important;
    }
    
    /* Mobile touch targets for portfolio action buttons override */
    .portfolio-actions .btn-small {
        min-height: 36px;
        padding: 6px 10px !important;
    }

    /* Compare ticker chips — compact remove, not full touch bar */
    .compare-ticker-pill .compare-remove-ticker {
        min-width: 28px !important;
        min-height: 28px !important;
        width: 28px !important;
        height: 28px !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
    }
    
    /* Mobile search results */
    .search-results {
        max-height: 300px !important;
        font-size: 0.9rem;
    }
    
    /* Mobile sidebar search */
    .sidebar-search {
        padding: 10px !important;
    }
    
    .search-input {
        font-size: 0.85rem !important;
    }
}

/* Page Header Styles - Consistent across all pages */
.page-header {
    grid-column: 1 / -1;
    margin-bottom: 30px;
    padding: 40px 35px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.37),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: visible;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--rainbow-gradient);
    background-size: 300% 100%;
    animation: rainbowBorder 3s linear infinite;
    z-index: 1;
    border-radius: 20px 20px 0 0;
}

.page-header::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, 
        rgba(59, 130, 246, 0.1) 0%,
        rgba(16, 185, 129, 0.08) 30%,
        rgba(255, 0, 128, 0.06) 60%,
        transparent 100%);
    opacity: 0.4;
    animation: glassShimmer 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.page-header > * {
    position: relative;
    z-index: 2;
}

.page-header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
    flex-wrap: wrap;
}

.page-title-wrapper {
    flex: 1;
    min-width: 0;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 14px;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.page-title-icon > .fas,
.page-title-icon > .far {
    font-size: 2rem;
    line-height: 1;
    vertical-align: middle;
}

.analysis-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.analysis-type-icon > .fas {
    font-size: 1.55rem;
    opacity: 0.92;
    color: #ffffff;
}

.analysis-report-hero-icon > .fas {
    font-size: 2.25rem;
    line-height: 1;
}

.report-section-icon > .fas {
    margin-right: 0.4em;
    opacity: 0.88;
    font-size: 0.95em;
}

.notification-item-icon .fas {
    font-size: 1rem;
    opacity: 0.9;
}

.charts-icon .fas,
.history-icon .fas {
    opacity: 0.85;
    margin-right: 0.35em;
}

.refresh-icon .fas {
    font-size: 1rem;
    vertical-align: middle;
}

.no-charts-icon .fas,
.empty-state-icon .fas {
    font-size: 2.75rem;
    opacity: 0.45;
    line-height: 1;
}

.badge-icon .fas,
.action-icon .fas,
.btn-icon .fas {
    font-size: 1em;
}

.liquidity-type-icon .fas {
    margin-right: 0.3em;
}

.settings-tab-label .fas {
    margin-right: 0.45em;
    opacity: 0.88;
}

.stock-card-icon .fas,
.stock-card-expanded-icon .fas {
    font-size: 2rem;
    opacity: 0.55;
}

.help-section-title .fas {
    margin-right: 0.45em;
    opacity: 0.85;
}

.error-page-icon .fas {
    font-size: 6rem;
    opacity: 0.75;
    line-height: 1;
}

.btn-inline-icon .fas,
.btn-inline-icon .far {
    margin-right: 0.4em;
}

.toolbar-btn-icon .fas {
    margin-right: 0.35em;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
    margin: 0;
    line-height: 1.6;
    max-width: 65ch;
}

.page-header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

/* Settings Section Styles */
.settings-section {
    grid-column: 1 / -1;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    color-scheme: dark;
}

.settings-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.settings-group {
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.3s;
    box-sizing: border-box;
}

.settings-group:hover {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 12px 48px 0 rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 30px rgba(59, 130, 246, 0.2);
}

.settings-group h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.settings-group p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.settings-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.settings-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-item-label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.settings-item-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Settings: fields match .settings-code-block / <code> (e.g. stocks.db) */
.settings-section input[type="text"],
.settings-section input[type="search"],
.settings-section input[type="number"],
.settings-section input[type="email"],
.settings-section input[type="url"],
.settings-section input[type="password"],
.settings-section textarea {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color: var(--text-secondary);
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

/* Select: never use `background:` shorthand — it clears the chevron and lets Win/Chrome paint white */
.settings-section select {
    width: 100%;
    max-width: 100%;
    padding: 12px 38px 12px 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color: var(--text-primary);
    background-color: rgba(15, 23, 42, 0.5);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.settings-section select option {
    background-color: rgb(15, 23, 42);
    color: var(--text-primary);
}

.settings-section input::placeholder,
.settings-section textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.65;
}

.settings-section input:hover:not(:disabled):not(:focus),
.settings-section textarea:hover:not(:disabled):not(:focus) {
    border-color: var(--border-color);
    background-color: rgba(15, 23, 42, 0.58);
}

.settings-section select:hover:not(:disabled):not(:focus) {
    border-color: var(--border-color);
    background-color: rgba(15, 23, 42, 0.58);
}

.settings-section input:focus,
.settings-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(15, 23, 42, 0.55);
    color: var(--text-primary);
    box-shadow: none;
}

.settings-section select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(15, 23, 42, 0.55);
    color: var(--text-primary);
    box-shadow: none;
}

.settings-section input:disabled,
.settings-section select:disabled,
.settings-section textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.settings-section input:-webkit-autofill,
.settings-section input:-webkit-autofill:hover,
.settings-section input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-secondary);
    caret-color: var(--text-secondary);
    transition: background-color 99999s ease-out;
    box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.5) inset;
}

.settings-section input:focus:-webkit-autofill {
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
}

.settings-section .stock-search-wrapper input[type="text"],
.settings-section .stock-search-wrapper input#borsdata-company-input {
    margin: 0;
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color: var(--text-secondary);
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

section.settings-section #borsdata-company-input {
    background-color: rgba(15, 23, 42, 0.5) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

section.settings-section #borsdata-company-input:focus {
    background-color: rgba(15, 23, 42, 0.55) !important;
    color: var(--text-primary) !important;
    border-color: var(--primary-color) !important;
}

section.settings-section #borsdata-company-input:hover:not(:disabled):not(:focus) {
    background-color: rgba(15, 23, 42, 0.58) !important;
}

section.settings-section #borsdata-company-input::placeholder {
    color: var(--text-secondary) !important;
    opacity: 0.65;
}

/* Native search UI often paints a white field; flatten to match code block */
.settings-section input[type="search"] {
    appearance: none;
    -webkit-appearance: none;
}

.settings-section input[type="search"]::-webkit-search-decoration,
.settings-section input[type="search"]::-webkit-search-cancel-button,
.settings-section input[type="search"]::-webkit-search-results-button,
.settings-section input[type="search"]::-webkit-search-results-decoration {
    display: none;
    -webkit-appearance: none;
    appearance: none;
}

.settings-section input[type="search"].settings-input,
.settings-section input[type="search"]#borsdata-loaded-filter {
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color: var(--text-secondary);
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: none;
}

.settings-section input[type="search"].settings-input:focus,
.settings-section input[type="search"]#borsdata-loaded-filter:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(15, 23, 42, 0.55);
    color: var(--text-primary);
}

.settings-section input[type="search"].settings-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.65;
}

/* Ticker editor — same code-block look */
.settings-section .ticker-category-name,
.settings-section .ticker-add-input {
    padding: 12px;
    font-size: 0.9rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: none;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.settings-section .ticker-category-name:focus,
.settings-section .ticker-add-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(15, 23, 42, 0.55);
    color: var(--text-primary);
    box-shadow: none;
}

.settings-section .ticker-add-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.65;
}

/* Enhanced Dashboard Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure dashboard-grid spans full width in main-content grid */
.main-content > .dashboard-grid,
.main-content > .analysis-page-grid {
    grid-column: 1 / -1;
}

/* Analysis page - ensure side by side layout */
.analysis-page .dashboard-grid,
.analysis-page-grid,
.dashboard-grid:has(.control-panel):has(.results-section) {
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure dashboard-grid matches page-header width exactly */
.page-header + .analysis-page-grid,
.page-header + .dashboard-grid:has(.control-panel):has(.results-section) {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.analysis-page .dashboard-grid .control-panel,
.analysis-page-grid .control-panel,
.dashboard-grid:has(.control-panel):has(.results-section) .control-panel {
    grid-column: 1;
}

.analysis-page .dashboard-grid .results-section,
.analysis-page-grid .results-section,
.dashboard-grid:has(.control-panel):has(.results-section) .results-section {
    grid-column: 2;
    grid-column-end: auto; /* Override the 1 / -1 rule */
}

.dashboard-quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure dashboard-quick-stats spans full width in main-content grid */
.main-content > .dashboard-quick-stats {
    grid-column: 1 / -1;
}

.quick-stat-card {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.quick-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--rainbow-gradient);
    background-size: 200% 100%;
    opacity: 0;
    transition: opacity 0.3s;
    animation: rainbowBorder 3s linear infinite;
}

.quick-stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 12px 48px 0 rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 30px rgba(59, 130, 246, 0.2);
}

.quick-stat-card:hover::before {
    opacity: 1;
}

.quick-stat-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

.quick-stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.quick-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Responsive adjustments for page headers */
@media (max-width: 768px) {
    .page-header {
        padding: 30px 20px;
    }
    
    .page-title {
        font-size: 1.8rem;
    }
    
    .page-subtitle {
        font-size: 0.95rem;
    }
    
    .page-header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    /* Stack on mobile for analysis page */
    .analysis-page .dashboard-grid,
    .analysis-page-grid {
        grid-template-columns: 1fr;
    }
    
    .analysis-page .dashboard-grid .control-panel,
    .analysis-page-grid .control-panel,
    .dashboard-grid:has(.control-panel):has(.results-section) .control-panel {
        grid-column: 1;
    }
    
    .analysis-page .dashboard-grid .results-section,
    .analysis-page-grid .results-section,
    .dashboard-grid:has(.control-panel):has(.results-section) .results-section {
        grid-column: 1;
    }
}

/* ==========================================================================
   RESPONSIVE SCALING IMPROVEMENTS
   Ensures text/content never overflows containers at any viewport width
   ========================================================================== */

/* --- Global overflow safety --- */
.main-wrapper,
.container,
.main-content,
section,
.card,
.modal-content {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* --- Flex containers: always allow wrapping --- */
.portfolio-header,
.chart-footer,
.chart-modal-header,
.form-row,
.page-header-actions,
.shortcut-item {
    flex-wrap: wrap;
}

/* --- Charts grid: lower minimum to prevent horizontal scroll --- */
.charts-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
}

@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    }
}

/* --- Tables: always scrollable horizontally --- */
.table-responsive,
.portfolio-table-wrapper,
[style*="overflow-x"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    table-layout: auto;
}

/* --- Modals: never wider than viewport --- */
.modal-content {
    width: min(90vw, 600px);
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    margin: 5vh auto;
}

/* --- Images & embeds: fluid (chart previews fill .chart-wrapper; see .chart-wrapper .chart-iframe) --- */
img, iframe, video, svg, canvas, embed, object {
    max-width: 100%;
    height: auto;
}

.chart-wrapper .chart-iframe {
    height: 100%;
    min-height: 240px;
    max-height: none;
}

/* --- Form inputs: fluid width --- */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="url"],
textarea,
select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fallback: dark dropdown list for any native select in the app */
.ocean-app select option {
    background-color: rgb(15, 23, 42);
    color: var(--text-primary);
}

/* ==================== 1024px breakpoint ==================== */
@media (max-width: 1024px) {
    .container {
        padding: 20px 16px;
    }

    .charts-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
        gap: 20px;
    }

    .portfolio-header {
        gap: 12px;
    }

    .portfolio-header h2 {
        font-size: 1.5rem;
    }

    section {
        padding: 20px !important;
    }

    .portfolio-card {
        padding: 14px 16px;
    }

    .portfolio-card-header h3 {
        font-size: 1.1rem;
    }

    .portfolio-actions {
        gap: 6px;
    }

    .portfolio-actions .btn-small {
        padding: 5px 8px;
        font-size: 0.7rem;
    }

    .portfolio-stats {
        grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
        gap: 8px;
        padding: 10px;
    }

    .portfolio-stat .stat-label {
        font-size: 0.65rem;
    }

    .portfolio-stat .stat-value {
        font-size: 0.85rem;
    }
}

/* ==================== 768px breakpoint enhancements ==================== */
@media (max-width: 768px) {
    .container {
        padding: 16px 12px;
    }

    .portfolio-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-modal-header h3 {
        font-size: 1.1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .modal-content {
        width: 95vw;
        max-width: 95vw;
        padding: 20px 16px;
        margin: 3vh auto;
    }

    .modal-content h2 {
        font-size: 1.3rem;
    }

    h1, .page-title {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem;
    }

    section {
        padding: 16px !important;
        border-radius: 10px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-small {
        font-size: 0.8rem;
        padding: 8px 14px;
    }

    /* Portfolio quick stats grid */
    .quick-stats-grid,
    .dashboard-quick-stats {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
        gap: 10px;
    }

    .quick-stat-value {
        font-size: 1.3rem;
    }

    .portfolio-card {
        padding: 12px 14px;
    }

    .portfolio-card-header {
        flex-direction: column;
        gap: 8px;
    }

    .portfolio-card-header h3 {
        font-size: 1rem;
    }

    .portfolio-actions {
        width: 100%;
        gap: 6px;
    }

    .portfolio-stats {
        grid-template-columns: repeat(auto-fit, minmax(min(110px, 48%), 1fr));
        gap: 8px;
        padding: 10px;
    }

    .portfolio-stat .stat-label {
        font-size: 0.6rem;
    }

    .portfolio-stat .stat-value {
        font-size: 0.8rem;
    }

    .investments-table {
        min-width: 0;
    }

    .investments-table th {
        font-size: 0.65rem;
        padding: 5px 6px;
    }

    .investments-table td {
        font-size: 0.65rem;
        padding: 4px 6px;
    }

    .investment-details-panel {
        grid-template-columns: 1fr;
        padding-left: 28px;
    }

    .btn-investment-action {
        min-height: 36px;
        padding: 8px 12px;
    }
}

/* ==================== 480px breakpoint (small phones) ==================== */
@media (max-width: 480px) {
    .container {
        padding: 12px 8px;
    }

    .sidebar:hover {
        width: 220px;
    }

    section {
        padding: 12px !important;
        border-radius: 8px;
    }

    h1, .page-title {
        font-size: 1.25rem !important;
    }

    h2 {
        font-size: 1.1rem;
    }

    .page-subtitle {
        font-size: 0.85rem;
    }

    .page-header {
        padding: 20px 12px;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-header-actions .btn-primary,
    .page-header-actions .btn-small {
        flex: 1;
        text-align: center;
        font-size: 0.75rem;
        padding: 8px 10px;
    }

    .modal-content {
        width: 98vw;
        max-width: 98vw;
        padding: 16px 12px;
        margin: 2vh auto;
        border-radius: 10px;
    }

    .modal-content h2 {
        font-size: 1.15rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .chart-footer {
        padding: 12px;
    }

    .chart-card {
        border-radius: 12px;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        text-align: center;
    }

    /* Tables: tighter on small screens */
    table th, table td {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .quick-stats-grid,
    .dashboard-quick-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .quick-stat-value {
        font-size: 1.1rem;
    }

    .empty-state {
        padding: 30px 12px;
    }

    .portfolio-card {
        padding: 10px 12px;
    }

    .portfolio-card-header h3 {
        font-size: 0.95rem;
    }

    .portfolio-actions .btn-small {
        padding: 4px 6px;
        font-size: 0.65rem;
    }

    .portfolio-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 8px;
    }

    .portfolio-stat .stat-value {
        font-size: 0.75rem;
    }

    .investments-table {
        min-width: 0;
    }
}

/* --- Accessibility & shell polish --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-icon-svg {
    display: block;
    flex-shrink: 0;
}

button.sidebar-link.sidebar-nav-action {
    font: inherit;
    cursor: pointer;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    background: transparent;
    box-shadow: none;
    width: 100%;
    text-align: left;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

button.sidebar-link.sidebar-nav-action::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* Match anchor .sidebar-link hover (button reset above would otherwise block it) */
button.sidebar-link.sidebar-nav-action:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
    transform: translateX(2px);
}

.sidebar-footer button.sidebar-nav-action:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Notification row: badge overlaps icon column (same flex layout as other .sidebar-link items) */
.sidebar-notifications-trigger.sidebar-link {
    overflow: visible;
}

.sidebar-notifications-trigger .sidebar-link-icon {
    position: relative;
}

.sidebar-notifications-trigger .notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 1;
    background: var(--primary-color);
    color: white;
    border-radius: 999px;
    padding: 0 4px;
    font-size: 0.58rem;
    font-weight: 600;
    line-height: 13px;
    min-width: 13px;
    height: 13px;
    text-align: center;
    box-sizing: border-box;
    border: none;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.85);
}

.sidebar-search-block {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: -32px;
    box-sizing: border-box;
}

.sidebar-search-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 0;
}

.sidebar-search-icon-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 44px;
    height: 44px;
    margin: 0 auto;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
}

.sidebar-search-icon-btn:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
}

.sidebar-search-icon-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.sidebar-global-search-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    box-sizing: border-box;
    flex: 1 1 auto;
    min-width: 0;
}

/* --- Pinned sidebar: always full search field --- */
html[data-sidebar-mode="pinned"] .sidebar-search-icon-btn {
    display: none !important;
}

html[data-sidebar-mode="pinned"] .sidebar-search-block {
    padding: 20px !important;
    margin-top: -32px !important;
}

html[data-sidebar-mode="pinned"] .sidebar-search-inner {
    flex-direction: column;
    align-items: stretch;
}

/* --- Hover-expand (default mode only): magnifier when narrow, field when sidebar hovered --- */
html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:not(:hover) .sidebar-search-block {
    padding: 10px 12px 14px;
    margin-top: -12px;
}

html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:not(:hover) .sidebar-search-inner {
    justify-content: center;
}

html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:not(:hover) .sidebar-search-icon-btn {
    display: flex;
}

html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:not(:hover) .sidebar-global-search-input {
    /* Collapsed rail: no visible field — only the magnifier control */
    box-sizing: border-box !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 0 !important;
    max-width: 0 !important;
    min-width: 0 !important;
    height: 0 !important;
    flex: 0 0 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:hover .sidebar-search-block {
    padding: 20px;
    margin-top: -32px;
}

html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:hover .sidebar-search-inner {
    flex-direction: column;
    align-items: stretch;
}

html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:hover .sidebar-search-icon-btn {
    display: none !important;
}

html:not([data-sidebar-mode="pinned"]):not([data-sidebar-mode="icons"]) .sidebar:hover .sidebar-global-search-input {
    position: static;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: auto;
    flex: 1 1 auto;
    margin: 0;
    overflow: visible;
    clip-path: none;
    opacity: 1;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Icons-only rail: always magnifier until focus popover (JS adds .sidebar-search--popover) */
html[data-sidebar-mode="icons"] .sidebar-search-block {
    padding: 10px 12px 14px;
    margin-top: -12px;
}

html[data-sidebar-mode="icons"] .sidebar-search-inner {
    justify-content: center;
}

html[data-sidebar-mode="icons"] .sidebar-search-icon-btn {
    display: flex !important;
}

html[data-sidebar-mode="icons"] .sidebar-global-search-input {
    box-sizing: border-box !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 0 !important;
    max-width: 0 !important;
    min-width: 0 !important;
    height: 0 !important;
    flex: 0 0 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

html[data-sidebar-mode="icons"] .sidebar-search-block.sidebar-search--popover .sidebar-search-icon-btn {
    display: none !important;
}

html[data-sidebar-mode="icons"] .sidebar-search-block.sidebar-search--popover .sidebar-global-search-input {
    position: static;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: auto;
    flex: 1 1 auto;
    margin: 0;
    overflow: visible;
    clip-path: none;
    opacity: 1;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Shim row in sidebar while search UI is portaled to <body> */
.sidebar-search-mount-placeholder {
    flex-shrink: 0;
    box-sizing: border-box;
    min-height: 56px;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

/* Floating search while collapsed + focused (keyboard “/” or icon click); mounted on body to sit above sidebar */
.sidebar-search-block.sidebar-search--popover {
    position: fixed;
    z-index: 10060;
    width: min(320px, calc(100vw - 24px));
    margin-top: 0 !important;
    padding: 12px 14px !important;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    box-shadow: var(--shadow-lg);
}

.sidebar-search-block.sidebar-search--popover .sidebar-search-inner {
    flex-direction: column;
    align-items: stretch;
}

.sidebar-search-block.sidebar-search--popover .sidebar-global-search-input {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: auto !important;
    flex: 1 1 auto !important;
    margin: 0 !important;
    overflow: visible !important;
    clip-path: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.sidebar-search-block.sidebar-search--popover .sidebar-search-icon-btn {
    display: none !important;
}

.search-results-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 2;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.analysis-tabs-nav:not(.analysis-tabs-nav--segmented) {
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    grid-column: 1 / -1;
}

.analysis-tablist {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
}

.analysis-tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
}

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

.analysis-tab-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.analysis-tab-btn.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
}

.analysis-tab-panel {
    margin-top: 20px;
    width: 100%;
}

.analysis-tab-panel.is-hidden {
    display: none !important;
}

.analysis-tab-panel--history {
    grid-column: 1 / -1 !important;
}

.analysis-type-help {
    color: var(--text-secondary);
    font-size: 0.7rem;
    display: block;
    margin-top: 4px;
}

.analysis-type-card.active {
    outline: 2px solid rgba(96, 165, 250, 0.95);
    outline-offset: 3px;
}

button.modal-close {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    line-height: 1;
}

.modal-header--row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.modal-title-inline {
    margin: 0;
    font-size: 1.35rem;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close--nested {
    position: static;
    transform: none;
}

.modal-content--notifications {
    max-width: min(500px, 95vw);
}

.notifications-list-body {
    max-height: 500px;
    overflow-y: auto;
}

.notifications-state {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.notifications-error .btn-small {
    margin-top: 12px;
}

.notification-item {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item-unread {
    background: rgba(59, 130, 246, 0.1);
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.notification-item-inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.notification-item-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notification-item-body {
    flex: 1;
    min-width: 0;
}

.notification-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.notification-item-msg {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.notification-item-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.notification-unread-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    margin-top: 8px;
    flex-shrink: 0;
}

/* Background data jobs (Settings) — persists across navigation */
.ocean-bg-job-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    padding: 10px 18px;
    font-size: 0.875rem;
    line-height: 1.45;
    background: rgba(15, 23, 42, 0.96);
    border-top: 1px solid rgba(148, 163, 184, 0.28);
    color: #e2e8f0;
    text-align: center;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

.ocean-bg-job-banner--progress {
    border-top-color: rgba(59, 130, 246, 0.45);
}

.ocean-bg-job-banner--success {
    border-top-color: rgba(34, 197, 94, 0.5);
    color: #bbf7d0;
}

.ocean-bg-job-banner--error {
    border-top-color: rgba(239, 68, 68, 0.55);
    color: #fecaca;
}

.modal-content--user-menu {
    max-width: min(300px, 95vw);
}

.modal-content--user-menu .user-menu-heading {
    margin-top: 0;
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.user-menu-inner {
    padding: 15px;
    text-align: center;
}

.user-menu-avatar-lg {
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    color: var(--text-secondary);
}

.user-menu-avatar-svg {
    opacity: 0.85;
}

.user-menu-username {
    font-weight: 600;
    margin-bottom: 16px;
}

.user-menu-actions-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-menu-fullbtn {
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
}

.modal-content--shortcuts {
    max-width: 600px;
}

.shortcuts-modal-grid {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    flex-wrap: wrap;
}

.kbd-key {
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
}

.help-section-title {
    display: flex;
    align-items: center;
    gap: 0.45em;
    flex-wrap: wrap;
}

.toolbar-btn-icon .fas {
    margin-right: 0.35em;
}

.toolbar-btn-icon .fas:only-child {
    margin-right: 0;
}

/* ========== Insights journal (/insights) ========== */
.page-header-content .insights-header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.65rem;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .page-header:has(.insights-header-actions) .page-header-content {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem 1.5rem;
    }
}

.insights-secondary-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    justify-content: flex-end;
    font-size: 0.82rem;
    font-weight: 500;
}

.insights-secondary-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.25rem 0;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.insights-secondary-nav a:hover {
    color: var(--primary-color);
    border-bottom-color: rgba(59, 130, 246, 0.45);
}

.insights-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem 1.1rem;
    margin-bottom: 1.15rem;
    padding: 1rem 1.1rem;
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 12px;
    box-sizing: border-box;
}

.insights-field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.28rem;
}

.insights-controls-search {
    flex: 1 1 220px;
    min-width: 180px;
}

.insights-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.55);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.insights-controls-sort select {
    min-width: 10.5rem;
    padding: 0.52rem 2rem 0.52rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.6);
    color: var(--text-primary);
    font-size: 0.88rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.insights-controls-sort select option,
.insights-controls-pagination select option {
    background-color: rgb(15, 23, 42);
    color: var(--text-primary);
}

.insights-controls-meta {
    flex: 1 1 200px;
    min-width: 160px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.35;
    padding-bottom: 0.12rem;
}

.insights-controls-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.insights-controls-pagination label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.insights-controls-pagination select {
    padding: 0.35rem 1.75rem 0.35rem 0.45rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.6);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.insights-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    min-height: 200px;
    grid-column: 1 / -1;
}

.insights-loading-text {
    margin: 0.85rem 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.insights-message {
    grid-column: 1 / -1;
    padding: 1.25rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
}

.insights-message--error {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Uniform card grid (/insights journal) */
.journal-bento {
    display: grid;
    gap: 0.65rem;
    width: 100%;
    align-items: start;
    grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
}

@media (min-width: 640px) {
    .journal-bento {
        grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
    }
}

@media (min-width: 1024px) {
    .journal-bento {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.65rem 0.7rem;
    }
}

.journal-card {
    position: relative;
    background: linear-gradient(155deg, rgba(15, 23, 42, 0.92) 0%, rgba(30, 41, 59, 0.55) 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
}

.journal-card:focus {
    outline: none;
}

.journal-card:focus-visible {
    border-color: rgba(96, 165, 250, 0.9);
    box-shadow:
        0 0 0 2px rgba(15, 23, 42, 0.95),
        0 0 0 4px rgba(59, 130, 246, 0.45);
}

.journal-card::before {
    content: '';
    pointer-events: none;
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0.45;
    background:
        radial-gradient(900px 240px at 0% 0%, rgba(59, 130, 246, 0.14), transparent 55%),
        radial-gradient(700px 200px at 100% 100%, rgba(139, 92, 246, 0.1), transparent 50%);
    transition: opacity 0.25s ease;
    z-index: 0;
}

.journal-card:hover {
    border-color: rgba(59, 130, 246, 0.45);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(59, 130, 246, 0.12);
    transform: translateY(-2px);
}

.journal-card:hover::before {
    opacity: 0.75;
}

.journal-card-cover {
    position: relative;
    z-index: 1;
    aspect-ratio: 4 / 3;
    width: 100%;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.65);
    overflow: hidden;
}

.journal-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    display: block;
}

.journal-card-cover-fallback {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(145deg, rgba(51, 65, 85, 0.95) 0%, rgba(15, 23, 42, 0.9) 60%, rgba(30, 58, 138, 0.35) 100%);
}

.journal-card-info {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    flex: 0 0 auto;
    min-height: 3.5rem;
    padding: 0.32rem 0.55rem 0.28rem;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    overflow: hidden;
    justify-content: center;
}

.journal-card-name {
    margin: 0;
    flex: 0 0 auto;
    min-height: 1.1rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.journal-card-stats {
    margin: 0;
    flex: 0 0 auto;
    min-height: 0.88rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    line-height: 1.12;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.journal-card-updated {
    margin: 0;
    flex: 0 0 auto;
    min-height: 0.82rem;
    font-size: 0.65rem;
    color: rgba(148, 163, 184, 0.92);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.journal-card-updated time {
    color: inherit;
}

.insights-empty {
    margin: 2rem auto;
    padding: 2.75rem 1.75rem;
    max-width: 26rem;
    text-align: center;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 16px;
}

.insights-empty-icon {
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.22);
    color: var(--primary-color);
    font-size: 1.35rem;
}

.insights-empty h2 {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    border: none;
    padding: 0;
}

.insights-empty p {
    margin: 0 0 1.35rem;
    line-height: 1.55;
    font-size: 0.92rem;
}

.insights-empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: center;
}

.insights-empty-actions a {
    text-decoration: none;
}

.insights-empty--muted .insights-empty-icon {
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.22);
    color: var(--text-secondary);
}

