/**
 * UX improvements — hierarchy, tooltips, touch targets, nav grouping.
 */

/* ── Breadcrumbs (page-level; journal uses digest-breadcrumb) ── */
.page-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    margin: 0 0 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.page-breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}
.page-breadcrumb a:hover {
    text-decoration: underline;
}
.page-breadcrumb .sep {
    opacity: 0.5;
    user-select: none;
}
.page-breadcrumb .current {
    color: var(--text-primary);
}

/* ── Accessible tooltips ── */
.tooltip-wrapper,
.stat-label-with-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.info-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -10px -8px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.info-trigger:hover,
.info-trigger:focus-visible {
    color: var(--primary-color);
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.tooltip-bubble {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.98);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    max-width: 260px;
    width: max-content;
    z-index: 30;
    box-shadow: var(--shadow);
    pointer-events: none;
}

.tooltip-wrapper:not([data-open="true"]) .tooltip-bubble[hidden],
.info-trigger:not([aria-expanded="true"]) + .tooltip-bubble[hidden] {
    display: none;
}

.tooltip-wrapper[data-open="true"] .tooltip-bubble,
.info-trigger[aria-expanded="true"] + .tooltip-bubble {
    display: block;
    pointer-events: auto;
}

/* ── Portfolio dashboard stat hierarchy ── */
.dashboard-stats--primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
}

.stat-card--primary .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
}

.stat-card--primary {
    border-color: rgba(59, 130, 246, 0.35);
}

.dashboard-stats-more {
    margin-bottom: 20px;
}

.dashboard-stats-more summary {
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 4px;
    list-style: none;
    user-select: none;
}

.dashboard-stats-more summary::-webkit-details-marker {
    display: none;
}

.dashboard-stats-more summary::before {
    content: "▸ ";
    display: inline-block;
    transition: transform 0.15s ease;
}

.dashboard-stats-more[open] summary::before {
    transform: rotate(90deg);
}

.dashboard-stats-more summary:hover {
    color: var(--primary-color);
}

.stat-label-full {
    display: inline;
}
.stat-label-short {
    display: none;
}

@media (max-width: 640px) {
    .dashboard-stats--primary {
        grid-template-columns: 1fr;
    }
    .stat-label-full {
        display: none;
    }
    .stat-label-short {
        display: inline;
    }
    .stat-label-with-info .info-trigger {
        min-width: 36px;
        min-height: 36px;
        margin: -6px -4px;
    }
}

/* ── Analysis type hierarchy ── */
.analysis-more-types {
    margin-top: 12px;
}

.analysis-more-types summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 8px 0;
    list-style: none;
}

.analysis-more-types summary::-webkit-details-marker {
    display: none;
}

.analysis-more-types summary::before {
    content: "▸ ";
    display: inline-block;
    transition: transform 0.15s ease;
}

.analysis-more-types[open] summary::before {
    transform: rotate(90deg);
}

.analysis-types-grid--featured {
    grid-template-columns: 1fr;
}

.analysis-types-grid--featured .analysis-type-card.active {
    border-color: var(--primary-color);
}

/* ── Touch targets: icon buttons ── */
.btn-icon {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-investment-action {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 0.78rem;
}

.btn-small:focus-visible,
.btn-icon:focus-visible,
.chart-toolbar-btn:focus-visible,
#chart-actions .btn-small:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Visualizations chart toolbar — min touch height */
#chart-actions .btn-small,
.chart-toolbar-btn {
    min-height: 44px !important;
    height: auto !important;
    max-height: none !important;
    padding: 8px 14px !important;
}

@media (max-width: 768px) {
    #chart-actions .btn-small .toolbar-btn-icon + span,
    #chart-actions .btn-small:not(.toolbar-btn-icon) {
        /* keep icon+text on mobile where present */
    }
}

/* ── Compare loading & feedback ── */
.compare-loading-wrap {
    padding: 32px 16px;
    text-align: center;
}

