/* MyInvestAI — modern design system */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bg: #eef2f7;
    --bg-elevated: #ffffff;
    --surface-muted: #f8fafc;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.12);
    --accent: #059669;
    --accent-soft: rgba(5, 150, 105, 0.12);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, 0.12);
    --chart-benchmark: #d97706;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --header-from: #0f172a;
    --header-to: #1e3a5f;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-full: 999px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 10px 24px -4px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.15);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --bg-muted: #f1f5f9;
    --callout-info-bg: #f0f9ff;
    --callout-info-border: #3b82f6;
    --callout-info-text: #1e3a8a;
    --callout-info-heading: #1e40af;
    --callout-success-bg: #f0fdf4;
    --callout-success-border: #10b981;
    --callout-success-text: #047857;
    --callout-success-heading: #065f46;
    --callout-warn-bg: #fffbeb;
    --callout-warn-border: #f59e0b;
    --callout-neutral-bg: #f9fafb;
    --copilot-user-bg: #e0e7ff;
    --copilot-prominent-from: #eef2ff;
    --copilot-prominent-to: #f8fafc;
    --copilot-prominent-border: #c7d2fe;
    --copilot-prominent-label: #3730a3;
}

/* Dark tokens — manual (data-theme) or system (prefers-color-scheme) */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --surface-muted: #334155;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border: #334155;
    --border-strong: #475569;
    --accent: #34d399;
    --primary-soft: rgba(59, 130, 246, 0.18);
    --accent-soft: rgba(52, 211, 153, 0.15);
    --warn-soft: rgba(251, 191, 36, 0.12);
    --danger-soft: rgba(248, 113, 113, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 10px 24px -4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
    --bg-muted: #334155;
    --callout-info-bg: rgba(59, 130, 246, 0.14);
    --callout-info-border: #60a5fa;
    --callout-info-text: #bfdbfe;
    --callout-info-heading: #93c5fd;
    --callout-success-bg: rgba(16, 185, 129, 0.14);
    --callout-success-border: #34d399;
    --callout-success-text: #6ee7b7;
    --callout-success-heading: #a7f3d0;
    --callout-warn-bg: rgba(245, 158, 11, 0.14);
    --callout-warn-border: #fbbf24;
    --callout-neutral-bg: #334155;
    --copilot-user-bg: rgba(99, 102, 241, 0.22);
    --copilot-prominent-from: rgba(99, 102, 241, 0.18);
    --copilot-prominent-to: #1e293b;
    --copilot-prominent-border: #475569;
    --copilot-prominent-label: #c7d2fe;
}

html[data-theme="light"] {
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        color-scheme: dark;
        --bg: #0f172a;
        --bg-elevated: #1e293b;
        --surface-muted: #334155;
        --text: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        --border: #334155;
        --border-strong: #475569;
        --accent: #34d399;
        --primary-soft: rgba(59, 130, 246, 0.18);
        --accent-soft: rgba(52, 211, 153, 0.15);
        --warn-soft: rgba(251, 191, 36, 0.12);
        --danger-soft: rgba(248, 113, 113, 0.12);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 10px 24px -4px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
        --bg-muted: #334155;
        --callout-info-bg: rgba(59, 130, 246, 0.14);
        --callout-info-border: #60a5fa;
        --callout-info-text: #bfdbfe;
        --callout-info-heading: #93c5fd;
        --callout-success-bg: rgba(16, 185, 129, 0.14);
        --callout-success-border: #34d399;
        --callout-success-text: #6ee7b7;
        --callout-success-heading: #a7f3d0;
        --callout-warn-bg: rgba(245, 158, 11, 0.14);
        --callout-warn-border: #fbbf24;
        --callout-neutral-bg: #334155;
        --copilot-user-bg: rgba(99, 102, 241, 0.22);
        --copilot-prominent-from: rgba(99, 102, 241, 0.18);
        --copilot-prominent-to: #1e293b;
        --copilot-prominent-border: #475569;
        --copilot-prominent-label: #c7d2fe;
    }
}

/* ---- Dark-mode overrides for position cards (inline styles workaround) ---- */
html[data-theme="dark"] .position-card,
html[data-theme="dark"] .overview-summary-card {
    background: var(--bg-elevated) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow-sm) !important;
    color: var(--text) !important;
}
html[data-theme="dark"] .overview-card-header {
    border-bottom-color: var(--border) !important;
}
/* overview-card-name has inline color:#111827 that needs explicit override */
html[data-theme="dark"] .overview-card-name,
html[data-theme="dark"] .overview-summary-title {
    color: var(--text) !important;
}
/* neutral metric values (price/qty/value) have no inline color — inherit from card */
/* coloured values (daily change, P&L) keep their green/red via inline style (no !important here) */
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .position-card,
    html[data-theme="system"] .overview-summary-card {
        background: var(--bg-elevated) !important;
        border-color: var(--border) !important;
        box-shadow: var(--shadow-sm) !important;
        color: var(--text) !important;
    }
    html[data-theme="system"] .overview-card-header {
        border-bottom-color: var(--border) !important;
    }
    html[data-theme="system"] .overview-card-name,
    html[data-theme="system"] .overview-summary-title {
        color: var(--text) !important;
    }
}

/* Dividend yield row on position cards */
.overview-card-div-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 8px;
    margin-top: 2px;
    border-top: 1px solid var(--border, #e5e7eb);
    font-size: 12px;
}
.overview-div-yield-val {
    font-weight: 600;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
}

body {
    font-family: var(--font) !important;
    background: var(--bg) !important;
    color: var(--text) !important;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    overscroll-behavior-x: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: pan-x pan-y pinch-zoom;
}

/* ——— Header ——— */
.header {
    background: linear-gradient(135deg, var(--header-from) 0%, var(--header-to) 100%) !important;
    padding-top: max(16px, calc(env(safe-area-inset-top, 0px) + 8px)) !important;
    padding-bottom: 14px !important;
    padding-left: max(24px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(24px, env(safe-area-inset-right, 0px)) !important;
    min-height: calc(72px + env(safe-area-inset-top, 0px)) !important;
    box-shadow: var(--shadow) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 100%;
    overflow-x: hidden;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
}

.header-logo {
    width: auto !important;
    height: auto !important;
    max-width: min(320px, 48vw) !important;
    padding: 8px 16px !important;
    background: #000 !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    line-height: 0 !important;
    flex-shrink: 0;
    align-self: flex-start;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.header-logo img {
    display: block !important;
    height: 40px !important;
    width: auto !important;
    max-width: 100% !important;
    object-fit: contain !important;
    object-position: left center !important;
}

.language-selector {
    top: max(16px, calc(env(safe-area-inset-top, 0px) + 8px)) !important;
    right: max(24px, env(safe-area-inset-right, 0px)) !important;
    gap: 10px !important;
}

.user-info {
    font-size: 12px !important;
    font-weight: 500;
    opacity: 0.9;
    letter-spacing: 0.02em;
    max-width: min(100%, 42vw);
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: right;
}

.lang-flag {
    width: auto !important;
    min-width: 40px !important;
    height: 32px !important;
    padding: 0 12px !important;
    border-radius: var(--radius-sm) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.lang-flag:hover {
    background: rgba(255, 255, 255, 0.18) !important;
    transform: translateY(-1px) !important;
}

.lang-flag.active {
    background: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2) !important;
}

.logout-button {
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: var(--radius-sm) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.logout-button:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-1px) !important;
}

/* ——— Navigation ——— */
@media (min-width: 769px) {
    .nav#mainNav {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        background: var(--bg-elevated) !important;
        padding: 10px 20px !important;
        box-shadow: var(--shadow-sm) !important;
        border-bottom: 1px solid var(--border) !important;
        gap: 6px !important;
        position: sticky;
        top: 0;
        z-index: 50;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav#mainNav .nav-button {
        flex-shrink: 0;
    }

    .nav#mainNav::-webkit-scrollbar {
        display: none;
    }
}

.nav#mainNav {
    display: none;
}

.nav-button-admin--hidden {
    display: none !important;
}

.nav-button {
    padding: 10px 18px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: var(--radius-full) !important;
    background: transparent !important;
    color: var(--text-secondary) !important;
    border: 1px solid transparent !important;
    transition: var(--transition) !important;
    white-space: nowrap;
}

.nav-button:hover {
    background: var(--surface-muted) !important;
    color: var(--text) !important;
}

.nav-button.active {
    background: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35) !important;
}

/* ——— Layout ——— */
.container {
    max-width: 1400px !important;
    width: 100%;
    margin: 24px auto !important;
    padding: 0 20px 48px !important;
    box-sizing: border-box;
}

.market-movers-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 100%;
}

#overviewPortfolioTable {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

#overviewPortfolioTableBody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.chart-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

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

.portfolio-chart-benchmark {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.portfolio-chart-benchmark[hidden] {
    display: none !important;
}

.portfolio-chart-benchmark__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.portfolio-chart-benchmark__toggle input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--chart-benchmark, var(--warn));
}

.portfolio-chart-benchmark__disclaimer {
    margin: 0;
    max-width: 42rem;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
}

.portfolio-chart-wrap {
    min-height: 220px;
}

.portfolio-chart-skeleton {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 10px 10px;
    background: var(--bg-elevated, #fff);
    border-radius: var(--radius-sm, 6px);
}

.portfolio-chart-skeleton[hidden],
.portfolio-chart-empty[hidden] {
    display: none !important;
}

.portfolio-chart-skeleton__bars {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-height: 140px;
}

.portfolio-chart-skeleton__bar {
    flex: 1;
    min-width: 0;
    border-radius: 4px 4px 0 0;
}

.portfolio-chart-skeleton__label {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted, #64748b);
    text-align: center;
}

.portfolio-chart-empty {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    margin: 0;
    text-align: center;
    background: var(--bg-elevated, #fff);
    border-radius: var(--radius-sm, 6px);
}

.portfolio-chart-empty .empty-state__hint {
    max-width: 22rem;
}

.portfolio-chart-wrap.portfolio-chart--loading canvas {
    visibility: hidden;
    pointer-events: none;
}

.grid {
    gap: 16px !important;
    margin-bottom: 16px !important;
}

/* ——— Cards ——— */
.card {
    background: var(--bg-elevated) !important;
    padding: 20px !important;
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow) !important;
}

.card h2 {
    color: var(--text) !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    margin-bottom: 16px !important;
    padding-bottom: 0 !important;
    border-bottom: none !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card h2::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--primary);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ——— Metrics ——— */
.metric {
    padding: 12px 0 !important;
    border-bottom: 1px solid var(--border) !important;
}

.metric-label {
    color: var(--text-secondary) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
}

.metric-value {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    font-variant-numeric: tabular-nums;
}

.positive {
    color: var(--accent) !important;
}

.negative {
    color: var(--danger) !important;
}

/* ——— Buttons ——— */
.button,
.btn {
    font-family: var(--font) !important;
    font-weight: 600 !important;
    border-radius: var(--radius-sm) !important;
    transition: var(--transition) !important;
    box-shadow: var(--shadow-sm);
}

.button {
    padding: 10px 18px !important;
    font-size: 13px !important;
    background: var(--primary) !important;
}

.button:hover {
    background: var(--primary-dark) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
}

.button.success {
    background: var(--accent) !important;
}

.button.success:hover {
    background: #047857 !important;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3) !important;
}

.button.danger {
    background: var(--danger) !important;
}

.button.btn-sell,
button[data-i18n="portfolio.addSale"],
button[data-i18n="portfolio.saveSale"] {
    background: var(--warn) !important;
}

.button.btn-sell:hover {
    background: #b45309 !important;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35) !important;
}

.compact-button {
    padding: 8px 14px !important;
    font-size: 12px !important;
    border-radius: var(--radius-sm) !important;
}

/* ——— Forms ——— */
.input-group {
    margin: 14px 0 !important;
}

.input-group label {
    color: var(--text-secondary) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    margin-bottom: 6px !important;
}

.input-group input,
.input-group select,
.form-group input,
.form-group select {
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    font-family: var(--font) !important;
    background: var(--bg-elevated) !important;
    transition: border-color var(--transition), box-shadow var(--transition) !important;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select {
    width: 100%;
    box-sizing: border-box;
}

.input-group input:focus,
.input-group select:focus,
.form-group input:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-soft) !important;
}

/* ——— Portfolio positions table (tab) ——— */
.portfolio-positions-table-wrap {
    overflow-x: auto;
    margin-top: 8px;
}

.portfolio-positions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.portfolio-positions-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    background: var(--surface-muted);
}

.portfolio-positions-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.portfolio-positions-table tbody tr.portfolio-position-row {
    cursor: pointer;
}

.portfolio-positions-table tbody tr.portfolio-position-row:hover {
    background: var(--surface-muted);
}

.portfolio-positions-table tbody tr.portfolio-details-row:hover {
    background: transparent;
}

.portfolio-details-row {
    display: none;
}

.portfolio-details-cell {
    padding: 0 12px 14px !important;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.portfolio-details-cell .position-details-panel {
    margin: 10px 0 4px;
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

#portfolioPositions .portfolio-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
}

#portfolioPositions .portfolio-mobile-card-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#portfolioPositions .portfolio-mobile-card {
    margin: 0;
    cursor: pointer;
}

#portfolioPositions .portfolio-mobile-expand {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 13px;
    touch-action: manipulation;
    background: var(--surface-muted);
    color: var(--text);
    border: 1px solid var(--border);
}

#portfolioPositions .portfolio-mobile-expand:hover {
    background: var(--bg-elevated);
}

#portfolioPositions .portfolio-mobile-details {
    padding: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

#portfolioPositions .portfolio-mobile-details .transaction-table {
    font-size: 12px;
}

#portfolioPositions .portfolio-summary-bar {
    margin-bottom: 12px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.summary-bar__label {
    color: var(--text-muted);
    font-size: 11px;
}

.position-chart-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
}

