/* === Reset & Utilities === */
*, *::before, *::after { box-sizing: border-box; }
.hidden { display: none !important; }

:root {
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Montserrat', sans-serif;
    --font-serif: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, serif;

    /* Light-mode palette */
    --text-primary: #333;
    --text-secondary: #666;
    --primary-color: #eb3f3f;
    --primary-dark: #a82e2e;
    --secondary-color: #3f7feb;
    --surface-color: #fff;
    --dark-surface-color: #F1F1F1;
    --border-color: #e2e8f0;

    /* Auth / dark-card palette */
    --auth-red: #dc2626;
    --auth-red-dark: #b91c1c;
    --auth-muted: #a1a1aa;
    --auth-muted-light: #d4d4d8;
    --auth-hint: #71717a;
    --auth-text: #f4f4f5;
    --auth-bg: #121212;
    --auth-input-bg: #0f0f0f;
    --auth-border: rgba(255, 255, 255, 0.14);

    /* Shared RGBA tokens (primary at various opacities) */
    --primary-06: rgba(235, 63, 63, 0.06);
    --primary-07: rgba(235, 63, 63, 0.07);
    --primary-22: rgba(235, 63, 63, 0.22);
    --primary-25: rgba(235, 63, 63, 0.25);
    --primary-45: rgba(235, 63, 63, 0.45);
    --white-08: rgba(255, 255, 255, 0.08);
    --white-14: rgba(255, 255, 255, 0.14);
    --white-18: rgba(255, 255, 255, 0.18);
    --white-20: rgba(255, 255, 255, 0.2);
    --white-35: rgba(255, 255, 255, 0.35);
    --white-45: rgba(255, 255, 255, 0.45);

    /* Shared surfaces */
    --matte-gradient: linear-gradient(145deg, #1a1a1e 0%, #252528 45%, #1e1e22 100%);
    --logo-invert: brightness(0) invert(1);

    /* Radii & shadows */
    --border-radius: 8px;
    --radius-pill: 999px;
    --radius-sm: 4px;
    --shadow-small: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    /* Layout */
    --app-header-height: 4.5rem;
    --content-max-width: 1200px;
}

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;400;700&display=swap');

/* === Base === */
body {
    font-family: var(--font-sans);
    background: var(--surface-color);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
}

/* /financial-data dark: clientside sets body[data-page-theme="dark"] so shell matches page */
body[data-page-theme="dark"] {
    background: #1a1a1e;
    color-scheme: dark;
}

body[data-page-theme="dark"] .app-shell {
    background: #1a1a1e;
}

body[data-page-theme="dark"] main.page-content {
    background: #1a1a1e;
    color: #e4e4e7;
}

body[data-page-theme="dark"] .footer {
    background: #121212;
    border-top-color: rgba(255, 255, 255, 0.12);
}

body[data-page-theme="dark"] .footer-copyright,
body[data-page-theme="dark"] .footer-disclosure-heading {
    color: #a1a1aa;
}

body[data-page-theme="dark"] .footer-disclosure-body {
    color: #a1a1aa;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1 0 auto;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 1rem 2rem;
    width: 100%;
}

/* Full-bleed pages (home + auth) share this override */
main.page-content:has(.home-page),
main.page-content:has(.auth-page-shell) {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
}

/* === Header === */
.app-header {
    background: #28282B;
    border-bottom: 1px solid rgba(235, 63, 63, 0.2);
    box-shadow: var(--shadow-medium);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.brand-cluster {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo-link,
.brand-home-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease;
}

.brand-logo-link:hover,
.brand-home-link:hover { opacity: 0.9; }

.brand-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    filter: var(--logo-invert);
}

.brand-divider {
    width: 1px;
    height: 30px;
    background: linear-gradient(to bottom, transparent, var(--white-35), transparent);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 1px;
    color: #fff;
    text-transform: uppercase;
}

.brand-terminal {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--primary-color);
    text-transform: uppercase;
}

/* Header — user area + Financial Data theme toggle */
.header-right-cluster {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user-area {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
}

/* Theme toggle: visible only on /financial-data (clientside sets display) */
.theme-toggle-wrap {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 0.25rem;
    gap: 0.2rem;
}

.theme-toggle-label {
    font-size: 0.65rem;
    font-weight: 500;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.72);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.theme-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 999px;
}

.theme-toggle-track {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: background 0.25s ease, border-color 0.25s ease;
}

.theme-toggle--on .theme-toggle-track {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.theme-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.25s ease;
    pointer-events: none;
}

.theme-toggle--on .theme-toggle-thumb {
    transform: translateX(20px);
}

.header-user-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-username { font-weight: 600; color: #fff; }

.header-admin-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    background: var(--dark-surface-color);
    color: var(--primary-dark);
}