.compare-loading-progress {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.compare-loading-progress strong {
    color: var(--text-primary);
}

.compare-skeleton-table {
    width: 100%;
    border-collapse: collapse;
    opacity: 0.5;
}

.compare-skeleton-table th,
.compare-skeleton-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.compare-skeleton-bar {
    height: 12px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 4px;
    animation: compare-skeleton-pulse 1.2s ease-in-out infinite;
}

@keyframes compare-skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

@media (prefers-reduced-motion: reduce) {
    .compare-skeleton-bar {
        animation: none;
    }
}

.compare-form-message {
    font-size: 0.85rem;
    margin-top: 8px;
    min-height: 1.25em;
}

.compare-form-message--error {
    color: var(--error-color);
}

/* compare-metric-cell, compare-legend — see compare-page.css */

/* ── Portfolio header more menu ── */
.header-more-menu {
    position: relative;
    z-index: 10;
    display: inline-block;
}

.header-more-toggle {
    min-height: 44px;
}

.header-more-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: rgb(22, 32, 48);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    padding: 6px;
    z-index: 50;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.header-more-dropdown[hidden] {
    display: none !important;
}

.header-more-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    background: rgb(22, 32, 48);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 6px;
    min-height: 44px;
}

.header-more-dropdown button:hover,
.header-more-dropdown button:focus-visible {
    background: rgb(30, 42, 62);
    outline: none;
}

/* ── Sidebar nav grouping ── */
.sidebar-nav-group {
    margin: 4px 0;
}

.sidebar-nav-group-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
    border-radius: 8px;
    user-select: none;
}

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

.sidebar-nav-group-summary::before {
    content: "▸";
    font-size: 0.7rem;
    transition: transform 0.15s ease;
    width: 12px;
}

.sidebar-nav-group[open] .sidebar-nav-group-summary::before {
    transform: rotate(90deg);
}

.sidebar-nav-group-items {
    display: flex;
    flex-direction: column;
    padding-left: 8px;
}

.sidebar-link--sub {
    padding-left: 28px !important;
    font-size: 0.9rem;
}

.sidebar-link--sub .sidebar-link-text {
    opacity: 0.92;
}

/* ── Empty state CTA ── */
.empty-state .btn-primary {
    margin-top: 16px;
}

@media (max-width: 768px) {
    .investment-details-panel {
        grid-template-columns: 1fr;
        padding-left: 24px;
    }

    .btn-investment-action {
        min-height: 44px !important;
        padding: 8px 12px !important;
        font-size: 0.78rem !important;
    }
}

/* Help tabs — segmented workspace chrome (ux-improvements.css) */
.help-tabs-nav {
    margin-bottom: 0;
}

.help-section #help-content {
    margin-top: 8px;
}

/* ── Skip link (H7) ── */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 10000;
    padding: 12px 20px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}
.skip-link:focus {
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
}

/* ── Toasts (H4) ── */
.ocean-toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10050;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}
.ocean-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.97);
    box-shadow: var(--shadow-lg);
    animation: ocean-toast-in 0.2s ease;
}
.ocean-toast--success { border-color: rgba(16, 185, 129, 0.45); }
.ocean-toast--error { border-color: rgba(239, 68, 68, 0.5); }
.ocean-toast--warning { border-color: rgba(245, 158, 11, 0.5); }
.ocean-toast-text { flex: 1; font-size: 0.9rem; line-height: 1.45; color: var(--text-primary); }
.ocean-toast-action {
    flex-shrink: 0;
    border: none;
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-color);
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    min-height: 36px;
}
.ocean-toast-dismiss {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
}
.ocean-toast--out { opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; }
@keyframes ocean-toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.ocean-confirm-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10060;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(15, 23, 42, 0.98);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}
.ocean-confirm-msg { margin: 0; flex: 1; min-width: 200px; color: var(--text-primary); }
.ocean-confirm-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ── Inline validation (H5) ── */
.field-error {
    display: block;
    color: var(--error-color);
    font-size: 0.82rem;
    margin-top: 6px;
    line-height: 1.35;
}
.field-error[hidden] { display: none; }
.field-invalid {
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.35);
}

