/* Extracted from base.html (W3.A2, M-17) - the shared application stylesheet.
   Served versioned+immutable via asset_url; edit here, not in the template. */

        /* ============================================
           REVOLUT-INSPIRED DESIGN SYSTEM 2025
           Clean, Modern, Fintech
           ============================================ */

        :root {
            /* Core Colors - Deep Dark Theme */
            --bg-primary: #000000;
            --bg-secondary: #0a0a0a;
            --bg-tertiary: #141414;
            --bg-card: #1a1a1a;
            --bg-elevated: #242424;
            --bg-input: #1a1a1a;

            /* Text */
            --text-primary: #ffffff;
            --text-secondary: #a3a3a3;
            --text-muted: #9aa0a8;   /* audit F9: was #8a8a8a (3.5:1) — now >=4.5:1 on the dark bg */
            --text-link: #0066ff;

            /* Borders */
            --border-primary: #2a2a2a;
            --border-secondary: #1f1f1f;
            --border-subtle: rgba(255, 255, 255, 0.06);

            /* Accent Colors - Revolut Style */
            --accent-primary: #0066ff;
            --accent-green: #00d084;
            --accent-red: #ff3b30;
            --accent-orange: #ff9500;
            --accent-purple: #af52de;
            --accent-cyan: #5ac8fa;
            --accent-blue: #0066ff;

            /* Chart */
            --chart-grid: #2a2a2a;

            /* Glass Effect */
            --glass-bg: rgba(26, 26, 26, 0.8);
            --glass-border: rgba(255, 255, 255, 0.06);
            --glass-hover: rgba(255, 255, 255, 0.04);

            /* Gradients */
            --gradient-primary: linear-gradient(135deg, #0066ff 0%, #5ac8fa 100%);
            --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
            --gradient-green: linear-gradient(135deg, #00d084 0%, #00b371 100%);
            --gradient-red: linear-gradient(135deg, #ff3b30 0%, #ff6b6b 100%);
            --gradient-purple: linear-gradient(135deg, #af52de 0%, #5856d6 100%);
            --gradient-orange: linear-gradient(135deg, #ff9500 0%, #ff6b00 100%);
            --gradient-dark: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);

            /* Shadows */
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
            --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
            --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
            --shadow-glow: 0 0 20px rgba(0, 102, 255, 0.3);
            --shadow-glow-green: 0 0 20px rgba(0, 208, 132, 0.3);

            /* Layout */
            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 16px;
            --radius-xl: 24px;
            --radius-full: 9999px;

            /* Spacing */
            --space-xs: 4px;
            --space-sm: 8px;
            --space-md: 16px;
            --space-lg: 24px;
            --space-xl: 32px;
            --space-2xl: 48px;

            /* Transitions */
            --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
            --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
            --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
            --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

            /* Layout */
            --navbar-height: 72px;

            /* Legacy compatibility */
            --card-radius: 16px;
            --accent-green-dark: #00b371;

            /* ====================================================
               DESIGN SYSTEM v2 (Phase 0)
               Semantic tokens layered on top of the Revolut palette.
               New components use these; existing components stay on
               legacy tokens until per-page refactor migrates them.
               ==================================================== */

            /* Bento card — every logical block on every page uses this */
            --bento-bg:      #121214;
            --bento-border:  #1F1F23;
            --bento-hover:   #1A1A1E;
            --bento-radius:  8px;
            --bento-radius-sm: 6px;

            /* Semantic indicators (success / danger / neutral pairs).
               Dark-mode pastel-on-dark per the design spec. */
            --success-bg:    #052E16;
            --success-text:  #4ADE80;
            --success-soft:  rgba(74, 222, 128, 0.10);
            --danger-bg:     #450A0A;
            --danger-text:   #F87171;
            --danger-soft:   rgba(248, 113, 113, 0.10);
            --neutral-bg:    rgba(255, 255, 255, 0.04);
            --neutral-text:  var(--text-secondary);

            /* Typography */
            --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
            --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, 'Roboto Mono', monospace;
        }

        /* Light Theme */
        body.light-theme {
            --bg-primary: #f5f5f7;
            --bg-secondary: #ffffff;
            --bg-tertiary: #f0f0f0;
            --bg-card: #ffffff;
            --bg-elevated: #ffffff;
            --bg-input: #f5f5f7;

            --text-primary: #1d1d1f;
            --text-secondary: #6e6e73;
            --text-muted: #6e7076;   /* audit F9: was #8e8e93 (3.4:1 on white) — now >=4.5:1 */
            --text-link: #0066ff;

            --border-primary: #e5e5e5;
            --border-secondary: #f0f0f0;
            --border-subtle: rgba(0, 0, 0, 0.06);

            --glass-bg: rgba(255, 255, 255, 0.9);
            --glass-border: rgba(0, 0, 0, 0.06);
            --glass-hover: rgba(0, 0, 0, 0.02);

            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
            --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
            --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

            --chart-grid: #e5e5e5;

            /* Design System v2 — light variants (pastel-on-light) */
            --bento-bg:      #FFFFFF;
            --bento-border:  #E4E4E7;
            --bento-hover:   #F4F4F5;
            --success-bg:    #DCFCE7;
            --success-text:  #15803D;
            --success-soft:  rgba(21, 128, 61, 0.08);
            --danger-bg:     #FEE2E2;
            --danger-text:   #B91C1C;
            --danger-soft:   rgba(185, 28, 28, 0.08);
            --neutral-bg:    rgba(0, 0, 0, 0.04);
        }

        /* Light Theme - html-level for flash prevention (variables cascade to body) */
        html.light-theme {
            --bg-primary: #f5f5f7;
            --bg-secondary: #ffffff;
            --bg-tertiary: #f0f0f0;
            --bg-card: #ffffff;
            --bg-elevated: #ffffff;
            --bg-input: #f5f5f7;
            --text-primary: #1d1d1f;
            --text-secondary: #6e6e73;
            --text-muted: #6e7076;   /* audit F9: was #8e8e93 (3.4:1 on white) — now >=4.5:1 */
            --text-link: #0066ff;
            --border-primary: #e5e5e5;
            --border-secondary: #f0f0f0;
            --border-subtle: rgba(0, 0, 0, 0.06);
            --glass-bg: rgba(255, 255, 255, 0.9);
            --glass-border: rgba(0, 0, 0, 0.06);
            --glass-hover: rgba(0, 0, 0, 0.02);
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
            --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
            --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
            --chart-grid: #e5e5e5;

            /* Design System v2 — light variants (flash-prevention block) */
            --bento-bg:      #FFFFFF;
            --bento-border:  #E4E4E7;
            --bento-hover:   #F4F4F5;
            --success-bg:    #DCFCE7;
            --success-text:  #15803D;
            --success-soft:  rgba(21, 128, 61, 0.08);
            --danger-bg:     #FEE2E2;
            --danger-text:   #B91C1C;
            --danger-soft:   rgba(185, 28, 28, 0.08);
            --neutral-bg:    rgba(0, 0, 0, 0.04);
        }

        /* Reset */
        *, *::before, *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Remove number input spinners globally */
        input[type='number']::-webkit-inner-spin-button,
        input[type='number']::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
        input[type='number'] {
            -moz-appearance: textfield;
        }

        /* Base */
        html {
            font-size: 16px;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
            background: var(--bg-primary);
            color: var(--text-secondary);
            line-height: 1.5;
            min-height: 100vh;
        }

        /* ═══════════════════════════════════════════════════════════
           CANONICAL LAYOUT (Layout Unification, 15. 7. 2026)

           The base .container is THE one page container of the whole
           application (base.html wraps every block content in it):
           - the content starts right after the sidebar with a single
             gutter (clamp 16/3vw/48) — the identical left edge of
             every page;
           - full available width — an authenticated page must NEVER
             add its own centered or width-limited wrapper (that was
             the root cause of pages feeling like different products;
             guard test: tests/unit/test_layout_canon.py).

           Documented exceptions:
           - long-form READING text constrains its measure with
             .page-content--reading (typography — the header stays on
             the shared edge);
           - the container-- modifiers below exist for PUBLIC pages
             only (landing, guide, privacy, terms) — never use them
             on authenticated app pages;
           - hero CARDS (stock detail, /dane) keep their internal
             padding — the card itself sits on the shared edge.

           Page structure classes (use these, no custom layout CSS):
             .page-header   title+subtitle left, .page-actions right
             .page-actions  aligned action buttons
             .page-section  standard vertical rhythm between sections
           ═══════════════════════════════════════════════════════════ */
        .container {
            width: 100%;
            max-width: var(--page-max-width, none);
            margin: 0 auto;
            padding: var(--space-lg) clamp(16px, 3vw, 48px);
        }
        .container--narrow  { --page-max-width: 900px;  }  /* PUBLIC pages only */
        .container--reading { --page-max-width: 1000px; }  /* PUBLIC pages only */
        .container--medium  { --page-max-width: 1400px; }  /* PUBLIC pages only */

        .page-header {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            align-items: flex-start;
            gap: 12px 24px;
            margin: 0 0 18px;
        }
        .page-header h1 {
            font-size: 1.85rem;
            margin: 0 0 6px;
            letter-spacing: -0.01em;
        }
        .page-header-intro p {
            color: var(--text-secondary);
            margin: 0;
            font-size: 0.95rem;
        }
        .page-actions {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 8px;
        }
        .page-section { margin: 0 0 20px; }
        .page-content--reading { max-width: 900px; }

        /* Scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-secondary);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--border-primary);
            border-radius: var(--radius-full);
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--text-muted);
        }

        /* Selection */
        ::selection {
            background: var(--accent-primary);
            color: white;
        }

        /* ====================================================
           DESIGN SYSTEM v2 — UTILITY CLASSES (Phase 0)

           Migration plan: per-page refactor in following commits
           moves card / badge / table / button markup to use these
           classes. Until then, new components use them, existing
           keep their legacy styles, and the two co-exist.
           ==================================================== */

        /* Bento card — the universal container for any logical block */
        .bento {
            background: var(--bento-bg);
            border: 1px solid var(--bento-border);
            border-radius: var(--bento-radius);
            transition: background 0.15s, border-color 0.15s;
        }
        .bento--padded   { padding: 20px 22px; }
        .bento--compact  { padding: 12px 14px; }
        .bento--tight    { border-radius: var(--bento-radius-sm); }
        .bento:hover     { background: var(--bento-hover); }
        .bento--static:hover { background: var(--bento-bg); }

        /* Semantic badges — success / danger / neutral. Use for tags,
           chips, status indicators, P/L pills, etc. */
        .badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px 9px;
            border-radius: 999px;
            font-size: 0.74rem;
            font-weight: 600;
            line-height: 1.2;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }
        .badge--success { background: var(--success-bg); color: var(--success-text); }
        .badge--danger  { background: var(--danger-bg);  color: var(--danger-text); }
        .badge--neutral { background: var(--neutral-bg); color: var(--neutral-text); }

        /* Inline semantic colors — for raw $/% numbers in tables/charts */
        .is-success { color: var(--success-text); }
        .is-danger  { color: var(--danger-text); }
        .is-muted   { color: var(--text-muted); }

        /* Monospace numerics — MANDATORY on every $ / % / share / date.
           Pair with font-variant-numeric: tabular-nums so decimals line
           up vertically in tables. .mono is the canonical class. */
        .mono {
            font-family: var(--font-mono);
            font-variant-numeric: tabular-nums;
            letter-spacing: -0.01em;
        }

        /* Buttons — unified primary/secondary across the app.
           Existing .btn-modern / .btn-modern-primary remain valid; new
           pages should prefer .btn-v2 for the design-system look. */
        .btn-v2 {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 9px 16px;
            border-radius: var(--bento-radius);
            font-family: var(--font-ui);
            font-size: 0.88rem;
            font-weight: 500;
            line-height: 1.2;
            cursor: pointer;
            text-decoration: none;
            transition: background 0.15s, border-color 0.15s, color 0.15s;
            border: 1px solid transparent;
        }
        .btn-v2--primary {
            background: var(--text-primary);
            color: var(--bg-primary);
            border-color: var(--text-primary);
        }
        .btn-v2--primary:hover {
            background: var(--text-secondary);
            border-color: var(--text-secondary);
        }
        .btn-v2--secondary {
            background: transparent;
            color: var(--text-primary);
            border-color: var(--bento-border);
        }
        .btn-v2--secondary:hover {
            background: var(--bento-hover);
            border-color: var(--text-muted);
        }
        .btn-v2--danger {
            background: var(--danger-bg);
            color: var(--danger-text);
            border-color: var(--danger-bg);
        }
        .btn-v2:disabled,
        .btn-v2[aria-disabled="true"] {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Bento table — the canonical table component for the whole
           app. Per spec part 2.3: zebra striping, hover-only row
           actions, table-layout: fixed for fast rendering, monospace
           numerics. Apply class .bento-table to any <table> to opt in. */
        .bento-table {
            width: 100%;
            border-collapse: collapse;
            table-layout: fixed;        /* fast render for long lists */
            font-size: 0.88rem;
            background: var(--bento-bg);
        }
        .bento-table thead th {
            text-align: left;
            padding: 12px 14px;
            font-size: 0.68rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-muted);
            border-bottom: 1px solid var(--bento-border);
            background: var(--bento-bg);
            white-space: nowrap;
        }
        .bento-table thead th.num   { text-align: right; }
        .bento-table tbody tr {
            border-bottom: 1px solid var(--bento-border);
            transition: background 0.12s;
        }
        .bento-table tbody tr:nth-child(even) { background: var(--bento-hover); }
        .bento-table tbody tr:hover  { background: var(--bento-hover); }
        .bento-table tbody tr:last-child { border-bottom: 0; }
        .bento-table td {
            padding: 12px 14px;
            color: var(--text-secondary);
            vertical-align: middle;
        }
        .bento-table td.num {
            text-align: right;
            font-family: var(--font-mono);
            font-variant-numeric: tabular-nums;
            color: var(--text-primary);
        }
        .bento-table td.col-symbol {
            font-weight: 700;
            color: var(--text-primary);
        }
        /* Row-level actions — hidden until hover. Wrap action <button>s
           inside <td class="row-actions"> to opt in. */
        .bento-table td.row-actions {
            text-align: right;
            opacity: 0;
            transition: opacity 0.12s;
        }
        .bento-table tbody tr:hover td.row-actions,
        .bento-table tbody tr:focus-within td.row-actions {
            opacity: 1;
        }
        /* Best-in-class cell highlight — auto-applied via Jinja or JS
           on comparison tables. Subtle success tint. */
        .bento-table td.best { color: var(--success-text); font-weight: 700; }
        .bento-table td.best-soft { background: var(--success-soft); }

        /* Comparison-table column layout — the user's spec part 2.5
           says compare views go from rows to columns. .compare-grid
           is the shell, .compare-row is each metric. */
        .compare-grid {
            display: grid;
            gap: 0;
            border: 1px solid var(--bento-border);
            border-radius: var(--bento-radius);
            overflow: hidden;
            background: var(--bento-bg);
        }
        .compare-grid > div {
            padding: 12px 14px;
            border-right: 1px solid var(--bento-border);
            border-bottom: 1px solid var(--bento-border);
        }
        .compare-grid > div.compare-label {
            font-size: 0.7rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-muted);
            background: var(--bento-hover);
        }
        .compare-grid > div.compare-val {
            font-family: var(--font-mono);
            font-variant-numeric: tabular-nums;
            color: var(--text-primary);
        }
        .compare-grid > div.compare-best {
            color: var(--success-text);
            font-weight: 700;
            background: var(--success-soft);
        }

        /* ====================================================
           APP SIDEBAR (Phase 1)

           Per spec part 2.1: fixed left-side navigation panel,
           visible ONLY for authenticated users (body.has-app-sidebar).
           Public visitor pages keep the existing top-nav layout.

           Desktop ≥ 1024 px: sidebar visible, top dropdown menus hidden.
           Mobile < 1024 px: sidebar hidden, hamburger + top menus
           restored as fallback (drawer-style sidebar is a future step).
           ==================================================== */
        .app-sidebar {
            position: fixed;
            top: var(--navbar-height);
            left: 0;
            bottom: 0;
            width: 232px;
            background: var(--bento-bg);
            border-right: 1px solid var(--bento-border);
            overflow-y: auto;
            padding: 18px 0 24px;
            z-index: 50;
            display: none;
        }
        body.has-app-sidebar .app-sidebar { display: block; }

        .app-sidebar__section {
            position: relative;
            padding: 18px 18px 6px;
            margin-top: 10px;
            font-size: 0.64rem;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            font-weight: 700;
            color: var(--text-muted);
            opacity: 0.6;
        }
        /* Subtle divider line above each section header EXCEPT the
           first one — gives clean visual breaks between Overview /
           Portfolio / Tools / Help. */
        .app-sidebar__section + .app-sidebar__item ~ .app-sidebar__section::before,
        .app-sidebar__section:not(:first-of-type)::before {
            content: "";
            position: absolute;
            top: 0; left: 18px; right: 18px;
            height: 1px;
            background: var(--bento-border);
        }
        /* First section sits flush to the top of the sidebar — no
           extra margin, no divider above. Label stays visible (small
           muted text), just doesn't push everything else down. */
        .app-sidebar__section:first-of-type {
            padding-top: 4px;
            margin-top: 0;
        }

        .app-sidebar__item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px 18px;
            color: var(--text-secondary);
            text-decoration: none;
            border-left: 2px solid transparent;
            font-size: 0.88rem;
            font-weight: 500;
            line-height: 1.3;
            transition: color 0.12s, background 0.12s, border-left-color 0.12s;
            cursor: pointer;
            background: transparent;
            border-top: 0; border-right: 0; border-bottom: 0;
            width: 100%;
            text-align: left;
            font-family: inherit;
        }
        .app-sidebar__item:hover {
            background: var(--bento-hover);
            color: var(--text-primary);
        }
        .app-sidebar__item.is-active {
            color: #fff;
            font-weight: 600;
            background: linear-gradient(90deg, rgba(59,130,246,0.18), rgba(59,130,246,0.04));
            border-left: 3px solid var(--accent-blue, #3b82f6);
            padding-left: calc(16px - 3px); /* compensate so text doesn't shift */
            box-shadow: inset 0 0 0 1px rgba(59,130,246,0.10);
        }
        .app-sidebar__item svg {
            width: 17px;
            height: 17px;
            flex-shrink: 0;
            opacity: 0.85;
        }
        .app-sidebar__item.is-active svg { opacity: 1; }
        /* Active item uses white text for the dark sidebar; in light theme the
           pale-blue highlight would leave white-on-pale (unreadable), so switch
           the active text/icon to the brand blue — readable on the tint and
           matching the left-border indicator. */
        body.light-theme .app-sidebar__item.is-active,
        body.light-theme .app-sidebar__item.is-active svg { color: var(--accent-blue, #2563eb); }
        body.light-theme .app-sidebar__item.is-active {
            background: linear-gradient(90deg, rgba(59,130,246,0.14), rgba(59,130,246,0.03));
        }

        .app-sidebar__badge {
            margin-left: auto;
            padding: 1px 6px;
            border-radius: 4px;
            font-size: 0.58rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.06em;
        }
        .app-sidebar__badge--beta { background: rgba(0, 102, 255, 0.16); color: var(--accent-blue); }
        .app-sidebar__badge--new  { background: var(--accent-green); color: #fff; }

        /* ====================================================
           SINGLE-SOURCE NAV (sidebar is the only menu).
           Desktop ≥ 1024px: sidebar fixed on the left, no hamburger.
           Mobile  < 1024px: sidebar becomes an off-canvas drawer the
                             hamburger slides in. No separate top menus.
           ==================================================== */

        /* Hamburger only exists for authenticated users, and only on mobile. */
        body.has-app-sidebar .hamburger-btn { display: none; }

        /* Desktop: sidebar pinned, content pushed right, topbar full width. */
        @media (min-width: 1024px) {
            body.has-app-sidebar {
                padding-left: 232px;
                padding-top: var(--navbar-height);
            }
            body.has-app-sidebar > nav {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                z-index: 100;          /* above sidebar (z-index 50) */
            }
        }

        /* Mobile: sidebar slides off-canvas; hamburger toggles it. */
        @media (max-width: 1023px) {
            body.has-app-sidebar .hamburger-btn { display: inline-flex; }
            body.has-app-sidebar .app-sidebar {
                display: block;
                top: var(--navbar-height);
                transform: translateX(-100%);
                transition: transform 0.22s ease;
                box-shadow: 2px 0 16px rgba(0, 0, 0, 0.4);
                z-index: 1000;          /* above overlay (999) */
            }
            body.has-app-sidebar .app-sidebar.is-open {
                transform: translateX(0);
            }
        }

        /* Native date inputs on the dark theme — `color-scheme: dark` tells
           the browser to render the whole control (incl. the calendar-picker
           icon + the popup) in dark mode, so the icon is a visible light
           glyph. NOTE: do NOT also add `filter: invert` on the picker
           indicator — color-scheme already lightens it, and inverting would
           darken it back to invisible. One global rule covers the app. */
        input[type="date"],
        input[type="datetime-local"],
        input[type="month"],
        input[type="time"] {
            color-scheme: dark;
        }
        input[type="date"]::-webkit-calendar-picker-indicator,
        input[type="datetime-local"]::-webkit-calendar-picker-indicator,
        input[type="month"]::-webkit-calendar-picker-indicator,
        input[type="time"]::-webkit-calendar-picker-indicator {
            cursor: pointer;
            opacity: 0.9;
        }

        /* Unified tooltip icon — canonical style for all info tooltips.
           Rendered as a clearly-visible blue ⓘ at rest (the old muted-grey
           version read as faint/blurry), filling solid on hover. */
        .info-tip {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: rgba(59, 130, 246, 0.16);
            color: var(--accent-blue, #3b82f6);
            font-size: 10px;
            font-weight: 700;
            font-style: normal;
            line-height: 1;
            cursor: help;
            margin-left: 5px;
            vertical-align: middle;
            border: 1px solid rgba(59, 130, 246, 0.40);
            transition: all 0.15s ease;
            -webkit-font-smoothing: antialiased;
            flex: 0 0 auto;
        }
        .info-tip:hover {
            background: var(--accent-blue, #3b82f6);
            color: #fff;
            border-color: var(--accent-blue, #3b82f6);
        }

        /* Yahoo Finance Link - global style */
        .yahoo-link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 22px;
            height: 22px;
            border-radius: 4px;
            background: var(--bg-tertiary);
            color: var(--text-muted);
            text-decoration: none;
            transition: all 0.2s;
            vertical-align: middle;
            margin-left: 6px;
        }
        .yahoo-link:hover {
            background: var(--accent-purple);
            color: white;
        }
        .yahoo-link svg {
            width: 14px;
            height: 14px;
        }

        /* ============================================
           NAVIGATION - Revolut Style
           ============================================ */

        nav {
            background: rgba(10, 10, 10, 0.82);
            border-bottom: 1px solid var(--border-subtle);
            padding: var(--space-md) 0;
            position: sticky;
            top: 0;
            z-index: 1000;
            backdrop-filter: blur(12px) saturate(1.2);
            -webkit-backdrop-filter: blur(12px) saturate(1.2);
        }

        nav .container {
            display: flex;
            align-items: center;
            gap: var(--space-lg);
            /* The generic .container adds var(--space-lg) vertical padding; the
               nav already has its own padding, so the inherited top/bottom made
               the bar ~117px tall for a single logo+icons row. Zero it → ~68px. */
            padding-top: 0;
            padding-bottom: 0;
        }

        /* Logo */
        .logo {
            flex: 0 0 auto;
            font-size: 1.25rem;
            font-weight: 700;
            color: var(--text-primary);
            text-decoration: none;
            letter-spacing: -0.5px;
            transition: var(--transition-base);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .logo:hover {
            opacity: 0.8;
        }

        .logo-icon {
            width: 24px;
            height: 24px;
            flex-shrink: 0;
        }

        /* Hamburger (mobile only) */
        .hamburger-btn {
            display: none;
            width: 36px;
            height: 36px;
            background: none;
            border: 1px solid var(--border-primary);
            border-radius: var(--radius-md);
            color: var(--text-primary);
            cursor: pointer;
            align-items: center;
            justify-content: center;
            transition: var(--transition-base);
            font-family: inherit;
        }

        .hamburger-btn:hover {
            background: var(--bg-elevated);
        }

        /* Nav Overlay (click-away) */
        .nav-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            z-index: 999;
            pointer-events: none;
            background: rgba(0, 0, 0, 0);
            transition: background 0.22s ease;
        }

        .nav-overlay.active {
            pointer-events: auto;
            background: rgba(0, 0, 0, 0.5);
        }

        /* In-page beta badge (next to page titles) */
        .beta-badge {
            display: inline-flex;
            align-items: center;
            font-size: 0.65rem;
            font-weight: 600;
            color: var(--accent-purple, #8b5cf6);
            background: rgba(175, 82, 222, 0.08);
            border: 1px solid rgba(175, 82, 222, 0.2);
            padding: 2px 8px;
            border-radius: 4px;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            cursor: help;
            outline: none;
            vertical-align: middle;
            position: relative;
            top: -2px;
        }

        .beta-badge:focus-visible {
            outline: 2px solid var(--accent-purple, #8b5cf6);
            outline-offset: 2px;
        }

        body.light-theme .beta-badge {
            background: rgba(175, 82, 222, 0.06);
            border-color: rgba(175, 82, 222, 0.15);
        }

        /* Navigation Controls */
        .nav-controls {
            display: flex;
            justify-content: flex-end;
            gap: var(--space-sm);
            align-items: center;
            margin-left: auto;
        }

        /* Visitor Controls (language + theme for unauthenticated) */
        .visitor-controls {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .visitor-nav-link {
            height: 36px;
            display: flex;
            align-items: center;
            padding: 0 12px;
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 0.875rem;
            font-weight: 500;
            border-radius: var(--radius-md);
            transition: color 0.15s ease, background 0.15s ease;
            white-space: nowrap;
        }

        .visitor-nav-link:hover {
            color: var(--text-primary);
            background: var(--glass-bg);
        }

        /* Visitor mobile menu (<768px) */
        .visitor-menu-btn {
            display: none;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            margin-left: auto;
            background: transparent;
            border: 1px solid var(--glass-border);
            border-radius: var(--radius-md);
            color: var(--text-secondary);
            cursor: pointer;
        }
        .visitor-menu-btn:hover { color: var(--text-primary); }
        .visitor-menu {
            display: none;
            position: fixed;
            top: 60px;
            right: 10px;
            min-width: 200px;
            background: var(--bg-secondary);
            border: 1px solid var(--glass-border);
            border-radius: 12px;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
            padding: 8px;
            z-index: 10000;
        }
        .visitor-menu.open { display: block; }
        .visitor-menu hr {
            border: none;
            border-top: 1px solid var(--glass-border);
            margin: 6px 0;
        }
        .visitor-menu-label {
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            color: var(--text-muted);
            padding: 4px 10px 2px;
        }
        .visitor-menu-item {
            display: block;
            width: 100%;
            text-align: left;
            box-sizing: border-box;
            padding: 8px 10px;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 0.875rem;
            border-radius: 8px;
            cursor: pointer;
        }
        .visitor-menu-item:hover { background: var(--glass-bg); color: var(--text-primary); }

        @media (max-width: 768px) {
            .visitor-nav-link { display: none; }
            #visitorLangWrapper,
            #visitorCurrencyWrapper,
            #visitorThemeBtn { display: none; }
            .visitor-menu-btn { display: inline-flex; }
        }

        .visitor-lang-wrapper {
            position: relative;
        }

        .visitor-lang-btn {
            display: flex;
            align-items: center;
            gap: 4px;
            height: 36px;
            padding: 0 8px;
            background: none;
            border: none;
            color: var(--text-secondary);
            font-size: 0.8rem;
            font-weight: 500;
            cursor: pointer;
            font-family: inherit;
            opacity: 0.7;
            transition: opacity 0.15s ease;
            white-space: nowrap;
        }

        .visitor-lang-btn:hover {
            opacity: 1;
        }

        .visitor-lang-btn .visitor-chevron {
            width: 8px;
            height: 8px;
            opacity: 0.6;
            transition: transform 0.15s ease;
        }

        .visitor-lang-wrapper.open .visitor-chevron {
            transform: rotate(180deg);
        }

        .visitor-lang-dropdown {
            display: none;
            position: absolute;
            top: calc(100% + 4px);
            right: 0;
            min-width: 120px;
            background: var(--bg-card);
            border: 1px solid var(--border-primary);
            border-radius: 8px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
            padding: 4px;
            z-index: 1001;
        }

        .visitor-lang-wrapper.open .visitor-lang-dropdown {
            display: block;
        }

        .visitor-lang-dropdown a {
            display: block;
            padding: 7px 12px;
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 0.8rem;
            font-weight: 500;
            border-radius: 6px;
            transition: background 0.12s ease, color 0.12s ease;
        }

        .visitor-lang-dropdown a:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
        }

        .visitor-lang-dropdown a.active {
            color: var(--accent-blue);
            font-weight: 600;
        }

        .visitor-theme-btn {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.06);
            border: none;
            color: var(--text-secondary);
            font-size: 0.95rem;
            cursor: pointer;
            border-radius: 50%;
            opacity: 0.7;
            transition: opacity 0.15s ease, background 0.15s ease;
        }

        .visitor-theme-btn:hover {
            opacity: 1;
            background: rgba(255, 255, 255, 0.1);
        }

        body.light-theme .visitor-theme-btn {
            background: rgba(0, 0, 0, 0.04);
        }

        body.light-theme .visitor-theme-btn:hover {
            background: rgba(0, 0, 0, 0.08);
        }

        body.light-theme .visitor-lang-dropdown {
            background: #ffffff;
            border-color: var(--border-primary);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
        }

        body.light-theme .visitor-lang-dropdown a:hover {
            background: var(--bg-secondary);
        }

        /* User Menu Styles */
        /* ── Global Stock Search (topbar entry to the research layer) ── */
        .global-search-btn {
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            border-radius: 11px;
            color: var(--text-muted);
            height: 40px;
            min-width: 230px;
            display: inline-flex;
            align-items: center;
            gap: 9px;
            padding: 0 9px 0 13px;
            cursor: pointer;
            margin-right: 12px;
            font-size: 0.9rem;
            transition: color .15s ease, border-color .15s ease, background .15s ease;
        }
        .global-search-btn:hover {
            color: var(--text-primary);
            border-color: var(--accent-blue);
            background: rgba(59, 130, 246, 0.06);
        }
        .global-search-btn .gsb-text { flex: 1; text-align: left; white-space: nowrap; }
        .global-search-btn .gsb-kbd {
            font-family: inherit; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em;
            color: var(--text-muted); padding: 3px 7px; border-radius: 6px;
            background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border);
        }
        body.light-theme .global-search-btn { background: #f1f5f9; border-color: rgba(15, 23, 42, 0.10); }
        body.light-theme .global-search-btn:hover { background: #e8eef6; }
        body.light-theme .global-search-btn .gsb-kbd { background: #ffffff; border-color: rgba(15, 23, 42, 0.10); }
        /* collapse to an icon-only square on narrow viewports */
        @media (max-width: 760px) {
            .global-search-btn { min-width: 0; width: 38px; height: 38px; padding: 0; justify-content: center; gap: 0; }
            .global-search-btn .gsb-text, .global-search-btn .gsb-kbd { display: none; }
        }
        .global-search-modal {
            position: fixed;
            inset: 0;
            z-index: 10000;
            background: rgba(0, 0, 0, 0.55);
            backdrop-filter: blur(3px);
            display: flex;
            align-items: flex-start;
            justify-content: center;
            padding-top: 14vh;
        }
        .global-search-box {
            width: min(560px, 92vw);
            background: var(--bg-secondary);
            border: 1px solid var(--glass-border);
            border-radius: 14px;
            box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
            overflow: hidden;
        }
        #globalSearchInput {
            width: 100%;
            box-sizing: border-box;
            background: transparent;
            border: none;
            outline: none;
            color: var(--text-primary);
            font-size: 1rem;
            padding: 16px 18px;
            border-bottom: 1px solid var(--glass-border);
        }
        .global-search-results {
            max-height: 320px;
            overflow-y: auto;
        }
        .gs-result {
            display: flex;
            align-items: baseline;
            gap: 12px;
            width: 100%;
            background: transparent;
            border: none;
            cursor: pointer;
            padding: 10px 18px;
            text-align: left;
        }
        .gs-result:hover,
        .gs-result.active {
            background: var(--glass-bg);
        }
        .gs-result-symbol {
            color: var(--text-primary);
            font-weight: 700;
            min-width: 64px;
        }
        .gs-result-name {
            color: var(--text-secondary);
            font-size: 0.85rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            flex: 1;
        }
        .gs-result-stat {
            font-size: 0.78rem;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
            flex: none;
        }
        .gs-result-yield { color: var(--accent-green); font-weight: 600; }
        .gs-result-safety { color: var(--text-muted); font-weight: 600; }
        .gs-result-safety[data-band="high"] { color: var(--accent-green); }
        .gs-result-safety[data-band="good"] { color: var(--accent-blue); }
        .gs-result-safety[data-band="mid"]  { color: var(--accent-orange, #f59e0b); }
        .gs-result-safety[data-band="low"]  { color: var(--accent-red); }
        #globalSearchEmpty {
            color: var(--text-muted);
            font-size: 0.85rem;
            padding: 14px 18px;
        }
        .global-search-hint {
            color: var(--text-muted);
            font-size: 0.7rem;
            padding: 8px 18px 10px;
            border-top: 1px solid var(--glass-border);
        }

        .user-menu {
            position: relative;
            display: flex;
            align-items: center;
        }

        .btn-login {
            height: 36px;
            padding: 0 16px;
            background: var(--gradient-primary);
            color: white;
            border: none;
            border-radius: var(--radius-md);
            font-size: 0.875rem;
            font-weight: 600;
            text-decoration: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            margin-left: 16px;
            transition: box-shadow 0.15s ease;
        }

        .btn-login:hover {
            box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
        }

        .user-dropdown {
            position: relative;
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--gradient-primary);
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            color: white;
            font-size: 0.875rem;
            transition: var(--transition-base);
        }

        .user-avatar:hover {
            transform: scale(1.05);
            box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.3);
        }

        .user-dropdown-menu {
            display: none;
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            min-width: 260px;
            max-width: 300px;
            max-height: calc(100vh - 100px);
            overflow-y: auto;
            overscroll-behavior: contain;
            padding-bottom: 6px;
            background: var(--bg-card);
            border: 1px solid var(--border-primary);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-lg);
            z-index: 1001;
            padding: 4px 0;
        }

        .user-dropdown-menu.show {
            display: block;
        }

        /* Subtle scrollbar inside the user menu (Webkit / Chromium) */
        .user-dropdown-menu::-webkit-scrollbar {
            width: 6px;
        }
        .user-dropdown-menu::-webkit-scrollbar-track {
            background: transparent;
        }
        .user-dropdown-menu::-webkit-scrollbar-thumb {
            background: var(--border-primary);
            border-radius: 3px;
        }
        .user-dropdown-menu::-webkit-scrollbar-thumb:hover {
            background: var(--text-muted);
        }
        /* Firefox */
        .user-dropdown-menu {
            scrollbar-width: thin;
            scrollbar-color: var(--border-primary) transparent;
        }

        .user-dropdown-menu .user-info {
            padding: 10px 16px 8px;
        }

        .user-dropdown-menu .user-name {
            display: block;
            font-weight: 600;
            font-size: 0.9rem;
            color: var(--text-primary);
        }

        .user-dropdown-menu .user-email {
            display: block;
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 3px;
        }

        .user-dropdown-menu hr {
            border: none;
            border-top: 1px solid var(--border-primary);
            margin: 4px 0;
        }

        /* the digest toggle is a <button> reusing the item look */
        .user-dropdown-menu button.dropdown-item {
            width: 100%;
            background: none;
            border: none;
            cursor: pointer;
            font: inherit;
            text-align: left;
        }

        .user-dropdown-menu .dropdown-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 7px 16px;
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 0.875rem;
            transition: background 0.15s ease, color 0.15s ease;
            border-radius: 0;
        }

        .user-dropdown-menu .dropdown-item:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
        }

        .user-dropdown-menu .dropdown-item-danger {
            color: var(--accent-red);
        }

        .user-dropdown-menu .dropdown-item-danger:hover {
            background: rgba(239, 68, 68, 0.08);
            color: var(--accent-red);
        }

        .btn-modern-danger:disabled {
            opacity: 0.4;
            cursor: not-allowed;
            transform: none;
        }

        .delete-account-warning-list {
            list-style: none;
            padding: 0;
            margin: 12px 0;
        }

        .delete-account-warning-list li {
            padding: 6px 0;
            color: var(--text-secondary);
            font-size: 0.875rem;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .delete-account-warning-list li::before {
            content: '\2022';
            color: var(--accent-red);
            font-weight: bold;
        }

        /* Settings sections in dropdown */
        .dropdown-section {
            padding: 4px 16px 6px;
        }

        .dropdown-section-label {
            font-size: 0.6875rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            font-weight: 600;
            margin-bottom: 4px;
        }

        .language-options {
            display: flex;
            flex-direction: column;
            gap: 1px;
        }

        .language-option {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 4px 8px;
            border-radius: var(--radius-sm);
            cursor: pointer;
            transition: background 0.15s ease;
            color: var(--text-secondary);
            font-size: 0.85rem;
        }

        .language-option:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
        }

        .language-option input[type="radio"] {
            accent-color: var(--accent-primary);
            width: 15px;
            height: 15px;
            margin: 0;
            flex-shrink: 0;
        }

        .domicile-select {
            width: 100%;
            margin: 4px 0 2px;
            padding: 8px 10px;
            background: var(--bg-secondary);
            color: var(--text-primary);
            border: 1px solid var(--glass-border);
            border-radius: 8px;
            font-size: 0.88rem;
            cursor: pointer;
        }
        .domicile-select:focus {
            outline: none;
            border-color: var(--accent-blue);
        }
        .domicile-select option {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }

        .language-option input[type="radio"]:checked + span {
            color: var(--text-primary);
            font-weight: 500;
        }

        /* (help-toggle removed — glossary moved to Help dropdown) */

        /* Light theme nav */
        body.light-theme nav {
            background: rgba(255, 255, 255, 0.95);
            border-bottom-color: var(--border-primary);
        }

        body.light-theme .hamburger-btn {
            border-color: var(--border-primary);
            color: var(--text-primary);
        }

        /* (light-theme help-toggle removed) */

        /* ============================================
           CARDS - Revolut Style
           ============================================ */

        .card {
            background: var(--bg-card);
            border: 1px solid var(--border-primary);
            border-radius: var(--radius-xl);
            padding: var(--space-lg);
            margin-bottom: var(--space-lg);
            transition: var(--transition-base);
        }

        .card:hover {
            border-color: var(--border-secondary);
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: var(--space-lg);
            padding-bottom: var(--space-md);
            border-bottom: 1px solid var(--border-primary);
        }

        .card-title {
            font-size: 1.2rem;
            font-weight: 600;
            color: var(--text-primary);
            letter-spacing: -0.3px;
        }

        /* ============================================
           BUTTONS - Revolut Style
           ============================================ */

        .btn, button, [type="button"], [type="submit"] {
            font-family: inherit;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition-base);
        }

        /* ====================================================
           UNIFIED BUTTONS (Phase 11 — spec part 2.4)

           Two variants per spec: Primary (filled, high contrast)
           and Secondary (transparent + border). Plus Danger /
           Success for semantic actions. All share the same
           padding, radius (Bento 8px), font weight, transitions.

           No more translateY hover jump, no more glow shadow —
           calm, premium per spec part 1 ("klidný finanční vzhled
           — barva nese informaci, ne dramatičnost"). One CSS
           change ripples through every .btn-modern* and .btn-*
           call site in the app.
           ==================================================== */

        /* Shared base — all variants. */
        .btn-primary, .btn-modern-primary,
        .btn-secondary, .btn-modern-secondary,
        .btn-success, .btn-modern-success,
        .btn-danger, .btn-modern-danger {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 9px 18px;
            border-radius: var(--bento-radius);
            font-family: var(--font-ui);
            font-size: 0.88rem;
            font-weight: 500;
            line-height: 1.2;
            cursor: pointer;
            text-decoration: none;
            transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
            border: 1px solid transparent;
        }

        /* Primary — filled blue, white text. High contrast. */
        .btn-primary, .btn-modern-primary {
            background: var(--accent-primary);
            color: white;
        }
        .btn-primary:hover, .btn-modern-primary:hover {
            background: #0052cc;
        }

        /* Secondary — transparent + border. Inherits text from theme. */
        .btn-secondary, .btn-modern-secondary {
            background: transparent;
            color: var(--text-primary);
            border-color: var(--bento-border);
        }
        .btn-secondary:hover, .btn-modern-secondary:hover {
            background: var(--bento-hover);
            border-color: var(--text-muted);
        }

        /* Success — filled green (use for "Save" / "Confirm" actions). */
        .btn-success, .btn-modern-success {
            background: var(--accent-green);
            color: white;
        }
        .btn-success:hover, .btn-modern-success:hover {
            background: #00b371;
        }

        /* Danger — semantic red, soft fill that gets stronger on hover. */
        .btn-danger, .btn-modern-danger {
            background: var(--danger-soft);
            color: var(--danger-text);
            border-color: rgba(248, 113, 113, 0.25);
        }
        .btn-danger:hover, .btn-modern-danger:hover {
            background: var(--accent-red);
            color: white;
            border-color: var(--accent-red);
        }

        /* Disabled state — works across all variants */
        .btn-primary:disabled, .btn-modern-primary:disabled,
        .btn-secondary:disabled, .btn-modern-secondary:disabled,
        .btn-success:disabled, .btn-modern-success:disabled,
        .btn-danger:disabled, .btn-modern-danger:disabled,
        [class*="btn-"][aria-disabled="true"] {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .btn-sm {
            padding: 6px 12px;
            font-size: 0.8rem;
        }

        .btn-lg {
            padding: var(--space-md) var(--space-xl);
            font-size: 1rem;
        }

        .btn-icon {
            width: 40px;
            height: 40px;
            padding: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: var(--radius-md);
        }

        /* ============================================
           FORM INPUTS - Revolut Style
           ============================================ */

        input, select, textarea {
            font-family: inherit;
            font-size: 0.9375rem;
            color: var(--text-primary);
            background: var(--bg-input);
            border: 1px solid var(--border-primary);
            border-radius: var(--radius-md);
            padding: var(--space-sm) var(--space-md);
            transition: var(--transition-base);
            width: 100%;
        }

        input:focus, select:focus, textarea:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15);
        }

        input::placeholder, textarea::placeholder {
            color: var(--text-muted);
        }

        select {
            appearance: none;
            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='%23666666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 12px center;
            padding-right: 36px;
            cursor: pointer;
        }

        select option {
            background: var(--bg-secondary, #12121a);
            color: var(--text-primary, #ffffff);
        }

        /* ── Custom Dropdown (shared component) ── */
        .custom-dropdown {
            position: relative;
            min-width: 220px;
            max-width: 300px;
        }
        .dropdown-selected {
            padding: 6px 28px 6px 10px;
            border-radius: 8px;
            border: 1px solid var(--glass-border);
            background: var(--bg-tertiary);
            color: var(--text-primary);
            font-size: 0.82rem;
            cursor: pointer;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 8px center;
            transition: border-color 0.2s;
        }
        .dropdown-selected:hover,
        .custom-dropdown.open .dropdown-selected {
            border-color: var(--accent-blue);
        }
        .dropdown-list {
            display: none;
            position: absolute;
            top: calc(100% + 4px);
            left: 0;
            min-width: 100%;
            width: max-content;
            max-height: 320px;
            overflow-y: auto;
            background: var(--bg-secondary);
            border: 1px solid var(--glass-border);
            border-radius: 8px;
            z-index: 1001;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
            padding: 4px 0;
        }
        .custom-dropdown.open .dropdown-list {
            display: block;
        }
        /* Searchable combobox: a type-to-filter input pinned at the top of the
           dropdown list (injected by initCustomDropdown). */
        .dropdown-search {
            position: sticky;
            top: 0;
            width: 100%;
            box-sizing: border-box;
            padding: 8px 12px;
            margin: 0 0 4px;
            background: var(--bg-secondary);
            border: none;
            border-bottom: 1px solid var(--glass-border);
            color: var(--text-primary);
            font-size: 0.82rem;
            outline: none;
        }
        .dropdown-search::placeholder { color: var(--text-muted); }
        .dropdown-item {
            display: grid;
            grid-template-columns: 70px 1fr;
            gap: 10px;
            align-items: center;
            padding: 6px 12px;
            cursor: pointer;
            font-size: 0.82rem;
            transition: background 0.15s;
        }
        .dropdown-item:hover {
            background: rgba(255, 255, 255, 0.05);
        }
        .dropdown-item.selected {
            background: rgba(59, 130, 246, 0.15);
        }
        .dropdown-item .symbol {
            font-weight: 600;
            color: var(--text-primary);
        }
        .dropdown-item .name {
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .dropdown-item[data-symbol=""] {
            display: block;
            color: var(--text-secondary);
        }
        .dropdown-item[data-symbol=""] .symbol {
            font-weight: 400;
            color: var(--text-secondary);
        }
        body.light-theme .dropdown-selected {
            background: rgba(0, 0, 0, 0.04);
            border-color: rgba(0, 0, 0, 0.12);
        }
        body.light-theme .dropdown-list {
            background: #fff;
            border-color: rgba(0, 0, 0, 0.12);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        }
        body.light-theme .dropdown-item:hover {
            background: rgba(0, 0, 0, 0.04);
        }
        body.light-theme select option {
            background: #ffffff;
            color: #24292f;
        }
        @media (max-width: 768px) {
            .custom-dropdown {
                min-width: 0;
                max-width: 100%;
                width: 100%;
            }
        }

        /* ── Filter Select (shared component) ── */
        .filter-select {
            padding: 6px 28px 6px 10px;
            border-radius: 8px;
            border: 1px solid var(--glass-border);
            background: var(--bg-tertiary);
            color: var(--text-primary);
            font-size: 0.82rem;
            outline: none;
            transition: border-color 0.2s;
            cursor: pointer;
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 8px center;
            width: auto;
        }
        .filter-select:hover,
        .filter-select:focus {
            border-color: var(--accent-blue);
        }
        .filter-select option {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }
        .filter-custom-input {
            width: 60px;
            padding: 6px 8px;
            border-radius: 8px;
            border: 1px solid var(--accent-blue);
            background: var(--bg-tertiary);
            color: var(--text-primary);
            font-size: 0.82rem;
            outline: none;
        }
        .filter-custom-input::-webkit-inner-spin-button { opacity: 0.5; }
        body.light-theme .filter-select {
            background: rgba(0, 0, 0, 0.04);
            border-color: rgba(0, 0, 0, 0.12);
        }
        body.light-theme .filter-select option {
            background: #fff;
            color: #333;
        }
        body.light-theme .filter-custom-input {
            background: rgba(0, 0, 0, 0.04);
            border-color: var(--accent-blue);
        }

        /* ── Filter Search Input (shared component) ── */
        .filter-search-input {
            padding: 6px 10px 6px 32px;
            border-radius: 8px;
            border: 1px solid var(--glass-border);
            background: var(--bg-tertiary);
            color: var(--text-primary);
            font-family: inherit;
            font-size: 0.82rem;
            outline: none;
            min-width: 170px;
            max-width: 240px;
            transition: border-color 0.2s, box-shadow 0.2s;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: 10px center;
        }
        .filter-search-input::placeholder {
            color: var(--text-muted);
        }
        .filter-search-input:hover,
        .filter-search-input:focus {
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
        }
        body.light-theme .filter-search-input {
            background-color: rgba(0, 0, 0, 0.04);
            border-color: rgba(0, 0, 0, 0.12);
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
        }

        /* ── Watchlist Filter Bar ── */
        .watchlist-filter-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px 0;
            gap: 12px;
        }
        .watchlist-count {
            background: var(--accent-blue);
            color: #fff;
            font-size: 0.75rem;
            font-weight: 600;
            padding: 2px 10px;
            border-radius: 12px;
            white-space: nowrap;
        }
        @media (max-width: 768px) {
            .filter-search-input {
                min-width: 0;
                max-width: none;
                flex: 1;
            }
        }

        label {
            display: block;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-secondary);
            margin-bottom: var(--space-xs);
        }

        .form-group {
            margin-bottom: var(--space-md);
        }

        /* ============================================
           TABLES - Revolut Style
           ============================================ */

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th {
            text-align: left;
            font-size: 0.85rem;
            font-weight: 600;
            letter-spacing: 0;
            color: var(--text-muted);
            padding: var(--space-md);
            border-bottom: 1px solid var(--border-primary);
        }

        td {
            padding: var(--space-md);
            border-bottom: 1px solid var(--border-primary);
            color: var(--text-secondary);
            font-size: 0.9375rem;
        }

        tbody tr:nth-child(even) td {
            background: rgba(255, 255, 255, 0.015);
        }

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

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

        /* Number styling */
        .number, .amount {
            font-variant-numeric: tabular-nums;
            font-feature-settings: "tnum";
        }

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

        .amount-negative, .negative, .red {
            color: var(--accent-red) !important;
        }

        /* Grid */
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: var(--space-xl);
        }

        /* Stats */
        .stat {
            text-align: center;
        }

        .stat-value {
            font-size: 2rem;
            font-weight: bold;
            color: var(--text-primary);
        }

        .stat-label {
            font-size: 0.875rem;
            color: var(--text-muted);
            margin-top: 5px;
        }

        .stat-value.positive, .positive { color: var(--accent-green); }
        .stat-value.negative, .negative { color: var(--accent-red); }

        /* Buttons */
        .btn {
            display: inline-block;
            padding: 8px 16px;
            border: none;
            border-radius: 6px;
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            text-decoration: none;
            transition: all 0.2s;
        }

        .btn-primary {
            background: #238636;
            color: white;
        }

        .btn-primary:hover {
            background: #2ea043;
        }

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

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

        .btn-danger {
            background: #da3633;
            color: white;
        }

        .btn-danger:hover {
            background: #f85149;
        }

        .btn-sm {
            padding: 4px 10px;
            font-size: 0.75rem;
        }

        /* Tables */
        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid var(--border-primary);
            color: var(--text-secondary);
        }

        th {
            font-weight: 600;
            color: var(--text-muted);
            font-size: 0.875rem;
        }

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

        /* Forms */
        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .form-control {
            width: 100%;
            padding: 10px 12px;
            background: var(--bg-input);
            border: 1px solid var(--border-primary);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 1rem;
            color-scheme: dark;
        }

        .form-control:focus {
            outline: none;
            border-color: var(--text-link);
            box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
        }

        /* Badge */
        .badge {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: 500;
        }

        .badge-success { background: #238636; color: white; }
        .badge-warning { background: #9e6a03; color: white; }
        .badge-danger { background: #da3633; color: white; }
        .badge-info { background: #1f6feb; color: white; }
        .badge-secondary { background: var(--bg-tertiary); color: var(--text-muted); }

        /* Score badges */
        .score-badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 20px;
            font-weight: bold;
            font-size: 0.9rem;
        }
        .score-excellent { background: #238636; color: white; }
        .score-good { background: #3fb950; color: white; }
        .score-moderate { background: #9e6a03; color: white; }
        .score-poor { background: #da3633; color: white; }

        /* Stock link */
        .stock-link {
            color: var(--text-link);
            text-decoration: none;
        }
        .stock-link:hover {
            text-decoration: underline;
        }

        /* Toggle */
        .toggle {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 26px;
        }

        .toggle input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: var(--border-primary);
            border-radius: 26px;
            transition: 0.3s;
        }

        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 20px;
            width: 20px;
            left: 3px;
            bottom: 3px;
            background: white;
            border-radius: 50%;
            transition: 0.3s;
        }

        .toggle input:checked + .toggle-slider {
            background: var(--accent-green-dark);
        }

        .toggle input:checked + .toggle-slider:before {
            transform: translateX(24px);
        }

        /* Utilities */
        .text-right { text-align: right; }
        .text-center { text-align: center; }
        .mt-20 { margin-top: 20px; }
        .mb-20 { margin-bottom: 20px; }

        /* Modal - Modern 2024/2025 */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            z-index: 1000;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .modal-overlay.active {
            display: flex;
            animation: fadeIn 0.2s ease-out;
        }

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

        @keyframes slideUp {
            from { opacity: 0; transform: translateY(20px) scale(0.95); }
            to { opacity: 1; transform: translateY(0) scale(1); }
        }

        .modal {
            background: var(--glass-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--glass-border);
            border-radius: var(--card-radius);
            padding: 28px;
            width: 90%;
            max-width: 500px;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: var(--shadow-elevated), 0 0 60px rgba(0, 0, 0, 0.3);
            animation: slideUp 0.3s ease-out;
        }

        /* audit F10/F32: width:90% + 20px overlay padding + 28px box padding
           left ~230px of form on a 320px phone — inputs shrank to ~37px */
        @media (max-width: 576px) {
            .modal-overlay { padding: 12px; }
            /* !important: two import modals carry inline min-width/width/resize
               meant for desktop — on phones the viewport wins, always */
            .modal {
                width: 100% !important;
                min-width: 0 !important;
                max-width: 100% !important;
                padding: 20px 16px;
                resize: none !important;
            }
        }

        /* Modal hardening: dvh respects mobile browser chrome (URL bar) so the
           footer never hides behind it; vh keeps older browsers working */
        .modal {
            max-height: calc(100vh - 24px);
            max-height: calc(100dvh - 24px);
        }

        /* Shared modal footer: right-aligned on desktop, wraps to full-width
           rows on narrow screens instead of pushing buttons off the edge */
        .modal-footer {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            flex-wrap: wrap;
            margin-top: 20px;
        }
        @media (max-width: 400px) {
            .modal-footer > button, .modal-footer > a { flex: 1 1 auto; }
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            padding-bottom: 16px;
            border-bottom: 1px solid var(--glass-border);
        }

        .modal-header h3 {
            font-size: 1.25rem;
            font-weight: 600;
            background: linear-gradient(135deg, var(--text-primary), var(--accent-blue));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin: 0;
        }

        .modal-close {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            color: var(--text-muted);
            font-size: 1.25rem;
            cursor: pointer;
            transition: var(--transition-smooth);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .modal-close:hover {
            background: rgba(239, 68, 68, 0.1);
            border-color: #ef4444;
            color: #ef4444;
            transform: rotate(90deg);
        }

        /* Modal form elements */
        .modal .form-group {
            margin-bottom: 20px;
        }

        .modal .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--text-secondary);
            font-size: 0.9rem;
        }

        .modal .form-control {
            width: 100%;
            padding: 12px 14px;
            background: var(--bg-input);
            border: 1px solid var(--glass-border);
            border-radius: 10px;
            color: var(--text-secondary);
            font-size: 1rem;
            transition: var(--transition-smooth);
            color-scheme: dark;
        }

        .modal .form-control:focus {
            outline: none;
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
        }

        .modal .btn {
            padding: 12px 24px;
            border-radius: 10px;
            font-weight: 600;
            transition: var(--transition-smooth);
        }

        .modal .btn-primary {
            background: var(--gradient-blue);
            border: none;
            color: white;
            box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
        }

        .modal .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
        }

        /* Login Modal — compact Google-only */
        .login-modal {
            max-width: 420px;
            padding: 24px 28px;
        }

        .btn-google-modal {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            padding: 12px 20px;
            font-size: 0.95rem;
            font-weight: 500;
            font-family: inherit;
            color: #333;
            background: #fff;
            border: 1px solid rgba(0, 0, 0, 0.15);
            border-radius: 10px;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-google-modal:hover {
            background: #f8f8f8;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .btn-google-modal svg {
            flex-shrink: 0;
        }

        .login-modal-subtitle {
            font-size: 0.85rem;
            color: var(--text-muted);
            margin: 0 0 18px 0;
        }

        .login-trust {
            margin-top: 18px;
            padding-left: 0;
            list-style: none;
            font-size: 0.82rem;
            color: var(--text-muted);
            opacity: 0.85;
        }

        .login-trust li {
            margin-bottom: 6px;
        }

        /* Microsoft button — modal */
        .btn-microsoft-modal {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            padding: 12px 20px;
            font-size: 0.95rem;
            font-weight: 500;
            font-family: inherit;
            color: #fff;
            background: #2f2f2f;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.2s ease;
            margin-top: 10px;
        }

        .btn-microsoft-modal:hover {
            background: #404040;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        body.light-theme .btn-microsoft-modal {
            background: #fff;
            color: #333;
            border-color: rgba(0, 0, 0, 0.15);
        }

        body.light-theme .btn-microsoft-modal:hover {
            background: #f8f8f8;
        }

        /* Auth divider — modal */
        .auth-divider-modal {
            display: flex;
            align-items: center;
            margin: 14px 0;
            gap: 10px;
        }

        .auth-divider-modal::before,
        .auth-divider-modal::after {
            content: '';
            flex: 1;
            height: 1px;
            background: var(--glass-border);
        }

        .auth-divider-modal span {
            color: var(--text-muted);
            font-size: 0.8rem;
            text-transform: lowercase;
        }

        /* Magic link — modal */
        .magic-link-modal-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .magic-link-modal-input {
            width: 100%;
            padding: 11px 14px;
            background: var(--bg-tertiary);
            border: 1px solid var(--glass-border);
            border-radius: 10px;
            color: var(--text-primary);
            font-size: 0.9rem;
            font-family: inherit;
            outline: none;
            transition: border-color 0.2s;
            box-sizing: border-box;
        }

        body.light-theme .magic-link-modal-input {
            background: #f8f8f8;
            border-color: rgba(0, 0, 0, 0.12);
        }

        .magic-link-modal-input:focus {
            border-color: var(--accent-blue);
        }

        .magic-link-modal-input::placeholder {
            color: var(--text-muted);
        }

        .btn-magic-link-modal {
            width: 100%;
            padding: 11px 20px;
            background: transparent;
            border: 1px solid var(--accent-blue);
            border-radius: 10px;
            color: var(--accent-blue);
            font-size: 0.9rem;
            font-weight: 600;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-magic-link-modal:hover {
            background: rgba(59, 130, 246, 0.1);
        }

        .btn-magic-link-modal:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .magic-link-modal-error {
            color: var(--accent-red);
            font-size: 0.8rem;
            margin-top: 6px;
            text-align: center;
        }

        .magic-link-modal-success {
            text-align: center;
            padding: 8px 0;
        }

        .magic-link-modal-success svg {
            margin-bottom: 6px;
        }

        .magic-link-modal-success span {
            display: block;
            font-size: 0.95rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 4px;
        }

        .magic-link-modal-success p {
            color: var(--text-muted);
            font-size: 0.78rem;
            margin: 0;
        }

        /* Light theme modal */
        body.light-theme .modal {
            background: rgba(255, 255, 255, 0.95);
            border-color: rgba(0, 0, 0, 0.08);
        }

        body.light-theme .modal-close {
            background: rgba(0, 0, 0, 0.05);
            border-color: rgba(0, 0, 0, 0.1);
        }

        body.light-theme .modal .form-control {
            background: rgba(255, 255, 255, 0.8);
            border-color: rgba(0, 0, 0, 0.1);
            color-scheme: light;
        }

        /* Theme Toggle Icons */
        .theme-icon-light { display: none; }
        .theme-icon-dark { display: inline; }
        body.light-theme .theme-icon-light { display: inline; }
        body.light-theme .theme-icon-dark { display: none; }

        /* Global Help Panel */
        .global-help-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.7);
            z-index: 2000;
            justify-content: center;
            align-items: flex-start;
            padding: 50px 20px;
            overflow-y: auto;
        }
        .global-help-overlay.active {
            display: flex;
        }
        .global-help-panel {
            background: var(--bg-secondary);
            border: 1px solid var(--border-primary);
            border-radius: 12px;
            padding: 30px;
            width: 100%;
            max-width: 1000px;
            max-height: calc(100vh - 100px);
            overflow-y: auto;
        }
        .global-help-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--border-primary);
        }
        .global-help-header h2 {
            margin: 0;
            color: var(--text-primary);
            font-size: 1.5rem;
        }
        .global-help-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 2rem;
            cursor: pointer;
            line-height: 1;
            padding: 0;
            transition: color 0.2s;
        }
        .global-help-close:hover {
            color: var(--accent-red);
        }
        .help-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 25px;
        }
        .help-section {
            background: var(--bg-tertiary);
            border-radius: 8px;
            padding: 20px;
        }
        .help-section h3 {
            color: var(--text-link);
            margin-bottom: 15px;
            font-size: 1.1rem;
            border-bottom: 1px solid var(--border-primary);
            padding-bottom: 10px;
        }
        .help-section dl {
            margin: 0;
        }
        .help-section dt {
            font-weight: 600;
            color: var(--text-primary);
            margin-top: 12px;
            font-size: 0.95rem;
        }
        .help-section dt:first-child {
            margin-top: 0;
        }
        .help-section dd {
            margin: 5px 0 0 0;
            color: var(--text-secondary);
            font-size: 0.85rem;
            line-height: 1.5;
        }
        body.light-theme .global-help-overlay {
            background: rgba(0,0,0,0.4);
        }
        body.light-theme .global-help-panel {
            background: #ffffff;
            border-color: #d0d7de;
        }
        body.light-theme .help-section {
            background: #f6f8fa;
        }

        /* Page Header Modern */
        .page-header-modern {
            margin-bottom: var(--space-xl);
        }

        .page-header-modern .page-header-content {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .page-subtitle {
            color: var(--text-muted);
            font-size: 0.95rem;
            margin: 8px 0 0 0;
        }

        /* Page Info Box - help/description for each page */
        /* ============================================
           COLLAPSIBLE HELP BOX - Modern Design
           ============================================ */

        /* Help Toggle Button */
        .help-toggle-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            background: var(--glass-bg);
            border: 1px solid var(--border-primary);
            border-radius: var(--radius-full);
            color: var(--text-secondary);
            font-size: 0.8rem;
            font-weight: 500;
            cursor: pointer;
            transition: var(--transition-base);
            backdrop-filter: blur(10px);
        }

        .help-toggle-btn:hover {
            background: var(--glass-hover);
            border-color: var(--accent-blue);
            color: var(--accent-blue);
            transform: translateY(-1px);
        }

        .help-toggle-btn.active {
            background: rgba(0, 102, 255, 0.1);
            border-color: var(--accent-blue);
            color: var(--accent-blue);
        }

        .help-toggle-btn .help-icon {
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--accent-blue);
            color: white;
            border-radius: 50%;
            font-size: 11px;
            font-weight: 700;
            transition: var(--transition-base);
        }

        .help-toggle-btn:hover .help-icon,
        .help-toggle-btn.active .help-icon {
            transform: scale(1.1);
        }

        /* Collapsible Page Info — migrated to Bento (Phase 4).
           Was a blue→green gradient with thick 4px left border.
           Now: solid Bento background, subtle 2px left accent. */
        .page-info {
            background: var(--bento-bg);
            border: 1px solid var(--bento-border);
            border-left: 2px solid var(--accent-blue);
            border-radius: var(--bento-radius);
            overflow: hidden;
            /* Default: HIDDEN (prevents flash on load) */
            max-height: 0;
            opacity: 0;
            transform: translateY(-10px);
            padding: 0 20px;
            margin-top: 0;
            margin-bottom: 0;
            transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                        opacity 0.3s ease,
                        transform 0.3s ease,
                        margin 0.3s ease,
                        padding 0.3s ease;
        }

        .page-info.expanded {
            max-height: 500px;
            opacity: 1;
            transform: translateY(0);
            padding: 16px 20px;
            margin-top: 16px;
            margin-bottom: var(--space-lg);
        }

        .page-info-inner {
            display: flex;
            gap: 15px;
            align-items: flex-start;
        }

        .page-info .info-icon {
            width: 32px;
            height: 32px;
            min-width: 32px;
            background: var(--accent-blue);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 16px;
            flex-shrink: 0;
        }

        .page-info .info-content {
            flex: 1;
            min-width: 0;
        }

        .page-info .info-content h4 {
            margin: 0 0 8px 0;
            color: var(--text-primary);
            font-size: 0.95rem;
            font-weight: 600;
        }

        .page-info .info-content p {
            margin: 0;
            color: var(--text-secondary);
            font-size: 0.875rem;
            line-height: 1.5;
        }

        .page-info .info-content ul {
            margin: 10px 0 0 0;
            padding-left: 18px;
            color: var(--text-secondary);
            font-size: 0.85rem;
            line-height: 1.6;
        }

        .page-info .info-content ul li {
            margin-bottom: 4px;
        }

        .page-info .info-content ul li strong {
            color: var(--text-primary);
        }

        body.light-theme .page-info {
            background: linear-gradient(135deg, rgba(9, 105, 218, 0.06) 0%, rgba(26, 127, 55, 0.03) 100%);
        }

        body.light-theme .help-toggle-btn {
            background: rgba(255, 255, 255, 0.8);
        }

        /* Page Header with Help Button */
        .page-header-with-help {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            flex-wrap: wrap;
        }

        .page-header-with-help .page-title-section {
            flex: 1;
            min-width: 200px;
        }

        /* Legacy .page-info support (always visible) */
        .page-info.always-visible,
        .page-info.expanded.always-visible {
            max-height: none;
            opacity: 1;
            transform: none;
            padding: 15px 20px;
            margin-top: 16px;
            margin-bottom: var(--space-lg);
        }

        /* Prevent flash of untranslated content */
        [data-i18n]:not(.i18n-ready) {
            visibility: visible; /* Keep visible but allow quick update */
        }

        /* Headings */
        h1, h2, h3, h4, h5, h6 {
            color: var(--text-primary);
        }

        /* Links */
        a {
            color: var(--text-link);
        }

        /* Small/muted text */
        small, .text-muted {
            color: var(--text-muted);
        }

        /* Help box */
        .help-box {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-primary);
            border-left: 4px solid var(--text-link);
            border-radius: 6px;
            padding: 15px;
            margin-bottom: 20px;
        }
        .help-box-title {
            margin-bottom: 10px;
            color: var(--text-link);
        }

        /* Scoring grid */
        .scoring-grid {
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 10px;
        }
        .scoring-item {
            padding: 10px;
            background: var(--bg-tertiary);
            border-radius: 6px;
        }
        .scoring-item strong {
            color: var(--text-muted);
        }
        .scoring-item p {
            font-size: 0.85rem;
            margin: 5px 0 0 0;
        }

        /* Light Theme */
        body.light-theme {
            background: #f6f8fa;
            color: #24292f;
        }
        body.light-theme nav {
            background: rgba(255, 255, 255, 0.82);
            border-bottom-color: rgba(0, 0, 0, 0.08);
        }
        body.light-theme .logo {
            color: #1a1a1a;
        }
        /* Light theme: adjust logo icon colors for visibility on white */
        body.light-theme .logo-icon .logo-stroke-primary {
            stroke: #0055cc;
        }
        body.light-theme .logo-icon .logo-fill-primary {
            fill: #0055cc;
        }
        body.light-theme .logo-icon .logo-fill-accent {
            fill: #0077e6;
        }
        body.light-theme .card {
            background: #ffffff;
            border-color: #d0d7de;
        }
        body.light-theme .card-title {
            color: #24292f;
        }
        body.light-theme th {
            color: #57606a;
        }
        body.light-theme th, body.light-theme td {
            border-bottom-color: #d0d7de;
        }
        body.light-theme tr:hover {
            background: #f6f8fa;
        }
        body.light-theme .form-control {
            background: #ffffff;
            border-color: #d0d7de;
            color: #24292f;
            color-scheme: light;
        }
        body.light-theme .btn-secondary {
            background: #f6f8fa;
            color: #24292f;
            border-color: #d0d7de;
        }
        body.light-theme .btn-secondary:hover {
            background: #eaeef2;
        }
        body.light-theme .badge-secondary {
            background: #eaeef2;
            color: #57606a;
        }
        body.light-theme .toggle-slider {
            background: #d0d7de;
        }
        body.light-theme .modal {
            background: #ffffff;
            border-color: #d0d7de;
        }
        body.light-theme .modal-overlay {
            background: rgba(0,0,0,0.4);
        }
        /* Light theme - Extended styles */
        body.light-theme .stat-value {
            color: #24292f;
        }
        body.light-theme .stat-label {
            color: #57606a;
        }
        body.light-theme .positive {
            color: #1a7f37;
        }
        body.light-theme .negative {
            color: #cf222e;
        }
        body.light-theme .stock-link {
            color: #0969da;
        }
        body.light-theme input[type="number"],
        body.light-theme input[type="text"],
        body.light-theme input[type="date"],
        body.light-theme select {
            background: #ffffff;
            border-color: #d0d7de;
            color: #24292f;
            color-scheme: light;
        }
        body.light-theme input:focus,
        body.light-theme select:focus {
            border-color: #0969da;
            box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.2);
        }
        body.light-theme .category-select,
        body.light-theme .shares-input,
        body.light-theme .cost-input {
            background: #ffffff;
            border-color: #d0d7de;
            color: #24292f;
        }
        body.light-theme .search-dropdown {
            background: #ffffff;
            border-color: #d0d7de;
        }
        body.light-theme .search-item {
            border-bottom-color: #d0d7de;
        }
        body.light-theme .search-item:hover {
            background: #f6f8fa;
        }
        body.light-theme .search-item-symbol {
            color: #0969da;
        }
        body.light-theme .search-item-name,
        body.light-theme .search-item-exchange {
            color: #57606a;
        }
        body.light-theme .category-header {
            background: #f6f8fa;
        }
        body.light-theme .category-item {
            background: #f6f8fa;
        }

        /* Stock Autocomplete Component */
        .stock-autocomplete {
            position: relative;
            width: 100%;
        }

        .stock-autocomplete input {
            width: 100%;
            padding: 10px 12px;
            background: var(--bg-input);
            border: 1px solid var(--border-primary);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 1rem;
        }

        .stock-autocomplete input:focus {
            outline: none;
            border-color: var(--text-link);
            box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
        }

        .stock-autocomplete-dropdown {
            position: absolute;
            top: 100%;
            left: 0;
            min-width: 340px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-primary);
            border-top: none;
            border-radius: 0 0 6px 6px;
            max-height: 250px;
            overflow-y: auto;
            z-index: 1000;
            display: none;
        }

        .stock-autocomplete-dropdown.active {
            display: block;
        }

        .stock-autocomplete-item {
            padding: 10px 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 10px;
            border-bottom: 1px solid var(--border-secondary);
        }

        .stock-autocomplete-item:last-child {
            border-bottom: none;
        }

        .stock-autocomplete-item:hover,
        .stock-autocomplete-item.selected {
            background: var(--bg-tertiary);
        }

        .stock-autocomplete-symbol {
            font-weight: 600;
            color: var(--text-link);
            min-width: 60px;
        }

        .stock-autocomplete-name {
            color: var(--text-secondary);
            font-size: 0.9rem;
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .stock-autocomplete-yield {
            color: var(--accent-green);
            font-size: 0.85rem;
            font-weight: 500;
        }

        .stock-autocomplete-loading,
        .stock-autocomplete-empty {
            padding: 15px;
            text-align: center;
            color: var(--text-muted);
            font-size: 0.9rem;
        }

        .stock-autocomplete-yahoo-action {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 16px;
            color: var(--accent-blue);
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            border-top: 1px solid var(--glass-border);
            transition: background 0.15s ease;
        }
        .stock-autocomplete-yahoo-action:hover,
        .stock-autocomplete-yahoo-action.selected {
            background: rgba(59, 130, 246, 0.1);
        }
        .stock-autocomplete-yahoo-action svg {
            flex-shrink: 0;
        }

        body.light-theme .stock-autocomplete input {
            background: #ffffff;
            border-color: #d0d7de;
            color: #24292f;
        }

        body.light-theme .stock-autocomplete-dropdown {
            background: #ffffff;
            border-color: #d0d7de;
        }

        body.light-theme .stock-autocomplete-item:hover {
            background: #f6f8fa;
        }

        body.light-theme .stock-autocomplete-symbol {
            color: #0969da;
        }
        body.light-theme .stock-autocomplete-yahoo-action {
            border-top-color: #d0d7de;
        }
        body.light-theme .stock-autocomplete-yahoo-action:hover,
        body.light-theme .stock-autocomplete-yahoo-action.selected {
            background: #f0f6ff;
        }
        body.light-theme .help-box {
            background: #ddf4ff;
            border-color: #0969da;
        }
        body.light-theme .cache-info {
            background: #f6f8fa;
        }
        body.light-theme .cache-age {
            color: #57606a;
        }
        body.light-theme .payback-bar-container,
        body.light-theme .mini-payback-bar {
            background: #d0d7de;
        }
        body.light-theme .safety-tooltip {
            background: #ffffff;
            border-color: #d0d7de;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }
        body.light-theme .safety-tooltip-bar {
            background: #d0d7de;
        }
        body.light-theme .safety-warnings {
            color: #9a6700;
        }
        body.light-theme .payback-item {
            border-bottom-color: #d0d7de;
        }
        body.light-theme .payback-item-details {
            color: #57606a;
        }
        body.light-theme h1, body.light-theme h2, body.light-theme h3 {
            color: #24292f;
        }
        body.light-theme .card-header {
            border-bottom-color: #d0d7de;
        }

        /* ============================================
           MODERN SHARED COMPONENTS
           ============================================ */

        /* Content offset — push content below sticky navbar */
        body > .container {
            padding-top: var(--navbar-height);
        }

        /* Section anchor scroll offset — avoids navbar covering anchored headings */
        section[id],
        [id].landing-section {
            scroll-margin-top: calc(var(--navbar-height) + 16px);
        }

        /* Modern Page Container */
        .modern-page,
        .investments-page,
        .tax-page,
        .ttd-page,
        .ir-page,
        .rcl-page {
            --glass-bg: rgba(255, 255, 255, 0.03);
            --glass-border: rgba(255, 255, 255, 0.08);
            --glass-hover: rgba(255, 255, 255, 0.06);
            position: relative;
            min-height: calc(100vh - var(--navbar-height));
            /* No extra horizontal padding: the single sidebar→content gutter
               is the base .container padding (clamp 16/3vw/48), so every page
               lines up with /portfolio-insights. Adding more here is what made
               these wrappers sit ~26px further right than the rest. */
            padding: 0;
        }

        /* Aurora Background Effect */
        .modern-page::before {
            content: '';
            position: fixed;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background:
                radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 40% 40%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
            animation: aurora 20s ease-in-out infinite;
            pointer-events: none;
            z-index: -1;
        }

        @keyframes aurora {
            0%, 100% { transform: translate(0, 0) rotate(0deg); }
            25% { transform: translate(2%, 2%) rotate(1deg); }
            50% { transform: translate(-1%, 3%) rotate(-1deg); }
            75% { transform: translate(1%, -2%) rotate(0.5deg); }
        }

        body.light-theme .modern-page {
            --glass-bg: rgba(255, 255, 255, 0.7);
            --glass-border: rgba(0, 0, 0, 0.08);
            --glass-hover: rgba(240, 245, 255, 0.95);
        }

        body.light-theme .modern-page::before {
            background:
                radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 40% 40%, rgba(16, 185, 129, 0.03) 0%, transparent 40%);
        }

        /* Modern Card — migrated to Bento tokens (Phase 4).
           Touches 37 templates instantly via the shared .card-modern
           class. Tighter radius (8px vs 16px), solid Bento bg, no
           heavy shadow — premium minimalist per spec part 1.3. */
        .card-modern {
            background: var(--bento-bg);
            border: 1px solid var(--bento-border);
            border-radius: var(--bento-radius);
            padding: 24px;
            margin-bottom: var(--space-xl);
            transition: background 0.15s, border-color 0.15s;
        }

        .card-modern:last-child {
            margin-bottom: 0;
        }

        .card-modern:hover {
            background: var(--bento-hover);
        }
        /* Light theme variants are now inherited automatically from the
           Phase-0 --bento-bg/--bento-border tokens which already define
           themselves per body.light-theme. No per-class override needed. */
        /* Light-mode "design pass": give every card depth via a soft shadow and
           a near-invisible border (instead of the flat hairline that read as
           sterile). Cards now lift off the page. Dark theme keeps its flat
           glass look. */
        body.light-theme .card-modern,
        body.light-theme .stat-card-modern,
        body.light-theme .group-card-modern {
            border-color: rgba(16, 24, 40, 0.05);
            box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 28px -18px rgba(16, 24, 40, 0.14);
        }
        body.light-theme .card-modern:hover {
            background: var(--bento-bg);
            box-shadow: 0 2px 6px rgba(16, 24, 40, 0.05), 0 18px 38px -20px rgba(16, 24, 40, 0.18);
        }

        /* ============================================
           STAT CARDS — migrated to Bento (Phase 8)
           Used on /calendar, /groups, and a few legacy spots.
           Numbers inside get mono via the typographic class .mono
           if the template chooses to add it; this rule set just
           handles the container and per-color left-edge accent.
           ============================================ */

        .stat-card-modern {
            background: var(--bento-bg);
            border: 1px solid var(--bento-border);
            border-radius: var(--bento-radius);
            padding: 18px 20px;
            position: relative;
            overflow: hidden;
            transition: background 0.15s, border-color 0.15s;
        }

        .stat-card-modern:hover {
            background: var(--bento-hover);
        }

        .stat-card-modern .stat-label {
            font-size: 0.7rem;
            font-weight: 600;
            color: var(--text-muted);
            margin-bottom: 10px;
            text-transform: uppercase;
            letter-spacing: 0.08em;
        }

        .stat-card-modern .stat-value {
            font-family: var(--font-mono);
            font-variant-numeric: tabular-nums;
            font-size: 1.7rem;
            font-weight: 700;
            color: var(--text-primary);
            letter-spacing: -0.02em;
            line-height: 1;
        }

        .stat-card-modern .stat-change {
            font-size: 0.78rem;
            font-weight: 600;
            margin-top: 10px;
            display: flex;
            align-items: center;
            gap: 4px;
            font-variant-numeric: tabular-nums;
        }

        .stat-card-modern .stat-change.positive { color: var(--success-text); }
        .stat-card-modern .stat-change.negative { color: var(--danger-text); }

        /* Subtle left-edge color accent — preserved for color-coded
           "kind of stat" hint (e.g. green = income, purple = forecast). */
        .stat-card-modern.green  { border-left: 2px solid var(--success-text); }
        .stat-card-modern.blue   { border-left: 2px solid var(--accent-blue); }
        .stat-card-modern.purple { border-left: 2px solid var(--accent-purple); }
        .stat-card-modern.orange { border-left: 2px solid var(--accent-orange); }
        /* Light-theme variants are inherited from Phase-0 bento tokens. */

        /* ============================================
           MODERN BUTTONS — base sizing
           (Variants live in the unified-buttons block above
           Phase 11. This rule just sets the common base for the
           .btn-modern class without a variant suffix.)
           ============================================ */

        .btn-modern {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 9px 18px;
            border-radius: var(--bento-radius);
            font-family: var(--font-ui);
            font-size: 0.88rem;
            font-weight: 500;
            line-height: 1.2;
            cursor: pointer;
            text-decoration: none;
            transition: background 0.15s, border-color 0.15s, color 0.15s;
            border: 1px solid transparent;
        }

        /* .btn-modern-primary / -secondary / -success / -danger
           variants are now defined once in the Phase-11 unified
           block above. The duplicated rules that used to live here
           (with translateY hover jumps and glow shadows) were
           overriding the unified styles. They're removed so the
           unified styles win. */

        /* .btn-modern-danger variant defined in the unified Phase-11
           block above. The duplicate that used to live here is removed
           so the unified style wins. */

        /* Modern Action Button */
        .action-btn-modern {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            border: 1px solid var(--glass-border);
            background: var(--glass-bg);
            color: var(--text-muted);
            cursor: pointer;
            transition: var(--transition-smooth);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .action-btn-modern:hover {
            background: var(--glass-hover);
            color: var(--text-link);
            border-color: var(--text-link);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
        }

        body.light-theme .action-btn-modern {
            background: #f1f5f9;
            border: 1px solid #cbd5e1;
            color: #475569;
        }

        body.light-theme .action-btn-modern:hover {
            background: linear-gradient(135deg, #e0f2fe 0%, #ede9fe 100%);
            border-color: #3b82f6;
            color: #1e40af;
        }

        /* Modern Table Row — unified transparent style */
        .table-row-modern {
            background: transparent;
            border-bottom: 1px solid rgba(255, 255, 255, 0.04);
            transition: background 0.15s;
        }

        .table-row-modern:hover {
            background: var(--glass-hover);
        }

        body.light-theme .table-row-modern {
            background: transparent;
            border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        }

        body.light-theme .table-row-modern:hover {
            background: rgba(0, 0, 0, 0.02);
        }

        /* ============================================
           STOCK CELL — reusable avatar + symbol + name
           ============================================ */
        .stock-cell {
            display: flex;
            align-items: center;
            gap: 10px;
            text-decoration: none;
            color: inherit;
        }
        .stock-cell:hover .stock-cell-sym { color: var(--accent-blue); }
        .stock-cell-avatar {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            font-weight: 700;
            font-size: 0.75rem;
            color: #fff;
            background: var(--avatar-bg, linear-gradient(135deg, #3b82f6, #8b5cf6));
            overflow: hidden;
            position: relative;
        }
        .stock-cell-avatar img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            border-radius: 6px;
            background: #fff;
            padding: 2px;
        }
        .stock-cell-avatar .avatar-fallback {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .stock-cell-info {
            display: flex;
            flex-direction: column;
            line-height: 1.3;
            min-width: 0;
        }
        .stock-cell-sym {
            font-weight: 700;
            font-size: 0.9rem;
            color: var(--text-primary);
            transition: color 0.15s;
        }
        .stock-cell-name {
            font-size: 0.75rem;
            color: var(--text-muted);
            max-width: 180px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* ============================================
           POSITIONS TABLE - Shared Data Table
           Used by investments.html, transactions.html
           ============================================ */

        .table-container {
            width: 100%;
            overflow-x: auto;
            padding: 0 16px 16px;
            -webkit-overflow-scrolling: touch;
        }

        .positions-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.9rem;
            /* Phase 12 — performance: opt-in to table-layout: fixed
               via the .table-fixed modifier class when a specific
               table sets explicit column widths. Global fixed layout
               would shrink columns without widths to equal slices,
               breaking ticker / name truncation. */
        }
        .positions-table.table-fixed { table-layout: fixed; }
        /* .bento-table already has table-layout: fixed by default
           (see Phase 0 declaration). */

        .positions-table th {
            font-weight: 600;
            color: var(--text-muted);
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            padding: 12px 10px;
            text-align: left;
            border-bottom: 1px solid var(--glass-border);
            white-space: nowrap;
            vertical-align: middle;
        }

        .positions-table .col-right { text-align: right; }
        .positions-table .col-center { text-align: center; }

        .positions-table th.sortable {
            cursor: pointer;
            user-select: none;
        }

        .positions-table th.sortable:hover {
            color: var(--text-link);
        }

        .positions-table th.sortable .sort-indicator {
            margin-left: 4px;
            font-size: 0.65rem;
            color: var(--text-muted);
            opacity: 0.5;
        }

        .positions-table th.sortable:hover .sort-indicator { opacity: 0.8; }

        .positions-table th.sortable.sort-active .sort-indicator {
            color: var(--text-link);
            opacity: 1;
            font-size: 0.7rem;
        }

        /* Disable base.html sort arrows for this table (uses own .sort-indicator) */
        .positions-table th[data-sort]::after,
        .positions-table th .sort-indicator::after {
            display: none !important;
            content: none !important;
        }

        /* .positions-table th tooltip sizing handled by unified .info-tip above */

        .positions-table tbody tr {
            border-bottom: 1px solid var(--glass-border);
            transition: background 0.12s;
        }

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

        /* Zebra striping — spec part 2.3 ("Střídej pozadí řádků pro
           snadné čtení"). Hover wins over zebra via specificity. */
        .positions-table tbody tr:nth-child(even) {
            background: var(--bento-hover);
        }

        .positions-table tbody tr:hover {
            background: var(--bento-hover);
        }

        .positions-table td {
            padding: 10px 8px;
            color: var(--text-primary);
            vertical-align: middle;
            font-variant-numeric: tabular-nums;
        }

        /* Numeric columns get the monospace font for vertical decimal
           alignment — spec part 1.3. Apply class .num OR .col-right on
           td/th cells that hold $ / % / shares / dates. */
        .positions-table td.col-right,
        .positions-table td.num,
        .positions-table th.num {
            font-family: var(--font-mono);
            letter-spacing: -0.01em;
        }

        /* Row actions — hidden until hover (spec part 2.3 "Destruktivní
           nebo editační tlačítka schovej, musí se objevit pouze při
           najetí myší"). Apply class .row-actions on the <td> that
           wraps Delete/Edit buttons. */
        .positions-table td.row-actions {
            text-align: right;
            opacity: 0;
            transition: opacity 0.12s;
        }
        .positions-table tbody tr:hover td.row-actions,
        .positions-table tbody tr:focus-within td.row-actions {
            opacity: 1;
        }

        .positions-table td.col-center {
            overflow: visible;
            white-space: nowrap;
        }

        /* Symbol cell */
        .symbol-cell {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .symbol-cell .symbol {
            color: var(--text-link);
            text-decoration: none;
            font-weight: 600;
            font-size: 0.95rem;
        }

        .symbol-cell .symbol:hover {
            text-decoration: underline;
        }

        .symbol-cell .badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 18px;
            height: 18px;
            border-radius: 4px;
            font-size: 0.6rem;
            font-weight: 700;
            text-transform: uppercase;
            flex-shrink: 0;
        }

        .symbol-cell .badge.monthly {
            background: rgba(16, 185, 129, 0.15);
            color: #10b981;
        }

        .symbol-cell .badge.quarterly {
            background: rgba(59, 130, 246, 0.15);
            color: #3b82f6;
        }

        .symbol-cell .badge.annual {
            background: rgba(139, 92, 246, 0.15);
            color: #8b5cf6;
        }

        /* P/L cell colors */
        .positions-table td.pl-positive { color: #10b981; }
        .positions-table td.pl-negative { color: #ef4444; }

        /* Colored value cells */
        .positions-table td.text-green { color: var(--accent-green); }
        .positions-table td.text-blue { color: var(--accent-blue); }

        /* Action buttons in tables */
        .action-btn {
            width: 30px;
            height: 30px;
            border-radius: 6px;
            border: 1px solid var(--glass-border);
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-left: 4px;
            transition: all 0.2s ease;
        }

        .action-btn:first-child { margin-left: 0; }

        .action-btn:hover {
            background: var(--glass-hover);
            color: var(--text-link);
            border-color: var(--text-link);
        }

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

        .action-btn.primary:hover {
            transform: scale(1.05);
        }

        .action-btn.danger:hover {
            background: rgba(239, 68, 68, 0.15);
            color: #ef4444;
            border-color: #ef4444;
        }

        /* Sell button in tables */
        .btn-sell-position {
            padding: 4px 12px;
            border-radius: 6px;
            border: 1px solid rgba(239, 68, 68, 0.3);
            background: rgba(239, 68, 68, 0.1);
            color: #ef4444;
            font-size: 0.78rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-sell-position:hover {
            background: rgba(239, 68, 68, 0.2);
            border-color: #ef4444;
        }
        /* Touch devices: the canonical Sell action keeps a 44px target
           (specific-lot sell UX correction, 15. 7. 2026 — applies to
           the Positions tab and transaction rows alike). */
        @media (max-width: 768px) {
            .btn-sell-position {
                min-height: 44px;
                padding: 8px 14px;
            }
        }

        /* Table footer (totals row) */
        .positions-table tfoot tr {
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
            border-top: 2px solid var(--glass-border);
            font-weight: 700;
        }

        .positions-table tfoot td {
            padding: 12px 10px;
        }

        /* Light theme table overrides */
        body.light-theme .positions-table tbody tr:hover {
            background: rgba(59, 130, 246, 0.04);
        }

        body.light-theme .action-btn {
            background: #f1f5f9;
            border-color: #cbd5e1;
            color: #475569;
        }

        body.light-theme .action-btn:hover {
            background: #e0f2fe;
            border-color: #3b82f6;
        }

        /* ============================================
           UNIFIED FREQUENCY BADGES
           Consistent badge styles across all pages
           ============================================ */

        .freq-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 6px;
            font-size: 0.72rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.02em;
        }
        .freq-badge-monthly { background: rgba(16, 185, 129, 0.15); color: #10b981; }
        .freq-badge-quarterly { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
        .freq-badge-annual { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
        .freq-badge-semiannual { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

        /* Mini frequency badge (symbol cells) */
        .freq-badge-mini {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 18px; height: 18px;
            border-radius: 4px;
            font-size: 0.6rem;
            font-weight: 700;
        }
        .freq-badge-mini.monthly { background: rgba(16, 185, 129, 0.15); color: #10b981; }
        .freq-badge-mini.quarterly { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
        .freq-badge-mini.annual { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
        .freq-badge-mini.semiannual { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

        /* ============================================
           SORTABLE TABLE SYSTEM
           Click column headers to sort
           ============================================ */

        th[data-sort] {
            cursor: pointer;
            user-select: none;
            transition: background 0.2s ease;
        }

        th[data-sort]:hover {
            background: var(--glass-hover) !important;
        }

        th[data-sort]::after {
            content: '';
            display: inline-block;
            width: 0;
            height: 0;
            margin-left: 6px;
            vertical-align: middle;
            opacity: 0.3;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
            border-bottom: 5px solid currentColor;
        }

        th[data-sort].sort-asc::after {
            opacity: 1;
            border-bottom: 5px solid var(--accent-blue);
            border-top: none;
        }

        th[data-sort].sort-desc::after {
            opacity: 1;
            border-bottom: none;
            border-top: 5px solid var(--accent-blue);
        }

        /* Sort indicator for headers with nested content */
        .sort-indicator {
            display: inline-block;
            margin-left: 6px;
            font-size: 10px;
            opacity: 0.4;
            transition: opacity 0.2s;
        }

        th[data-sort]:hover .sort-indicator {
            opacity: 0.7;
        }

        th[data-sort].sort-asc .sort-indicator::after {
            content: '▲';
            color: var(--accent-blue);
            opacity: 1;
        }

        th[data-sort].sort-desc .sort-indicator::after {
            content: '▼';
            color: var(--accent-blue);
            opacity: 1;
        }

        /* ============================================
           TOOLTIP SYSTEM
           Info icons with hover tooltips
           ============================================ */

        .th-with-tooltip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        /* Tooltip popup - positioned by JavaScript */
        #tooltip-popup {
            display: none;
            position: fixed;
            width: 240px;
            padding: 12px 14px;
            background: #1a1a1a;
            border: 1px solid #444;
            border-radius: 10px;
            color: #e0e0e0;
            font-size: 13px;
            font-weight: 400;
            line-height: 1.5;
            text-align: left;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
            z-index: 99999;
            pointer-events: none;
        }

        body.light-theme #tooltip-popup {
            background: white;
            border-color: #ddd;
            color: #333;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
        }

        body.light-theme .info-tip {
            background: rgba(59, 130, 246, 0.12);
            color: #2563eb;
            border-color: rgba(59, 130, 246, 0.45);
        }

        body.light-theme .info-tip:hover {
            background: #3b82f6;
            color: white;
            border-color: #3b82f6;
        }

        /* Modern Toggle */
        .toggle-modern {
            position: relative;
            width: 44px;
            height: 24px;
            background: var(--bg-tertiary);
            border-radius: 12px;
            cursor: pointer;
            transition: var(--transition-smooth);
        }

        .toggle-modern input { display: none; }

        .toggle-modern .slider {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 20px;
            height: 20px;
            background: var(--text-muted);
            border-radius: 50%;
            transition: var(--transition-smooth);
        }

        .toggle-modern input:checked + .slider {
            background: white;
            left: 22px;
        }

        .toggle-modern.active {
            background: var(--gradient-green);
        }

        body.light-theme .toggle-modern {
            background: #cbd5e1;
            border: 1px solid #94a3b8;
        }

        body.light-theme .toggle-modern .slider {
            background: #64748b;
        }

        body.light-theme .toggle-modern.active {
            background: linear-gradient(135deg, #10b981, #059669);
            border-color: #059669;
        }

        body.light-theme .toggle-modern.active .slider {
            background: white;
        }

        /* Gradient Title */
        .gradient-title {
            font-size: 2rem;
            font-weight: 700;
            color: var(--text-primary);
        }

        body.light-theme .gradient-title {
            color: #1e293b;
        }

        /* Animations */
        @keyframes fadeInUp {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        @keyframes scaleIn {
            from { opacity: 0; transform: scale(0.9); }
            to { opacity: 1; transform: scale(1); }
        }

        @keyframes slideInLeft {
            from { opacity: 0; transform: translateX(-30px); }
            to { opacity: 1; transform: translateX(0); }
        }

        @keyframes shimmer {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(100%); }
        }

        .animate-fade-in { animation: fadeInUp 0.5s ease-out backwards; }
        .animate-scale-in { animation: scaleIn 0.5s ease-out backwards; }
        .animate-slide-in { animation: slideInLeft 0.5s ease-out backwards; }

        /* Modern Icon */
        .icon-modern {
            width: 48px;
            height: 48px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
        }

        .icon-modern.blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
        .icon-modern.green { background: rgba(16, 185, 129, 0.15); color: #10b981; }
        .icon-modern.purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
        .icon-modern.orange { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
        .icon-modern.red { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

        /* Stats Grid */
        .stats-grid-modern {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        /* Frequency Badge */
        .freq-badge {
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
        }

        .freq-badge.monthly { background: rgba(16, 185, 129, 0.15); color: #10b981; }
        .freq-badge.quarterly { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
        .freq-badge.annual { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

        /* Page Footer */
        .page-footer {
            margin-top: 60px;
            padding: 0 20px 40px;
        }

        .footer-content {
            max-width: none;
            margin: 0 auto;
            padding: 0 clamp(16px, 3vw, 48px);
        }

        .footer-divider {
            height: 1px;
            background: linear-gradient(90deg,
                transparent 0%,
                var(--border-primary) 20%,
                var(--border-primary) 80%,
                transparent 100%);
            margin-bottom: 24px;
        }

        .footer-links {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            flex-wrap: wrap;
            font-size: 0.8rem;
            color: var(--text-muted);
            margin-bottom: 8px;
        }

        .footer-brand {
            display: flex;
            align-items: center;
            gap: 6px;
            font-weight: 600;
            color: var(--text-secondary);
        }

        .footer-brand svg {
            opacity: 0.7;
        }

        .footer-separator {
            opacity: 0.3;
        }

        .footer-link {
            color: var(--text-muted);
            text-decoration: none;
            transition: color 0.2s;
        }

        .footer-link:hover {
            color: var(--text-secondary);
        }

        .footer-copyright {
            font-weight: 500;
        }

        .footer-disclaimer {
            text-align: center;
            font-size: 0.75rem;
            font-style: italic;
            color: var(--text-muted);
            opacity: 0.7;
            max-width: 600px;
            margin: 0 auto;
        }

        /* Light theme footer */
        body.light-theme .footer-divider {
            background: linear-gradient(90deg,
                transparent 0%,
                #e2e8f0 20%,
                #e2e8f0 80%,
                transparent 100%);
        }

        body.light-theme .footer-link:hover {
            color: var(--text-primary);
        }

        /* Cookie Consent Banner */
        .cookie-banner {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 10000;
            background: var(--glass-bg);
            border-top: 1px solid var(--glass-border);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            padding: 16px 24px;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .cookie-content {
            max-width: none;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 20px;
            flex-wrap: wrap;
        }

        .cookie-text {
            font-size: 0.85rem;
            color: var(--text-secondary);
        }

        .cookie-accept {
            background: var(--accent-blue);
            color: white;
            border: none;
            padding: 8px 24px;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
            white-space: nowrap;
        }

        .cookie-accept:hover {
            background: #2563eb;
        }

        /* =============================================================================
           APP MESSAGE SYSTEM - Global toast/notification component
           ============================================================================= */
        .app-message-container {
            position: fixed;
            top: 80px;
            right: 24px;
            z-index: 10000;
            display: flex;
            flex-direction: column;
            gap: 16px;
            max-width: 450px;
            min-width: 360px;
            pointer-events: none;
        }

        .app-message {
            background: var(--bg-card);
            border-radius: 16px;
            padding: 20px 48px 20px 24px; /* Extra right padding for close button */
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
            border-left: 5px solid var(--accent-blue);
            display: flex;
            gap: 16px;
            align-items: flex-start;
            animation: slideInRight 0.3s ease-out;
            pointer-events: auto;
            position: relative;
        }

        .app-message.hiding {
            animation: slideOutRight 0.3s ease-in forwards;
        }

        @keyframes slideInRight {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        @keyframes slideOutRight {
            from { transform: translateX(0); opacity: 1; }
            to { transform: translateX(100%); opacity: 0; }
        }

        .app-message-icon {
            font-size: 1.5rem;
            flex-shrink: 0;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
        }

        .app-message.info { border-left-color: var(--accent-blue); }
        .app-message.info .app-message-icon { background: rgba(0, 102, 255, 0.15); }

        .app-message.success { border-left-color: var(--accent-green); }
        .app-message.success .app-message-icon { background: rgba(0, 208, 132, 0.15); }

        .app-message.warning { border-left-color: var(--accent-orange); }
        .app-message.warning .app-message-icon { background: rgba(255, 149, 0, 0.15); }

        .app-message.error { border-left-color: var(--accent-red); }
        .app-message.error .app-message-icon { background: rgba(255, 59, 48, 0.15); }

        .app-message-content {
            flex: 1;
            min-width: 0;
        }

        .app-message-title {
            font-weight: 700;
            font-size: 1.1rem;
            color: var(--text-primary);
            margin-bottom: 6px;
        }

        .app-message-text {
            font-size: 0.95rem;
            color: var(--text-secondary);
            line-height: 1.5;
            white-space: pre-line; /* render \n as line breaks for multi-line messages */
        }

        .app-message-suggestion {
            font-size: 0.875rem;
            color: var(--accent-cyan);
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid var(--border-subtle);
            font-weight: 500;
            white-space: pre-line;
        }

        .app-message-close {
            position: absolute;
            top: 12px;
            right: 12px;
            background: var(--bg-tertiary);
            border: none;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 6px 10px;
            font-size: 1.1rem;
            line-height: 1;
            border-radius: 6px;
            transition: all var(--transition-fast);
        }

        .app-message-close:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
        }

        /* Light theme */
        body.light-theme .app-message {
            background: #ffffff;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
        }

        @media (max-width: 480px) {
            .app-message-container {
                top: 10px;
                right: 10px;
                left: 10px;
                max-width: none;
            }
        }

        /* ============================================
           RESPONSIVE NAVIGATION (visitor pages only — authed users
           use the sidebar/drawer handled above via .has-app-sidebar)
           ============================================ */
        @media (max-width: 1024px) {
            .hamburger-btn {
                display: flex;
            }
        }

        @media (max-width: 768px) {
            .stats-grid-modern {
                grid-template-columns: 1fr;
            }
            .table-container,
            table {
                display: block;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }
        }

        /* Small mobile */
        @media (max-width: 480px) {
            nav .container {
                gap: var(--space-sm);
            }
            .logo {
                font-size: 1rem;
            }
            .logo-icon {
                width: 20px;
                height: 20px;
            }
            .nav-controls {
                gap: 4px;
            }
            .visitor-controls {
                gap: 6px;
            }
            .btn-login {
                margin-left: 10px;
            }
        }

    
/* ── Shared row-action helpers (W3.A4, M-17 — sprite icons, no inline styles) ──
   div-scoped: `td.row-actions` above is a separate, dormant hover-reveal
   convention and must not inherit this flex layout. */
.icon-14 { width: 14px; height: 14px; }
div.row-actions { display: flex; gap: 6px; justify-content: center; align-items: center; }
/* Row actions reveal on hover/focus (spec 2.3 — same convention as
   td.row-actions; owner 15. 7.: the red lot-sell button was shouting
   from every row). Touch devices have no hover — actions stay
   visible there. Applies to the whole action group incl. the
   canonical .btn-sell-position. */
@media (hover: hover) {
    .positions-table tbody tr div.row-actions {
        opacity: 0;
        transition: opacity 0.12s;
    }
    .positions-table tbody tr:hover div.row-actions,
    .positions-table tbody tr:focus-within div.row-actions {
        opacity: 1;
    }
}
.row-locked { font-size: 0.7rem; color: var(--text-muted); }
/* Transactions history — deterministic action slots (owner 15. 7.:
   "není to zarovnané"). Rows carry different button sets (Prodat only
   on open BUY lots, Edit only on USD rows), so a centered flex group
   made every button land at a different x. Fixed grid slots instead:
   sell | edit (30px) | delete (30px), anchored right — an absent
   button leaves its slot empty and everything below stays in column. */
#transactionsTable div.row-actions {
    display: grid;
    grid-template-columns: max-content 30px 30px;
    justify-content: end;
    justify-items: center;
}
#transactionsTable div.row-actions .btn-sell-position { grid-column: 1; }
#transactionsTable div.row-actions .js-edittransaction { grid-column: 2; }
#transactionsTable div.row-actions .js-deletetransaction { grid-column: 3; }
/* Shrink-to-content columns: date (and the bulk-select checkbox) don't
   need the surplus width auto layout hands them — freeing it pulls the
   symbol column toward the date column (owner: "symbol posunout více
   směrem ke sloupci datum") and gives the slack to Type/Notes. */
#transactionsTable th[data-sort="date"],
#transactionsTable th.brk-sel-col { width: 1%; }
/* The shrunk column must not break "2026-07-08" at the hyphens. */
#transactionsTable td.txn-date-cell { white-space: nowrap; }

/* ── Section toolbar: filters left, actions right (transactions/dividends) ──
   On narrow screens the filter group wraps into a tall column; without
   flex-wrap the action buttons floated centred OVER it (mobile overlap bug,
   2. 7. 2026). Wrap instead: actions drop below filters, full row. */
.txn-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.txn-toolbar-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1; min-width: 0; }
.txn-toolbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
@media (max-width: 700px) {
    .txn-toolbar-actions { width: 100%; justify-content: flex-start; }
}
/* Phone-width tidy-up (owner 9.7.: "není to zarovnané, je to nehezké"):
   filters stack full-width; the primary action takes the whole first
   row, icon + danger buttons share the second — no lonely floaters. */
@media (max-width: 576px) {
    .txn-toolbar-filters > * { flex: 1 1 45%; min-width: 0 !important; }
    .txn-toolbar-filters .custom-dropdown { flex: 1 1 100%; }
    .txn-toolbar-actions .btn-modern-success,
    .txn-toolbar-actions .btn-modern-primary { flex: 1 1 100%; justify-content: center; }
    .txn-toolbar-actions .btn-modern-danger { flex: 1 1 auto; justify-content: center; margin-left: 0 !important; }
    .txn-toolbar-actions .icon-btn { flex: 0 0 auto; }
}

/* ================================================================
   DESIGN TOKENS (M-18, W3.B1) - the one visual language.
   Source of truth: Portfolio Insights (the owner-approved style).
   Rules: flat titles (no gradient text) - Inter everywhere, numerics
   via tabular-nums (no second mono family on rebuilt pages) - KPI
   cards with uppercase muted labels - state colours red=decide,
   amber=watch, green=OK (never for a tax amount).
   Adopt page by page: Investments first, then Watchlist (M-25).
   ================================================================ */
.tok-page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 2px; }
.tok-page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; letter-spacing: -0.01em; }
.tok-page-title-row { display: flex; align-items: center; gap: 12px; }
.tok-page-sub { color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 14px; }
.tok-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.tok-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 8px 0 18px; }
.tok-kpi { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 12px; padding: 14px 16px; }
.tok-kpi-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.tok-kpi-value { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); margin-top: 6px; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tok-kpi-unit { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); margin-left: 3px; letter-spacing: 0; }
.tok-kpi-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.tok-kpi-meta--pos { color: var(--accent-green); }
.tok-kpi-meta--neg { color: var(--accent-red); }
.tok-kpi-progress { margin-top: 8px; height: 4px; border-radius: 999px; background: rgba(128,128,128,0.15); overflow: hidden; }
.tok-kpi-progress-bar { height: 100%; border-radius: 999px; background: var(--accent-blue); transition: width 0.5s ease; }
.tok-icon { width: 1em; height: 1em; vertical-align: -0.12em; }

/* M-25: watchlist Held badge — the one trace of ownership on the research
   list; everything money lives in Holdings. */
.wl-held-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; color: var(--accent-blue); background: rgba(59, 130, 246, 0.12); text-decoration: none; white-space: nowrap; }
.wl-held-badge:hover { background: rgba(59, 130, 246, 0.22); }

/* ================================================================
   M-31 — Mobile bottom navigation (.bnav*). Generic classes: the
   adult base renders Today/Portfolio/Holdings/Menu; the JUNIOR base
   will render its own item set (Domov/Cil/Lekce) with the same
   component. Desktop (>768px) never sees any of this.
   ================================================================ */
.bnav, .bnav-sheet, .bnav-sheet-overlay { display: none; }

@media (max-width: 768px) {
    body.has-bnav { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
    /* The bar replaces the top hamburger on phones. */
    body.has-bnav .hamburger-btn { display: none !important; }

    .bnav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        position: fixed;
        left: 0; right: 0; bottom: 0;
        top: auto; height: auto; width: auto; transform: none;
        /* ^ the app styles the top navbar via a bare `nav` element
           selector (top:0 etc.) — neutralise everything positional it
           sets so the bottom bar sizes to its content. */
        z-index: 950;
        background: var(--bg-secondary, #12121a);
        border-top: 1px solid var(--glass-border, rgba(255,255,255,0.08));
        padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .bnav-item {
        appearance: none; background: none; border: none;
        display: flex; flex-direction: column; align-items: center; gap: 3px;
        padding: 4px 2px; min-height: 48px;
        font-size: 0.66rem; font-weight: 600; letter-spacing: 0.01em;
        color: var(--text-muted); text-decoration: none; cursor: pointer;
    }
    .bnav-item svg { width: 22px; height: 22px; }
    .bnav-item.is-active { color: var(--accent-blue, #3b82f6); }

    .bnav-sheet-overlay {
        display: block; position: fixed; inset: 0; z-index: 960;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0; transition: opacity 0.18s ease; pointer-events: none;
    }
    .bnav-sheet-overlay.is-open { opacity: 1; pointer-events: auto; }
    .bnav-sheet-overlay[hidden] { display: none; }

    .bnav-sheet {
        display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 970;
        background: var(--bg-secondary, #12121a);
        border-top: 1px solid var(--glass-border, rgba(255,255,255,0.08));
        border-radius: 18px 18px 0 0;
        padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px));
        max-height: 75vh; overflow-y: auto;
        transform: translateY(100%); transition: transform 0.18s ease;
    }
    .bnav-sheet.is-open { transform: translateY(0); }
    .bnav-sheet[hidden] { display: none; }

    .bnav-sheet-grip {
        width: 36px; height: 4px; border-radius: 999px;
        background: var(--glass-border, rgba(255,255,255,0.2));
        margin: 4px auto 12px;
    }
    .bnav-sheet-grid {
        display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px;
    }
    .bnav-sheet-item {
        display: flex; align-items: center; gap: 10px;
        padding: 11px 8px; border-radius: 10px;
        font-size: 0.9rem; color: var(--text-primary); text-decoration: none;
    }
    .bnav-sheet-item svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
    .bnav-sheet-item.is-active { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue, #3b82f6); }
    .bnav-sheet-item:active { background: var(--glass-bg, rgba(255,255,255,0.05)); }
    .bnav-sheet-footer {
        margin-top: 8px; padding-top: 8px;
        border-top: 1px solid var(--glass-border, rgba(255,255,255,0.08));
    }
}

body.light-theme .bnav,
body.light-theme .bnav-sheet { background: #ffffff; }

/* PWA install banner must sit ABOVE the bottom nav on phones (M-31). */
@media (max-width: 768px) {
    body.has-bnav #pwaInstallBanner {
        position: fixed !important;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
        left: 0; right: 0;
    }
}

/* Cookie banner sits ABOVE the bottom nav on phones (M-31). */
@media (max-width: 768px) {
    body.has-bnav .cookie-banner {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    }
}


/* ════════════════════════════════════════════════════════════════
   SHARED SUB-NAV PILLS (moved from transactions.html so they load
   in <head> — no flash of unstyled tabs) + TAB SYSTEM. Used by
   /transactions and /portfolio-insights; `.is-active` is an alias
   for pages whose JS toggles that class instead of `.active`.
   ════════════════════════════════════════════════════════════════ */
/* Sub-Navigation */
.txn-subnav {
    position: sticky;
    top: 0; /* JS sets actual value from measured navbar height */
    z-index: 90;
    display: flex;
    gap: 4px;
    padding: 6px;
    margin-bottom: 24px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    transition: box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}

.txn-subnav.is-stuck {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.12);
}

.txn-subnav-item {
    /* full reset — the pills are <button>s on some pages and the UA
       default buttonface background made them look different */
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    font-family: inherit;
    flex: 1;
    text-align: center;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.18s ease-out, color 0.18s ease-out,
                transform 0.18s ease-out, box-shadow 0.18s ease-out;
    cursor: pointer;
    white-space: nowrap;
}

.txn-subnav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.txn-subnav-item.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
}

.txn-subnav-item.active:hover {
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.35);
}

/* Light theme */
body.light-theme .txn-subnav {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .txn-subnav.is-stuck {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .txn-subnav-item {
    color: var(--text-secondary);
}

body.light-theme .txn-subnav-item:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.04);
}

body.light-theme .txn-subnav-item.active {
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

/* Mobile responsive: the pill bar scrolls WITHIN itself — five tabs
   cannot fit 375px and used to widen the whole document to ~506px,
   dragging bottom nav / banners along (owner: "na mobilu je to
   peklo"). */
@media (max-width: 576px) {
    .txn-subnav {
        gap: 2px;
        padding: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .txn-subnav::-webkit-scrollbar { display: none; }
    .txn-subnav-item {
        flex: 1 0 auto;
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    .txn-subnav-item.active {
        transform: none;
    }
}

/* ════════════════════════════════════════════════════════════════
   TAB SYSTEM
   Inactive panels are forcibly hidden with !important so they
   override any inline display:block (e.g. Tax Summary, which has
   its own display toggle). Active panels get no display rule from
   us — they respect their natural / inline display, so Tax Summary
   still stays hidden until its own feature flag turns it on.
   ════════════════════════════════════════════════════════════════ */
.tab-panel:not(.is-active) { display: none !important; }

/* Sub-nav count badge — small pill after the tab label */
.txn-subnav-count {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.txn-subnav-item.active .txn-subnav-count {
    background: rgba(255, 255, 255, 0.20);
    color: #fff;
}
body.light-theme .txn-subnav-count {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
}
.txn-subnav-item.is-active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}
body.light-theme .txn-subnav-item.is-active { color: #fff; }


/* ════════════════════════════════════════════════════════════════
   GLOBAL FOCUS VISIBILITY (audit F8)
   Scattered `outline: none` resets (app.css + 22 templates) left
   keyboard users with NO focus indicator anywhere. This single rule
   restores it app-wide; !important is required to beat those resets
   without hunting all of them. Mouse/touch focus stays outline-free
   (:focus-visible matches keyboard navigation only).
   ════════════════════════════════════════════════════════════════ */
:focus-visible {
    outline: 2px solid var(--accent-blue, #3b82f6) !important;
    outline-offset: 2px;
}
/* Reduced motion (audit A5): honour the OS preference. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ════════════════════════════════════════════════════════════════
   SYSTEMIC (audit F6, found on calendar + compare, present in 16
   templates): page-title rows carrying the help "?" button are
   inline-styled no-wrap flex rows — at 320-390px the button and the
   long H1 pushed the whole page wide. One :has() rule makes every
   such row wrappable; titles may shrink.
   ════════════════════════════════════════════════════════════════ */
div:has(> .help-toggle-btn) {
    flex-wrap: wrap;
    min-width: 0;
}
div:has(> .help-toggle-btn) > h1 {
    min-width: 0;
}