.header-logout-btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--white-35);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
}

.header-auth-guest { display: flex; align-items: center; gap: 1rem; }

.header-auth-link {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.88rem;
    text-decoration: none;
}
.header-auth-link:hover { color: #fff; text-decoration: underline; }

@media (max-width: 768px) {
    .header-container { padding: 0.75rem 1rem; }
    .brand-logo { height: 32px; }
    .brand-divider { height: 24px; }
    .brand-name { font-size: 1rem; }
    .brand-terminal { font-size: 0.65rem; }
}

@media (max-width: 480px) {
    .brand-text, .brand-divider { display: none; }
}

/* === Footer === */
.footer {
    background: var(--dark-surface-color);
    border-top: 1px solid var(--border-color);
    padding: 0.875rem 1.5rem 1rem;
    margin-top: auto;
}

.footer-inner { max-width: var(--content-max-width); margin: 0 auto; }

.footer-copyright {
    font-size: 0.65rem;
    line-height: 1.35;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
    letter-spacing: 0.02em;
}

.footer-disclosure-heading {
    font-size: 0.6rem;
    font-weight: 600;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin: 0 0 0.35rem;
}

.footer-disclosure-body {
    font-size: 0.65rem;
    line-height: 1.45;
    color: #5c5c5c;
    max-width: 52rem;
}

.footer-disclosure-body p { margin: 0 0 0.4rem; }
.footer-disclosure-body p:last-child { margin-bottom: 0; }

/* === Home Landing === */
.home-hero {
    position: relative;
    width: 100%;
    min-height: calc(100vh - var(--app-header-height));
    min-height: calc(100dvh - var(--app-header-height));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 2rem;
    overflow: hidden;
    background: var(--matte-gradient);
}

.home-floating-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.home-floating-layer .home-floating-ticker { pointer-events: auto; }

.home-loading-shell {
    width: 100%;
    min-height: calc(100vh - var(--app-header-height));
    min-height: calc(100dvh - var(--app-header-height));
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--matte-gradient);
}

.home-spinner {
    position: relative;
    width: 20rem;
    height: 20rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 7px solid transparent;
    border-top-color: var(--primary-color);
    border-right-color: var(--primary-color);
    animation: home-spinner-ring-spin 1.1s linear infinite;
    box-shadow: 0 0 40px var(--primary-25);
}

.home-spinner-logo {
    width: 64%;
    height: 64%;
    object-fit: contain;
    animation: home-spinner-logo-pulse 1.6s ease-in-out infinite;
    filter: drop-shadow(0 0 6px var(--primary-45));
}

@keyframes home-spinner-ring-spin {
    to { transform: rotate(360deg); }
}

@keyframes home-spinner-logo-pulse {
    0%, 100% { transform: scale(1);    opacity: 0.92; }
    50%      { transform: scale(1.08); opacity: 1; }
}

.home-floating-ticker {
    position: absolute;
    transform: translate(-50%, -50%);
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #fff;
    background: var(--white-08);
    border: 1px solid var(--white-18);
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    animation: home-float-drift var(--home-float-drift-sec, 14s) ease-in-out infinite;
    white-space: nowrap;
    max-width: min(92vw, 28rem);
}

.home-floating-ticker .home-float-name {
    display: none;
    margin-left: 0.45rem;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0.92;
}

.home-floating-ticker:nth-child(3n) {
    animation-duration: calc(var(--home-float-drift-sec, 14s) * 0.78);
}
.home-floating-ticker:nth-child(3n + 1) {
    animation-duration: calc(var(--home-float-drift-sec, 14s) * 1.18);
}

.home-floating-ticker:hover {
    transform: translate(-50%, -50%) scale(1.08);
    background: var(--primary-22);
    box-shadow: 0 0 18px var(--primary-45);
}

.home-floating-ticker:hover .home-float-name {
    display: inline;
}

@keyframes home-float-drift {
    0%, 100% { transform: translate(-50%, -50%) translate(0, 0); }
    25%      { transform: translate(-50%, -50%) translate(6px, -10px); }
    50%      { transform: translate(-50%, -50%) translate(-8px, 5px); }
    75%      { transform: translate(-50%, -50%) translate(4px, 8px); }
}

.home-search-shell {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.home-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    color: #f5f5f5;
    margin: 0 0 0.5rem;
    letter-spacing: 0.02em;
}

.home-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.65);
    margin: 0 0 1.5rem;
}

.home-ticker-combo { margin: 0 auto; max-width: 320px; }