/* ── Dashboard stat skeletons (M7) ── */
.stat-value--skeleton {
    display: block;
    min-height: 1.35rem;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.12) 25%, rgba(148, 163, 184, 0.22) 50%, rgba(148, 163, 184, 0.12) 75%);
    background-size: 200% 100%;
    animation: stat-skeleton-shimmer 1.2s ease-in-out infinite;
}
@keyframes stat-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .stat-value--skeleton { animation: none; background: rgba(148, 163, 184, 0.18); }
    .ocean-toast { animation: none; }
}

/* Auth pages — card shell in portfolio-action-modals.css */

.ocean-app {
    color-scheme: dark;
}

html {
    color-scheme: dark;
    overflow-x: clip;
}

/* Component display:* must not override the HTML hidden attribute */
[hidden] {
    display: none !important;
}

/* Dark native selects — avoid white dropdown chrome on Windows/Chrome */
.ocean-app select,
.visualization-container select,
.analysis-page select,
.portfolio-section select,
.currencies-page-shell select,
.settings-section select,
.currency-selector,
.portfolio-currency-select,
.analysis-more-option-select,
.control-group select,
.form-group select,
.modal-content select {
    color-scheme: dark;
    background-color: rgb(15, 23, 42);
    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;
    padding-right: 38px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    color: rgb(241, 245, 249);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.ocean-app select:hover:not(:disabled),
.visualization-container select:hover:not(:disabled),
.control-group select:hover:not(:disabled),
.form-group select:hover:not(:disabled) {
    border-color: rgba(59, 130, 246, 0.45);
    background-color: rgb(20, 28, 46);
}

.ocean-app select:focus,
.visualization-container select:focus,
.control-group select:focus,
.form-group select:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.65);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.ocean-app select option,
.ocean-app select optgroup,
.visualization-container select option,
.analysis-page select option,
.portfolio-section select option,
.currencies-page-shell select option,
.settings-section select option,
.currency-selector option,
.portfolio-currency-select option,
.control-group select option,
.form-group select option {
    background-color: rgb(15, 23, 42);
    color: rgb(241, 245, 249);
}

/* Stock search / autocomplete — prevent clipping and white bleed */
.stock-search-wrapper,
.control-group.stock-search-wrapper,
.viz-stock-search,
.stock-search-wrapper--settings {
    position: relative;
    overflow: visible;
}

.stock-search-wrapper:focus-within,
.control-group.stock-search-wrapper:focus-within,
.viz-stock-search:focus-within {
    z-index: 40;
}

.ss-dropdown-container,
.search-results-dropdown,
.viz-stock-dropdown,
#borsdata-company-dropdown,
#ticker-autocomplete {
    background: rgba(15, 23, 42, 0.98) !important;
    border: 1px solid rgba(148, 163, 184, 0.22) !important;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    z-index: 10000;
    max-height: min(450px, 60vh);
    overflow-y: auto;
}

.control-panel,
.controls-panel {
    overflow: visible;
}

/* Buttons — clearer click affordance and alignment */
.btn-small,
a.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 8px 14px;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
    border-radius: 8px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-small:hover,
a.btn-small:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.12);
    transform: translateY(-1px);
}

.btn-small:active,
a.btn-small:active {
    transform: translateY(0);
}

.btn-primary,
a.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    cursor: pointer;
    font-weight: 600;
}

.date-preset-btn,
.analysis-tab-btn,
.settings-tab-btn {
    cursor: pointer;
}

/* Segmented workspace tabs — unified soft panel (tabs + context) */
.analysis-tabs-nav--segmented,
.tabs-navigation-wrapper.analysis-tabs-nav--segmented {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 10px;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 4px 16px rgba(0, 0, 0, 0.12);
    border-bottom: none;
}