.position-chart-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    padding: 4px;
    background: var(--surface-muted);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.position-chart-period-btn {
    flex: 1 1 auto;
    min-width: 2.75rem;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.position-chart-period-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.position-chart-period-btn.is-active {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.position-chart-period-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.modal-chart-container {
    min-height: 280px;
}

.portfolio-name-cell {
    max-width: 220px;
}

.portfolio-name-text {
    font-weight: 600;
    color: var(--text);
}

.portfolio-chart-link {
    cursor: pointer;
    color: var(--primary);
    font-size: 12px;
    margin-left: 4px;
}

.daily-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 12px;
    white-space: nowrap;
}

.daily-pill.positive {
    background: var(--accent-soft, #d1fae5);
    color: var(--accent, #047857);
}

.daily-pill.negative {
    background: var(--danger-soft, #fee2e2);
    color: var(--danger, #b91c1c);
}

.pct-arrow {
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    opacity: 1;
}

.pct-arrow-sm {
    font-size: inherit;
    font-weight: inherit;
}

.portfolio-expand-cell {
    text-align: right;
    width: 36px;
}

.position-details-panel {
    margin-bottom: 12px;
}

/* ——— Position cards ——— */
.position-card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 16px !important;
    margin-bottom: 12px !important;
    background: var(--bg-elevated) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: var(--transition) !important;
}

.position-card:hover {
    border-color: var(--border-strong) !important;
    box-shadow: var(--shadow) !important;
}

/* Compact overview position cards — denser layout, same information, smoother to scan.
   #id prefix raises specificity above the mobile media-query rules so it wins everywhere. */
#overviewPortfolioTableBody .position-card.overview-position-card {
    padding: 10px !important;
    margin-bottom: 0 !important;
    border-radius: 10px !important;
}
#overviewPortfolioTableBody .position-card.overview-position-card .overview-card-header {
    gap: 8px !important;
    margin-bottom: 6px !important;
    padding-bottom: 6px !important;
}
#overviewPortfolioTableBody .position-card.overview-position-card .overview-card-name {
    margin-top: 2px !important;
    line-height: 1.25 !important;
}
#overviewPortfolioTableBody .position-card.overview-position-card .overview-card-grid {
    gap: 6px 10px !important;
}
#overviewPortfolioTableBody .position-card.overview-position-card .overview-metric-value {
    line-height: 1.2 !important;
}
#overviewPortfolioTableBody .position-card.overview-position-card .overview-card-metric .ux-metric-sublabel {
    display: inline-block;
    line-height: 1.1 !important;
    margin-bottom: 1px;
}
#overviewPortfolioTableBody .position-card.overview-position-card .overview-card-logo .company-logo {
    width: 38px !important;
    height: 38px !important;
}

.ticker-badge {
    background: var(--primary-soft) !important;
    color: var(--primary-dark) !important;
    padding: 4px 10px !important;
    border-radius: var(--radius-full) !important;
    font-size: 11px !important;
    font-weight: 700 !important;
}

.ticker-clickable:hover {
    transform: scale(1.05);
}

.position-metrics {
    gap: 12px !important;
    margin: 12px 0 !important;
}

.metric-label-small {
    font-size: 10px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted) !important;
}

.metric-value-large {
    font-size: 14px !important;
    font-weight: 700 !important;
}

.transaction-table th {
    background: var(--surface-muted) !important;
    color: var(--text-secondary) !important;
    font-size: 11px !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 10px 8px !important;
}

.transaction-table td {
    padding: 10px 8px !important;
    font-size: 12px !important;
}

.position-action-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-top: 8px;
}

.position-action-links .add-transaction-link,
.position-action-links .sell-transaction-link {
    margin-top: 0 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.4;
    text-decoration: none;
}

.add-transaction-link {
    color: var(--primary) !important;
}

.sell-transaction-link {
    color: var(--warn, #b45309) !important;
}

.add-transaction-link:hover,
.sell-transaction-link:hover {
    text-decoration: underline !important;
}

/* ——— Tables ——— */
th {
    background: var(--surface-muted) !important;
    color: var(--text-secondary) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

td {
    font-size: 13px !important;
}

/* ——— Alerts & status ——— */
.alert {
    border-radius: var(--radius) !important;
    font-size: 14px !important;
}

.status-badge {
    border-radius: var(--radius-full) !important;
    padding: 4px 12px !important;
}

/* ——— Modal ——— */
.modal-content {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border) !important;
}

/* ——— Chart ——— */
.chart-container {
    height: 280px !important;
    margin-top: 16px !important;
    padding: 8px;
    background: var(--surface-muted);
    border-radius: var(--radius);
}

/* ——— Install PWA button ——— */
#installBtn {
    background: var(--header-from) !important;
    border-radius: var(--radius-full) !important;
    padding: 14px 22px !important;
    font-family: var(--font) !important;
    font-weight: 600 !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

#installBtn:hover {
    transform: translateY(-2px);
}

/* ——— Auth pages (login / register) ——— */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37, 99, 235, 0.25), transparent),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(5, 150, 105, 0.15), transparent),
        linear-gradient(160deg, #0f172a 0%, #1e3a5f 45%, #0f172a 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: authIn 0.4s ease-out;
}

@keyframes authIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-card .auth-logo {
    height: 48px;
    width: auto;
    max-width: 100%;
    margin: 0 auto 24px;
    display: block;
    background: #000;
    border-radius: 6px;
    padding: 10px 18px;
    box-sizing: content-box;
}

.auth-card h1 {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.auth-card > p,
.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.auth-card .form-group {
    margin-bottom: 18px;
}

.auth-card .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.auth-card .btn {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    font-size: 15px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.auth-card .btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.auth-card .btn-secondary {
    background: var(--surface-muted);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    margin-top: 10px;
}

.auth-card .btn-secondary:hover {
    background: var(--border);
    box-shadow: none;
    transform: none;
}

.auth-card .error {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
    padding: 10px;
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
}

.auth-card .error:empty {
    display: none;
    margin: 0;
    padding: 0;
    min-height: 0;
    border: none;
    background: transparent;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

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

.twofa-hint {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    text-align: center;
}

.qr-wrap {
    display: flex;
    justify-content: center;
    margin: 8px 0 20px;
}

.qr-wrap img {
    width: min(280px, 100%);
    height: auto;
    aspect-ratio: 1;
    display: block;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    padding: 12px;
    box-sizing: border-box;
}

.secret-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-align: center;
}

.secret-code {
    display: block;
    text-align: center;
    word-break: break-all;
    padding: 10px 12px;
    margin-bottom: 18px;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, monospace;
    font-size: 13px;
}

/* Splash */
.splash-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}

.splash-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: authIn 0.5s ease-out;
}

.splash-card .title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
}

.splash-card .subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Reports grid */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.report-card {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.report-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.report-card--return-highlight {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow-sm) !important;
}

.report-card-icon {
    font-size: 28px;
    margin-bottom: 12px;
}

.report-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}

.report-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
    margin: 0 0 16px;
}

.report-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-secondary-report {
    background: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-strong) !important;
    box-shadow: none !important;
}

.btn-secondary-report:hover {
    background: var(--surface-muted) !important;
    transform: none !important;
}

/* News feed — grouped by stock */
.news-feed-list,
.news-feed-preview {
    width: 100%;
}

.news-feed-by-stock {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.news-feed-preview .news-feed-by-stock {
    gap: 14px;
}

.news-stock-group {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.news-stock-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--surface-muted) 0%, var(--bg-elevated) 100%);
    border-bottom: 1px solid var(--border);
}

.news-stock-header-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px 14px;
    min-width: 0;
}

.news-stock-ticker {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    background: var(--primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.news-stock-name {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.news-feed-preview .news-stock-name {
    font-size: 15px;
}

.news-stock-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.news-stock-articles {
    list-style: none;
    margin: 0;
    padding: 0;
}

.news-article {
    border-bottom: 1px solid var(--border);
}

.news-article:last-child {
    border-bottom: none;
}

.news-article-row {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 16px;
    padding: 18px 20px;
    transition: background var(--transition);
}

a.news-article-row {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.news-article-row:hover {
    background: var(--surface-muted);
    color: inherit;
}

a.news-article-row:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.news-feed-preview .news-article-row {
    grid-template-columns: 72px 1fr;
    gap: 12px;
    padding: 12px 16px;
}

.news-article:hover .news-article-row:not(a) {
    background: var(--surface-muted);
}

.news-article--clickable:hover .news-article-title-text {
    color: var(--primary);
}

.news-article-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.4;
    padding-top: 2px;
}

.news-article-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
}

.news-feed-preview .news-article-title {
    font-size: 14px;
    margin-bottom: 4px;
}

.news-article-title a,
.news-article-title-text {
    color: var(--text);
    text-decoration: none;
}

.news-article-title a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.news-article-summary {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-secondary);
}

.news-article-publisher {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.news-stock-empty {
    margin: 0;
    padding: 16px 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.news-feed-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding: 10px 14px;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.news-feed-muted {
    color: var(--text-muted);
    font-size: 15px;
    margin: 0;
    padding: 24px;
    text-align: center;
}

@media (max-width: 520px) {
    .news-article-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .news-article-date {
        font-size: 11px;
    }

    .news-stock-header {
        padding: 14px 16px;
    }
}

/* Account & admin user management */
.account-card {
    max-width: 560px;
}

#account {
    display: none !important;
}

#account.active {
    display: block !important;
}

#account .account-prefs-card {
    max-width: 720px;
    margin-top: 16px;
}

/* Two-column layout on desktop: profile/password left, prefs right */
@media (min-width: 1024px) {
    #account.active {
        display: grid !important;
        grid-template-columns: minmax(auto, 560px) 1fr;
        gap: 0 24px;
        align-items: start;
    }
    #account > .account-card {
        max-width: none;
        grid-column: 1;
        grid-row: 1 / span 20;
    }
    #account > .account-prefs-card {
        max-width: none;
        grid-column: 2;
        margin-top: 0;
        margin-bottom: 16px;
    }
    #account > .account-prefs-card:last-child {
        margin-bottom: 0;
    }
}

.account-intro {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 20px;
}

.account-summary {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.account-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px 20px;
    font-size: 14px;
}

.account-summary-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.account-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ——— Admin Panel Dark Mode ——— */
.admin-panel > .card {
    background: var(--bg-elevated) !important;
}

/* Verificer portefølje-beregninger card */
.admin-panel div[style*="background: #f0f9ff"] {
    background: var(--surface-muted) !important;
    border-color: var(--border) !important;
}

.admin-panel div[style*="background: #f0f9ff"] h3 {
    color: var(--text) !important;
}

.admin-panel div[style*="background: #f0f9ff"] p {
    color: var(--text-secondary) !important;
}

.admin-panel div[style*="background: #f0f9ff"] label {
    color: var(--text-secondary) !important;
}

.admin-panel div[style*="background: #f0f9ff"] input {
    background: var(--bg-base) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* Pre/Result box */
.admin-panel pre {
    background: var(--bg-base) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* New User Form */
.admin-panel div[style*="background: #f9fafb"] {
    background: var(--surface-muted) !important;
    border-color: var(--border) !important;
}

.admin-panel div[style*="background: #f9fafb"] h3,
.admin-panel div[style*="background: #f9fafb"] label {
    color: var(--text) !important;
}

.admin-panel div[style*="background: #f9fafb"] p {
    color: var(--text-secondary) !important;
}

.admin-panel div[style*="background: #f9fafb"] input {
    background: var(--bg-base) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* Users table and rows */
.admin-panel table {
    background: var(--bg-elevated) !important;
}

.admin-panel tbody tr {
    background: var(--bg-elevated) !important;
    border-color: var(--border) !important;
}

.admin-panel tbody tr td {
    color: var(--text) !important;
}

.admin-panel tbody tr[style*="background: #fef3c7"] {
    background: var(--primary-soft) !important;
}

.admin-panel tbody tr[style*="background: #fef3c7"] td {
    color: var(--text) !important;
}

.account-section-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px;
}

.account-password-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: -6px 0 12px;
    line-height: 1.45;
}

.account-message {
    margin: 12px 0;
    font-size: 14px;
    font-weight: 500;
}

.admin-panel .admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-panel .admin-users-table th {
    padding: 12px !important;
    text-align: left;
}

.admin-panel .admin-users-table td {
    padding: 12px !important;
    border-bottom: 1px solid var(--border);
}

.admin-panel .admin-users-table tr:nth-child(even) td {
    background: var(--surface-muted);
}

.admin-panel .admin-users-table tr.admin-row td {
    background: var(--warn-soft);
}

.ux-admin-muted {
    color: var(--text-muted);
}

.ux-admin-error {
    color: var(--danger);
}

.ux-admin-header-row {
    background: var(--surface-muted);
}

.ux-admin-badge {
    color: var(--warn);
}

/* Analysis results polish */
.analysis-results-wrap {
    position: relative;
    min-height: 200px;
}

.analysis-results-skeleton {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 10px 10px;
    background: var(--bg-elevated, #fff);
    border-radius: var(--radius-sm, 6px);
}

.analysis-results-skeleton[hidden],
.analysis-results-empty[hidden],
.analysis-results-content[hidden] {
    display: none !important;
}

.analysis-results-skeleton__lines {
    flex: 1;
    min-height: 120px;
}

.analysis-results-skeleton__label {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted, #64748b);
    text-align: center;
}

.analysis-results-empty {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    margin: 0;
    text-align: center;
    background: var(--bg-elevated, #fff);
    border-radius: var(--radius-sm, 6px);
}

.analysis-results-empty .empty-state__hint {
    max-width: 22rem;
}

.analysis-results-wrap.analysis-results--loading .analysis-results-content {
    visibility: hidden;
}

.briefing-results-wrap,
.digest-results-wrap {
    position: relative;
    min-height: 160px;
    margin-top: 10px;
}

.briefing-results-wrap.analysis-results--loading .briefing-results-content,
.digest-results-wrap.analysis-results--loading .digest-results-content {
    visibility: hidden;
}

.analysis-results-error {
    color: var(--danger, #ef4444);
    font-size: 14px;
    margin: 0;
}

#analysisResultsContent > div,
#analysisResults > div {
    font-size: 14px;
}

#analysisResultsContent h3,
#analysisResults h3 {
    font-weight: 700 !important;
}

/* Analysis / Copilot / Risk — theme-aware panels (JS + static) */
.analysis-results-root {
    line-height: 1.6;
}

.analysis-callout {
    margin-bottom: 15px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--callout-border, var(--border));
    background: var(--callout-bg, var(--surface-muted));
}

.analysis-callout--info {
    --callout-bg: var(--callout-info-bg);
    --callout-border: var(--callout-info-border);
}

.analysis-callout--success {
    --callout-bg: var(--callout-success-bg);
    --callout-border: var(--callout-success-border);
}

.analysis-callout__title {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--callout-heading, var(--text));
}

.analysis-callout--info .analysis-callout__title {
    --callout-heading: var(--callout-info-heading);
}

.analysis-callout--success .analysis-callout__title {
    --callout-heading: var(--callout-success-heading);
}

.analysis-callout__body {
    margin: 0;
    font-size: 13px;
    color: var(--callout-text, var(--text-secondary));
}

.analysis-callout--info .analysis-callout__body {
    --callout-text: var(--callout-info-text);
}

.analysis-callout--success .analysis-callout__body {
    --callout-text: var(--callout-success-text);
}

.analysis-section-title {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.analysis-section-title--success {
    color: var(--accent);
}

.analysis-section-title--warn {
    color: var(--warn);
}

.analysis-section-title--primary {
    color: var(--primary);
}

.analysis-list {
    margin: 0 0 15px 20px;
    padding: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.analysis-list li {
    margin-bottom: 6px;
}

.analysis-position-card {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--callout-neutral-bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.analysis-position-card--research {
    background: var(--callout-success-bg);
    border-left-color: var(--callout-success-border);
}

.analysis-position-card__badge {
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--callout-success-text);
}

.analysis-position-card__stock-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 4px 0 8px;
}

.analysis-news-box {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--callout-info-bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--callout-info-border);
}

.analysis-news-box__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--callout-info-heading);
    margin-bottom: 8px;
}