.home-ticker-input {
    width: 100%;
    min-height: 3rem;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    border: 1px solid var(--white-20);
    border-radius: var(--radius-pill);
    background: var(--white-08);
    backdrop-filter: blur(10px);
    color: #fff;
    outline: none;
    box-shadow: 0 0 20px var(--primary-25);
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}
.home-ticker-input::placeholder {
    color: var(--white-45);
    line-height: 1.5;
    opacity: 1;
}
.home-ticker-input:focus {
    border-color: rgba(235, 63, 63, 0.6);
    box-shadow: 0 0 24px var(--primary-45);
}

.home-suggestion-list { text-align: left; }
.home-suggestion-list .company-suggestion-row { color: var(--text-primary); }

/* === Financial Data Page === */
.financial-data-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Financial Data — dark theme (header toggle; data-theme set clientside) */
.financial-data-page[data-theme="dark"] {
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --surface-color: #1a1a1e;
    --dark-surface-color: #252528;
    --border-color: rgba(255, 255, 255, 0.12);
    --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.5);

    background: #1a1a1e;
    color: #e4e4e7;
    color-scheme: dark;
}

.financial-data-page[data-theme="dark"] .popup-content {
    background: #252528;
    color: #e4e4e7;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

.financial-data-page[data-theme="dark"] .popup-header {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .comparison-ticker-section {
    background: #252528;
    border-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .comparison-ticker-prompt {
    color: #a1a1aa;
}

.financial-data-page[data-theme="dark"] .comp-ticker-label {
    background: #252528;
    color: #e4e4e7;
    border-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .comp-ticker-symbol {
    color: #e4e4e7;
}

.financial-data-page[data-theme="dark"] .comp-ticker-input {
    background: #1a1a1e;
    color: #e4e4e7;
    border-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .comp-ticker-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-22);
}

.financial-data-page[data-theme="dark"] .plot-settings-btn,
.financial-data-page[data-theme="dark"] .export-csv-btn {
    background: #252528;
    color: #e4e4e7;
}

.financial-data-page[data-theme="dark"] .plot-settings-btn:hover,
.financial-data-page[data-theme="dark"] .export-csv-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.financial-data-page[data-theme="dark"] .settings-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.financial-data-page[data-theme="dark"] .formula-popup-footer {
    border-top-color: rgba(255, 255, 255, 0.12);
}

/* Formula editor: text inputs and number fields (native controls ignore CSS variables) */
.financial-data-page[data-theme="dark"] .formula-name-input,
.financial-data-page[data-theme="dark"] .formula-expression-input {
    background-color: #1a1a1e;
    color: #e4e4e7;
    border-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .formula-input-row {
    background: #252528;
    border-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .formula-input-row .window-input,
.financial-data-page[data-theme="dark"] .formula-output-controls .window-input {
    background-color: #1a1a1e;
    color: #e4e4e7;
    border-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .formula-input-row input[type="number"] {
    color-scheme: dark;
}

.financial-data-page[data-theme="dark"] .metric-picker-tabs {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

.financial-data-page[data-theme="dark"] .company-suggestion-row {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/*
 * Dash 4 dropdown — dark theme.
 * Dash 4 dcc.Dropdown renders its own component using --Dash-* CSS custom
 * properties (defined on :root).  Override the design tokens on the dark
 * scope so every dropdown inside the page inherits dark colours automatically.
 * body[data-page-theme] catches portaled popover menus rendered on <body>.
 */
.financial-data-page[data-theme="dark"],
body[data-page-theme="dark"] {
    --Dash-Fill-Inverse-Strong: #1a1a1e;
    --Dash-Stroke-Strong: rgba(255, 255, 255, 0.12);
    --Dash-Stroke-Weak: rgba(255, 255, 255, 0.06);
    --Dash-Text-Strong: #e4e4e7;
    --Dash-Text-Primary: #e4e4e7;
    --Dash-Text-Weak: #a1a1aa;
    --Dash-Text-Disabled: #71717a;
    --Dash-Fill-Interactive-Strong: var(--primary-color);
    --Dash-Fill-Interactive-Weak: rgba(235, 63, 63, 0.08);
    --Dash-Fill-Disabled: rgba(255, 255, 255, 0.08);
    --Dash-Fill-Primary-Hover: rgba(255, 255, 255, 0.04);
    --Dash-Fill-Primary-Active: rgba(255, 255, 255, 0.08);
    --Dash-Shading-Strong: rgba(0, 0, 0, 0.55);
    --Dash-Shading-Weak: rgba(0, 0, 0, 0.35);
}

/* Option hover highlight (uses the primary accent) */
.financial-data-page[data-theme="dark"] .dash-dropdown-option:hover,
body[data-page-theme="dark"] .dash-dropdown-option:hover {
    background-color: rgba(235, 63, 63, 0.10);
}

/* Portaled popover content background (Dash 4 renders outside .financial-data-page) */
body[data-page-theme="dark"] .dash-dropdown-content {
    background: #252528;
    border-color: rgba(255, 255, 255, 0.12);
}

/* Dropdown faces + menus: rounded corners */
.financial-data-page .dash-dropdown-content {
    border-radius: var(--border-radius);
}

body[data-page-theme="dark"] .dash-dropdown-content {
    border-radius: var(--border-radius);
}

/* === Ticker Search (shared combo) === */
.ticker-search-combo {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    position: relative;
    z-index: 40;
}

.ticker-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    width: 200px;
    background: var(--surface-color);
}

.financial-data-page .ticker-search-row {
    display: flex;
    align-items: flex-start;
    width: 100%;
}

.financial-data-page .ticker-search-combo {
    flex: 1 1 auto;
    width: 100%;
    max-width: min(100%, 36rem);
    min-width: min(100%, 20rem);
}

.financial-data-page .ticker-input { width: 100%; min-width: 0; }

/* Wrapper for idle animation (inputs lack pseudo-elements) */
.ticker-input-anim-wrap {
    display: block;
    position: relative;
    width: 100%;
    border-radius: var(--border-radius);
}

.ticker-input-anim-wrap .ticker-input {
    position: relative;
    z-index: 1;
    background: var(--surface-color);
}

/* Company autocomplete dropdown */
.company-suggestion-list--dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 3px);
    z-index: 50;
    max-height: 260px;
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium), 0 16px 40px -12px rgba(15, 23, 42, 0.18);
    -webkit-overflow-scrolling: touch;
}

.company-suggestion-list--compact { max-height: 220px; }

.company-suggestion-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.85rem;
    border: none;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.company-suggestion-row:hover,
.company-suggestion-row:focus-visible {
    background: var(--primary-07);
    outline: none;
}

.company-suggestion-ticker {
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.company-suggestion-name {
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.35;
    color: var(--text-secondary);
}

.company-suggestion-row:last-child { border-bottom: none; }

/* Comparison ticker */
.comp-suggestion-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: transparent;
    cursor: default;
}

.comparison-ticker-combo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    z-index: 30;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 560px;
}

.comp-ticker-input-anim-wrap {
    display: block;
    position: relative;
    width: 100%;
}

.comparison-ticker-search-row .comparison-ticker-combo { width: auto; }

.search-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--border-radius);
    background: var(--primary-color);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}
.search-btn:hover { background: var(--primary-dark); }

/* === Loading Spinners === */
.company-info-loading-wrap,
.chart-loading-wrap { width: 100%; }
.chart-loading-wrap { min-height: 380px; }

.loading-custom {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.85rem;
}

.loading-custom-text { font-size: 0.95rem; font-weight: 600; color: var(--text-secondary); }
.loading-custom--chart .loading-custom-text { color: var(--text-primary); }
.loading-custom--company .loading-custom-text { font-size: 0.9rem; font-weight: 500; }

.loading-circle {
    display: inline-block;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: cydonia-loading-spin 0.72s linear infinite;
}

.loading-circle--chart { width: 1.4rem; height: 1.4rem; border-width: 3px; }

.loading-circle--company {
    width: 1.05rem;
    height: 1.05rem;
    border-style: dashed;
    border-top-color: var(--primary-color);
    animation: cydonia-loading-spin 1.1s linear infinite;
}

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

/* === Company Info === */
.company-info { position: relative; }

.company-info-dismiss {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    z-index: 2;
    width: 2rem;
    height: 2rem;
    padding: 0;
    line-height: 1;
    border: none;
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
}
.company-info-dismiss:hover { color: var(--text-primary); background: rgba(0, 0, 0, 0.06); }

.company-info-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: var(--dark-surface-color);
    padding: 1.5rem 2.75rem 1.5rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-small);
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.company-name { font-weight: 700; font-size: 1.25rem; color: var(--text-primary); margin-bottom: 0.25rem; }
.company-sector { color: var(--text-secondary); font-size: 0.95rem; }
.error-text { color: var(--primary-color); font-weight: 600; }