.analysis-tabs-nav--segmented .analysis-tablist {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    width: 100%;
    padding: 3px;
    border-radius: 11px;
    background: rgba(15, 23, 42, 0.42);
    border: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.analysis-tabs-nav--segmented .analysis-tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 14px;
    border: none;
    border-bottom: none;
    border-radius: 9px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.analysis-tabs-nav--segmented .analysis-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.07);
}

.analysis-tabs-nav--segmented .analysis-tab-btn.active,
.analysis-tabs-nav--segmented .analysis-tab-btn.is-active {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.16);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border-bottom: none;
}

a.analysis-tab-btn {
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}

a.analysis-tab-btn:hover {
    text-decoration: none;
}

.analysis-tab-btn--solo {
    cursor: default;
    pointer-events: none;
}

/* Sticky workspace tab bars — no rectangular backdrop (rounded panel provides chrome) */
.research-tabs-sticky,
.insights-tabs-sticky,
.stocks-tabs-sticky,
.compare-tabs-sticky,
.stock-tabs-sticky,
.portfolio-tabs-sticky,
.analysis-tabs-sticky,
.currencies-tabs-sticky,
.viz-tabs-sticky,
.settings-tabs-sticky,
.help-tabs-sticky {
    position: sticky;
    top: 0;
    z-index: 20;
    grid-column: 1 / -1;
    background: transparent;
    padding: 0 0 6px;
    margin-bottom: 14px;
}

.viz-tabs-sticky {
    z-index: 25;
}

.stock-tabs-nav .stock-tab-meta {
    display: inline-block;
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--primary-color);
    vertical-align: middle;
    line-height: 1.3;
}

.stock-tabs-nav .stock-tab-meta--draft {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
}

.stocks-tab-panel.is-hidden {
    display: none;
}

.analysis-tab-subtitle,
.currencies-tab-subtitle,
.portfolio-tab-subtitle,
.viz-mode-subtitle,
.insights-tab-subtitle,
.stocks-tab-subtitle,
.compare-tab-subtitle,
.stock-tab-subtitle {
    margin: 0;
    padding: 0;
    font-size: inherit;
    color: inherit;
    line-height: inherit;
    max-width: none;
}

/* ── Tab context panel (subtitle under workspace tabs) ── */
.tab-context {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 11px 14px 12px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.62) 0%, rgba(30, 41, 59, 0.38) 100%);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-left: 3px solid rgba(59, 130, 246, 0.75);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Nested inside segmented tab bar — melt into parent panel */
.analysis-tabs-nav--segmented .tab-context {
    margin-top: 8px;
    padding: 8px 6px 2px;
    border-radius: 0;
    background: transparent;
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.08);
    box-shadow: none;
}

.analysis-tabs-nav--segmented .tab-context__eyebrow {
    margin-bottom: 4px;
    font-size: 0.625rem;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.72);
}

.analysis-tabs-nav--segmented .tab-context__text,
.analysis-tabs-nav--segmented .analysis-tab-subtitle {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: rgba(203, 213, 225, 0.88);
}

@media (max-width: 768px) {
    .analysis-tabs-nav--segmented {
        padding: 8px;
        border-radius: 14px;
    }

    .analysis-tabs-nav--segmented .analysis-tab-btn {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }

    .analysis-tabs-nav--segmented .analysis-tab-label {
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.tab-context__eyebrow {
    display: block;
    margin: 0 0 5px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(147, 197, 253, 0.8);
}

.tab-context__text {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.5;
    color: rgba(241, 245, 249, 0.92);
    max-width: none;
    width: 100%;
}

/* ── Page header actions (title row) ── */
.page-header-content {
    align-items: flex-start;
    gap: 20px 24px;
    overflow: visible;
}

.page-header-actions-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: min(100%, 320px);
    flex: 0 1 auto;
    overflow: visible;
}

.page-header-actions-bar--wide {
    min-width: min(100%, 420px);
}

.page-header-actions-bar__primary {
    flex-shrink: 0;
    white-space: nowrap;
}

.page-header-actions-bar__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px 12px;
    width: 100%;
    overflow: visible;
}