.analysis-news-item {
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.analysis-news-item a {
    color: var(--primary);
    text-decoration: underline;
}

.analysis-news-item__meta {
    color: var(--text-muted);
}

.copilot-message {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.copilot-message--user {
    background: var(--copilot-user-bg);
}

.copilot-message--assistant {
    background: var(--bg-elevated);
}

.copilot-stream-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: currentColor;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: copilot-blink 0.8s step-end infinite;
}

@keyframes copilot-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

.copilot-message__role {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.copilot-message__sources {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.ux-callout {
    margin-bottom: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--callout-border, var(--border));
    background: var(--callout-bg, var(--surface-muted));
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.ux-callout--success {
    --callout-bg: var(--callout-success-bg);
    --callout-border: var(--callout-success-border);
}

.ux-alert-banner,
.card.ux-alert-banner {
    margin-bottom: 8px;
    padding: 10px 12px !important;
    border-left: 4px solid var(--callout-warn-border) !important;
    background: var(--callout-warn-bg) !important;
    color: var(--text-secondary);
}

.ux-alert-banner strong {
    color: var(--warn);
}

.ux-risk-alerts-body {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.ux-btn-ghost-sm {
    font-size: 10px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    cursor: pointer;
    color: var(--text-secondary);
}

.ux-muted-caption {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.ux-metric-sublabel {
    color: var(--text-muted);
}

.ux-chart-countdown {
    color: var(--text-muted);
}

.ux-section-intro {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0 0;
}

.ux-section-intro--spaced {
    margin-bottom: 20px;
}

.market-movers-panel {
    border-radius: var(--radius-sm);
    padding: 12px;
    color: #fff;
}

.market-movers-panel--winners {
    background: #1e3a8a;
}

.market-movers-panel--losers {
    background: #7f1d1d;
}

.market-movers-panel__title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #fff;
}

.market-movers-panel__body {
    min-height: 200px;
}

.copilot-briefing-box,
.news-digest-panel {
    margin-bottom: 0;
    padding: 0;
    background: none;
    border: none;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* News digest — theme-aware (renderNewsDigest) */
/* Digest: narrative freshness/source line */
.news-digest-asof {
    margin: -6px 0 12px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* Digest: today's movers (price↔news coupling) */
.news-digest-movers {
    margin: 0 0 14px;
    padding: 10px 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.news-digest-movers__title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text);
}
.news-digest-mover {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    padding: 6px 0;
    border-top: 1px solid var(--border);
}
.news-digest-mover:first-of-type {
    border-top: none;
}
.news-digest-mover .mover__head {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    flex-shrink: 0;
}
.news-digest-mover .mover__tk {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
}
.news-digest-mover .mover__pct {
    font-weight: 700;
    font-size: 13px;
}
.news-digest-mover.mover--up .mover__pct { color: var(--accent, #34d399); }
.news-digest-mover.mover--down .mover__pct { color: var(--danger, #ef4444); }
.news-digest-mover .mover__driver {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1 1 240px;
    min-width: 0;
}
.news-digest-mover .mover__cause {
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    font-weight: 600;
}
.news-digest-mover .mover__src { color: var(--text-muted); }

/* Digest: sentiment / materiality badges */
.digest-badge {
    font-size: 11px;
    vertical-align: baseline;
}
.digest-badge--pos { color: var(--accent, #34d399); }
.digest-badge--neg { color: var(--danger, #ef4444); }
.digest-badge--mat { color: var(--warn, #fbbf24); }

.news-digest-theme {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.news-digest-theme:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.news-digest-narrative {
    margin: 0 0 12px;
    color: var(--text-secondary);
}

/* Portfolio assessment block (folded in from the former Analysis page) */
.digest-assessment {
    margin: 0 0 16px;
    padding: 14px 16px;
    background: var(--surface-muted, rgba(127,127,127,0.05));
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
}

.digest-assessment__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-bottom: 8px;
}

.digest-assessment__title {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text, #111827);
}

.digest-assessment__asof {
    font-size: 0.72rem;
    color: var(--text-muted, #9ca3af);
}

.digest-assessment__lead {
    margin: 0 0 12px;
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--text-secondary, #6b7280);
}

.digest-assessment__group {
    margin-top: 10px;
}

.digest-assessment__grouptitle {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    color: var(--text-secondary, #6b7280);
}

.digest-assessment__group--pos .digest-assessment__grouptitle { color: var(--accent, #10b981); }
.digest-assessment__group--neg .digest-assessment__grouptitle { color: var(--danger, #ef4444); }
.digest-assessment__group--rec .digest-assessment__grouptitle { color: var(--primary, #2563eb); }

.digest-assessment__list {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.digest-assessment__list li {
    font-size: 0.86rem;
    line-height: 1.45;
    color: var(--text, #111827);
}

/* AI focus-stocks section (watchlist + price targets) */
.digest-focus {
    margin: 0 0 16px;
    padding: 14px 16px;
    background: var(--surface-muted, rgba(127,127,127,0.05));
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
}

.digest-focus__title {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text, #111827);
    margin-bottom: 2px;
}

.digest-focus__intro {
    margin: 0 0 12px;
    font-size: 0.78rem;
    color: var(--text-muted, #9ca3af);
    line-height: 1.45;
}

.digest-focus__item {
    padding: 11px 0;
    border-top: 1px solid var(--border, #e5e7eb);
}

.digest-focus__item:first-of-type {
    border-top: none;
    padding-top: 2px;
}

.digest-focus__head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin-bottom: 5px;
}

.digest-focus__name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text, #111827);
}

.digest-focus__badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 5px;
}

.digest-focus__badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.digest-focus__badge--wl {
    background: var(--accent-soft, rgba(16,185,129,0.12));
    color: var(--accent, #10b981);
}

.digest-focus__badge--pt {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary, #2563eb);
}

.digest-focus__progress {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0 0 7px;
}

.digest-focus__now {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
}

.digest-focus__dist {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary, #2563eb);
}

.digest-focus__dist--reached {
    background: var(--accent-soft, rgba(16,185,129,0.14));
    color: var(--accent, #10b981);
}

.digest-focus__insight {
    margin: 0 0 6px;
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--text-secondary, #374151);
}

.digest-focus__insight--muted {
    color: var(--text-muted, #9ca3af);
    font-style: italic;
}

.digest-focus__sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.digest-focus__source {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary, #2563eb);
    text-decoration: none;
    padding: 2px 8px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 999px;
}

.digest-focus__source:hover {
    border-color: var(--primary, #2563eb);
    background: var(--primary-soft, rgba(37,99,235,0.08));
}

.digest-focus-loading {
    font-size: 0.82rem;
    color: var(--text-muted, #9ca3af);
    padding: 8px 0;
}

.news-digest-theme__title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.news-digest-theme__tickers {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.news-digest-articles {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-secondary);
}

.news-digest-articles li {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.news-digest-articles a {
    color: var(--primary);
    text-decoration: underline;
}

.news-digest-articles a:hover {
    color: var(--primary-dark);
}

.news-digest-article__source {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.news-digest-theme__more {
    margin: 8px 0 0;
}

.news-digest-news-link {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.news-digest-news-link:hover {
    color: var(--primary-dark);
}

.news-digest-footer {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.news-digest-article--stale {
    opacity: 0.55;
}

.news-digest-article__age {
    font-size: 0.72em;
    color: var(--text-muted, #888);
    margin-left: 5px;
    font-style: italic;
}

.news-digest-article__date {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 6px;
    font-style: italic;
}

.news-digest-article__summary {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.news-digest-articles li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.news-digest-news-link--primary {
    font-size: 13px;
}

.news-digest-disclaimer {
    margin: 8px 0 0;
    font-size: 11px;
    color: var(--text-muted);
}

.copilot-briefing-box__summary {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    margin: 0 0 8px;
}

.copilot-briefing-box__paused {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* Overview position grid cards (JS-generated inline styles overridden where possible) */
#overviewPortfolioTableBody > div[style*="border"] {
    border-radius: var(--radius) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: var(--transition) !important;
}

#overviewPortfolioTableBody .overview-position-card,
#overviewPortfolioTableBody .overview-summary-card {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
}

#overviewPortfolioTableBody .overview-card-header {
    min-width: 0;
}

#overviewPortfolioTableBody .overview-card-title {
    min-width: 0;
}

#overviewPortfolioTableBody .overview-card-name {
    display: block;
    margin-top: 6px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

#overviewPortfolioTableBody .overview-card-grid {
    min-width: 0;
}

#overviewPortfolioTableBody .overview-card-metric {
    min-width: 0;
    overflow-wrap: anywhere;
}

#overviewPortfolioTableBody .overview-metric-value {
    display: inline-block;
    max-width: 100%;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

    #overviewPortfolioTableBody .overview-metric-value .pct-arrow {
        white-space: nowrap;
        font-size: inherit;
        font-weight: inherit;
    }

#overviewPortfolioTableBody .overview-summary-stats {
    max-width: 100%;
}

/* Mobile */
@media (max-width: 768px) {
    .header {
        padding-top: max(48px, calc(env(safe-area-inset-top, 0px) + 16px)) !important;
        padding-bottom: 12px !important;
        padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
        min-height: calc(64px + env(safe-area-inset-top, 0px)) !important;
        flex-wrap: wrap;
        align-items: flex-start;
        align-content: flex-start;
        gap: 10px;
    }

    .header-logo {
        max-width: min(200px, calc(48vw - env(safe-area-inset-left, 0px))) !important;
        padding: 6px 10px !important;
        margin-right: auto;
    }

    .header-logo img {
        height: 32px !important;
        max-width: 100% !important;
    }

    .language-selector {
        position: static !important;
        top: auto !important;
        right: auto !important;
        width: 100%;
        max-width: 100%;
        flex-direction: row !important;
        justify-content: flex-end;
        align-items: center;
        flex-wrap: wrap;
        margin-top: 4px;
        margin-left: 0 !important;
    }

    .user-info {
        max-width: 100%;
    }

    .container {
        padding: 0 12px 32px !important;
        margin-top: 16px !important;
    }

    .card {
        padding: 16px !important;
        max-width: 100%;
        overflow-x: hidden;
    }

    .nav-button {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }

    .market-movers-row {
        grid-template-columns: 1fr;
    }

    #overviewPortfolioTableBody {
        grid-template-columns: 1fr;
        gap: 8px;
        overflow-x: hidden;
    }

    #overviewPortfolioTableBody .overview-position-card,
    #overviewPortfolioTableBody .overview-summary-card {
        padding: 16px !important;
    }

    #overviewPortfolioTableBody .overview-card-header {
        gap: 12px;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    #overviewPortfolioTableBody .overview-card-logo .company-logo {
        width: 44px;
        height: 44px;
        padding: 4px;
    }

    #overviewPortfolioTableBody .overview-ticker-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        min-width: 44px;
        padding: 10px 14px !important;
        font-size: 12px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    #portfolioPositions .overview-position-card {
        padding: 16px !important;
    }

    #portfolioPositions .overview-ticker-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        min-width: 44px;
        padding: 10px 14px !important;
        font-size: 12px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    #portfolioPositions .portfolio-mobile-details .transaction-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #overviewPortfolioTableBody .overview-card-name {
        font-size: 14px !important;
    }

    #overviewPortfolioTableBody .overview-card-grid {
        gap: 14px 12px !important;
    }

    #overviewPortfolioTableBody .overview-metric-label {
        display: block;
        font-size: 11px !important;
        line-height: 1.4;
        margin-bottom: 4px;
        letter-spacing: 0.02em;
    }

    #overviewPortfolioTableBody .overview-metric-value {
        font-size: 14px !important;
    }

    #overviewPortfolioTableBody .overview-metric-value .pct-arrow {
        white-space: nowrap;
        font-size: inherit;
        font-weight: inherit;
    }

    #overviewPortfolioTableBody .overview-summary-title {
        font-size: 15px !important;
        margin-bottom: 14px !important;
    }

    #overviewPortfolioTableBody .overview-summary-stats {
        gap: 20px !important;
        justify-content: space-around !important;
        padding: 0 4px;
    }

    #overviewPortfolioTableBody .overview-summary-stats > div {
        min-width: 0;
        flex: 1 1 120px;
        max-width: 100%;
    }

    #overviewPortfolioTableBody .overview-summary-stats span[style*="font-weight: 700"] {
        font-size: 15px !important;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }
}

/* Overview accordion: clickable cards with inline detail panels */
.overview-card-wrap {
    transition: box-shadow 0.15s ease;
    border-radius: 8px;
    /* min-width:0 so this grid item never forces the track wider than the column */
    min-width: 0;
    max-width: 100%;
}
.overview-card-wrap:hover .overview-position-card,
.overview-card-wrap:hover .portfolio-mobile-card {
    box-shadow: 0 0 0 2px var(--primary, #3b82f6) !important;
}
.overview-card-wrap.overview-card-expanded .overview-position-card,
.overview-card-wrap.overview-card-expanded .portfolio-mobile-card {
    box-shadow: 0 0 0 2px var(--primary, #3b82f6) !important;
}
.overview-card-wrap .overview-position-card,
.overview-card-wrap .portfolio-mobile-card {
    /* Remove bottom margin so the card wrapper stays tight */
    margin-bottom: 0 !important;
    border-radius: 8px;
    transition: box-shadow 0.15s ease;
}
/* Detail panel: full-width row below the card in the grid.
   min-width:0 is critical — without it the grid item refuses to shrink
   below the 36rem table min-content, which blows out the whole grid track
   and makes every card wider than the viewport. */
.overview-detail-panel {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    animation: ov-detail-in 0.18s ease;
}
/* Make the transaction table scrollable horizontally within the panel */
.overview-detail-panel .table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
/* Keep the inner table at its natural readable width and let it scroll */
.overview-detail-panel .transaction-table {
    min-width: 36rem;
}
@keyframes ov-detail-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (display-mode: standalone) {
    .header {
        padding-top: max(48px, calc(env(safe-area-inset-top, 0px) + 16px)) !important;
    }

    .language-selector {
        top: max(48px, calc(env(safe-area-inset-top, 0px) + 16px)) !important;
    }
}

/* iOS home screen / standalone PWA */
@media (display-mode: standalone), (max-width: 768px) {
    html,
    body {
        overflow-x: hidden;
        overscroll-behavior-x: none;
    }

    .header,
    .nav,
    .container,
    .section,
    .card {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ——— UX layer (ux.js) ——— */
.ux-skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 10000;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.ux-skip-link:focus,
.ux-skip-link:focus-visible {
    left: 12px;
    top: 12px;
    width: auto;
    height: auto;
    overflow: visible;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.ux-help-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.ux-help-menu__toggle {
    height: 32px;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.ux-help-menu__toggle:hover,
.ux-help-menu__toggle:focus-visible {
    background: rgba(255, 255, 255, 0.2);
}

.ux-help-menu__toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.ux-help-menu__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    padding: 6px;
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius-sm, 6px);
    box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 23, 42, 0.12));
    z-index: 200;
}

.ux-help-menu__item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--text, #0f172a);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
}

.ux-help-menu__item:hover,
.ux-help-menu__item:focus-visible {
    background: var(--bg-muted, #f1f5f9);
    outline: none;
}

.ux-help-menu__theme {
    padding: 8px 10px 10px;
    margin-top: 4px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.ux-help-menu__theme-label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #94a3b8);
}

/* ===================== Help Center (slide-in drawer) ===================== */
.ux-help-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ux-help-backdrop.ux-help-backdrop--open {
    opacity: 1;
}

.ux-help-center {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1201;
    width: min(460px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated, #fff);
    border-left: 1px solid var(--border, #e2e8f0);
    box-shadow: -14px 0 44px rgba(0, 0, 0, 0.28);
    transform: translateX(100%);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.ux-help-center.ux-help-center--open {
    transform: translateX(0);
}

.ux-help-center__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.ux-help-center__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text, #0f172a);
}

.ux-help-center__subtitle {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
    line-height: 1.4;
}

.ux-help-center__close {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: none;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    border-radius: 8px;
}

.ux-help-center__close:hover {
    background: var(--surface-muted, rgba(127,127,127,0.08));
    color: var(--text, #0f172a);
}

.ux-help-center__searchwrap {
    position: relative;
    padding: 14px 20px 6px;
}

.ux-help-center__searchicon {
    position: absolute;
    left: 32px;
    top: 28px;
    font-size: 0.85rem;
    opacity: 0.55;
    pointer-events: none;
}

.ux-help-center__search {
    width: 100%;
    height: 42px;
    padding: 0 14px 0 38px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--bg-elevated, #fff);
    color: var(--text, #0f172a);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.ux-help-center__search:focus {
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(37, 99, 235, 0.18));
}

.ux-help-center__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 20px 4px;
}

.ux-help-action {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--surface-muted, rgba(127,127,127,0.06));
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 9px;
    color: var(--text, #0f172a);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.12s, background 0.12s;
}

.ux-help-action:hover {
    border-color: var(--primary, #2563eb);
    background: var(--primary-soft, rgba(37, 99, 235, 0.08));
}

.ux-help-center__themebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px 12px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.ux-help-center__themelabel {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #94a3b8);
    white-space: nowrap;
}

.ux-help-center__themebar .ux-theme-switch {
    flex: 1;
}

.ux-help-center__topics {
    flex: 1;
    overflow-y: auto;
    padding: 8px 20px 28px;
}

.ux-help-cat__title {
    margin: 16px 0 7px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #475569);
}

.ux-help-cat:first-child .ux-help-cat__title {
    margin-top: 4px;
}

.ux-help-topic {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    margin-bottom: 6px;
    background: var(--surface-muted, rgba(127,127,127,0.04));
    overflow: hidden;
}

.ux-help-topic > summary {
    list-style: none;
    cursor: pointer;
    padding: 11px 13px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text, #0f172a);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ux-help-topic > summary::-webkit-details-marker {
    display: none;
}

.ux-help-topic > summary::before {
    content: '▸';
    color: var(--text-muted, #94a3b8);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.ux-help-topic[open] > summary::before {
    transform: rotate(90deg);
}

.ux-help-topic__body {
    padding: 0 13px 13px 31px;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--text-secondary, #475569);
}

.ux-help-topic__body p {
    margin: 0 0 8px;
}

.ux-help-topic__body ul {
    margin: 0 0 8px;
    padding-left: 18px;
}

.ux-help-topic__body li {
    margin-bottom: 3px;
}

.ux-help-topic__body strong {
    color: var(--text, #0f172a);
}

.ux-help-kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 5px;
    background: var(--bg-elevated, #fff);
    font-size: 0.78rem;
    font-weight: 600;
}

.ux-help-center__empty {
    padding: 24px 20px;
    text-align: center;
    color: var(--text-muted, #94a3b8);
    font-size: 0.88rem;
}

@media (max-width: 520px) {
    .ux-help-center {
        width: 100vw;
    }
    .ux-help-center__actions {
        flex-direction: column;
    }
    .ux-help-action {
        flex: 1 1 100%;
    }
}

.ux-theme-switch {
    display: flex;
    gap: 4px;
    width: 100%;
}

.ux-theme-switch__btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 32px;
    padding: 6px 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-secondary, #475569);
    background: var(--bg-muted, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    touch-action: manipulation;
}

.ux-theme-switch__btn:hover,
.ux-theme-switch__btn:focus-visible {
    color: var(--text, #0f172a);
    border-color: var(--border-strong, #cbd5e1);
    outline: none;
}

.ux-theme-switch__btn[aria-checked="true"] {
    color: #fff;
    background: var(--primary, #2563eb);
    border-color: var(--primary-dark, #1d4ed8);
}

.ux-theme-switch__btn:focus-visible {
    box-shadow: 0 0 0 2px var(--bg-elevated, #fff), 0 0 0 4px var(--primary, #2563eb);
}

.account-theme {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.account-theme .ux-theme-switch__btn {
    min-height: 36px;
    font-size: 12px;
}

.ux-kbd-modal {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

.ux-kbd-modal[hidden] {
    display: none !important;
}

.ux-kbd-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.ux-kbd-modal__panel {
    position: relative;
    width: min(440px, 100%);
    max-height: min(85vh, 560px);
    overflow: auto;
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius, 10px);
    box-shadow: var(--shadow-md, 0 12px 40px rgba(15, 23, 42, 0.18));
}

.ux-kbd-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 0;
}

.ux-kbd-modal__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text, #0f172a);
    line-height: 1.3;
}

.ux-kbd-modal__close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    margin: -4px -4px 0 0;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted, #64748b);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
}

.ux-kbd-modal__close:hover,
.ux-kbd-modal__close:focus-visible {
    color: var(--text, #0f172a);
    background: var(--bg-muted, #f1f5f9);
    outline: none;
}

.ux-kbd-modal__intro {
    margin: 8px 18px 0;
    font-size: 13px;
    color: var(--text-secondary, #64748b);
    line-height: 1.45;
}

.ux-kbd-modal__list {
    margin: 14px 0 0;
    padding: 0 18px 18px;
    list-style: none;
}

.ux-kbd-modal__row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--border, #e2e8f0);
}

.ux-kbd-modal__row:first-child {
    border-top: none;
    padding-top: 4px;
}

.ux-kbd-modal__keys {
    flex: 0 0 auto;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-width: 88px;
    max-width: 120px;
}

.ux-kbd-modal__key {
    display: inline-block;
    padding: 3px 7px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text, #0f172a);
    background: var(--bg-muted, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
    white-space: nowrap;
}

.ux-kbd-modal__plus {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #64748b);
}

.ux-kbd-modal__desc {
    flex: 1 1 auto;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text, #0f172a);
}

body.ux-kbd-modal-open {
    overflow: hidden;
}

.ux-toast-root {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
    left: max(16px, env(safe-area-inset-left, 0px));
    z-index: 10050;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}

.ux-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: min(420px, 100%);
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.ux-toast--success {
    border-left: 4px solid var(--accent);
    background: var(--callout-success-bg, #f0fdf4);
    color: var(--text, #14532d);
}

.ux-toast--error {
    border-left: 4px solid var(--danger);
    background: var(--danger-soft, #fef2f2);
    color: var(--text, #7f1d1d);
}

.ux-toast--warn {
    border-left: 4px solid var(--warn);
    background: var(--callout-warn-bg, #fffbeb);
    color: var(--text, #78350f);
}

.ux-toast--info {
    border-left: 4px solid var(--primary);
}

.ux-toast__text {
    flex: 1;
}

.ux-toast__close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.ux-toast__close:hover {
    color: var(--text);
}

.ux-welcome-banner {
    background: linear-gradient(90deg, #eff6ff 0%, #f0fdf4 100%);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
}

.ux-welcome-banner__inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ux-welcome-banner__text {
    flex: 1;
}

.ux-welcome-banner__text strong {
    color: var(--text);
}

.ux-link-btn {
    border: none;
    background: none;
    padding: 0;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
}

.ux-welcome-banner__close {
    flex-shrink: 0;
    border: none;
    background: rgba(15, 23, 42, 0.06);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--text-secondary);
}

.ux-welcome-banner__close:hover {
    background: rgba(15, 23, 42, 0.1);
}

/* Connection / offline status (ux.js) */
.ux-offline-banner[hidden] {
    display: none !important;
}

.ux-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10150;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 6px 12px;
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    background: #7f1d1d;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.ux-offline-banner__text {
    margin: 0;
}

body.ux-offline-banner-visible {
    padding-top: calc(28px + env(safe-area-inset-top, 0px));
}

/* Guided onboarding tour (ux.js) */
.ux-onboard {
    position: fixed;
    inset: 0;
    z-index: 10035;
    pointer-events: none;
}

.ux-onboard__overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    pointer-events: auto;
}

.ux-onboard__spotlight {
    position: fixed;
    border-radius: 14px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55),
                0 0 0 3px rgba(37, 99, 235, 0.45),
                0 0 32px 6px rgba(37, 99, 235, 0.28);
    border: 2px solid var(--primary);
    background: transparent;
    pointer-events: none;
    z-index: 1;
    transition: top 0.42s cubic-bezier(0.22, 1, 0.36, 1),
                left 0.42s cubic-bezier(0.22, 1, 0.36, 1),
                width 0.42s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    animation: uxOnboardPulse 2.4s ease-in-out infinite;
}

@keyframes uxOnboardPulse {
    0%, 100% { box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55), 0 0 0 3px rgba(37, 99, 235, 0.45), 0 0 26px 4px rgba(37, 99, 235, 0.22); }
    50%      { box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55), 0 0 0 4px rgba(37, 99, 235, 0.6),  0 0 40px 10px rgba(37, 99, 235, 0.38); }
}

.ux-onboard__card {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(400px, calc(100vw - 32px));
    padding: 18px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    z-index: 2;
    transition: top 0.42s cubic-bezier(0.22, 1, 0.36, 1),
                left 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    animation: uxOnboardCardIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Once JS sets top/left, drop the centring transform so positioning is exact. */
.ux-onboard__card[style*="top"] {
    transform: none;
}

.ux-onboard__card--docked {
    transform: none;
}

@keyframes uxOnboardCardIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.ux-onboard__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.ux-onboard__title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary);
}

.ux-onboard__step-label {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

.ux-onboard__close {
    flex-shrink: 0;
    border: none;
    background: rgba(15, 23, 42, 0.06);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--text-secondary);
    margin-left: 4px;
}

.ux-onboard__close:hover {
    background: rgba(15, 23, 42, 0.1);
}

.ux-onboard__heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
    line-height: 1.3;
}

.ux-onboard__body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 14px;
}

.ux-onboard__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ux-onboard__btn {
    font-size: 13px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
}

.ux-onboard__btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.ux-onboard__btn--ghost:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-muted);
}

.ux-onboard__btn--ghost:disabled {
    opacity: 0.4;
    cursor: default;
}

.ux-onboard__btn--primary {
    margin-left: auto;
}

.ux-onboard__dots {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 2px 0 14px;
}

.ux-onboard__dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--border);
    transition: background 0.25s ease, width 0.25s ease;
}

.ux-onboard__dot.is-done {
    background: var(--primary);
    opacity: 0.55;
}

.ux-onboard__dot.is-active {
    width: 22px;
    background: var(--primary);
}

body.ux-onboard-active {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .ux-onboard__spotlight,
    .ux-onboard__card {
        transition: none;
        animation: none;
    }
}

.section-intro {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 16px;
    max-width: 72ch;
}

.section-intro--compact {
    margin-bottom: 12px;
    font-size: 13px;
}

.ux-required {
    color: var(--danger);
    font-weight: 700;
}

.ux-btn-loading {
    opacity: 0.85;
    cursor: wait;
}

.ux-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ux-spin 0.7s linear infinite;
    vertical-align: -2px;
}

.button .ux-spinner {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}

@keyframes ux-spin {
    to {
        transform: rotate(360deg);
    }
}

.nav-menu-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 51;
}

.nav-menu-toggle {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
}

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 49;
}

.nav-backdrop--visible {
    display: block;
}

body.nav-menu-open {
    overflow: hidden;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--border, #e2e8f0) 25%, var(--surface-muted, #f1f5f9) 50%, var(--border, #e2e8f0) 75%);
    background-size: 200% 100%;
    animation: ux-shimmer 1.2s ease-in-out infinite;
}

@keyframes ux-shimmer {
    0% {
        background-position: 100% 0;
    }
    100% {
        background-position: -100% 0;
    }
}

.overview-loading-placeholder.skeleton-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px !important;
    text-align: left !important;
}

.metric-value--skeleton {
    display: inline-block;
    min-width: 5.5rem;
    min-height: 1.35rem;
    border-radius: 6px;
    color: transparent !important;
    background: linear-gradient(90deg, var(--border, #e2e8f0) 25%, var(--surface-muted, #f1f5f9) 50%, var(--border, #e2e8f0) 75%);
    background-size: 200% 100%;
    animation: ux-shimmer 1.2s ease-in-out infinite;
    vertical-align: middle;
}

#overviewMetricsGrid.ux-metrics-loading .metric-value--skeleton {
    pointer-events: none;
}

.ux-overview-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.ux-overview-positions-card {
    margin-top: 0;
    margin-bottom: 8px;
    padding: 10px 12px;
}

.ux-overview-positions-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px 12px;
    margin-bottom: 8px;
}

.ux-overview-positions-title {
    margin: 0;
    font-size: 14px;
    line-height: 1.3;
}

.ux-overview-data-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin-left: auto;
}

.ux-overview-data-status__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
    text-align: right;
}

.ux-overview-last-updated,
.ux-overview-countdown {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-muted);
}

.ux-overview-countdown {
    font-variant-numeric: tabular-nums;
}

.ux-overview-countdown:empty {
    display: none;
}

.ux-overview-stale-note {
    display: none;
    margin: 0 0 6px;
    font-size: 11px;
    color: var(--warn, #b45309);
}

.ux-overview-stale-note:not([hidden]) {
    display: block;
}

@keyframes ux-live-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}
.ux-overview-stale-note--live {
    animation: ux-live-pulse 2.4s ease-in-out infinite;
}

.ux-overview-refresh {
    flex: 0 0 auto;
    padding: 7px 12px !important;
    font-size: 12px !important;
    min-height: 36px;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .ux-overview-data-status {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .ux-overview-data-status__meta {
        align-items: flex-start;
        text-align: left;
        flex: 1 1 auto;
    }

    .ux-overview-refresh {
        flex-shrink: 0;
    }
}

.ux-kbd-hint {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-muted);
    background: var(--bg-muted, #f1f5f9);
    border: 1px solid var(--border);
    border-radius: 4px;
    vertical-align: middle;
}

.copilot-messages {
    min-height: 180px;
    max-height: 360px;
    overflow-y: auto;
    padding: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.copilot-empty-state {
    text-align: center;
    padding: 24px 12px 16px;
    color: var(--text-secondary);
}

.copilot-empty-state[hidden] {
    display: none !important;
}

.copilot-empty-state__title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.copilot-empty-state__hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
}

.copilot-suggestions-wrap {
    margin-bottom: 12px;
}

.copilot-suggestions-label {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.copilot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.copilot-suggestions-wrap--prominent {
    padding: 14px 14px 12px;
    background: linear-gradient(135deg, var(--copilot-prominent-from) 0%, var(--copilot-prominent-to) 100%);
    border: 1px solid var(--copilot-prominent-border);
    border-radius: 10px;
}

.copilot-suggestions-wrap--prominent .copilot-suggestions-label {
    font-size: 13px;
    color: var(--copilot-prominent-label);
}

.copilot-suggestions-wrap--prominent .copilot-chip {
    font-size: 14px !important;
    padding: 10px 16px !important;
    min-height: 44px;
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(30, 58, 138, 0.08);
}

.whatif-panel {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.whatif-panel__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.whatif-quick-actions__label {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.whatif-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.whatif-quick-actions__chip {
    font-size: 12px;
    padding: 8px 12px;
    min-height: 40px;
    text-align: left;
}

.whatif-panel__form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.whatif-panel__form-label {
    font-size: 13px;
}

.whatif-panel__input {
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text);
}

.whatif-panel__input--pct {
    width: 64px;
}

.whatif-panel__input--ticker {
    width: 88px;
    text-transform: uppercase;
}

.whatif-panel__result {
    font-size: 12px;
    color: var(--text-muted);
    margin: 8px 0 0;
}

/* Portfolio structure / health score */
.ux-health-card--empty {
    padding: 14px 16px;
    background: var(--ux-surface-muted, #f8fafc);
    border: 1px dashed var(--ux-border, #e2e8f0);
}

.ux-health-card__empty-title {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ux-text, #1e293b);
}

.ux-health-card__empty-hint {
    margin: 0 0 12px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ux-muted, #64748b);
}

.ux-health-card__empty-cta {
    font-size: 12px;
}

.ux-health-card {
    margin-bottom: 8px;
    padding: 14px;
    border-left: 4px solid var(--health-band, #64748b);
    background: linear-gradient(135deg, var(--health-bg, var(--surface-muted)) 0%, var(--bg-elevated) 72%);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.ux-health-card--excellent {
    --health-band: #10b981;
    --health-bg: #ecfdf5;
}

.ux-health-card--good {
    --health-band: #22c55e;
    --health-bg: #f0fdf4;
}

.ux-health-card--fair {
    --health-band: #f59e0b;
    --health-bg: #fffbeb;
}

.ux-health-card--caution {
    --health-band: #f97316;
    --health-bg: #fff7ed;
}

.ux-health-card--poor {
    --health-band: #ef4444;
    --health-bg: #fef2f2;
}

.ux-health-card__inner {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ux-health-card__ring {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.ux-health-card__svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ux-health-card__track {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 4;
}

.ux-health-card__fill {
    fill: none;
    stroke: var(--health-band);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 113;
    transition: stroke-dashoffset 0.85s ease-out;
}

.ux-health-card__score {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    color: var(--health-band);
}

.ux-health-card__copy {
    flex: 1 1 140px;
    min-width: 0;
}

.ux-health-card__title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.ux-health-card__label {
    font-size: 13px;
    color: var(--text-secondary, #334155);
    margin-top: 2px;
}

.ux-health-card__meter {
    margin-top: 8px;
    height: 6px;
    border-radius: 999px;
    background: var(--border, #e2e8f0);
    overflow: hidden;
}

.ux-health-card__meter-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--health-band);
    transition: width 0.85s ease-out;
}

.ux-health-card__factors {
    margin: 10px 0 0;
    padding-left: 18px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    width: 100%;
}

/* Overview benchmark comparison (dashboard.html) */
.benchmark-compare-card {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 12px;
    line-height: 1.35;
}

.benchmark-compare-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.benchmark-compare-card__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
}

.benchmark-compare-card__info {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1;
    cursor: help;
}

.benchmark-compare-card__info:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.benchmark-compare-card__grid {
    display: grid;
    grid-template-columns: minmax(3.5rem, 0.9fr) repeat(3, 1fr);
    gap: 6px 8px;
    align-items: center;
}

.benchmark-compare-card__grid--head {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.benchmark-compare-card__row + .benchmark-compare-card__row {
    margin-top: 2px;
}

.benchmark-compare-card__period {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.benchmark-compare-card__val {
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--text);
}

.benchmark-compare-card__diff {
    font-weight: 600;
}

#benchmarkVsIndex.positive,
#benchmarkVsIndex.negative {
    display: inline-block;
}

/* Overview briefing teaser */
.ux-briefing-teaser-card {
    margin-top: 0;
    margin-bottom: 12px;
}

.ux-briefing-teaser-card[hidden],
#overviewPerformanceChartCard[hidden] {
    display: none !important;
}

.lazy-widget-sentinel {
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
}

.ux-briefing-teaser-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px 12px;
    margin-bottom: 12px;
}

.ux-briefing-teaser-card__hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.briefing-teaser__meta {
    margin: 0 0 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.briefing-teaser__narrative {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

.briefing-teaser__changes {
    margin: 0 0 12px;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
}

.briefing-teaser__changes li + li {
    margin-top: 6px;
}

.briefing-teaser__muted {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.briefing-teaser__cta {
    margin-top: 4px;
}

.lazy-widget-skeleton {
    padding: 4px 0;
}

/* Pull-to-refresh (mobile overview) */
.ux-ptr {
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transform: translate(-50%, -120%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.ux-ptr--visible {
    opacity: 1;
}

.ux-ptr__icon {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
}

.ux-ptr--loading .ux-ptr__icon {
    animation: ux-ptr-spin 0.8s linear infinite;
}

.ux-ptr--ready:not(.ux-ptr--loading) .ux-ptr__icon {
    border-top-color: var(--primary);
    transform: rotate(180deg);
}

.ux-ptr__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.ux-ptr--ready .ux-ptr__label {
    color: var(--primary);
}

@keyframes ux-ptr-spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 769px) {
    .ux-ptr {
        display: none !important;
    }
}

.ux-copilot-insights {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}

.ux-copilot-insights__title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #475569;
}

.ux-copilot-insight-block {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px 12px;
}

.ux-copilot-insight-block__head {
    flex: 1 1 180px;
    min-width: 0;
}

.ux-copilot-insight-block__label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.ux-copilot-insight-block__hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.copilot-briefing-box[hidden] {
    display: none !important;
}

.copilot-briefing-box {
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    line-height: 1.5;
}

.copilot-briefing-box__msg {
    margin: 0;
    color: var(--text-secondary, #64748b);
}

.copilot-briefing-box__msg--error {
    color: #ef4444;
}

.copilot-briefing-box__msg--loading {
    color: var(--text-secondary, #64748b);
}

.copilot-briefing-box__disclaimer {
    margin: 10px 0 0;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

.ux-overview-digest-card {
    margin-top: 0;
    margin-bottom: 12px;
}

.ux-overview-chart-card {
    position: relative;
    margin-bottom: 12px;
}

.ux-overview-chart-card__toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ux-chart-period-btns {
    display: flex;
    gap: 2px;
}

.ux-chart-period-btn {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--border, #374151);
    background: transparent;
    color: var(--text-secondary, #9ca3af);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ux-chart-period-btn:hover {
    background: var(--surface-muted, #1f2937);
    color: var(--text-primary, #f9fafb);
}

.ux-chart-period-btn--active {
    background: var(--accent, #3b82f6);
    border-color: var(--accent, #3b82f6);
    color: #fff;
}

/* Period buttons are now in __head and always visible — remove old hide rule */
/* @media (max-width: 480px) { .ux-chart-period-btns { display: none; } } */

.ux-overview-chart-card .ux-chart-countdown {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
}

.ux-overview-market-card {
    margin-top: 12px;
}

.ux-copilot-digest-card__head {
    margin-bottom: 10px;
}

.ux-copilot-digest-card__title {
    margin: 0 0 6px;
    font-size: 1.1rem;
}

.ux-copilot-digest-card__intro {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ux-copilot-digest-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.ux-cta-chip {
    min-height: 44px;
    padding: 10px 16px !important;
    font-size: 13px !important;
    font-weight: 600;
    border-radius: 999px;
}

.ux-cta-chip--primary {
    background: var(--primary) !important;
    color: #fff !important;
    border: 1px solid var(--primary) !important;
}

.ux-cta-chip--primary:hover {
    background: var(--primary-dark) !important;
}

.ux-cta-chip--ghost {
    background: var(--bg-elevated, #fff) !important;
    color: var(--primary) !important;
    border: 1px solid var(--primary-soft, #c7d2fe) !important;
}

.ux-cta-chip--ghost:hover {
    background: var(--primary-soft, #eef2ff) !important;
}

@media (max-width: 768px) {
    .ux-overview-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .ux-overview-refresh {
        width: 100%;
    }

    .copilot-suggestions-wrap--prominent .copilot-chip {
        flex: 1 1 100%;
        text-align: center;
    }

    .ux-copilot-insight-block {
        flex-direction: column;
        align-items: stretch;
    }

    .ux-copilot-insight-block .ux-cta-chip,
    .ux-copilot-digest-card__actions .ux-cta-chip {
        width: 100%;
        justify-content: center;
    }

    .whatif-quick-actions__chip {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}

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

.empty-state__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state__hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.empty-state .button {
    margin-top: 4px;
}

.ux-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.ux-quick-action {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.ux-quick-action:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.ux-quick-action--primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.ux-quick-action--primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.ux-glossary {
    margin-bottom: 14px;
    padding: 0 !important;
    overflow: hidden;
}

.ux-glossary summary {
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ux-glossary summary::-webkit-details-marker {
    display: none;
}

.ux-glossary summary::after {
    content: '+';
    font-size: 18px;
    color: var(--text-muted);
    font-weight: 400;
}

.ux-glossary[open] summary::after {
    content: '\2212';
}

.ux-glossary__body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
}

.ux-glossary__intro {
    margin: 12px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.ux-glossary__section {
    margin: 16px 0 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.ux-glossary__section:first-of-type {
    margin-top: 12px;
}

.ux-glossary dl {
    margin: 12px 0 0;
}

.ux-glossary dt {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-top: 10px;
}

.ux-glossary dt:first-child {
    margin-top: 0;
}

.ux-glossary dd {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.metric {
    position: relative;
}

.metric-help {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.35;
}

#overviewMetricsGrid .metric {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 16px;
    row-gap: 2px;
    align-items: center;
    padding: 10px 0 !important;
}

#overviewMetricsGrid .metric .metric-label {
    grid-column: 1;
    grid-row: 1;
}

#overviewMetricsGrid .metric .metric-help:first-of-type {
    grid-column: 1;
    grid-row: 2;
    margin-top: 0;
}

#overviewMetricsGrid .metric .metric-value {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    text-align: right;
    white-space: nowrap;
}

#overviewMetricsGrid .metric #benchmarkVsIndex,
#overviewMetricsGrid .metric #benchmarkCompareCard {
    grid-column: 1 / -1;
}

#overviewMetricsGrid .metric #benchmarkVsIndex {
    grid-row: 3;
    margin-top: 4px;
}

#overviewMetricsGrid .metric #benchmarkCompareCard {
    grid-row: 4;
    margin-top: 8px;
}

#overview .metric.metric--explainable {
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

#overview .metric.metric--explainable:hover {
    background: rgba(30, 58, 138, 0.04);
}

#overview .metric.metric--explainable:focus-visible {
    outline: 2px solid #1e3a8a;
    outline-offset: 2px;
}

.ux-glossary-dt--highlight {
    background: #fef3c7;
    border-radius: 4px;
    padding: 2px 4px;
    margin-left: -4px;
    transition: background-color 0.3s ease;
}

.metric-label-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.auth-brand {
    text-align: center;
    margin-bottom: 20px;
}

.auth-brand__fallback {
    display: none;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 22px;
    font-weight: 700;
}

.auth-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 400 !important;
    margin-bottom: 15px !important;
}

.auth-remember input[type="checkbox"] {
    width: auto !important;
    margin: 0 !important;
    cursor: pointer;
    accent-color: var(--primary);
}

.auth-form--loading {
    pointer-events: none;
}

.auth-form--loading .form-group input:not([type="checkbox"]) {
    opacity: 0.72;
}

.auth-password-wrap {
    position: relative;
}

.auth-password-wrap input {
    padding-right: 52px !important;
    width: 100%;
}

/* Use app Vis/Skjul toggle only — hide browser-native password reveal */
.auth-password-wrap input::-ms-reveal,
.auth-password-wrap input::-ms-clear {
    display: none;
}

.auth-password-wrap input::-webkit-credentials-auto-fill-button {
    visibility: hidden;
    pointer-events: none;
    position: absolute;
    right: 0;
}

.auth-password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 10px;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    line-height: 1;
}

.auth-password-toggle:hover {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.auth-password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ——— Mobile bottom nav (primary sections) ——— */
.ux-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .ux-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 52;
        align-items: stretch;
        justify-content: space-around;
        gap: 2px;
        padding: 6px max(8px, env(safe-area-inset-left, 0px)) max(6px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-right, 0px));
        background: var(--bg-elevated);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
    }

    body.ux-bottom-nav-visible {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    body.ux-bottom-nav-visible .container {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.ux-bottom-nav-visible #installBtn {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
        right: 12px !important;
    }

    body.ux-bottom-nav-visible .ux-pwa-hint {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .ux-bottom-nav__item {
        flex: 1 1 0;
        min-width: 0;
        min-height: 44px;
        padding: 6px 2px;
        border: none;
        border-radius: var(--radius-sm);
        background: transparent;
        color: var(--text-secondary);
        font-size: 10px;
        font-weight: 600;
        line-height: 1.15;
        cursor: pointer;
        touch-action: manipulation;
        transition: var(--transition);
    }

    .ux-bottom-nav__item:hover,
    .ux-bottom-nav__item:focus-visible {
        background: var(--surface-muted);
        color: var(--text);
        outline: none;
    }

    .ux-bottom-nav__item--active {
        color: var(--primary);
        background: rgba(37, 99, 235, 0.08);
    }

    body.nav-menu-open .ux-bottom-nav {
        display: none;
    }

    .nav-menu-bar {
        display: none;
    }

    .nav#mainNav {
        display: none !important;
        flex-direction: column;
        align-items: stretch;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 8px 12px max(12px, env(safe-area-inset-bottom, 0px)) !important;
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: min(58vh, 420px);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: var(--shadow-lg);
        z-index: 53;
        gap: 4px !important;
        flex-wrap: nowrap !important;
        background: var(--bg-elevated) !important;
    }

    .nav#mainNav.nav--open {
        display: flex !important;
    }

    .nav#mainNav .nav-button {
        width: 100%;
        text-align: left;
        padding: 12px 14px !important;
        font-size: 15px !important;
        border-radius: var(--radius-sm) !important;
        min-width: 0 !important;
        white-space: normal !important;
        flex-shrink: 0;
    }

    /* The mobile "Mere" sheet should only list pages NOT already in the bottom
       nav. Pages duplicated in the bottom bar (Oversigt/Risiko/Historik/Nyheder)
       are hidden here — they remain in the desktop top nav (min-width: 769px). */
    .nav#mainNav .nav-button--in-bottomnav {
        display: none !important;
    }

    .ux-toast-root {
        left: 12px;
        right: 12px;
        align-items: stretch;
    }

    .ux-toast {
        max-width: 100%;
    }
}

/* ——— PWA install hint (mobile, once) ——— */
.ux-pwa-hint {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    z-index: 999;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.ux-pwa-hint__text {
    flex: 1;
    margin: 0;
}

.ux-pwa-hint__close {
    flex-shrink: 0;
    border: none;
    background: rgba(15, 23, 42, 0.06);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: var(--text-secondary);
}

.ux-pwa-hint__close:hover {
    background: rgba(15, 23, 42, 0.1);
}

/* ——— Print: portfolio summary (overview metrics + positions) ——— */
.ux-print-header {
    display: none;
}

@media print {
    @page {
        margin: 12mm;
        size: A4;
    }

    html,
    body {
        background: #fff !important;
        color: #000 !important;
        overflow: visible !important;
        width: auto !important;
        max-width: none !important;
    }

    .header {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        border-bottom: 1px solid #ccc !important;
        padding: 8px 0 !important;
        min-height: 0 !important;
    }

    .header-logo {
        background: transparent !important;
        filter: none !important;
        padding: 0 !important;
    }

    .language-selector,
    .ux-help-menu,
    .ux-bottom-nav,
    .nav,
    .nav-menu-bar,
    .nav-backdrop,
    #installBtn,
    .ux-welcome-banner,
    .ux-offline-banner,
    .ux-pwa-hint,
    .ux-toast-root,
    .ux-onboard,
    #uxSkipLink,
    #iosInstallBanner,
    button,
    .button,
    .logout-button,
    .lang-flag {
        display: none !important;
    }

    .container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .section {
        display: none !important;
    }

    #overview {
        display: block !important;
    }

    .ux-print-header {
        display: block !important;
        margin: 0 0 12px;
        padding-bottom: 8px;
        border-bottom: 2px solid #0f172a;
    }

    .ux-print-header__title {
        font-size: 18px;
        font-weight: 700;
        margin: 0 0 4px;
        color: #0f172a;
    }

    .ux-print-header__meta {
        font-size: 11px;
        color: #475569;
        margin: 0;
    }

    #overview .section-intro,
    #overview .ux-overview-toolbar,
    #overview .ux-quick-actions,
    #overviewGlossary,
    #portfolioHealthCard,
    #portfolioAlertsBanner,
    #positionsCountdown,
    #positionsPriceStaleNote,
    #overview .card:has(#portfolioChart),
    #overview .card:has(#performanceChart),
    #overview .card:has(#topWinnersUS),
    #overview .card:has(.market-movers-row) {
        display: none !important;
    }

    #overview .card {
        box-shadow: none !important;
        border: 1px solid #cbd5e1 !important;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 10px !important;
        padding: 10px 12px !important;
    }

    #overviewMetricsGrid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    #overviewMetricsGrid .metric-help {
        display: none !important;
    }

    #overviewMetricsGrid .metric {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    #overviewMetricsGrid .metric-label {
        font-size: 10px !important;
        color: #475569 !important;
    }

    #overviewMetricsGrid .metric-value {
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #0f172a !important;
    }

    #overviewPortfolioTable,
    #overviewPortfolioTableBody {
        overflow: visible !important;
        max-width: none !important;
    }

    #overviewPortfolioTableBody {
        display: block !important;
    }

    #overviewPortfolioTableBody .overview-position-card,
    #overviewPortfolioTableBody .overview-summary-card {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #e2e8f0 !important;
        box-shadow: none !important;
        margin-bottom: 8px !important;
    }

    .portfolio-positions-table-wrap {
        overflow: visible !important;
    }

    .portfolio-positions-table {
        width: 100% !important;
        font-size: 10px !important;
    }

    .portfolio-positions-table thead th {
        background: #f1f5f9 !important;
        color: #0f172a !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .portfolio-positions-table tbody td {
        border-bottom: 1px solid #e2e8f0 !important;
    }

    .portfolio-positions-table .expand-icon,
    .portfolio-positions-table tbody tr.portfolio-details-row {
        display: none !important;
    }

    a[href]::after {
        content: none !important;
    }
}

/* Portfolio feature widgets (20260525t) */
.ux-feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.ux-feature-card h2 {
    font-size: 14px;
    margin: 0 0 8px;
}

.ux-feature-list {
    margin: 8px 0 0;
    padding-left: 18px;
    font-size: 13px;
}

.ux-allocation-warn {
    color: #b45309;
    font-size: 13px;
    margin: 6px 0;
}

.ux-timeline {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
}

.ux-timeline__item {
    margin-bottom: 10px;
}

.ux-timeline__date {
    display: block;
    font-size: 11px;
    color: var(--text-secondary, #64748b);
}

.ux-prefs-card {
    margin: 12px 0;
}

.ux-prefs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.ux-prefs-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.ux-prefs-field--wide {
    grid-column: 1 / -1;
}

.ux-prefs-field--check {
    flex-direction: row;
    align-items: center;
}

/* Alert prefs card */
.ux-alert-prefs-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.ux-alert-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.ux-alert-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.ux-alert-toggle-text {
    color: var(--text);
}

.ux-alert-pct-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.ux-alert-pct-input {
    width: 64px !important;
    text-align: center;
}

.ux-prefs-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ux-benchmark-select {
    max-width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.ux-alert-banner__list {
    margin: 8px 0 0;
    padding-left: 18px;
}

.whatif-saved-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.whatif-saved-list {
    margin-top: 8px;
}

.whatif-saved-item {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 12px;
    margin-bottom: 6px;
}

/* Mobile accordion for feature cards (20260525v) */
.ux-feature-card__summary,
.ux-prefs-card__summary {
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    margin: 0;
    padding: 0;
    color: var(--text);
}

.ux-feature-card__summary::-webkit-details-marker,
.ux-prefs-card__summary::-webkit-details-marker {
    display: none;
}

.ux-feature-card__summary::before,
.ux-prefs-card__summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.15s ease;
    color: var(--text-secondary, #64748b);
}

.ux-feature-card[open] > .ux-feature-card__summary::before,
.ux-prefs-card[open] > .ux-prefs-card__summary::before {
    transform: rotate(90deg);
}

.ux-feature-card__body {
    padding-top: 10px;
}

/* Top cards (watchlist / price targets) keep their full content — stats header +
   item cards — visible in the header at ALL times. Only the add-form (in the body)
   is hidden when collapsed and revealed when the card is expanded. The title row
   (chevron + label) is the toggle; clicking the content does not fold the card. */
#overviewTopCards .ux-feature-card__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 9px;
}

.ux-feature-card__summary-label {
    flex-shrink: 0;
}

.ux-feature-card__inline {
    flex-basis: 100%;
    width: 100%;
    margin-top: 11px;
    cursor: default;
    font-weight: 400;
}

.ux-tax-reminder {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-left: 3px solid var(--warn);
    background: var(--warn-soft);
    border-radius: 6px;
    font-size: 0.92rem;
    line-height: 1.45;
}

/* ——— Risiko: risikoscore + stress-test ——— */
.risk-gauge {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
}
.risk-gauge__num {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}
.risk-gauge__num span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
}
.risk-gauge__meta { flex: 1; min-width: 0; }
.risk-gauge__level { font-weight: 700; margin-bottom: 6px; }
.risk-gauge__bar,
.risk-factor__bar {
    height: 8px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.18));
    overflow: hidden;
}
.risk-gauge__fill,
.risk-factor__bar > div {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}
.risk-factors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.risk-factor {
    padding: 10px 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
}
.risk-factor__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 6px;
}
.risk-factor__score { font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.risk-factor__bar { margin-bottom: 6px; }
.risk-factor__detail { font-size: 0.82rem; color: var(--text-secondary, #6b7280); line-height: 1.4; }

.stress-list { display: flex; flex-direction: column; gap: 10px; }
.stress-row {
    padding: 12px 14px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: var(--bg-elevated, rgba(127,127,127,0.05));
}
.stress-row__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
.stress-row__title { font-weight: 700; }
.stress-row__impact { font-weight: 800; white-space: nowrap; }
.stress-row__impact small { font-weight: 600; opacity: 0.85; }
.stress-row__desc {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    margin: 4px 0 8px;
    line-height: 1.4;
}
.stress-row__pos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.stress-chip {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.14));
    border: 1px solid var(--border, #e5e7eb);
    white-space: nowrap;
}
.stress-row__new { font-size: 0.82rem; color: var(--text-secondary, #6b7280); }

.risk-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}
.risk-stat {
    padding: 10px 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    text-align: center;
}
.risk-stat__val { font-size: 1.25rem; font-weight: 800; line-height: 1.1; white-space: nowrap; }
.risk-stat__lbl { font-size: 0.78rem; color: var(--text-secondary, #6b7280); margin-top: 4px; }

.cur-list { display: flex; flex-direction: column; gap: 8px; }
.cur-row { display: flex; align-items: center; gap: 10px; }
.cur-row__code { font-weight: 700; font-size: 0.85rem; width: 46px; flex: none; }
.cur-row__bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.18));
    overflow: hidden;
}
.cur-row__bar > div { height: 100%; border-radius: 999px; }
.cur-row__pct { font-size: 0.82rem; font-weight: 600; width: 52px; text-align: right; flex: none; }

/* ——— Allokering & drift ——— */
.alloc-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.35;
    margin: 0 0 14px;
    padding: 8px 11px;
    border-radius: 8px;
}
.alloc-summary--ok { background: var(--accent-soft, rgba(16,185,129,0.12)); color: var(--accent, #10b981); }
.alloc-summary--warn { background: var(--warn-soft, rgba(217,119,6,0.12)); color: var(--warn, #d97706); }
.alloc-bars { display: flex; flex-direction: column; gap: 11px; }
.alloc-row__top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
.alloc-row__ticker { font-weight: 700; }
.alloc-row__pct { font-weight: 600; color: var(--text-secondary, #6b7280); }
.alloc-row__pct.over { color: var(--danger, #ef4444); }
.alloc-bar {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.16));
}
.alloc-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 999px;
    background: var(--accent, #10b981);
    transition: width 0.4s ease;
}
.alloc-fill.over { background: var(--danger, #ef4444); }
.alloc-limit {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: var(--text-secondary, #9ca3af);
    border-radius: 2px;
    opacity: 0.85;
}
.alloc-legend { font-size: 0.76rem; color: var(--text-secondary, #6b7280); margin: 10px 0 0; }
.alloc-sectors { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.alloc-sector { display: flex; justify-content: space-between; gap: 10px; font-size: 0.84rem; }
.alloc-sector__name { font-weight: 600; }
.alloc-sector__val { color: var(--text-secondary, #6b7280); }
.alloc-chip {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.14));
}
.alloc-chip.ok { background: var(--accent-soft, rgba(16,185,129,0.12)); color: var(--accent, #10b981); }
.alloc-chip.warn { background: var(--warn-soft, rgba(217,119,6,0.12)); color: var(--warn, #d97706); }
.alloc-hint { font-size: 0.82rem; color: var(--text-secondary, #6b7280); margin: 12px 0 0; }

/* ——— Tidligere investeringer ——— */
.inv-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}
.inv-stat {
    padding: 12px 14px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    background: var(--bg-elevated, rgba(127,127,127,0.05));
}
.inv-stat__val { font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
.inv-stat__lbl { font-size: 0.78rem; color: var(--text-secondary, #6b7280); margin-top: 5px; line-height: 1.3; }
.inv-stat--pos .inv-stat__val { color: var(--accent, #10b981); }
.inv-stat--neg .inv-stat__val { color: var(--danger, #ef4444); }

.inv-closed {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}
.inv-pos {
    padding: 12px 14px;
    border: 1px solid var(--border, #e5e7eb);
    border-left-width: 4px;
    border-radius: 10px;
}
.inv-pos--pos { border-left-color: var(--accent, #10b981); }
.inv-pos--neg { border-left-color: var(--danger, #ef4444); }
.inv-pos__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.inv-pos__ticker { font-weight: 800; font-size: 1rem; }
.inv-pos__pnl { font-weight: 800; white-space: nowrap; }
.inv-pos__pnl small { font-weight: 600; opacity: 0.85; }
.inv-pos__name { font-size: 0.82rem; color: var(--text-secondary, #6b7280); margin: 2px 0 8px; }
.inv-pos__row { font-size: 0.8rem; color: var(--text-secondary, #6b7280); line-height: 1.5; }
.inv-pos__held {
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 8px;
    border-radius: 6px;
}
.inv-pos__held.pos { background: var(--accent-soft, rgba(16,185,129,0.12)); color: var(--accent, #10b981); }
.inv-pos__held.neg { background: var(--warn-soft, rgba(217,119,6,0.12)); color: var(--warn, #d97706); }

.inv-pos .pos, .inv-log .pos { color: var(--accent, #10b981); }
.inv-pos .neg, .inv-log .neg { color: var(--danger, #ef4444); }

.inv-log { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.inv-log th, .inv-log td { padding: 7px 10px; border-bottom: 1px solid var(--border, #e5e7eb); white-space: nowrap; }
.inv-log th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary, #6b7280); text-align: left; }
.inv-side { font-size: 0.74rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.inv-side--buy { background: var(--accent-soft, rgba(16,185,129,0.12)); color: var(--accent, #10b981); }
.inv-side--sell { background: var(--warn-soft, rgba(217,119,6,0.12)); color: var(--warn, #d97706); }

/* ——— Skatteår ——— */
.tax-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tax-chip {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.1));
    border: 1px solid var(--border, #e5e7eb);
    color: var(--text-secondary, #6b7280);
}
.tax-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.tax-stat { padding: 11px 13px; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; }
.tax-stat__val { font-size: 1.4rem; font-weight: 800; line-height: 1.1; }
.tax-stat__lbl { font-size: 0.76rem; color: var(--text-secondary, #6b7280); margin-top: 5px; line-height: 1.3; }
.tax-stat--pos .tax-stat__val { color: var(--accent, #10b981); }
.tax-stat--neg .tax-stat__val { color: var(--danger, #ef4444); }
.tax-stat--save { background: var(--accent-soft, rgba(16,185,129,0.12)); border-color: transparent; }
.tax-stat--save .tax-stat__val { color: var(--accent, #10b981); }

.tax-rows { border: 1px solid var(--border, #e5e7eb); border-radius: 10px; overflow: hidden; }
.tax-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    font-size: 0.86rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.tax-row:last-child { border-bottom: none; }
.tax-row__lbl { color: var(--text-secondary, #6b7280); }
.tax-row__val { font-weight: 600; white-space: nowrap; text-align: right; }
.tax-row__val.pos { color: var(--accent, #10b981); }
.tax-row__val.neg { color: var(--danger, #ef4444); }
.tax-row--total { background: var(--bg-elevated, rgba(127,127,127,0.06)); }
.tax-row--total .tax-row__lbl, .tax-row--total .tax-row__val { font-weight: 700; color: var(--text, inherit); }
.tax-row--sub { padding: 4px 12px 4px 12px; font-size: 0.8rem; }

.tax-harvest {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--accent-soft, rgba(16,185,129,0.1));
    border-left: 3px solid var(--accent, #10b981);
}
.tax-harvest__title { font-weight: 700; margin-bottom: 5px; }
.tax-harvest__body { font-size: 0.86rem; line-height: 1.45; }
.tax-losers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tax-loser {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.12));
    border: 1px solid var(--border, #e5e7eb);
}

/* ——— Portefølje-tidslinje ——— */
.tl-list { list-style: none; margin: 0; padding: 0; }
.tl-item { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
/* connecting line between markers */
.tl-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: -1px;
    width: 2px;
    background: var(--border, #e5e7eb);
}
.tl-marker {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    background: var(--bg-elevated, rgba(127,127,127,0.12));
    border: 1px solid var(--border, #e5e7eb);
    position: relative;
    z-index: 1;
}
.tl-marker--pos { background: var(--accent-soft, rgba(16,185,129,0.14)); border-color: transparent; }
.tl-content { padding-top: 3px; min-width: 0; }
.tl-date {
    font-size: 0.72rem;
    color: var(--text-secondary, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.tl-title { font-weight: 700; font-size: 0.92rem; margin: 1px 0 2px; }
.tl-detail { font-size: 0.82rem; color: var(--text-secondary, #6b7280); line-height: 1.4; }

.ux-prefs-card__body {
    padding-top: 12px;
}

.ux-pulse-cron-hint {
    margin-top: 10px;
}

@media (min-width: 769px) {
    /* Overview feature cards are force-opened on desktop, so their summary is
       non-interactive. Account prefs cards (.ux-prefs-card) are real accordions
       at every width and must stay clickable — do NOT disable them here. */
    .ux-feature-card__summary {
        pointer-events: none;
        cursor: default;
    }

    .ux-feature-card__summary::before {
        display: none;
    }

    /* …except the watchlist / price-target cards (#overviewTopCards): these stay
       real, collapsible accordions on desktop so the user can fold them into a
       compact preview. Higher (#id) specificity wins over the rule above. */
    #overviewTopCards .ux-feature-card__summary {
        pointer-events: auto;
        cursor: pointer;
    }

    #overviewTopCards .ux-feature-card__summary::before {
        display: inline-block;
    }
}

@media (max-width: 768px) {
    .ux-feature-cards {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .ux-feature-card,
    .ux-prefs-card {
        padding: 12px 14px;
    }

    .ux-prefs-card:not([open]) .ux-prefs-actions,
    .ux-prefs-card:not([open]) .ux-prefs-grid,
    .ux-prefs-card:not([open]) .ux-pulse-cron-hint {
        display: none;
    }
}

/* ——— Intuitive navigation & page context (20260525z) ——— */
.ux-page-head {
    margin: 0 0 14px;
}

/* Overview: uniform flex-column gap replaces the patchwork of individual margins */
#overview.active {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#overview .ux-page-head,
#overview .ux-quick-actions,
#overview .ux-overview-positions-card,
#overview .ux-overview-digest-card,
#overview .ux-overview-chart-card,
#overview .ux-overview-market-card {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

#overview .grid {
    margin-bottom: 0 !important;
}

#overview .ux-page-head {
    margin-bottom: 0;
}

.ux-page-head__title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.ux-page-head__lead {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.ux-page-head__lead strong {
    font-weight: 600;
    color: var(--text);
}

.ux-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.ux-nav-sheet-title {
    display: none;
}

.ux-nav-button__hint {
    display: none;
}

#overview .ux-quick-actions {
    margin-bottom: 14px;
}

@media (max-width: 768px) {
    .ux-nav-sheet-title {
        display: block;
        margin: 4px 14px 10px;
        font-size: 12px;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .nav#mainNav.nav--open .nav-button {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        min-height: 52px;
    }

    .nav#mainNav.nav--open .ux-nav-button__hint {
        display: block;
        font-size: 12px;
        font-weight: 400;
        color: var(--text-muted);
        line-height: 1.35;
    }

    .ux-page-head__title {
        font-size: 20px;
    }
}

/* ——— Mobile UX pass (20260525x): touch, scroll, modals, tables ——— */
.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin: 8px 0;
}

.table-scroll .transaction-table {
    display: table;
    width: 100%;
    min-width: 36rem;
    margin: 0;
}

#overviewPortfolioTableBody .overview-ticker-btn,
#portfolioPositions .overview-ticker-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px !important;
    font-size: 12px !important;
    border: none;
    background: #667eea;
    color: #fff;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#portfolioPositions .portfolio-summary-bar {
    gap: 16px !important;
    padding: 12px !important;
}

@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .whatif-panel__input {
        font-size: 16px !important;
    }

    .section {
        scroll-margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .analysis-results-wrap,
    .analysis-results-content,
    #auditLogs,
    #reportsCatalog,
    #newsFeed {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .analysis-results-content table {
        display: table;
        min-width: 32rem;
    }

    .copilot-messages {
        max-height: min(42vh, 320px);
    }

    #copilot .card {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .copilot-input-row {
        position: sticky;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        z-index: 40;
        padding: 10px 0 4px;
        margin-bottom: 0;
        background: linear-gradient(180deg, transparent 0%, var(--bg-elevated) 24%);
    }

    body.nav-menu-open .copilot-input-row {
        bottom: max(8px, env(safe-area-inset-bottom, 0px));
    }

    .modal {
        padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
        align-items: flex-end;
    }

    .modal[style*="display: block"] {
        display: flex !important;
    }

    .modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        max-height: min(92vh, 92dvh);
        overflow-y: auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
        padding: 16px !important;
    }

    .modal-chart-container {
        height: min(52vh, 340px) !important;
    }

    .close-modal {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }

    .position-chart-period-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 8px 12px;
        touch-action: manipulation;
    }

    .ux-help-menu__panel:not([hidden]) {
        position: fixed;
        left: max(12px, env(safe-area-inset-left, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 8px);
        top: auto;
        min-width: 0;
        max-height: min(70vh, 420px);
        overflow-y: auto;
        z-index: 55;
    }

    body.nav-menu-open .ux-help-menu__panel:not([hidden]) {
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }

    .ux-help-menu__toggle,
    .logout-button,
    .lang-flag {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }

    .portfolio-positions-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -4px;
        padding: 0 4px;
    }

    .portfolio-positions-table {
        min-width: 40rem;
    }

    .ux-feature-card__summary,
    .ux-prefs-card__summary {
        min-height: 44px;
        padding: 12px 0;
    }

    .add-transaction-link,
    .sell-transaction-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding: 8px 4px;
    }
}

/* -------------------------------------------------------------------------
   Watchlist widget
   ---------------------------------------------------------------------- */
.ux-watchlist-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ux-watchlist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.12s;
}

.ux-watchlist-item:hover {
    border-color: var(--border-strong);
}

.ux-watchlist-item__identity {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ux-watchlist-ticker {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    letter-spacing: 0.02em;
}

.ux-watchlist-name {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.ux-watchlist-item__data {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ux-watchlist-price {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    line-height: 1;
}

.ux-watchlist-chg {
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
}

.ux-watchlist-yield-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 7px;
    white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Price target alerts
   ---------------------------------------------------------------------- */
.ux-price-target-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ux-price-target-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.12s;
}

.ux-price-target-item:hover {
    border-color: var(--border-strong);
}

.ux-pt-dir {
    font-size: 12px;
    font-weight: 700;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.ux-pt-dir--above { color: #10b981; }
.ux-pt-dir--below { color: #ef4444; }

.ux-pos { color: #10b981; }
.ux-neg { color: #ef4444; }

.ux-pt-identity {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 80px;
}

.ux-pt-ticker {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
}

.ux-pt-name {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.ux-pt-target {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.ux-pt-target b {
    color: var(--text);
    font-weight: 600;
}

/* -------------------------------------------------------------------------
   Watchlist — redesigned (stats header + rich rows)
   ---------------------------------------------------------------------- */
.wl-stats,
.pt-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 0 0 14px;
}

.wl-stat,
.pt-stat {
    padding: 11px 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    background: var(--surface-muted, rgba(127,127,127,0.05));
    text-align: center;
}

.wl-stat__val,
.pt-stat__val {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.1;
}

.wl-stat__sub {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted, #9ca3af);
}

.wl-stat__lbl,
.pt-stat__lbl {
    font-size: 0.72rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 4px;
    line-height: 1.3;
}

.wl-stat--pos { color: var(--accent, #10b981); }
.wl-stat--neg { color: var(--danger, #ef4444); }
.wl-stat--warn { color: #f59e0b; }

.wl-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wl-item {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    background: var(--surface-muted, rgba(127,127,127,0.05));
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    transition: border-color 0.12s, transform 0.12s;
}

.wl-item:hover {
    border-color: var(--border-strong, #d1d5db);
    transform: translateX(2px);
}

.wl-item__main {
    display: flex;
    align-items: center;
    gap: 11px;
}

.wl-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid var(--border, #e5e7eb);
}

.wl-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.71rem;
    font-weight: 600;
    line-height: 1.25;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bg-elevated, rgba(127,127,127,0.08));
    color: var(--text-secondary, #6b7280);
    border: 1px solid transparent;
    white-space: nowrap;
}

.wl-badge--div {
    background: var(--accent-soft, rgba(16,185,129,0.12));
    color: var(--accent, #10b981);
}

.wl-badge--earn {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary, #2563eb);
}

.wl-badge--soon {
    background: rgba(245, 158, 11, 0.16);
    color: #d97706;
    font-weight: 700;
}

.wl-badge--muted {
    background: transparent;
    color: var(--text-muted, #9ca3af);
    border-color: var(--border, #e5e7eb);
}

.wl-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    border: none;
    padding: 0;
    font-family: inherit;
}

/* Clickable avatar → opens the price chart */
.wl-avatar--chart {
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.wl-avatar--chart:hover {
    transform: scale(1.07);
    box-shadow: 0 0 0 2px var(--primary-soft, rgba(37,99,235,0.3));
}

.wl-avatar--pos { background: var(--accent-soft, rgba(16,185,129,0.14)); color: var(--accent, #10b981); }
.wl-avatar--neg { background: var(--danger-soft, rgba(239,68,68,0.12)); color: var(--danger, #ef4444); }

.wl-id {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wl-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wl-sub {
    font-size: 0.74rem;
    color: var(--text-muted, #9ca3af);
}

.wl-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.wl-price {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text, #111827);
    line-height: 1;
    white-space: nowrap;
}

.wl-chg {
    font-weight: 700;
    font-size: 0.74rem;
    line-height: 1;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.wl-chg--pos { color: var(--accent, #10b981); background: var(--accent-soft, rgba(16,185,129,0.12)); }
.wl-chg--neg { color: var(--danger, #ef4444); background: var(--danger-soft, rgba(239,68,68,0.12)); }

/* -------------------------------------------------------------------------
   Price targets — redesigned (progress toward goal)
   ---------------------------------------------------------------------- */
.pt-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pt-item {
    padding: 12px 13px;
    background: var(--surface-muted, rgba(127,127,127,0.05));
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    transition: border-color 0.12s;
}

.pt-item:hover { border-color: var(--border-strong, #d1d5db); }

.pt-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pt-marker {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
}

.pt-marker--above { background: var(--accent-soft, rgba(16,185,129,0.14)); color: var(--accent, #10b981); }
.pt-marker--below { background: var(--danger-soft, rgba(239,68,68,0.12)); color: var(--danger, #ef4444); }

.pt-id {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pt-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pt-sub {
    font-size: 0.74rem;
    color: var(--text-muted, #9ca3af);
}

.pt-progress-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 11px;
}

.pt-now {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
}

.pt-goal {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text, #111827);
    white-space: nowrap;
}

.pt-bar {
    flex: 1;
    height: 7px;
    background: var(--bg-elevated, rgba(127,127,127,0.14));
    border-radius: 999px;
    overflow: hidden;
}

.pt-bar__fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.45s ease;
}

.pt-bar__fill--above { background: linear-gradient(90deg, rgba(16,185,129,0.45), var(--accent, #10b981)); }
.pt-bar__fill--below { background: linear-gradient(90deg, rgba(239,68,68,0.45), var(--danger, #ef4444)); }
.pt-bar__fill--reached { background: var(--accent, #10b981); }

.pt-dist-row { margin-top: 8px; }

.pt-dist {
    font-size: 0.73rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    color: var(--text-muted, #9ca3af);
    background: var(--bg-elevated, rgba(127,127,127,0.1));
}

.pt-dist--close { color: #f59e0b; background: rgba(245,158,11,0.13); }
.pt-dist--reached { color: var(--accent, #10b981); background: var(--accent-soft, rgba(16,185,129,0.14)); }

.pt-target-plain {
    margin-top: 9px;
    font-size: 0.82rem;
    color: var(--text-secondary, #6b7280);
}

.pt-target-plain b { color: var(--text, #111827); font-weight: 700; }

/* -------------------------------------------------------------------------
   Shared remove button for watchlist & price-target items
   ---------------------------------------------------------------------- */
.ux-item-remove {
    flex-shrink: 0;
    margin-left: auto;
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.ux-item-remove:hover {
    background: var(--danger-soft);
    border-color: var(--danger, #dc2626);
    color: var(--danger, #dc2626);
}

/* -------------------------------------------------------------------------
   Shared add form — watchlist & price targets
   ---------------------------------------------------------------------- */
.widget-add-form {
    margin-top: 14px;
    padding: 16px;
    background: var(--surface-muted, rgba(127,127,127,0.05));
    border: 1px solid var(--border);
    border-radius: 12px;
}

.widget-add-form__hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 14px;
    line-height: 1.5;
}

.widget-add-form__row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.widget-add-form__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.widget-add-form__label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.widget-add-form__input,
.widget-add-form__select {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.2;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.widget-add-form__input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
    font-weight: 400;
    letter-spacing: normal;
}

.widget-add-form__input:hover,
.widget-add-form__select:hover {
    border-color: var(--border-strong);
}

.widget-add-form__input:focus,
.widget-add-form__select:focus {
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(37,99,235,.18));
}

.widget-add-form__input {
    width: 124px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.widget-add-form__select {
    width: 96px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 12px;
}

.widget-add-form__field--action .button {
    height: 40px !important;
    padding: 0 20px !important;
    font-size: 13px !important;
    white-space: nowrap;
    box-sizing: border-box !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

@media (max-width: 520px) {
    .widget-add-form__row {
        flex-direction: column;
        align-items: stretch;
    }
    .widget-add-form__field {
        width: 100%;
    }
    .widget-add-form__input,
    .widget-add-form__select,
    .widget-add-form__field--action .button {
        width: 100% !important;
    }
}

/* -------------------------------------------------------------------------
   Watchlist symbol search (find by company name or ticker)
   ---------------------------------------------------------------------- */
.widget-add-form__field--grow {
    /* Grow to fill the row; basis 0 (not 200px) so the vertical stacked layout
       doesn't turn the basis into a 200px-tall field. min-width controls wrapping. */
    flex: 1 1 0;
    min-width: 200px;
}

.wl-search-field {
    position: relative;
}

/* Names are typed in normal case (override the uppercase ticker styling) */
.wl-search-input {
    text-transform: none !important;
    width: 100% !important;
    letter-spacing: normal !important;
    font-weight: 500 !important;
}

.wl-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 40;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border-strong, #d1d5db);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    padding: 4px;
}

.wl-search-result {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.1s;
}

.wl-search-result:hover,
.wl-search-result:focus {
    background: var(--surface-muted, rgba(127,127,127,0.08));
    outline: none;
}

.wl-search-result__name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wl-search-result__meta {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted, #9ca3af);
    letter-spacing: 0.02em;
}

.wl-search-status {
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-muted, #9ca3af);
}

/* -------------------------------------------------------------------------
   Push notification row
   ---------------------------------------------------------------------- */
.ux-push-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}


/* ── Mobile fixes (2026-05-29) ──────────────────────────────────── */

/* 1. Chart toolbar: static flow on narrow screens so it doesn't overlap title */
@media (max-width: 640px) {
    .ux-overview-chart-card__toolbar {
        position: static;
        top: auto;
        right: auto;
        justify-content: flex-end;
        flex-wrap: wrap;
        margin-bottom: 8px;
        gap: 4px;
    }
}

/* 2. Horizontal scroll for tables without explicit wrappers */
.model-signals-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
#tradesTable {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 3. Risk section: clamp oversized inputs */
@media (max-width: 768px) {
    #riskConfigForm input[type="number"],
    #riskUniverseForm textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Reports grid: force single column on mobile */
    #reportsCatalog .grid,
    #reportsCatalog > .grid {
        grid-template-columns: 1fr !important;
    }

    /* Welcome banner CTAs: stack on tiny screens */
    .ux-welcome-banner__ctas {
        flex-direction: column;
        gap: 6px;
    }
    .ux-welcome-banner__ctas .button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* Analysis section: more readable text on narrow screens */
    .analysis-callout__body {
        font-size: 14px;
        line-height: 1.6;
    }

    /* Sector exposure table responsive */
    #portfolioSectorExposure,
    #overviewSectorExposure {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Quick action buttons: full width on mobile */
    .ux-quick-actions .ux-quick-action {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }
}

/* 4. Position detail modals fit narrow screens */
@media (max-width: 480px) {
    .ux-overview-chart-card__toolbar {
        gap: 2px;
    }
    .ux-btn-ghost-sm {
        font-size: 10px;
        padding: 3px 7px;
    }
    
    /* Add/edit forms: inputs take full width */
    .form-row,
    .input-row {
        flex-direction: column;
    }
    
    /* Copilot: suggestion chips full width */
    .copilot-suggestions-wrap .copilot-chip {
        width: 100%;
        text-align: center;
    }
}

/* 5. Ensure mobile nav drawer has correct z-index */
@media (max-width: 768px) {
    .nav#mainNav.nav--open {
        z-index: 200;
    }
    
    /* Risk check result box */
    #riskCheckResult {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        word-break: break-word;
    }
    
    /* Positions table row actions: wrap on mobile */
    .portfolio-row-actions {
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* Welcome banner: stack vertically on mobile */
@media (max-width: 640px) {
    .ux-welcome-banner__inner {
        flex-direction: column;
        gap: 8px;
    }
    .ux-welcome-banner__close {
        position: absolute;
        top: 8px;
        right: 8px;
    }
    .ux-welcome-banner {
        position: relative;
        padding-right: 36px;
    }
}

/* Chart card: title row with period buttons always visible */
.ux-overview-chart-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    padding-right: 120px; /* leave room for toolbar (Genberegn + countdown) */
}

.ux-overview-chart-card__head h2 {
    margin: 0;
}

/* Period buttons moved into head: always visible, no longer inside absolute toolbar */
.ux-overview-chart-card__head .ux-chart-period-btns {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

/* Keep the toolbar (rebuild btn + countdown) absolute as before */
/* But remove period buttons from toolbar — they're in __head now */
.ux-overview-chart-card__toolbar .ux-chart-period-btns {
    display: none !important;
}

/* On mobile: remove padding-right (toolbar is small) and allow wrapping */
@media (max-width: 640px) {
    .ux-overview-chart-card__head {
        padding-right: 90px; /* countdown + rebuild btn are smaller */
        gap: 6px;
    }
    .ux-chart-period-btn {
        padding: 4px 7px;
        font-size: 10px;
        min-height: 30px;
    }
}

/* Remove the old media query that hid period buttons on small screens */
/* (was: @media (max-width: 480px) { .ux-chart-period-btns { display: none; } }) */
/* — now overridden by the __head rules above */

/* Install App button — moved out of inline style for proper responsive control */
.ux-install-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary, #1e3a8a);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    cursor: pointer;
    touch-action: manipulation;
}

/* On mobile with bottom nav: push button above the nav bar */
@media (max-width: 768px) {
    .ux-install-btn {
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        right: 12px;
    }
}

/* ─── Copilot Tabs (Gmail-style) ─────────────────────────────────────── */
.ux-copilot-tabs {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ux-tabs__bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    background: var(--bg-elevated);
}

.ux-tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color 0.2s, background 0.2s;
    text-align: center;
    white-space: nowrap;
}

.ux-tab-btn:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.ux-tab-btn--active {
    color: var(--primary);
}

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

.ux-tab-panel {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    display: none;
}

.ux-tab-panel--active {
    display: block;
}

/* Tab content spacing */
.ux-tab-panel > *:first-child {
    margin-top: 0;
}

/* Mobile: stack tabs vertically on small screens */
@media (max-width: 640px) {
    .ux-tabs__bar {
        gap: 0;
        flex-wrap: wrap;
    }

    .ux-tab-btn {
        flex: 1 1 50%;
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* ===== Admin inbox viewer (trading@edelmann.dk) ===== */
.ux-inbox-list { display: flex; flex-direction: column; gap: 4px; }
.ux-inbox-row {
    display: grid;
    grid-template-columns: 14px minmax(110px, 1fr) minmax(0, 2fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    color: #1f2937;
}
.ux-inbox-row:hover { background: #f8fafc; border-color: #cbd5e1; }
.ux-inbox-row__dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.ux-inbox-row--unread { background: #eff6ff; border-color: #bfdbfe; font-weight: 600; }
.ux-inbox-row--unread .ux-inbox-row__dot { background: #2563eb; }
.ux-inbox-row__from { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ux-inbox-row__subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #475569; }
.ux-inbox-row--unread .ux-inbox-row__subject { color: #1f2937; }
.ux-inbox-row__date { white-space: nowrap; font-size: 12px; color: var(--text-muted, #94a3b8); }

.ux-inbox-viewer { margin-top: 16px; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; background: #fff; }
.ux-inbox-viewer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ux-inbox-viewer__subject { font-size: 17px; font-weight: 700; color: #0f172a; word-break: break-word; }
.ux-inbox-viewer__meta { font-size: 13px; color: #64748b; margin-top: 4px; word-break: break-word; }
.ux-inbox-viewer__att { font-size: 12px; color: #475569; margin-top: 6px; }
.ux-inbox-frame { width: 100%; min-height: 280px; max-height: 60vh; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; }
.ux-inbox-viewer__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ux-inbox-reply { margin-top: 14px; padding-top: 14px; border-top: 1px solid #e5e7eb; }
.ux-inbox-reply__label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin: 8px 0 4px; }
.ux-inbox-reply__field { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-family: inherit; }
textarea.ux-inbox-reply__field { resize: vertical; }

@media (max-width: 640px) {
    .ux-inbox-row { grid-template-columns: 10px 1fr auto; }
    .ux-inbox-row__subject { grid-column: 2 / 4; white-space: normal; }
}

/* ===== Stock Radar ===== */
.ux-radar-list { display: flex; flex-direction: column; gap: 8px; }
.ux-radar-row {
    display: grid;
    grid-template-columns: 30px 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px 14px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    background: var(--bg-elevated, #fff);
}
.ux-radar-rank { font-size: 15px; font-weight: 700; color: #94a3b8; text-align: center; padding-top: 3px; }
.ux-radar-main { min-width: 0; }
.ux-radar-headline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ux-radar-ticker { font-size: 16px; font-weight: 700; color: var(--text, #0f172a); }
.ux-radar-meta { font-size: 12px; color: #64748b; }
.ux-radar-name { font-size: 15px; font-weight: 700; color: var(--text, #0f172a); }
.ux-radar-ticker-tag { font-size: 11px; font-weight: 700; color: var(--text-secondary, #475569); background: var(--surface-muted, #f1f5f9); border-radius: 4px; padding: 1px 6px; }
.ux-radar-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.ux-radar-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 2px; }
.ux-radar-chip { font-size: 11px; color: var(--text-secondary, #334155); background: var(--surface-muted, #f1f5f9); border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.ux-radar-insight { font-size: 13px; line-height: 1.45; color: var(--text-secondary, #334155); margin: 6px 0 8px; }
.ux-radar-factors { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.ux-radar-factor { display: flex; align-items: center; gap: 6px; }
.ux-radar-factor__label { font-size: 11px; color: #64748b; }
.ux-radar-factor__bar { width: 46px; height: 5px; border-radius: 3px; background: var(--border, #eef2f7); overflow: hidden; }
.ux-radar-factor__bar > span { display: block; height: 100%; border-radius: 3px; }
.ux-radar-side { text-align: right; white-space: nowrap; }
.ux-radar-score { font-size: 26px; font-weight: 800; line-height: 1; }
.ux-radar-upside { font-size: 11px; color: #64748b; margin-top: 2px; }
.ux-radar-foot { font-size: 11px; color: #94a3b8; margin: 12px 0 0; }
.ux-radar-more-wrap { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.ux-radar-more-btn { padding: 7px 18px !important; font-size: 13px !important; }
/* "How to read the radar" collapsible legend */
.ux-radar-help { margin: 0 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); overflow: hidden; }
.ux-radar-help > summary { cursor: pointer; padding: 9px 12px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); list-style: none; user-select: none; }
.ux-radar-help > summary::-webkit-details-marker { display: none; }
.ux-radar-help > summary::after { content: '▸'; float: right; transition: transform 0.2s; opacity: 0.6; }
.ux-radar-help[open] > summary::after { transform: rotate(90deg); }
.ux-radar-help[open] > summary { border-bottom: 1px solid var(--border); }
.ux-radar-help__body { padding: 6px 12px 10px; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }
.ux-radar-help__body p { margin: 7px 0; }
.ux-radar-help__body b { color: var(--text); }
.ux-radar-help__note { font-size: 11px; opacity: 0.8; margin-top: 9px !important; }
/* Animated score ring */
.ux-radar-ring { display: block; margin: 0 0 2px auto; }
.ux-radar-ring__track { fill: none; stroke: var(--border, #eef2f7); stroke-width: 5; }
.ux-radar-ring__fill { fill: none; stroke-width: 5; stroke-linecap: round; transform-box: fill-box; transform-origin: center; transform: rotate(-90deg); transition: stroke-dashoffset 0.9s cubic-bezier(.4, 0, .2, 1); }
.ux-radar-ring__num { font-size: 17px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
/* Confidence + thin-data badges */
.ux-radar-conf { font-size: 10px; font-weight: 700; border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; line-height: 15px; display: inline-block; }
.ux-radar-thin { font-size: 10px; font-weight: 700; color: var(--warn, #b45309); background: var(--warn-soft, #fef3c7); border-radius: 999px; padding: 0 7px; line-height: 16px; display: inline-block; }
.ux-radar-new { font-size: 10px; font-weight: 800; color: #fff; background: #16a34a; border-radius: 999px; padding: 0 7px; line-height: 16px; display: inline-block; letter-spacing: .3px; }
/* Structured AI thesis (bull / bear / why-now + conviction) */
.ux-radar-conviction { font-size: 11px; font-weight: 700; margin: 7px 0 5px; }
.ux-radar-th { font-size: 13px; line-height: 1.42; color: var(--text-secondary, #334155); margin: 3px 0; display: flex; gap: 7px; align-items: flex-start; }
.ux-radar-th__ic { font-size: 10px; line-height: 1.7; flex: 0 0 auto; }
.ux-radar-th--bull .ux-radar-th__ic { color: #16a34a; }
.ux-radar-th--bear .ux-radar-th__ic { color: #dc2626; }
.ux-radar-th--now .ux-radar-th__ic { color: #d97706; }
/* Track record strip */
.ux-track { background: rgba(22, 163, 74, 0.07); border: 1px solid rgba(22, 163, 74, 0.25); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.ux-track__head { font-size: 12px; font-weight: 700; color: var(--text, #0f172a); margin-bottom: 6px; }
.ux-track__pending { font-size: 12px; color: var(--text-secondary, #64748b); line-height: 1.4; }
.ux-track__row { display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 2px 0; }
.ux-track__label { flex: 1; color: var(--text, #334155); font-weight: 600; }
.ux-track__ret { font-weight: 800; min-width: 56px; text-align: right; }
.ux-track__hit { color: var(--text-secondary, #475569); min-width: 64px; text-align: right; }
.ux-track__n { color: var(--text-secondary, #94a3b8); min-width: 44px; text-align: right; opacity: .8; }
.ux-track__foot { font-size: 10px; color: var(--text-secondary, #94a3b8); opacity: .75; margin-top: 6px; }
/* Anti-radar (red flags / avoid) */
.ux-avoid { margin: 14px 0 0; padding: 10px 12px; background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.30); border-radius: 10px; }
.ux-avoid__head { font-size: 12px; font-weight: 700; color: #ef4444; margin-bottom: 6px; }
.ux-avoid__row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; flex-wrap: wrap; }
.ux-avoid__name { font-weight: 600; color: var(--text, #334155); }
.ux-avoid__tag { font-size: 10px; font-weight: 700; color: var(--text-secondary, #64748b); background: var(--bg-elevated, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 4px; padding: 0 5px; }
.ux-avoid__weak { color: #ef4444; margin-left: auto; opacity: .9; }
.ux-avoid__score { font-weight: 800; color: #ef4444; min-width: 26px; text-align: right; }
.ux-avoid__foot { font-size: 10px; color: #ef4444; opacity: .7; margin-top: 6px; }
@media (max-width: 640px) {
    .ux-radar-row { grid-template-columns: 24px 1fr auto; padding: 10px; }
    .ux-radar-score { font-size: 22px; }
    .ux-radar-ring { width: 48px; height: 48px; }
    .ux-radar-factor__bar { width: 34px; }
}

/* Tablet / narrow desktop: two position cards per row (560–768px). Explicit two
   columns (not auto-fill) so it's predictable, and the cards stay wide enough that
   their inner metric columns don't cramp. Last in the file so it wins over the
   single-column mobile rule at this width. The summary/detail rows span via their
   own inline grid-column:1/-1, so they remain full width. */
@media (min-width: 560px) and (max-width: 768px) {
    html #overviewPortfolioTableBody {
        grid-template-columns: 1fr 1fr !important;
    }
}