/* === Controls Row === */
.controls-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.controls-row .open-metric-picker-main-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: unset;
    justify-content: center;
    min-height: 2.375rem;
}

.metric-dropdown { flex: 1; min-width: 250px; }

/* Shared toolbar button base */
.formula-editor-btn {
    flex-shrink: 0;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
}
.formula-editor-btn:hover { background: var(--dark-surface-color); }

.controls-row .formula-editor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.375rem;
    padding: 0.5rem 0.75rem;
    font-weight: 400;
}

.controls-row .formula-editor-btn .plot-settings-icon {
    display: block;
    max-height: 1.25rem;
    width: auto;
}

/* === Formula Editor Modal === */
.formula-popup-content { width: min(100%, 560px); }

.formula-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 12px 15px;
    border-top: 1px solid #e0e0e0;
}

.formula-editor-field { margin-bottom: 0.75rem; }

.formula-field-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.formula-name-input,
.formula-expression-input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.formula-add-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.25rem;
}

.formula-metric-dropdown { margin-bottom: 0.5rem; }

.formula-input-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.formula-input-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--dark-surface-color);
}

.formula-input-letter { font-weight: 700; min-width: 1.25rem; color: var(--primary-color); }
.formula-metric-label { flex: 1; min-width: 120px; font-size: 0.85rem; }