.page-header-actions-bar__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 4px 0;
    margin: 0;
    padding: 0;
    width: 100%;
}

.page-header-actions-bar__links a {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 2px 0;
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.page-header-actions-bar__links a + a {
    margin-left: 14px;
    padding-left: 14px;
    border-left: 1px solid rgba(148, 163, 184, 0.22);
}

.page-header-actions-bar__links a:hover,
.page-header-actions-bar__links a:focus-visible {
    color: var(--primary-color);
    border-bottom-color: rgba(59, 130, 246, 0.55);
    outline: none;
}

@media (max-width: 900px) {
    .page-header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header-actions-bar,
    .page-header-actions-bar--wide {
        align-items: stretch;
        min-width: 0;
        width: 100%;
    }

    .page-header-actions-bar__controls {
        justify-content: flex-start;
    }

    .page-header-actions-bar__links {
        justify-content: flex-start;
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .page-header-actions-bar__links a + a {
        margin-left: 10px;
        padding-left: 10px;
    }
}

@media (max-width: 480px) {
    .page-header-actions-bar__links {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .page-header-actions-bar__links a + a {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }

    .page-header-actions-bar__links a {
        min-height: 36px;
        padding: 6px 10px;
        border-radius: 8px;
        background: rgba(148, 163, 184, 0.08);
        border: 1px solid rgba(148, 163, 184, 0.16);
        border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    }

    .page-header-actions-bar__links a:hover,
    .page-header-actions-bar__links a:focus-visible {
        background: rgba(59, 130, 246, 0.12);
        border-color: rgba(59, 130, 246, 0.35);
    }
}

/* Analysis type cards — title only on surface; detail in title attr / tooltip */
.analysis-type-card .analysis-type-content p {
    display: none;
}

.analysis-type-help #analysis-type-description {
    display: none;
}

.analysis-type-duration {
    display: inline;
    margin-left: 0;
}

/* Checkbox / option rows — hide long inline descriptions */
.analysis-option-desc {
    display: none;
}

.analysis-option-title {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* Settings labels with optional info trigger */
.settings-label-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 4px;
    margin-bottom: 8px;
}

.settings-label-row .settings-item-label {
    margin-bottom: 0;
}

.settings-item-description--short {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 10px;
    line-height: 1.4;
}

.data-management-intro {
    max-width: 55ch;
}

.settings-tab-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.settings-tab-label i {
    opacity: 0.85;
}

/* Tab context + page toolbar — must win over page-specific CSS */
.tab-context .tab-context__text,
.tab-context .analysis-tab-subtitle {
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.5;
    color: rgba(241, 245, 249, 0.92);
    max-width: none;
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .btn-small:hover,
    a.btn-small:hover {
        transform: none;
    }
}

/* ── Flash messages ── */
.flash-messages { margin-bottom: 16px; }
.flash-messages .alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.flash-messages .alert-success { background: rgba(34, 197, 94, 0.12); color: #86efac; }
.flash-messages .alert-danger { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }
.flash-messages .alert-warning { background: rgba(245, 158, 11, 0.12); color: #fcd34d; }
.flash-messages .alert-info { background: rgba(59, 130, 246, 0.12); color: #93c5fd; }

/* ── Error pages ── */
.error-page { max-width: min(700px, 90vw); margin: 40px auto; padding: 20px; text-align: center; }
.error-page-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 40px 20px;
}
.error-page-lead { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 24px; line-height: 1.6; }
.error-page-actions { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
.error-traceback {
    margin-top: 24px;
    text-align: left;
    overflow: auto;
    max-height: 240px;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 12px;
    border-radius: 8px;
}
