/* ============================================================
   WAFFET MOBILE - CSS
   ============================================================ */
:root {
    --bg-dark: #060606;
    --bg-panel: #080808;
    --bg-card: #0f0f0f;
    --bg-input: #080808;
    --accent-primary: #61B754;
    --accent-glow: rgba(97, 183, 84, 0.4);
    --success: #00ff9d;
    --danger: #ff4757;
    --warning: #ffb142;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-tertiary: #555555;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --glass-bg: #080808;
    --glass-border: rgba(255, 255, 255, 0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --tab-bar-height: 60px;
    --header-height: 52px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', 'Plus Jakarta Sans', sans-serif; }

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ============ LOADER ============ */
.app-loader {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #060606; display: flex; align-items: center; justify-content: center;
    z-index: 9999; transition: opacity 0.4s ease, visibility 0.4s ease;
}
.app-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-content { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.loader-logo-wrapper { position: relative; width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; }
.loader-logo { width: 60px; height: 60px; object-fit: contain; z-index: 2; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.loader-spinner { position: absolute; top: 0; left: 0; width: 100px; height: 100px; border: 2px solid rgba(97,183,84,0.1); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: 14px; font-weight: 500; color: var(--text-secondary); }

/* Mini loader (in-app thinking indicator) */
.mini-loader {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(6,6,6,0.6); display: flex; align-items: center; justify-content: center;
    z-index: 9998; transition: opacity 0.2s ease, visibility 0.2s ease;
}
.mini-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.mini-loader-inner { position: relative; width: 56px; height: 56px; }
.mini-loader-logo { width: 32px; height: 32px; object-fit: contain; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; }
.mini-loader-spinner { position: absolute; top: 0; left: 0; width: 56px; height: 56px; border: 2px solid rgba(97,183,84,0.1); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; }

/* ============ HEADER ============ */
.mobile-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: calc(var(--header-height) - 2px);
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 28px; height: 28px; object-fit: contain; }
.header-title { font-family: 'Poppins', sans-serif; font-size: 1rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-icon-btn {
    background: rgba(255,255,255,0.06); border: none;
    color: var(--text-primary); border-radius: var(--radius-sm);
    padding: 4px 8px; font-size: 0.75rem; font-weight: 500; cursor: pointer;
    height: 26px; display: flex; align-items: center; justify-content: center;
    box-sizing: border-box; min-width: 32px;
}

/* ============ MAIN ============ */
.mobile-main {
    padding-top: calc(var(--header-height) - 2px);
    padding-bottom: var(--tab-bar-height);
    min-height: 100vh;
}
.tab-content { display: none; padding: 12px 14px; }
.tab-content.active { display: block; }

/* ============ TAB BAR ============ */
.tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    height: var(--tab-bar-height);
    background: var(--glass-bg);
    border-top: 1px solid var(--glass-border);
    display: flex; align-items: center; justify-content: space-around;
    padding: 0 12px env(safe-area-inset-bottom, 0) 12px;
}
.tab-bar-btn {
    display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 0;
    background: none; border: none; color: var(--text-tertiary);
    font-size: 0.72rem; font-weight: 600; cursor: pointer;
    padding: 8px 14px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50px; white-space: nowrap;
    flex: 0 0 auto;
}
.tab-bar-btn svg { width: 22px; height: 22px; flex-shrink: 0; transition: stroke 0.3s; }
.tab-bar-btn span { display: none; }
.tab-bar-btn.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    padding: 8px 16px;
}
.tab-bar-btn.active svg { stroke: var(--accent-primary); }
.tab-bar-btn.active span {
    display: inline;
    margin-left: 6px;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

/* ============ EXPLORE TAB ============ */
.explore-sticky-header {
    position: fixed; top: calc(var(--header-height) - 2px); left: 0; right: 0; z-index: 50;
    background: var(--bg-dark);
    padding: 14px 14px 4px 14px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}
.search-bar {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: 9px; padding: 0 10px; margin-bottom: 6px;
    height: 36px; box-sizing: border-box;
}
.search-bar input {
    flex: 1; background: none; border: none; color: var(--text-primary);
    font-size: 0.75rem; outline: none;
}
.search-bar input::placeholder { color: var(--text-tertiary); }
.search-icon { width: 14px; height: 14px; color: var(--text-secondary); flex-shrink: 0; }

/* Search clear button */
.search-clear-btn {
    display: none; background: none; border: none; color: var(--text-tertiary);
    cursor: pointer; padding: 4px; align-items: center; justify-content: center;
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 2;
}
.search-clear-btn.visible { display: flex; }
.search-clear-btn:active { color: var(--text-primary); }
.bt-search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    z-index: 2;
}

/* Category dropdown in sort-bar */
.cat-dropdown { position: relative; z-index: 10; }

/* Fixed widths so dropdowns don't resize when selection changes */
#categoryDropBtn { min-width: 0; width: 100%; }
#regionDropBtn { min-width: 0; width: 100%; }
#sortDropBtn { min-width: 0; width: 100%; }
#tfModeWrap { min-width: 0; flex: 1; }
#tfNumWrap { min-width: 0; flex: 1; }
#tfUnitWrap { min-width: 0; flex: 1; }
#tfRangeStartWrap { min-width: 0; flex: 1; }
#tfRangeEndWrap { min-width: 0; flex: 1; }

.sort-bar-wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 5px;
    margin-bottom: 8px;
}
.sort-bar-row {
    display: contents;
}
/* Row 1 left group: All + World */
.filter-left-group {
    display: flex; align-items: center; gap: 5px;
    min-width: 0;
}
.filter-left-group .cat-dropdown { flex: 1; min-width: 0; }
.filter-left-group #regionDropdownWrap { flex: 1; min-width: 0; }
.filter-left-group .cat-dropdown .mobile-drop-btn,
.filter-left-group #regionDropdownWrap .mobile-drop-btn { width: 100%; justify-content: space-between; }
/* Row 1 right: Total Return — matches view-unified width */
.sort-bar-row #sortDropdownWrap { width: 100%; }
.sort-bar-row #sortDropdownWrap .mobile-drop-btn { width: 100%; justify-content: space-between; }
/* Row 2 left: tf-unified fills to match All+World */
.sort-bar-row > .tf-unified { min-width: 0; }
/* Row 2 right: view-unified */
.sort-bar-row > .view-unified { width: 100%; }

/* Unified timeframe container (single rounded rectangle with dividers) */
.tf-unified {
    display: flex; align-items: center;
    background: rgba(255,255,255,0.06); border: none;
    border-radius: 9px; height: 28px;
    overflow: visible;
}
.sort-bar-row > .tf-unified { width: 100%; }
.sort-bar-row > .tf-unified .mobile-dropdown.tf-compact { flex: 1; min-width: 0; }
.sort-bar-row > .tf-unified .mobile-drop-btn.tf-unified-btn { justify-content: space-between; }
.tf-divider {
    width: 1px; height: 14px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}
.tf-unified .mobile-dropdown.tf-compact { flex-shrink: 0; }
.tf-unified .mobile-drop-btn.tf-unified-btn {
    background: transparent; border: none; border-radius: 0;
    padding: 4px 8px; font-size: 0.75rem; gap: 2px;
    height: 28px; box-sizing: border-box; width: 100%;
}
.tf-unified .mobile-dropdown.tf-compact:first-child .mobile-drop-btn.tf-unified-btn {
    border-radius: 9px 0 0 9px;
}
.tf-unified .mobile-dropdown.tf-compact:last-child .mobile-drop-btn.tf-unified-btn {
    border-radius: 0 9px 9px 0;
}
.tf-unified .mobile-drop-btn.tf-unified-btn.tf-unified-last {
    border-radius: 9px;
}
.tf-unified .mobile-drop-btn.tf-unified-btn.tf-unified-first {
    border-radius: 9px 0 0 9px;
}

/* Compact timeframe dropdowns */
.mobile-dropdown.tf-compact .mobile-drop-btn {
    padding: 5px 8px; font-size: 0.75rem; gap: 3px;
}
.mobile-dropdown.tf-compact .mobile-drop-arrow { width: 8px; height: 8px; }
.mobile-dropdown.tf-compact .mobile-drop-content { max-height: 200px; overflow-y: auto; }
.mobile-dropdown.tf-compact .mobile-drop-option { padding: 8px 14px; font-size: 0.75rem; }

/* Range date picker two-column layout */
.range-drop-content.range-drop-content {
    max-height: none;
    overflow: visible;
    animation: none;
    left: 0;
    right: auto;
    transform: none;
}
.range-cols {
    display: flex;
    min-width: 140px;
}
.range-col {
    flex: 1;
    max-height: 180px;
    overflow-y: auto;
    padding: 0;
}
.range-col-divider {
    width: 1px;
    background: var(--border-subtle, rgba(255,255,255,0.08));
    flex-shrink: 0;
}
.range-col-option {
    padding: 5px 8px;
    font-size: 0.65rem;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    border-radius: 3px;
}
.range-col-option:not(:last-child) { border-bottom: 1px solid var(--border-subtle); }
.range-col-option:hover { background: rgba(255,255,255,0.08); }
.range-col-option:active, .range-col-option.selected { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.range-col::-webkit-scrollbar { width: 3px; }
.range-col::-webkit-scrollbar-track { background: transparent; }
.range-col::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* ============ CUSTOM DROPDOWNS ============ */
.mobile-dropdown { position: relative; flex-shrink: 0; }
.mobile-drop-btn {
    background: rgba(255,255,255,0.06); border: none;
    border-radius: 9px; padding: 6px 10px;
    cursor: pointer; display: flex; align-items: center; gap: 4px;
    color: var(--text-primary); font-size: 0.75rem; font-weight: 500;
    font-family: 'Inter', sans-serif; transition: all 0.2s;
    white-space: nowrap; height: 28px; box-sizing: border-box;
}
.mobile-drop-btn:active { background: rgba(255,255,255,0.04); }
.mobile-drop-arrow { opacity: 0.4; flex-shrink: 0; transition: transform 0.2s; width: 8px; height: 8px; }
.mobile-drop-arrow.rotated { transform: rotate(180deg); }
.mobile-drop-content {
    display: none; position: absolute; left: 0; top: 100%;
    margin-top: 4px; z-index: 500;
    background: #1a1a1a; border: none;
    border-radius: 9px; overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    min-width: 100%;
}
.mobile-drop-content.show { display: block; animation: fadeIn 0.15s ease-out; }
.mobile-drop-option {
    padding: 8px 14px; cursor: pointer; transition: background 0.15s;
    color: var(--text-primary); font-size: 0.75rem; font-family: 'Inter', sans-serif;
    white-space: nowrap;
}
.mobile-drop-option:not(:last-child) { border-bottom: 1px solid var(--border-subtle); }
.mobile-drop-option:active, .mobile-drop-option.selected { background: rgba(255,255,255,0.08); }
.mobile-drop-option.selected { color: var(--text-primary); }

/* ============ ASSET LIST ============ */
.asset-list { display: flex; flex-direction: column; gap: 4px; contain: layout style; }
.asset-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-card); border: none;
    border-radius: var(--radius-md); padding: 12px; cursor: pointer;
    transition: background 0.15s;
    content-visibility: auto;
    contain-intrinsic-size: auto 62px;
    contain: layout style paint;
}
.asset-item:active { background: rgba(255,255,255,0.04); }
.asset-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; flex-shrink: 0; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.asset-info { flex: 1; min-width: 0; }
.asset-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-ticker { font-size: 0.7rem; color: var(--text-tertiary); }
.asset-right { text-align: right; flex-shrink: 0; }
.asset-price { font-size: 0.8rem; font-weight: 600; }
.asset-change { font-size: 0.7rem; font-weight: 500; padding: 2px 6px; border-radius: 4px; display: inline-block; }
.asset-change.positive { color: var(--accent-primary); background: rgba(97,183,84,0.1); }
.asset-change.negative { color: var(--danger); background: rgba(255,71,87,0.1); }
.asset-change.neutral { color: #a78bfa; background: rgba(167,139,250,0.1); }
.asset-minichart { width: 70px; height: 32px; flex-shrink: 0; contain: strict; }
.asset-minichart svg { width: 100%; height: 100%; }

/* ============ ASSET DETAIL ============ */
.asset-detail {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-dark); z-index: 200;
    padding: 0 14px; overflow-y: auto;
    padding-bottom: 30px;
}
.detail-header { display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.back-btn { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 4px; }
.detail-symbol-info { display: flex; align-items: center; gap: 10px; }
.detail-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.detail-name { font-size: 0.95rem; font-weight: 600; }
.detail-ticker { font-size: 0.75rem; color: var(--text-tertiary); }
.detail-price-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.detail-price { font-size: 1.6rem; font-weight: 700; }
.detail-change { font-size: 0.85rem; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.detail-change.positive { color: var(--accent-primary); background: rgba(97,183,84,0.12); }
.detail-change.negative { color: var(--danger); background: rgba(255,71,87,0.12); }

/* Favorite star in detail view */
.detail-fav-star {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.35;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}
.detail-fav-star svg {
    fill: none;
    stroke: #9ca3af;
    stroke-width: 1.5;
    transition: all 0.2s ease;
}
.detail-fav-star.favorited {
    opacity: 1;
}
.detail-fav-star.favorited svg {
    fill: #facc15;
    stroke: #eab308;
}
.detail-toolbar {
    display: flex; align-items: center;
    margin-bottom: 8px; gap: 8px;
}
.detail-toolbar .detail-chart-type { margin-bottom: 0; flex-shrink: 0; }
.detail-toolbar .tf-unified { margin-left: 0; flex: 1; min-width: 0; max-width: 72%; }
.detail-toolbar .tf-unified .mobile-dropdown.tf-compact { flex: 1 1 0; min-width: 0; }
.detail-toolbar .tf-unified .mobile-drop-btn.tf-unified-btn { justify-content: space-between; width: 100%; }
.detail-toolbar .tf-unified .mobile-drop-content { min-width: 100%; }
.detail-toolbar .tf-unified .range-drop-content.range-drop-content {
    left: 50%; right: auto; transform: translateX(-50%);
}
#dtfRangeEndWrap .range-drop-content.range-drop-content {
    left: auto; right: 0; transform: none;
}
.detail-chart-container { width: 100%; height: 220px; margin-bottom: 10px; }
.detail-chart-container canvas { width: 100% !important; height: 100% !important; }
.detail-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat-card {
    background: var(--bg-card); border: none;
    border-radius: var(--radius-md); padding: 8px 12px;
}
.stat-label { font-size: 0.65rem; color: var(--text-tertiary); margin-bottom: 2px; text-transform: capitalize; letter-spacing: 0.5px; }
.stat-value { font-size: 0.8rem; font-weight: 600; }
.stat-value.positive { color: var(--accent-primary); }
.stat-value.negative { color: var(--danger); }

/* ============ TEST TAB ============ */
.test-header h2, .ci-header h2, .settings-header h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.test-subtitle, .ci-subtitle { font-size: 0.8rem; color: var(--text-tertiary); margin-bottom: 16px; }
/* Backtest config layout */
.bt-config { display: flex; flex-direction: column; gap: 16px; margin-bottom: 14px; }
.bt-section { display: flex; flex-direction: column; gap: 16px; }
.bt-field { display: flex; flex-direction: column; }
.bt-field label { display: block; color: var(--text-tertiary); font-size: 0.7rem; margin-bottom: 6px; font-weight: 500; text-transform: capitalize; letter-spacing: 0.5px; }
.bt-field-half { flex: 1; }
.bt-row-horizontal { display: flex; gap: 12px; }

/* Symbol search input */
.bt-symbol-input {
    position: relative; display: flex; align-items: center;
}
.bt-search-icon {
    position: absolute; left: 10px; width: 14px; height: 14px;
    color: var(--text-tertiary); pointer-events: none;
}
.bt-symbol-input input {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    padding: 6px 12px 6px 32px; color: var(--text-primary);
    border-radius: 9px; font-size: 0.75rem; font-weight: 500;
    height: 28px; box-sizing: border-box; outline: none; transition: all 0.2s ease;
}
.bt-symbol-input input::placeholder { color: var(--text-tertiary); }
.bt-symbol-input input:hover { background: rgba(255,255,255,0.08); }
.bt-symbol-input input:focus { background: rgba(255,255,255,0.08); box-shadow: none; }

/* Input with prefix (Initial / Contribution) */
.bt-input-prefix { position: relative; display: flex; align-items: center; }
.bt-prefix {
    position: absolute; left: 10px; color: var(--text-tertiary);
    font-weight: 500; pointer-events: none; font-size: 0.75rem;
}
.bt-input-prefix input {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    padding: 6px 10px 6px 28px; color: var(--text-primary);
    border-radius: 9px; font-size: 0.75rem; font-weight: 500;
    height: 28px; box-sizing: border-box; outline: none; transition: all 0.2s ease;
}
.bt-input-prefix input:hover { background: rgba(255,255,255,0.08); }
.bt-input-prefix input:focus { background: rgba(255,255,255,0.08); box-shadow: none; outline: none; }
.bt-input-prefix input[type="number"]::-webkit-outer-spin-button,
.bt-input-prefix input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bt-input-prefix input[type="number"] { -moz-appearance: textfield; }

/* Input with suffix (Interest Rate %) */
.bt-input-suffix { position: relative; display: flex; align-items: center; }
.bt-suffix {
    position: absolute; right: 10px; color: var(--text-tertiary);
    font-weight: 500; pointer-events: none; font-size: 0.75rem;
}
.bt-input-suffix input {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    padding: 6px 24px 6px 10px; color: var(--text-primary);
    border-radius: 9px; font-size: 0.75rem; font-weight: 500;
    height: 28px; box-sizing: border-box; outline: none; transition: all 0.2s ease;
}
.bt-input-suffix input:hover { background: rgba(255,255,255,0.08); }
.bt-input-suffix input:focus { background: rgba(255,255,255,0.08); box-shadow: none; outline: none; }
.bt-input-suffix input[type="number"]::-webkit-outer-spin-button,
.bt-input-suffix input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bt-input-suffix input[type="number"] { -moz-appearance: textfield; }

/* Frequency buttons */
.bt-freq-buttons {
    display: flex; gap: 2px; background: rgba(255,255,255,0.06);
    border: none; border-radius: 9px; padding: 3px;
}
.bt-freq-btn {
    flex: 1; padding: 5px 4px; border: none; border-radius: 7px;
    background: transparent; color: var(--text-secondary);
    font-size: 0.7rem; font-weight: 500; cursor: pointer;
    transition: all 0.2s ease; text-transform: capitalize; letter-spacing: 0.3px;
    white-space: nowrap;
}
.bt-freq-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.bt-freq-btn.active {
    background: rgba(255,255,255,0.12); color: var(--text-primary); font-weight: 700;
    border: none;
}

/* Period / Duration buttons */
.bt-period-buttons {
    display: flex; gap: 2px; background: rgba(255,255,255,0.06);
    border: none; border-radius: 9px; padding: 3px;
}
.bt-period-btn {
    flex: 1; padding: 5px 4px; border: none; border-radius: 7px;
    background: transparent; color: var(--text-secondary);
    font-size: 0.7rem; font-weight: 500; cursor: pointer;
    transition: all 0.2s ease; text-transform: capitalize; letter-spacing: 0.3px;
    white-space: nowrap;
}
.bt-period-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.bt-period-btn.active {
    background: rgba(255,255,255,0.12); color: var(--text-primary); font-weight: 700;
    border: none;
}
.bt-period-custom {
    flex: 1; padding: 6px; display: flex; align-items: center; justify-content: center;
}
.bt-period-custom svg { display: block; }

/* Custom period panel */
.bt-custom-panel {
    display: flex; align-items: center; gap: 4px; margin-top: 6px;
    background: var(--bg-input); border: none;
    border-radius: var(--radius-sm); padding: 3px;
}
.bt-custom-input {
    width: 40px; min-width: 0; background: rgba(255, 255, 255, 0.06);
    border: none; border-radius: 4px;
    color: var(--text-primary); font-size: 0.7rem; font-weight: 600;
    text-align: center; padding: 4px 2px; outline: none;
    -moz-appearance: textfield;
}
.bt-custom-input::-webkit-outer-spin-button,
.bt-custom-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bt-custom-input:focus { border-color: transparent; }
.bt-custom-unit-toggle {
    display: flex; background: rgba(255, 255, 255, 0.04);
    border-radius: 4px; overflow: hidden; border: none;
}
.bt-custom-unit-btn {
    padding: 4px 8px; border: none; background: transparent;
    color: var(--text-secondary); font-size: 0.65rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s ease;
}
.bt-custom-unit-btn.active { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.bt-custom-apply {
    display: flex; align-items: center; justify-content: center;
    padding: 4px 6px; border: none; border-radius: 4px;
    background: rgba(255,255,255,0.12); color: #ffffff; cursor: pointer;
    transition: all 0.15s ease; margin-left: auto;
}
.bt-custom-apply:hover { background: rgba(255,255,255,0.18); }

/* Search results & asset rows (shared) */
.test-search-results {
    max-height: 200px; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
}
.test-search-results:empty { display: none; }
.test-search-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    cursor: pointer; transition: background 0.15s;
}
.test-search-item:active { background: rgba(255,255,255,0.04); }
.test-search-item img { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.test-search-item-name { font-size: 0.8rem; font-weight: 500; }
.test-search-item-ticker { font-size: 0.7rem; color: var(--text-tertiary); }
.test-assets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.test-assets:empty { display: none; }
.test-asset-row {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg-card); border: none;
    border-radius: var(--radius-md); padding: 6px 8px;
    min-width: 0;
}
.test-asset-row img { width: 22px; height: 22px; border-radius: 5px; object-fit: contain; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; flex-shrink: 0; }
.test-asset-row .asset-info { flex: 1; min-width: 0; overflow: hidden; }
.test-asset-row .asset-name { display: none; }
.test-asset-row .asset-ticker { font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.test-asset-weight {
    width: 40px; background: rgba(255,255,255,0.06); border: none;
    color: var(--text-primary); padding: 3px 4px; border-radius: 5px;
    font-size: 0.7rem; text-align: center; outline: none; transition: all 0.2s ease;
    flex-shrink: 0;
}
.test-asset-weight:hover, .test-asset-weight:focus { background: rgba(255,255,255,0.08); }
.test-asset-remove {
    background: none; border: none; color: var(--danger); cursor: pointer;
    font-size: 0.85rem; padding: 2px; opacity: 0.6; flex-shrink: 0;
}
.test-asset-remove:hover { opacity: 1; }

/* Legacy param styles kept for race/other subtabs */
.test-search {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    color: var(--text-primary); padding: 6px 10px; border-radius: 9px;
    font-size: 0.75rem; font-weight: 500; outline: none; height: 28px; box-sizing: border-box;
}
.test-search::placeholder { color: var(--text-tertiary); }
.param-row { display: flex; align-items: center; justify-content: space-between; }
.param-row label { font-size: 0.7rem; color: var(--text-tertiary); text-transform: capitalize; letter-spacing: 0.5px; }
.param-input-wrap {
    display: flex; align-items: center; gap: 4px;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); padding: 4px 10px;
}
.param-currency { font-size: 0.8rem; color: var(--text-tertiary); }
.param-input-wrap input {
    width: 80px; background: none; border: none; color: var(--text-primary);
    font-size: 0.85rem; text-align: right; outline: none;
}
.param-row select {
    background: var(--bg-card); border: 1px solid var(--glass-border);
    color: var(--text-primary); padding: 6px 10px; border-radius: var(--radius-sm);
    font-size: 0.8rem; outline: none;
}
.test-run-btn {
    width: 100%; padding: 6px 8px; border: none; border-radius: 4px;
    background: #1f4a1d; color: #ffffff; font-size: 0.7rem;
    font-weight: 700; cursor: pointer; transition: all 0.2s;
    text-transform: capitalize; letter-spacing: 0.3px;
}
.test-run-btn:active { background: #2d5a2a; }
.ci-calc-btn {
    width: 100%; padding: 14px; border: none; border-radius: var(--radius-md);
    background: var(--accent-primary); color: #000; font-size: 0.9rem;
    font-weight: 700; cursor: pointer; transition: opacity 0.2s;
}
.test-run-btn:active { background: #2d5a2a; }
.ci-calc-btn:active { opacity: 0.8; }
.test-results { margin-top: 16px; }
.test-result-chart { width: 100%; height: 200px; margin-bottom: 12px; }
.test-result-chart canvas { width: 100% !important; height: 100% !important; }
.test-result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ============ COMPOUND INTEREST TAB ============ */
.ci-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.ci-row { display: flex; align-items: center; justify-content: space-between; }
.ci-row label { font-size: 0.8rem; color: var(--text-secondary); }
.ci-input-wrap {
    display: flex; align-items: center; gap: 4px;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); padding: 4px 10px;
}
.ci-currency { font-size: 0.8rem; color: var(--text-tertiary); }
.ci-input-wrap input {
    width: 80px; background: none; border: none; color: var(--text-primary);
    font-size: 0.85rem; text-align: right; outline: none;
}
.ci-input-plain {
    width: 70px; background: var(--bg-card); border: 1px solid var(--glass-border);
    color: var(--text-primary); padding: 6px 10px; border-radius: var(--radius-sm);
    font-size: 0.85rem; text-align: right; outline: none;
}
.ci-row select {
    background: var(--bg-card); border: 1px solid var(--glass-border);
    color: var(--text-primary); padding: 6px 10px; border-radius: var(--radius-sm);
    font-size: 0.8rem; outline: none;
}
.ci-results { margin-top: 16px; }
.ci-summary { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; }
.ci-stat {
    background: var(--bg-card); border: none;
    border-radius: var(--radius-md); padding: 8px 12px; text-align: center;
}
.ci-stat-label { font-size: 0.65rem; color: var(--text-tertiary); text-transform: capitalize; letter-spacing: 0.5px; display: block; margin-bottom: 2px; }
.ci-stat-value { font-size: 0.8rem; font-weight: 700; color: var(--accent-primary); }
.ci-stat-value.ci-contributed { color: var(--text-primary); }
.ci-stat-value.ci-interest { color: var(--accent-primary); }
.ci-chart-container { width: 100%; height: 200px; margin-bottom: 16px; }
.ci-chart-container canvas { width: 100% !important; height: 100% !important; }
.ci-table-container { overflow-x: auto; }
.ci-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.ci-table th { color: var(--text-tertiary); font-weight: 500; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--glass-border); }
.ci-table td { padding: 8px 6px; border-bottom: 1px solid var(--glass-border); color: var(--text-secondary); }

/* ============ SETTINGS TAB ============ */
.settings-header { margin-bottom: 16px; }
.profile-overlay-inner .settings-header { padding-top: 36px; }
.settings-list { display: flex; flex-direction: column; gap: 16px; }
.settings-group { background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); overflow: visible; position: relative; z-index: 1; }
.settings-group:first-child { z-index: 2; }
.settings-group-title { font-size: 0.7rem; color: var(--text-tertiary); text-transform: capitalize; letter-spacing: 0.5px; padding: 12px 14px 6px; }
.settings-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--glass-border);
}
.settings-item:last-child { border-bottom: none; }
.settings-item-left { display: flex; align-items: center; gap: 10px; }
.settings-item-left svg { color: var(--text-secondary); }
.settings-item-left span { font-size: 0.85rem; }
.settings-select {
    background: rgba(255,255,255,0.08); border: none;
    color: var(--text-primary); padding: 5px 10px; border-radius: var(--radius-sm);
    font-size: 0.8rem; outline: none;
}
.settings-value { font-size: 0.8rem; color: var(--text-tertiary); }
.settings-item-clickable { cursor: pointer; }
.settings-item-clickable:active { opacity: 0.6; }