.formula-row-remove-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 0.25rem;
}
.formula-row-remove-btn:hover { color: var(--primary-color); }

.formula-output-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.formula-saved-section {
    margin-bottom: 0.85rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--dark-surface-color);
}

.formula-saved-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.formula-saved-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.saved-formula-select { margin-bottom: 0.65rem; }

.formula-saved-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.formula-delete-saved-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.formula-saved-status {
    min-height: 1rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.formula-saved-guest-note {
    margin-bottom: 0.85rem;
    padding: 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
}

.formula-saved-guest-text {
    margin: 0 0 0.45rem 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.formula-saved-guest-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
}

/* === Period Controls === */
.global-period-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.global-period-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.period-btn-group { display: flex; gap: 0; }

.period-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}
.period-btn:first-child  { border-radius: var(--border-radius) 0 0 var(--border-radius); }
.period-btn:last-child   { border-radius: 0 var(--border-radius) var(--border-radius) 0; }
.period-btn:not(:first-child) { border-left: none; }
.period-btn:hover { background: var(--dark-surface-color); }

.period-btn-active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}
.period-btn-active:hover { background: var(--primary-dark); }

/* === Metric Cards === */
.card-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
}

.metric-card {
    width: 240px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    box-shadow: var(--shadow-small);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* Content-aware expand/collapse animation via CSS grid row interpolation.
   Outer transitions grid-template-rows 1fr <-> 0fr; inner clips with
   overflow:hidden + min-height:0 so no magic max-height is needed. */
.metric-card-settings {
    display: grid;
    grid-template-rows: 1fr;
    opacity: 1;
    transition: grid-template-rows 0.25s ease-out, opacity 0.2s ease-out;
}

.metric-card-settings-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
    min-height: 0;
}

.metric-card-settings--collapsed {
    grid-template-rows: 0fr;
    opacity: 0;
}

.card-title {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-title--formula {
    font-style: italic;
    font-family: var(--font-serif);
    font-weight: 600;
}

.formula-card-settings-btn {
    flex-shrink: 0;
    padding: 0.25rem 0.35rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
.formula-card-settings-btn:hover { background: var(--dark-surface-color); }

.formula-card-settings-icon { height: 1.15rem; width: auto; display: block; }

.card-title-hit {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.35rem;
    margin: -0.15rem -0.35rem;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.card-title-hit:hover { background: var(--dark-surface-color); }
.card-title-hit:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }

/* Chevron drawn via CSS mask so its color follows var(--text-secondary)
   in both light and dark themes (matching the "X" remove button). */
.card-title-caret {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    display: inline-block;
    background-color: var(--text-secondary);
    -webkit-mask-image: url('chevron_down.svg');
            mask-image: url('chevron_down.svg');
    -webkit-mask-size: contain;
            mask-size: contain;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
    transform-origin: 50% 50%;
    transition: transform 0.25s ease-out;
}
.card-title-hit--open .card-title-caret { transform: rotate(-180deg); }

.remove-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}
.remove-btn:hover { color: var(--primary-color); }

.card-control { display: flex; flex-direction: column; gap: 0.15rem; }

.card-control label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.window-input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0;
}

.card-header-buttons { display: flex; gap: 5px; }

.settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 5px;
    border-radius: 3px;
}
.settings-btn:hover { background-color: #f0f0f0; }

/* === Date Range === */
.date-range-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.date-range-dropdowns { display: flex; gap: 0.75rem; }

.date-range-field { display: flex; flex-direction: column; gap: 0.2rem; }

.date-range-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.date-range-dropdown { width: 160px; }
.range-btn-group { display: flex; gap: 0; }

/* === Chart Section === */
.chart-section-wrap { display: flex; flex-direction: column; width: 100%; }

.chart-export-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.export-guest-prompt { width: 100%; }

.export-guest-prompt-card {
    position: relative;
    max-width: min(380px, 100%);
    padding: 0.85rem 2.25rem 0.85rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    box-shadow: var(--shadow-small);
}

.financial-data-page[data-theme="dark"] .export-guest-prompt-card {
    background: #252528;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.export-guest-prompt-text {
    margin: 0 0 0.65rem 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-primary);
}

.export-guest-prompt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.export-guest-prompt-link {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.export-guest-prompt-link:hover {
    text-decoration: underline;
}

.export-guest-prompt-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.2rem 0.45rem;
    color: var(--text-secondary);
}

.export-guest-prompt-close:hover {
    color: var(--text-primary);
}

.chart-controls-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.plot-settings-btn,
.export-csv-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}

.plot-settings-btn--icon {
    padding: 0.35rem 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.plot-settings-icon { height: 1.35rem; width: auto; display: block; }

.plot-settings-btn:hover,
.export-csv-btn:hover { background: #f5f5f5; }

.export-csv-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Guest: export is clickable but prompts for account (CSV still requires login) */
.export-csv-btn--guest {
    border-style: dashed;
    opacity: 0.92;
}

.financial-data-page[data-theme="dark"] .export-csv-btn--guest {
    border-color: rgba(255, 255, 255, 0.22);
}

.main-chart { min-height: 400px; }

/* === Plot Settings Modal === */
.plot-settings-popup {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.plot-settings-popup.hidden { display: none; }

.plot-settings-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.popup-content {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: min(100%, 480px);
    max-width: 95%;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.popup-title { font-weight: bold; font-size: 16px; }

.popup-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 0 5px;
    color: var(--text-secondary);
}
.popup-close-btn:hover { color: var(--text-primary); }

.popup-body { padding: 20px 15px; }

.settings-row {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.settings-row label { min-width: 80px; font-size: 14px; }

/* Trace settings rows */
.trace-settings-row {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.trace-settings-row:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.trace-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.45rem;
    line-height: 1.35;
}

.trace-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    align-items: center;
}

.trace-settings-toggle-group .period-btn { white-space: nowrap; }

/* === Comparison Ticker Section === */
.comparison-ticker-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    align-self: flex-start;
    margin: 15px 0;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border: 1px solid #e9ecef;
}

.comparison-ticker-search-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.65rem 1rem;
    min-width: 0;
}

.comparison-ticker-prompt {
    flex-shrink: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
    line-height: 1.4;
}

.comp-ticker-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-height: 0;
}
.comp-ticker-container:empty { display: none; }

.comp-ticker-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 2px solid;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.comp-ticker-symbol { color: #212529; }

.remove-comp-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transition: all 0.15s ease;
}
.remove-comp-btn:hover { background: #dc3545; color: white; }

.comp-ticker-input {
    width: 100%;
    min-width: 260px;
    max-width: 520px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 13px;
}
.comp-ticker-input:focus { outline: none; border-color: #80bdff; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1); }
.comp-ticker-input::placeholder { color: #adb5bd; }

#comp-ticker-error:not(:empty) { margin-top: 6px; font-size: 12px; color: #dc3545; }
#comp-ticker-error:empty { display: none; }

/* === Metric Picker Modal === */
.open-metric-picker-main-btn,
.open-metric-picker-formula-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.open-metric-picker-formula-btn { width: 100%; justify-content: flex-start; }

.open-metric-picker-main-btn:hover,
.open-metric-picker-formula-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-06);
}

/* Idle attention animations */
.open-metric-picker-main-btn.idle-attn,
.ticker-input-anim-wrap.idle-attn {
    position: relative;
    overflow: hidden;
}

/* Guest banner — Register FREE (same sweep as + Add data when link is visible, not prominent) */
.guest-banner-register-btn--inline:not(.guest-banner-register-btn--hidden):not(.guest-banner-register-btn--prominent) {
    position: relative;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    border-radius: var(--border-radius);
    padding: 0.2rem 0.45rem;
    box-sizing: border-box;
    border: 1px solid rgba(26, 58, 74, 0.22);
    animation: addDataBorderPulse 3s ease-in-out infinite, addDataSubtleGlow 4s ease-in-out infinite;
}

.guest-banner-register-label {
    position: relative;
    z-index: 1;
}

.guest-banner-register-btn--inline:not(.guest-banner-register-btn--hidden):not(.guest-banner-register-btn--prominent)::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(90deg, transparent, var(--white-35), var(--primary-22), transparent);
    transform: skewX(-25deg);
    animation: addDataShimmer 3s infinite;
    pointer-events: none;
}

.guest-banner-register-btn--inline:not(.guest-banner-register-btn--hidden):not(.guest-banner-register-btn--prominent)::after {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(90deg, transparent, transparent, var(--primary-color), var(--primary-dark), var(--primary-color), transparent, transparent);
    background-size: 300% 100%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: addDataBorderTravel 3s linear infinite;
    opacity: 0.55;
    pointer-events: none;
}

.open-metric-picker-main-btn.idle-attn {
    animation: addDataBorderPulse 3s ease-in-out infinite, addDataSubtleGlow 4s ease-in-out infinite;
}

.ticker-input-anim-wrap.idle-attn .ticker-input {
    animation: addDataBorderPulse 3s ease-in-out infinite, addDataSubtleGlow 4s ease-in-out infinite;
}