/* Privacy Policy Modal */
.privacy-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    justify-content: center; align-items: center; padding: 16px;
}
.privacy-modal-overlay.show { display: flex; }
.privacy-modal {
    position: relative; width: 100%; max-width: 600px;
    max-height: calc(100vh - 48px); background: var(--bg-card);
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    overflow-y: auto; padding: 24px 20px;
    -webkit-overflow-scrolling: touch;
}
.privacy-modal-close {
    position: sticky; top: 0; float: right;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: 50%; width: 32px; height: 32px;
    font-size: 1.3rem; color: var(--text-primary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 1;
}
.privacy-modal-close:active { opacity: 0.6; }
.privacy-modal-body { color: var(--text-secondary); font-size: 0.82rem; line-height: 1.6; }
.privacy-modal-body h2 { color: var(--text-primary); font-size: 1.05rem; margin: 0 0 16px; }
.privacy-modal-body h3 { color: var(--text-primary); font-size: 0.9rem; margin: 18px 0 6px; }
.privacy-modal-body p { margin: 0 0 10px; }
.privacy-modal-body ul { margin: 0 0 10px; padding-left: 18px; }
.privacy-modal-body li { margin-bottom: 4px; }
.privacy-modal-body a { color: var(--accent); }

/* Cookie Consent Banner */
.cookie-banner {
    display: none; position: fixed; bottom: 70px; left: 12px; right: 12px;
    z-index: 9998; background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg); padding: 16px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4); backdrop-filter: blur(12px);
    animation: cookieSlideUp 0.35s ease-out;
}
.cookie-banner.show { display: block; }
@keyframes cookieSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.cookie-banner-text {
    font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 12px;
}
.cookie-banner-text a { color: var(--accent); text-decoration: underline; font-size: 0.8rem; }
.cookie-banner-btns { display: flex; gap: 10px; }
.cookie-btn {
    flex: 1; padding: 10px 0; border-radius: var(--radius-md); font-size: 0.82rem;
    font-weight: 600; cursor: pointer; border: none; transition: opacity 0.15s;
}
.cookie-btn:active { opacity: 0.7; }
.cookie-btn-accept { background: #1f4a1d; color: #fff; border: 1px solid #2d5a2a; }
.cookie-btn-reject { background: transparent; color: var(--text-secondary); border: 1px solid var(--glass-border); }

/* Settings custom dropdowns */
.settings-dropdown { position: relative; }
.settings-drop-btn {
    background: rgba(255,255,255,0.12); border: none;
    border-radius: var(--radius-md); padding: 6px 12px;
    cursor: pointer; display: flex; align-items: center; gap: 8px;
    color: var(--text-primary); font-size: 0.85rem; font-weight: 400;
    font-family: 'Inter', sans-serif; transition: all 0.2s ease;
    white-space: nowrap; height: 32px; box-sizing: border-box;
    min-width: fit-content;
}
.settings-drop-btn:hover { background: rgba(255,255,255,0.15); }
.settings-drop-arrow { opacity: 0.4; flex-shrink: 0; transition: transform 0.2s; }
.settings-drop-arrow.rotated { transform: rotate(180deg); }
.settings-drop-content {
    display: none; position: absolute; right: 0; top: 100%;
    margin-top: 4px; z-index: 9999;
    background: var(--bg-panel); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    min-width: 100%;
}
.settings-drop-content.show { display: block; animation: fadeIn 0.2s ease-out; }
.settings-drop-option {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer; transition: all 0.2s ease;
    color: var(--text-primary); font-size: 0.85rem; font-family: 'Inter', sans-serif;
    font-weight: 400; white-space: nowrap;
}
.settings-drop-option:hover { background: rgba(255, 255, 255, 0.05); }
.settings-drop-option:not(:last-child) { border-bottom: 1px solid var(--border-subtle); }
.settings-drop-option.selected { background: rgba(255, 255, 255, 0.12); color: var(--text-primary); }
.settings-lang-flag {
    width: 20px; height: 15px; object-fit: cover; border-radius: 2px;
    image-rendering: crisp-edges; flex-shrink: 0;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* ============ ANIMATIONS ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* fadeIn removed from tab-content to reduce paint cost on tab switch */

/* ============ VIEW MODE (unified style like tf-unified) ============ */
.view-unified {
    display: flex; align-items: center;
    background: rgba(255,255,255,0.06); border: none;
    border-radius: 9px; height: 28px;
    flex-shrink: 0; overflow: visible;
}
.vu-btn {
    padding: 0 8px; background: none; border: none;
    color: var(--text-tertiary); cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex; align-items: center; justify-content: center;
    height: 28px; box-sizing: border-box;
    position: relative; z-index: 0;
}
.vu-btn:first-child { border-radius: 9px 0 0 9px; }
.vu-btn:last-child { border-radius: 0 9px 9px 0; }
.vu-btn.active {
    background: rgba(255,255,255,0.12); color: var(--text-primary);
    z-index: 1; margin: 0 -0.5px; padding: 0 8.5px;
}
.vu-btn.active:first-child { margin-left: 0; padding-left: 8px; }
.vu-btn.active:last-child { margin-right: 0; padding-right: 8px; }
/* Hide dividers adjacent to active button */
.vu-btn.active + .vu-divider,
.vu-divider:has(+ .vu-btn.active) { opacity: 0; }
.vu-btn svg { pointer-events: none; }
.vu-divider {
    width: 1px; height: 14px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

/* ============ RANKING VIEW ============ */
.ranking-container { display: flex; flex-direction: column; gap: 4px; }
.ranking-headers { display: none; }
.ranking-col-header {
    font-size: 0.7rem; font-weight: 600; text-transform: capitalize; letter-spacing: 0.5px;
    padding: 6px 8px; border-radius: var(--radius-sm); text-align: center;
}
.ranking-col-header.winners { color: var(--accent-primary); background: rgba(97,183,84,0.08); }
.ranking-col-header.losers { color: var(--danger); background: rgba(255,71,87,0.08); }
.ranking-columns { display: flex; flex-direction: column; gap: 10px; }
.ranking-column { display: flex; flex-direction: column; gap: 3px; }
.ranking-item {
    position: relative; overflow: hidden;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); padding: 8px 10px;
    display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.ranking-item:active { background: rgba(255,255,255,0.04); }
.ranking-bar {
    position: absolute; top: 0; left: 0; bottom: 0;
    opacity: 0.12; border-radius: var(--radius-sm);
}
.ranking-bar.positive { background: var(--accent-primary); }
.ranking-bar.negative { background: var(--danger); }
.ranking-bar.neutral { background: #a78bfa; }
.ranking-item img { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; background: #151515; position: relative; z-index: 1; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.ranking-item-info { position: relative; z-index: 1; flex: 1; min-width: 0; }
.ranking-item-ticker { font-size: 0.7rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking-item-return { font-size: 0.65rem; font-weight: 500; }
.ranking-item-return.positive { color: var(--accent-primary); }
.ranking-item-return.negative { color: var(--danger); }
.ranking-item-return.neutral { color: #a78bfa; }

/* ============ MAP VIEW ============ */
.map-container {
    width: 100%; height: 450px; overflow: hidden;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); position: relative;
    touch-action: none; cursor: grab;
}
.map-container.grabbing { cursor: grabbing; }
.map-container svg {
    display: block; pointer-events: all;
    transform-origin: 0 0;
}
.map-container svg path { fill: #1a1a1a; stroke: #333; stroke-width: 0.3; transition: fill 0.2s; cursor: pointer; }
.map-container svg path.has-data { cursor: pointer; }
.map-container svg path:hover { opacity: 0.85; }
.map-legend {
    display: flex; align-items: center; gap: 4px; padding: 8px 10px;
    font-size: 0.65rem; color: var(--text-tertiary); flex-wrap: wrap; justify-content: center;
    margin-top: 6px;
}
.map-legend-bar {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
    display: flex; align-items: center; gap: 4px; padding: 6px 10px;
    font-size: 0.6rem; color: var(--text-tertiary); flex-wrap: wrap; justify-content: center;
    background: rgba(13, 13, 13, 0.85); backdrop-filter: blur(4px);
    border-top: 1px solid var(--glass-border);
}
.map-legend-title { font-weight: 600; color: var(--text-secondary); margin-right: 4px; }
.map-legend-item { display: flex; align-items: center; gap: 3px; }
.map-legend-color { width: 12px; height: 8px; border-radius: 2px; }
.map-tooltip {
    position: fixed; z-index: 300; background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); padding: 8px 10px; pointer-events: none;
    font-size: 0.75rem; box-shadow: 0 4px 12px rgba(0,0,0,0.5); max-width: 200px;
}
.map-tooltip-name { font-weight: 600; margin-bottom: 2px; }
.map-tooltip-return { font-size: 0.7rem; }
.map-country-label { display: none; pointer-events: none; }
.map-country-label.visible { display: block; }

/* ============ HEATMAP VIEW ============ */
.heatmap-container {
    width: 100%; height: 450px; overflow: hidden;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); position: relative;
    touch-action: none; cursor: grab;
    contain: layout style;
}
.heatmap-container.grabbing { cursor: grabbing; }
.heatmap-inner { position: relative; transform-origin: 0 0; will-change: transform; contain: layout style; }
.heatmap-sector {
    position: absolute; overflow: hidden;
    border: 1px solid rgba(0,0,0,0.5);
    box-sizing: border-box;
    contain: layout style;
}
.heatmap-sector-label {
    position: absolute; top: 0; left: 0; right: 0;
    font-size: 0.45rem; font-weight: 700; color: rgba(255,255,255,0.5);
    background: #000;
    padding: 1px 4px; text-transform: uppercase; letter-spacing: 0.3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    pointer-events: none; z-index: 2;
}
.heatmap-cell {
    position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
    overflow: hidden; cursor: pointer;
    border: 0.5px solid rgba(0,0,0,0.3);
    box-sizing: border-box;
    contain: layout style;
}
.heatmap-cell:active { opacity: 0.7; }
.heatmap-cell-ticker, .heatmap-symbol { font-size: 0.45rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6); pointer-events: none; white-space: nowrap; }
.heatmap-cell-return, .heatmap-return { font-size: 0.25rem; font-weight: 500; color: rgba(255,255,255,0.7); text-shadow: 0 1px 2px rgba(0,0,0,0.6); pointer-events: none; white-space: nowrap; }
.heatmap-empty { padding: 40px; text-align: center; color: var(--text-tertiary); font-size: 0.85rem; }
/* During active zoom, suppress transitions and enable GPU layers */
.heatmap-container.zooming .heatmap-sector,
.heatmap-container.zooming .heatmap-cell { will-change: transform; }
.heatmap-cell.hm-culled { display: none !important; }


/* ============ TEST SUB-TABS ============ */
.test-subtabs-wrap {
    position: fixed; top: calc(var(--header-height) - 2px); left: 0; right: 0; z-index: 50;
    padding: 6px 14px 6px 14px;
    background: var(--bg-dark);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}
.test-subtabs {
    display: flex; gap: 2px; margin-bottom: 0;
    background: var(--bg-card); border-radius: var(--radius-md);
    padding: 3px; border: none;
}
.test-subtab {
    flex: 1; padding: 8px 0; background: none; border: none;
    color: var(--text-tertiary); font-size: 0.75rem; font-weight: 600;
    border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s;
    text-transform: capitalize; letter-spacing: 0.3px;
}
.test-subtab.active { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.test-subtab-content { display: none; }
.test-subtab-content.active { display: block; }

/* ============ RACE (ANIMATED) ============ */
.race-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); max-height: 180px; overflow-y: auto;
    display: none;
}
.race-dropdown.show { display: block; }
.race-drop-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    cursor: pointer; transition: background 0.15s;
}
.race-drop-item:active { background: rgba(255,255,255,0.04); }
.race-drop-item img { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.race-drop-item-name { font-size: 0.75rem; font-weight: 500; }
.race-drop-item-ticker { font-size: 0.65rem; color: var(--text-tertiary); }

/* Date input matching bt style */
.bt-date-input {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    color: var(--text-primary); padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500; height: 36px; box-sizing: border-box;
    outline: none; transition: all 0.2s ease; color-scheme: dark;
}
.bt-date-input:hover { background: rgba(255,255,255,0.08); }
.bt-date-input:focus { background: rgba(255,255,255,0.08); box-shadow: none; }

/* Inline field: label left, input right */
.bt-field-inline {
    display: flex; align-items: center; gap: 10px;
}
.bt-field-inline label {
    color: var(--text-tertiary); font-size: 0.7rem; font-weight: 500;
    min-width: 52px; flex-shrink: 0; text-transform: capitalize; letter-spacing: 0.5px;
}
.bt-field-inline .bt-symbol-input { flex: 1; }

/* Custom date picker (mobile) */
.custom-date-picker-mobile { position: relative; width: 100%; }
.bt-date-text-input {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    color: var(--text-primary); padding: 8px 36px 8px 12px; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 600; height: 36px; box-sizing: border-box;
    outline: none; transition: all 0.2s ease; cursor: text;
}
.bt-date-text-input::placeholder { color: var(--text-tertiary); font-weight: 400; }
.bt-date-text-input:hover { background: rgba(255,255,255,0.08); }
.bt-date-text-input:focus { background: rgba(255,255,255,0.08); box-shadow: none; }
.cal-icon-btn {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; background: transparent; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, 0.7); border-radius: var(--radius-sm); transition: all 0.2s ease;
}
.cal-icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: #ffffff; }
.cal-icon-btn svg { width: 16px; height: 16px; }

/* Calendar popup */
.mobile-calendar {
    display: none; position: absolute; top: 100%; left: 0; margin-top: 4px;
    background: var(--bg-panel); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    z-index: 9999; min-width: 260px; padding: 12px;
}
.mobile-calendar.show { display: block; }
.cal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.cal-nav-btn {
    background: transparent; border: none; color: var(--text-primary); cursor: pointer;
    padding: 4px 8px; border-radius: var(--radius-sm); transition: all 0.15s ease;
    display: flex; align-items: center; justify-content: center;
}
.cal-nav-btn:hover { background: rgba(255, 255, 255, 0.08); }
.cal-nav-btn svg { width: 16px; height: 16px; }
.cal-month-year { display: flex; gap: 8px; align-items: center; }
.cal-month-btn, .cal-year-btn {
    background: transparent; border: none; color: var(--text-primary);
    font-size: 0.85rem; font-weight: 600; font-family: 'Inter', sans-serif;
    cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: all 0.15s ease;
}
.cal-month-btn:hover, .cal-year-btn:hover { background: rgba(255, 255, 255, 0.08); }
.cal-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 8px;
}
.cal-weekday {
    text-align: center; font-size: 0.65rem; font-weight: 500;
    color: var(--text-secondary); padding: 4px; font-family: 'Inter', sans-serif;
}
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
    background: transparent; border: none; color: var(--text-primary);
    font-size: 0.75rem; font-family: 'Inter', sans-serif; font-weight: 400;
    cursor: pointer; padding: 7px 4px; border-radius: var(--radius-sm);
    transition: all 0.15s ease; text-align: center;
}
.cal-day:hover:not(.cal-disabled):not(.cal-other) { background: rgba(255, 255, 255, 0.08); }
.cal-day.cal-today { border: 1px solid var(--accent-primary); }
.cal-day.cal-selected { background: rgba(255, 255, 255, 0.15); color: var(--text-primary); }
.cal-day.cal-other { color: var(--text-tertiary); }
.cal-day.cal-disabled { color: var(--text-tertiary); cursor: not-allowed; opacity: 0.5; }