.open-metric-picker-main-btn.idle-attn::before,
.ticker-input-anim-wrap.idle-attn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(90deg, transparent, var(--white-35), var(--primary-22), transparent);
    transform: skewX(-25deg);
    animation: addDataShimmer 3s infinite;
    pointer-events: none;
}

.open-metric-picker-main-btn.idle-attn::after,
.ticker-input-anim-wrap.idle-attn::after {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: 0;
    border-radius: 10px;
    padding: 2px;
    background: linear-gradient(90deg, transparent, transparent, var(--primary-color), var(--primary-dark), var(--primary-color), transparent, transparent);
    background-size: 300% 100%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: addDataBorderTravel 3s linear infinite;
    opacity: 0.55;
    pointer-events: none;
}

.open-metric-picker-main-btn.idle-attn:hover { animation-play-state: paused; }
.ticker-input-anim-wrap.idle-attn:hover .ticker-input { animation-play-state: paused; }
.open-metric-picker-main-btn.idle-attn .plus-icon { animation: addDataPulseIcon 2s ease-in-out infinite; }

@keyframes addDataShimmer     { 0% { left: -100%; } 50%, 100% { left: 200%; } }
@keyframes addDataBorderPulse { 0%, 100% { border-color: var(--border-color); box-shadow: 0 0 0 rgba(235, 63, 63, 0); } 50% { border-color: var(--primary-45); box-shadow: 0 0 10px rgba(235, 63, 63, 0.14); } }
@keyframes addDataBorderTravel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes addDataSubtleGlow  { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.03); } }
@keyframes addDataPulseIcon   { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: 0.85; } }

/* Metric picker panel */
.metric-picker-popup-content {
    width: min(100%, 720px);
    max-height: min(70vh, 640px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.metric-picker-popup-content .popup-header { margin-bottom: 1.25rem; }

.metric-picker-popup-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0 0 4px;
}

.metric-picker-search {
    width: calc(100% - 30px);
    margin: 0 15px 12px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
}
.metric-picker-search:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px var(--primary-22); }

.metric-picker-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0 15px 12px;
    border-bottom: 1px solid #e0e0e0;
}

.metric-picker-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    border-bottom: 2px solid transparent;
}
.metric-picker-tab:hover { color: var(--text-primary); background: var(--dark-surface-color); }
.metric-picker-tab-active { color: var(--primary-color) !important; border-bottom-color: var(--primary-color) !important; }

.metric-picker-metrics-list {
    padding: 12px 15px 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 180px;
}

.metric-picker-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1rem 0;
    text-align: center;
}

.metric-picker-row {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    padding: 0.65rem 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.metric-picker-row:hover { border-color: var(--primary-color); box-shadow: var(--shadow-small); }

.metric-picker-row-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.metric-picker-row-title { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }

.metric-picker-row-chip {
    flex-shrink: 0;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    background: var(--dark-surface-color);
    color: var(--text-secondary);
}

.metric-picker-row-desc { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.35; }

/* === Auth Pages === */
.auth-page-shell--dark {
    min-height: calc(100vh - var(--app-header-height));
    min-height: calc(100dvh - var(--app-header-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.75rem 1.25rem 2.5rem;
    background: var(--matte-gradient);
}

.auth-card--dark {
    width: 100%;
    max-width: 420px;
    padding: 2rem 2rem 2.25rem;
    border-radius: 14px;
    background: var(--auth-bg);
    border: 1px solid var(--white-08);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.auth-brand-logo--dark {
    display: block;
    width: min(160px, 52vw);
    height: auto;
    margin: 0 auto 1.35rem;
    object-fit: contain;
    filter: var(--logo-invert);
    opacity: 0.95;
}

.auth-panels-stack { position: relative; width: 100%; min-height: 28rem; }

.auth-panel {
    width: 100%;
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
}

.auth-panel--active {
    position: relative;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    z-index: 1;
}

.auth-panel--hidden {
    position: absolute;
    inset: 0 0 auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px);
    z-index: 0;
}

.auth-title--dark {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.35rem;
    color: var(--auth-text);
    text-align: center;
    margin: 0 0 1.5rem;
    letter-spacing: 0.02em;
}

/* Auth input fields */
.auth-field-block { margin-bottom: 1rem; }

.auth-field-block--error .auth-input-outside {
    border-color: rgba(255, 255, 255, 0.42);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.auth-label-outside {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--auth-muted);
    margin-bottom: 0.35rem;
}

.auth-hint {
    font-size: 0.78rem;
    color: var(--auth-hint);
    margin: 0 0 0.4rem;
    line-height: 1.35;
}

.auth-input-outside {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.75rem 0.85rem;
    min-height: 2.75rem;
    line-height: 1.45;
    font-size: 0.95rem;
    color: var(--auth-text);
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-border);
    border-radius: var(--border-radius);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.auth-input-outside:focus { border-color: var(--auth-red); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22); }
.auth-input-outside::placeholder { color: var(--auth-hint); opacity: 1; }
.auth-input-outside--padded { padding-left: 2.35rem; padding-right: 2.75rem; }

.auth-input-icon-row { position: relative; display: flex; align-items: center; }

.auth-input-prefix {
    position: absolute;
    left: 0.65rem;
    font-size: 0.95rem;
    z-index: 1;
    pointer-events: none;
    opacity: 0.45;
}

/* Password toggle (shared base for sign-in + sign-up) */
.auth-password-toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.35rem 0.45rem;
    line-height: 1;
    font-size: 1rem;
    color: var(--auth-muted-light);
    opacity: 0.9;
    border-radius: 6px;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.auth-password-toggle:hover { opacity: 1; background: var(--white-08); }
.auth-password-toggle--reg { right: 0.35rem; left: auto; }

.auth-password-toggle-icon { display: inline-block; user-select: none; }

.auth-field-helper {
    min-height: 1.15rem;
    font-size: 0.8rem;
    color: var(--auth-muted);
    margin: 0.2rem 0 0 0.15rem;
}

.auth-forgot-row { display: flex; justify-content: flex-end; margin: 0.15rem 0 0.25rem; }

.auth-forgot-link {
    border: none;
    background: none;
    padding: 0;
    font-size: 0.82rem;
    color: var(--auth-muted);
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
}
.auth-forgot-link:hover { color: var(--auth-muted-light); }

/* Shared auth button base */
.auth-btn-signin,
.auth-btn-signup {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 0.98rem;
    font-weight: 600;
    color: #fafafa;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.auth-btn-signin:hover,
.auth-btn-signup:hover { filter: brightness(1.08); }
.auth-btn-signin:active,
.auth-btn-signup:active { transform: translateY(1px); }

.auth-btn-signin {
    margin-top: 1.15rem;
    background: var(--auth-red);
    box-shadow: 0 4px 18px rgba(220, 38, 38, 0.4);
}

.auth-btn-signup {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background: var(--auth-red-dark);
    box-shadow: 0 4px 16px rgba(185, 28, 28, 0.35);
}

.auth-error--banner {
    margin-top: 0.85rem;
    min-height: 1.2rem;
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--auth-muted);
}

.auth-footer-muted { font-size: 0.9rem; color: var(--auth-muted); }

.auth-link-inline {
    border: none;
    background: none;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--auth-muted);
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
}
.auth-link-inline:hover { color: var(--auth-muted-light); }

.auth-footer-link { margin-top: 1.35rem; text-align: center; }

@media (max-width: 480px) {
    .auth-card--dark { padding: 1.5rem 1.25rem 1.75rem; border-radius: 12px; }
    .auth-title--dark { font-size: 1.2rem; }
}

/* === Guest Banner === */
.guest-banner-wrap { width: 100%; border-bottom: 1px solid var(--border-color); }
.guest-banner-wrap--hidden { display: none !important; }

.guest-banner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0.5rem 2rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.guest-banner--normal  { background: #e8f4fc; color: #1a3a4a; }
.guest-banner--warning { background: #fff4e0; color: #5c3d00; border-bottom: 1px solid #f0c96a; }
.guest-banner--blocked { background: #fde8e8; color: #6b1c1c; border-bottom: 1px solid #e07070; }

body[data-page-theme="dark"] .guest-banner--normal {
    background: #252528;
    color: #e4e4e7;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

body[data-page-theme="dark"] .guest-banner--warning {
    background: #2a2418;
    color: #f0e6c8;
    border-bottom-color: rgba(240, 201, 106, 0.35);
}

body[data-page-theme="dark"] .guest-banner--blocked {
    background: #2a1818;
    color: #f0d4d4;
    border-bottom-color: rgba(224, 112, 112, 0.45);
}

body[data-page-theme="dark"] .guest-banner-wrap {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

body[data-page-theme="dark"] .guest-banner-register-btn--inline:not(.guest-banner-register-btn--hidden):not(.guest-banner-register-btn--prominent) {
    border-color: rgba(255, 255, 255, 0.22);
}

.guest-banner-text { flex: 1 1 280px; }

.guest-banner-register-btn--inline {
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
}
.guest-banner-register-btn--inline:hover { text-decoration: underline; }

.guest-banner-register-btn--prominent {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: var(--border-radius);
    background: var(--primary-color);
    color: #fff !important;
    text-decoration: none !important;
    box-shadow: var(--shadow-small);
}
.guest-banner-register-btn--prominent:hover { filter: brightness(1.05); }
.guest-banner-register-btn--hidden { display: none !important; }