/* Month/Year selector */
.cal-selector {
    display: none; position: absolute; top: 40px; left: 50%; transform: translateX(-50%);
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 1001; padding: 8px;
}
.cal-selector.show { display: block; }
.cal-months-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cal-years-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-height: 150px; overflow-y: auto; }
.cal-sel-btn {
    padding: 6px 8px; background: transparent; border: none; border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 0.75rem; font-family: 'Inter', sans-serif;
    font-weight: 400; cursor: pointer; transition: all 0.15s ease; text-align: center;
}
.cal-sel-btn:hover { background: rgba(255, 255, 255, 0.08); }
.cal-sel-btn.selected { background: rgba(255, 255, 255, 0.15); }

.race-selected { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.race-chip {
    display: flex; align-items: center; gap: 5px;
    background: var(--bg-card); border: none;
    border-radius: 20px; padding: 4px 10px 4px 4px; font-size: 0.7rem;
}
.race-chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: contain; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.race-chip-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.8rem; padding: 0 2px; opacity: 0.6; }
.race-chip-remove:active { opacity: 1; }

/* Race loading overlay */
.race-loading-overlay {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 20px; gap: 16px;
}
.race-loading-logo-wrap {
    position: relative; width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
}
.race-loading-logo-wrap img {
    width: 40px; height: 40px; object-fit: contain; z-index: 2;
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.race-loading-logo-wrap .race-spinner {
    position: absolute; top: 0; left: 0; width: 72px; height: 72px;
    border: 2px solid rgba(97,183,84,0.1); border-top-color: var(--accent-primary);
    border-radius: 50%; animation: spin 1s linear infinite;
}
.race-loading-text {
    font-size: 0.78rem; font-weight: 500; color: var(--text-secondary);
    letter-spacing: 0.3px;
}

/* Race chart area */
.race-chart-area { margin-top: 12px; }
.race-stop-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(255,70,70,0.25); color: #ff4757; border: none;
    border-radius: var(--radius-md); padding: 6px 14px; font-size: 0.7rem; font-weight: 600;
    cursor: pointer; margin-bottom: 8px;
}
.race-legend {
    display: flex; gap: 0; flex-wrap: nowrap; margin-bottom: 8px;
    padding: 6px 0; width: 100%;
}
.race-legend-item { display: flex; align-items: center; gap: 5px; font-size: 0.7rem; flex: 1 1 0; min-width: 0; }
.race-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.race-legend-value { font-weight: 600; color: var(--text-secondary); }
.race-chart-area canvas { width: 100%; height: 220px; }
.race-results {
    background: var(--bg-card); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); padding: 12px; margin-top: 10px;
}
.race-results-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; text-align: center; }
.race-result-row {
    display: flex; align-items: center; gap: 8px; padding: 6px 0;
    border-bottom: 1px solid var(--glass-border);
}
.race-result-row:last-of-type { border-bottom: none; }
.race-result-rank {
    width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; background: rgba(255,255,255,0.08); flex-shrink: 0;
}
.race-result-rank.gold { background: rgba(255,215,0,0.2); color: #ffd700; }
.race-result-rank.silver { background: rgba(192,192,192,0.2); color: #c0c0c0; }
.race-result-rank.bronze { background: rgba(205,127,50,0.2); color: #cd7f32; }
.race-result-symbol { display: flex; align-items: center; gap: 6px; flex: 1; }
.race-result-symbol img { width: 22px; height: 22px; border-radius: 6px; object-fit: contain; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.race-result-symbol span { font-size: 0.75rem; font-weight: 600; }
.race-result-value { font-size: 0.75rem; font-weight: 600; }
.race-result-return { font-size: 0.7rem; font-weight: 500; padding: 2px 6px; border-radius: 4px; }
.race-result-return.positive { color: var(--accent-primary); background: rgba(97,183,84,0.1); }
.race-result-return.negative { color: var(--danger); background: rgba(255,71,87,0.1); }
.race-actions-row {
    display: flex; gap: 8px; margin-top: 8px;
}
.race-replay-btn {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    flex: 1; padding: 8px; border: none;
    background: rgba(255,255,255,0.08); color: var(--text-primary); border-radius: var(--radius-sm);
    font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.race-download-btn {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    flex: 1; padding: 8px; border: none;
    background: rgba(255,255,255,0.08); color: var(--text-primary); border-radius: var(--radius-sm);
    font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.race-download-btn:active { background: rgba(255,255,255,0.14); }

/* ============ YEARS VIEW ============ */
.years-selected { margin-bottom: 8px; }
.years-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--bg-card); border: none;
    border-radius: 20px; padding: 4px 10px 4px 4px; font-size: 0.75rem; color: var(--text-primary);
}
.years-chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: contain; background: #151515; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.years-chart-area { margin-top: 12px; }
.years-chart-area canvas { width: 100%; height: 280px; }
.years-legend {
    display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; padding: 4px 0;
}
.years-legend-item {
    display: flex; align-items: center; gap: 3px; font-size: 0.65rem;
    padding: 3px 6px; border-radius: 4px; cursor: pointer;
    background: rgba(255,255,255,0.04); transition: opacity 0.2s;
}
.years-legend-item.hidden { opacity: 0.3; }
.years-legend-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }


/* ============ CHART TYPE TOGGLE (Line/Candle) ============ */
.detail-chart-type {
    display: flex; gap: 2px; margin-bottom: 8px;
    background: var(--bg-card); border-radius: var(--radius-sm);
    padding: 2px; border: none; width: fit-content;
}
.dct-btn {
    padding: 5px 12px; background: none; border: none;
    color: var(--text-tertiary); border-radius: 6px;
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.dct-btn.active { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.dct-btn svg { pointer-events: none; }


/* ============ RANKING RACE OVERLAY ============ */
.ranking-race-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-dark); z-index: 300;
    display: flex; flex-direction: column;
    opacity: 0; transition: opacity 0.3s ease;
}
.ranking-race-overlay.active { opacity: 1; }
.ranking-race-header {
    display: flex; flex-direction: column; gap: 6px; padding: 8px 14px;
    border-bottom: 1px solid var(--glass-border);
}
.ranking-race-row-top {
    display: flex; align-items: center; gap: 8px; height: 28px; overflow: hidden;
}
.ranking-race-row-bottom {
    display: flex; align-items: center; gap: 6px; height: 28px;
}
.ranking-race-title { font-size: 0.8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.ranking-race-date { font-size: 0.7rem; color: var(--accent-primary); font-weight: 600; min-width: 60px; text-align: center; flex-shrink: 0; }
.ranking-race-speed {
    display: flex; gap: 2px; background: var(--bg-card); border-radius: var(--radius-sm);
    padding: 2px; border: 1px solid var(--glass-border); flex-shrink: 0;
}
.race-speed-btn {
    padding: 4px 8px; background: none; border: none;
    color: var(--text-tertiary); font-size: 0.6rem; font-weight: 600;
    border-radius: 4px; cursor: pointer; transition: all 0.2s;
}
.race-speed-btn.active { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.ranking-race-btn {
    display: flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.08); border: none;
    color: var(--text-primary); padding: 4px 10px; border-radius: var(--radius-sm);
    font-size: 0.7rem; font-weight: 500; cursor: pointer;
}
.ranking-race-btn svg { flex-shrink: 0; }
.ranking-race-canvas-wrap { flex: 1; position: relative; overflow: hidden; }
.ranking-race-canvas-wrap canvas { width: 100%; height: 100%; display: block; }

/* Play button in ranking view */
.ranking-play-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 6px 8px; margin-bottom: 8px;
    background: #1f4a1d; border: 1px solid #2d5a2a;
    color: #ffffff; border-radius: var(--radius-md);
    font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.ranking-play-btn:active { background: #2d5a2a; }


/* ============ SUBCATEGORY CHIPS ============ */
.subcategory-chips-wrap {
    position: relative;
    grid-column: 1 / -1;
}
.subcategory-chips {
    display: flex; gap: 4px; overflow-x: auto; padding-bottom: 0;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.subcategory-chips::-webkit-scrollbar { display: none; }
.subchip-scroll-hint {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; color: var(--text-secondary);
    background: var(--bg-dark);
    box-shadow: 0 0 8px 6px var(--bg-dark);
    pointer-events: none; z-index: 2;
    opacity: 0; transition: opacity 0.2s;
}
.subchip-scroll-hint.left { left: 0; }
.subchip-scroll-hint.right { right: 0; }
.subcategory-chips-wrap.show-left > .subchip-scroll-hint.left { opacity: 1; }
.subcategory-chips-wrap.show-right > .subchip-scroll-hint.right { opacity: 1; }
.subchip {
    flex-shrink: 0; padding: 4px 10px; border-radius: 9px;
    background: transparent; border: 1px solid transparent;
    color: var(--text-tertiary); font-size: 0.65rem; font-weight: 500;
    cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s; white-space: nowrap;
}
.subchip.active {
    background: rgba(255,255,255,0.06); border-color: transparent;
    color: var(--text-primary);
}


/* ============================================================
   🔐 LOGIN SCREEN (MOBILE)
   ============================================================ */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #060606;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.login-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 300px;
    padding: 30px 20px;
}

.login-logo-wrapper {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.login-logo {
    width: 70px;
    height: 70px;
    object-fit: contain;
}

.login-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    text-transform: capitalize;
    margin-bottom: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.login-input {
    background: #141414;
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.login-input::placeholder { color: #666; }
.login-input:focus { border-color: transparent; }

.login-btn {
    background: #1a3a18;
    border: none;
    color: #ffffff;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.login-btn:hover { background: #245a20; }

.login-guest-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    font-size: 0.82rem;
    font-weight: 400;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    opacity: 0.7;
}

.login-guest-btn:hover { opacity: 1; color: var(--text-primary); }

.login-error {
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #f87171;
    font-size: 0.78rem;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    text-align: center;
    font-family: 'Inter', sans-serif;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}

.login-divider-line {
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.login-divider-text {
    color: #555;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
}

.login-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #1a1a1a;
    border: none;
    color: #ffffff;
    padding: 13px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-google-btn:hover {
    background: #222;
}

.login-signup-btn {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.login-signup-btn:hover { opacity: 1; }

/* 👤 PROFILE ICON (MOBILE HEADER) */
.profile-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.profile-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

/* 📋 PROFILE OVERLAY (MOBILE) */
.profile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #060606;
    z-index: 100000;
    animation: profileSlideIn 0.3s ease-out;
}

@keyframes profileSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-overlay-inner {
    padding: 24px 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
}

.profile-tab-inner {
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    padding-top: 8px;
    min-height: calc(100vh - var(--header-height) - var(--tab-bar-height) - 24px);
}
.profile-tab-inner .profile-header-section { padding-top: 12px; }

.profile-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.profile-close-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }

.profile-header-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 50px;
    padding-bottom: 24px;
}

.profile-avatar-area {
    position: relative;
    display: inline-block;
}

.profile-avatar-wrapper {
    width: 90px;
    height: 90px;
    border-radius: 14px;
    background: #141414;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.profile-avatar-placeholder { color: #555; display: flex; align-items: center; justify-content: center; }

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-edit-pencil {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #1a1a1a;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.profile-edit-pencil:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.profile-edit-pencil.avatar-pencil {
    position: absolute;
    bottom: -4px;
    right: -4px;
}

.profile-username-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-username {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}

.profile-email {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
}

.profile-bio-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.profile-bio {
    font-size: 0.82rem;
    font-weight: 400;
    color: #555;
    font-family: 'Inter', sans-serif;
    font-style: italic;
}

.profile-body { flex: 1; padding: 16px 0; }

/* ============ PRICE ALERTS ============ */
.profile-alerts-section { margin-top: 4px; }
.alerts-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.alerts-title {
    font-size: 0.7rem; font-weight: 400; color: var(--text-tertiary);
    text-transform: capitalize; letter-spacing: 0.5px;
}
.alerts-add-btn {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,0.08); border: none;
    color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
}
.alerts-add-btn:active { background: rgba(255,255,255,0.16); }
.alerts-add-btn.active { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.alert-form {
    background: var(--bg-card); border: none;
    border-radius: var(--radius-lg); padding: 12px; margin-bottom: 12px;
}
.alert-form-search {
    position: relative; display: flex; align-items: center;
}
.alert-search-icon {
    position: absolute; left: 10px; width: 14px; height: 14px;
    color: var(--text-tertiary); pointer-events: none;
}
.alert-form-search input {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    color: var(--text-primary); padding: 6px 32px 6px 32px; border-radius: 9px;
    font-size: 0.8rem; outline: none; height: 28px; box-sizing: border-box;
    transition: all 0.2s ease;
}
.alert-form-search input::placeholder { color: var(--text-tertiary); }
.alert-form-search input:hover { background: rgba(255,255,255,0.08); }
.alert-form-search input:focus { background: rgba(255,255,255,0.08); box-shadow: none; }
.alert-search-clear {
    position: absolute; right: 8px; background: none; border: none;
    color: var(--text-tertiary); cursor: pointer; padding: 2px;
}
.alert-search-results {
    max-height: 160px; overflow-y: auto;
}
.alert-search-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 4px;
    cursor: pointer; border-radius: var(--radius-sm); transition: background 0.15s;
}
.alert-search-item:active { background: rgba(255,255,255,0.06); }
.alert-search-item img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.alert-search-item-name { font-size: 0.8rem; font-weight: 500; color: var(--text-primary); }
.alert-search-item-ticker { font-size: 0.65rem; color: var(--text-tertiary); }
.alert-form-config { margin-top: 10px; }
.alert-selected-asset {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    background: rgba(255,255,255,0.04); border-radius: var(--radius-sm); margin-bottom: 10px;
}
.alert-selected-asset img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.alert-selected-asset .alert-asset-name { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.alert-selected-asset .alert-asset-ticker { font-size: 0.65rem; color: var(--text-tertiary); }
.alert-config-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.alert-dir-unified {
    display: flex; align-items: center;
    background: rgba(255,255,255,0.06); border: none;
    border-radius: 9px; height: 28px;
    flex: 2; overflow: visible;
}
.alert-dir-btn {
    flex: 1; padding: 0 8px; background: none; border: none;
    color: var(--text-tertiary); cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    height: 28px; box-sizing: border-box;
    font-size: 0.7rem; font-weight: 500;
    position: relative; z-index: 0;
}
.alert-dir-btn:first-child { border-radius: 9px 0 0 9px; }
.alert-dir-btn:last-child { border-radius: 0 9px 9px 0; }
.alert-dir-btn.active {
    background: rgba(255,255,255,0.12); color: var(--text-primary); font-weight: 700;
    z-index: 1;
}
.alert-dir-btn.active:first-child { margin-left: 0; }
.alert-dir-btn.active:last-child { margin-right: 0; }
.alert-dir-btn.active + .alert-dir-divider,
.alert-dir-divider:has(+ .alert-dir-btn.active) { opacity: 0; }
.alert-dir-divider {
    width: 1px; height: 14px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}
.alert-pct-wrap { position: relative; display: flex; align-items: center; flex: 1; }
.alert-pct-wrap input {
    width: 100%; background: rgba(255,255,255,0.06); border: none;
    padding: 6px 24px 6px 10px; color: var(--text-primary);
    border-radius: 9px; font-size: 0.8rem;
    height: 28px; box-sizing: border-box; outline: none; transition: all 0.2s ease;
}
.alert-pct-wrap input:hover { background: rgba(255,255,255,0.08); }
.alert-pct-wrap input:focus { background: rgba(255,255,255,0.08); }
.alert-pct-wrap input[type="number"]::-webkit-outer-spin-button,
.alert-pct-wrap input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.alert-pct-wrap input[type="number"] { -moz-appearance: textfield; }
.alert-pct-suffix {
    position: absolute; right: 10px; color: var(--text-tertiary);
    font-weight: 500; pointer-events: none; font-size: 0.75rem;
}
.alert-save-btn {
    width: 100%; padding: 6px 8px; border: none; border-radius: 4px;
    background: #1f4a1d; color: #fff; font-size: 0.7rem; font-weight: 700;
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center;
    justify-content: center; gap: 6px;
    text-transform: capitalize; letter-spacing: 0.3px;
}
.alert-save-btn:active { background: #2d5a2a; }
.alerts-list { display: flex; flex-direction: column; gap: 6px; }
.alerts-empty {
    text-align: center; color: var(--text-tertiary); font-size: 0.8rem;
    padding: 24px 0;
}
.alert-card {
    display: flex; align-items: center; gap: 10px; padding: 6px 12px;
    background: var(--bg-card); border: none;
    border-radius: var(--radius-md);
}
.alert-card:last-child { border-bottom: none; }
.alert-card img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.alert-card-info { flex: 1; min-width: 0; overflow: hidden; }
.alert-card-symbol { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-card-detail { font-size: 0.65rem; color: var(--text-tertiary); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-card-badge {
    padding: 3px 8px; border-radius: 7px; font-size: 0.65rem; font-weight: 600;
    white-space: nowrap; background: rgba(255,255,255,0.08); color: var(--text-primary);
}
.alert-card-delete {
    background: none; border: none; color: var(--text-tertiary); cursor: pointer;
    padding: 4px; transition: color 0.2s;
}
.alert-card-delete:active { color: var(--danger); }
.language-flag-mobile {
    width: 24px;
    height: 17px;
    object-fit: cover;
    border-radius: 2px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Language dropdown in mobile header */
.mobile-lang-dropdown {
    display: none;
    position: fixed;
    background: #0f0f0f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    min-width: 140px;
    z-index: 99999;
}

.mobile-lang-dropdown.show {
    display: block;
}

.mobile-lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
}

.mobile-lang-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mobile-lang-option:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-lang-option.selected {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-lang-option img {
    width: 18px;
    height: 13px;
    object-fit: cover;
    border-radius: 2px;
}

/* Currency dropdown in mobile header */
.mobile-currency-dropdown {
    display: none;
    position: fixed;
    background: #0f0f0f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    min-width: 120px;
    z-index: 99999;
}

.mobile-currency-dropdown.show {
    display: block;
}

.mobile-currency-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
}

.mobile-currency-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mobile-currency-option:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-currency-option.selected {
    background: rgba(255, 255, 255, 0.1);
}

.currency-sym {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.profile-footer { padding: 0; }
.profile-tab-inner .profile-footer {
    position: fixed;
    bottom: var(--tab-bar-height);
    left: 0; right: 0;
    z-index: 50;
    background: var(--bg-dark);
    padding: 10px 14px 16px 14px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}
.profile-tab-inner .profile-body {
    padding-bottom: 70px;
}

.profile-logout-btn {
    width: 100%;
    padding: 10px;
    background: rgba(255, 70, 70, 0.25);
    border: none;
    border-radius: var(--radius-md);
    color: #ff4757;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-logout-btn:hover { background: rgba(255, 70, 70, 0.15); }


/* ============================================================
   🌐 MOBILE LANGUAGE DROPDOWN (HEADER)
   ============================================================ */

.mobile-lang-dropdown {
    display: none;
    position: fixed;
    background: #0f0f0f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    min-width: 140px;
    z-index: 99999;
}

.mobile-lang-dropdown.show {
    display: block;
}

.mobile-lang-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
}

.mobile-lang-opt:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mobile-lang-opt:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mobile-lang-flag-opt {
    width: 18px;
    height: 13px;
    object-fit: cover;
    border-radius: 2px;
}

/* ============================================================
   👤 PROFILE - AVATAR, USERNAME, BIO WITH EDIT PENCILS (MOBILE)
   ============================================================ */
.profile-avatar-area {
    position: relative;
    display: inline-flex;
    align-items: flex-end;
}

.profile-avatar-area .profile-avatar-wrapper {
    position: relative;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
}

.profile-edit-pencil {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.profile-edit-pencil:hover {
    background: rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
}

.profile-edit-pencil.avatar-pencil {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 28px;
    height: 28px;
    background: #1a1a1a;
    border: none;
}

.profile-username-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.profile-username {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}

.profile-bio-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.profile-bio {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-style: italic;
}

.profile-email {
    font-size: 0.78rem;
    font-weight: 400;
    color: #555;
    font-family: 'Inter', sans-serif;
}


/* ============================================================
   ✏️ EDIT MODALS (IN-APP, DARK THEME)
   ============================================================ */
.edit-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.edit-modal {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.edit-modal-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    text-align: center;
}

.edit-modal-input {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.edit-modal-input:focus {
    background: rgba(255, 255, 255, 0.1);
}

.edit-modal-input::placeholder {
    color: #555;
}

.edit-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.edit-modal-cancel {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-modal-cancel:hover {
    background: rgba(255, 255, 255, 0.12);
}

.edit-modal-save {
    background: #1a3a18;
    border: 1px solid #2a5a26;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-modal-save:hover {
    background: #245a20;
}

/* Avatar upload button */
.avatar-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 12px;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.avatar-upload-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
}

.avatar-presets-note {
    text-align: center;
    font-size: 0.72rem;
    color: #444;
    font-family: 'Inter', sans-serif;
    font-style: italic;
    margin: 0;
}


/* ============================================================
   ✏️ PROFILE EDIT MODALS
   ============================================================ */
.profile-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.profile-modal {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 100%;
    max-width: 320px;
    overflow: hidden;
    animation: modalSlideUp 0.2s ease-out;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-modal-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}

.profile-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    padding: 0;
}

.profile-modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.profile-modal-body {
    padding: 16px 18px;
}

.profile-modal-input {
    width: 100%;
    background: #0f0f0f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.profile-modal-input:focus {
    border-color: rgba(255, 255, 255, 0.25);
}

.profile-modal-input::placeholder {
    color: #555;
}

.profile-modal-footer {
    display: flex;
    gap: 10px;
    padding: 12px 18px 16px;
    justify-content: flex-end;
}

.profile-modal-cancel {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
}

.profile-modal-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
}

.profile-modal-save {
    background: #1a3a18;
    border: 1px solid #2a5a26;
    color: #ffffff;
    padding: 8px 22px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
}

.profile-modal-save:hover {
    background: #245a20;
}

/* Avatar modal */
.avatar-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.avatar-upload-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 10px;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.15s ease;
}

.avatar-upload-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.avatar-presets-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.avatar-presets-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

.avatar-presets-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.avatar-presets-coming {
    font-size: 0.78rem;
    color: #444;
    font-family: 'Inter', sans-serif;
    font-style: italic;
}

/* ============================================================
   SCREENSHOT DOWNLOAD BUTTONS
   ============================================================ */
.screenshot-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.screenshot-btn:hover, .screenshot-btn:active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.screenshot-btn-float {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}
#backtestDlBtn {
    right: auto !important;
    left: 8px !important;
}
.detail-header {
    position: relative;
}
.detail-header > .screenshot-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}
.test-results, .years-chart-area, .ci-chart-container, .map-container, .heatmap-container {
    position: relative;
}

.screenshot-overlay-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 999;
    background: rgba(6,6,6,0.55);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: rgba(255,255,255,0.5);
    padding: 7px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: auto;
}
.screenshot-overlay-btn:hover, .screenshot-overlay-btn:active {
    background: rgba(6,6,6,0.75);
    color: #fff;
}
