/* ============================================
   Common UI Framework — shared across all pages
   Cache: 1 year immutable, DO NOT inline
   ============================================ */

:root {
    --bg-primary: #0c0c1d;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --border-color: rgba(255,255,255,0.06);
    --border-glow: rgba(108,125,240,0.08);
    --text-primary: #ffffff;
    --text-secondary: #8b8da3;
    --text-tertiary: var(--text-primary);
    --accent: #6c7df0;
    --accent-glow: rgba(108,125,240,0.3);
    --accent-subtle: rgba(108,125,240,0.12);
    --up: #f23645;
    --up-bg: rgba(242,54,69,0.12);
    --down: #089981;
    --down-bg: rgba(8,153,129,0.12);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --container-max: 520px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: #0c0c1d; scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar { display: none; }

body {
    background: var(--bg-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    min-height: 100vh; overflow-x: hidden;
    padding-bottom: calc(76px + var(--safe-bottom));
    max-width: var(--container-max); margin: 0 auto;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ====== Header ====== */
.header {
    background: linear-gradient(180deg, #141428 0%, #0f0f24 100%);
    padding: calc(16px + var(--safe-top)) 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    position: relative;
    overflow: hidden;
}
.header-top {
    display: flex;
    align-items: center;
    gap: 12px;
}
.back-btn {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    text-decoration: none;
}
.back-btn:active { transform: scale(0.88); background: rgba(255,255,255,0.1); }
.header h1 { flex: 1; font-size: 20px; font-weight: 700; }
.header h1 i { color: var(--accent); margin-right: 5px; }

/* ====== Buttons ====== */
.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, #6c7df0 0%, #8b5cf6 100%);
    border: none;
    color: #fff;
    padding: 11px 0;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: inherit;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(108,125,240,0.25);
    letter-spacing: 0.5px;
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(108,125,240,0.15); }
.btn-primary i { font-size: 13px; }

.btn-icon {
    width: 38px; height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 10px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-icon:hover { border-color: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-icon:active { background: rgba(255,255,255,0.08); transform: scale(0.92); }

/* ====== Slide Toggle ====== */
.slide-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    padding: 6px 10px;
    border-radius: 10px;
    transition: background 0.2s;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}
.slide-toggle:active { background: rgba(255,255,255,0.05); }
.slide-knob {
    position: relative;
    width: 34px; height: 18px;
    background: rgba(255,255,255,0.15);
    border-radius: 9px;
    transition: background 0.25s;
    flex-shrink: 0;
}
.slide-knob::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.slide-toggle.on .slide-knob {
    background: linear-gradient(135deg, #6c7df0, #8b5cf6);
    box-shadow: 0 0 10px rgba(108,125,240,0.4);
}
.slide-toggle.on .slide-knob::after { transform: translateX(16px); }
.slide-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.25s;
}
.slide-toggle.on .slide-label { color: var(--accent); }

/* ====== Stats Bar ====== */
.stats-bar {
    background: linear-gradient(135deg, rgba(26,26,46,0.9) 0%, rgba(30,30,52,0.9) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 8px 16px 10px;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-primary);
    backdrop-filter: blur(8px);
}
.stats-bar .stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
}
.stats-bar .stat-item strong { color: var(--text-primary); }
.stats-bar .stat-divider {
    width: 1px; height: 14px;
    background: var(--border-color);
}

/* ====== Bottom Nav (nav.php) ====== */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    background: rgba(14,14,30,0.92); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border-color);
    display: flex; justify-content: space-around; align-items: center;
    padding: 4px 0 calc(4px + var(--safe-bottom)); z-index: 200;
    max-width: var(--container-max); width: 100%;
}
.nav-item {
    flex: 1; text-align: center; padding: 4px 0; color: var(--text-secondary);
    font-size: 9px; cursor: pointer; text-decoration: none; transition: color 0.2s; position: relative;
}
.nav-item i { font-size: 20px; display: block; margin-bottom: 2px; }
.nav-item:active i { transform: scale(0.85); }
.nav-item.active { color: var(--text-primary); }
.nav-item.active i { filter: drop-shadow(0 0 10px var(--accent-glow)); }
.nav-item.active::after {
    content: ''; position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
    width: 16px; height: 3px; background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 2px;
}

/* ====== Toast ====== */
.toast {
    position: fixed;
    top: calc(20px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26,26,46,0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-primary);
    padding: 11px 22px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 500;
    z-index: 5000;
    animation: toastIn 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ====== Stock Card ====== */
.stock-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 2px 8px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    overflow: hidden;
}
.stock-card:hover { border-color: rgba(255,255,255,0.08); background: var(--bg-card-hover); }
.stock-card:active { transform: scale(0.985); }
.stock-card .rank-num {
    width: 20px; height: 20px;
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700;
    flex-shrink: 0; margin-right: 6px;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
}
.stock-card .rank-num.r1 { background: linear-gradient(135deg,#ffd700,#f0a500); color: #1a1a2e; }
.stock-card .rank-num.r2 { background: linear-gradient(135deg,#c0c0c0,#a0a0a0); color: #1a1a2e; }
.stock-card .rank-num.r3 { background: linear-gradient(135deg,#cd7f32,#b8860b); color: #fff; }
.stock-card .info { flex: 1; min-width: 0; }
.stock-card .info .name-code {
    font-size: 12px; font-weight: 600; color: var(--text-primary);
    display: flex; align-items: center; gap: 4px;
}
.stock-card .info .name-code .cd {
    font-size: 10px; font-weight: 400; color: var(--text-tertiary);
}
.stock-card .info .tags {
    font-size: 10px;
    margin-top: 2px;
    display: flex; align-items: center; flex-wrap: wrap; gap: 3px;
}
.stock-card .price-info { width: 78px; flex: none; display: flex; flex-direction: column; align-items: flex-end; align-self: stretch; justify-content: center; }
.stock-card .price-info .price { font-size: 14px; font-weight: 700; letter-spacing: -0.2px; }
.stock-card .price-info .price.up { color: var(--up); }
.stock-card .price-info .price.down { color: var(--down); }
.stock-card .price-info .change { font-size: 10px; font-weight: 600; margin-top: 0; }
.stock-card .price-info .change.up { color: var(--up); }
.stock-card .price-info .change.down { color: var(--down); }

/* ====== Price Display Utilities ====== */
.up { color: var(--up); }
.down { color: var(--down); }
.ret-up { color: var(--up); }
.ret-down { color: var(--down); }

/* ====== Prob / Risk / Warn Badges ====== */
.prob-badge { font-size: 9px; font-weight: 700; padding: 0 5px; border-radius: 3px; white-space: nowrap; }
.prob-badge.prob-high { background: linear-gradient(135deg,rgba(242,54,69,0.2),rgba(242,54,69,0.08)); color: #ff4757; border: 1px solid rgba(242,54,69,0.15); }
.prob-badge.prob-mid { background: linear-gradient(135deg,rgba(255,184,0,0.2),rgba(255,184,0,0.08)); color: #ffc53d; border: 1px solid rgba(255,184,0,0.15); }
.prob-badge.prob-low { background: rgba(140,140,180,0.1); color: #8c8cb4; border: 1px solid rgba(140,140,180,0.1); }
.risk-badge { font-size: 8px; font-weight: 600; padding: 0 5px; border-radius: 3px; white-space: nowrap; }
.risk-badge.mid { background: rgba(255,184,0,0.12); color: #ffc53d; border: 1px solid rgba(255,184,0,0.12); }
.risk-badge.high { background: rgba(242,54,69,0.12); color: #ff4757; border: 1px solid rgba(242,54,69,0.12); }
.warn-badge { font-size: 9px; font-weight: 600; padding: 0 5px; border-radius: 3px; white-space: nowrap; margin-right: 2px; cursor: help; }
.warn-badge.warn-hi { background: rgba(242,54,69,0.15); color: #ff4757; border: 1px solid rgba(242,54,69,0.25); }
.warn-badge.warn-md { background: rgba(255,152,0,0.15); color: #ff9800; border: 1px solid rgba(255,152,0,0.25); }
.warn-badge.warn-lo { background: rgba(255,235,59,0.12); color: #a89a3e; border: 1px solid rgba(255,235,59,0.15); }
.warn-badge.warn-ok { background: rgba(76,175,80,0.15); color: #4caf50; border: 1px solid rgba(76,175,80,0.3); font-size: 10px; padding: 1px 7px; }
.reason-tag { font-size: 9px; font-weight: 500; padding: 0 5px; border-radius: 3px; white-space: nowrap; background: rgba(108,125,240,0.1); color: var(--accent); border: 1px solid rgba(108,125,240,0.12); flex-shrink: 0; }
.signal-tag { font-size: 9px; font-weight: 500; padding: 0 5px; border-radius: 3px; white-space: nowrap; background: rgba(0,200,83,0.1); color: #00c853; border: 1px solid rgba(0,200,83,0.15); flex-shrink: 0; }
.limitup-badge {
    display:inline-block; padding:1px 6px; border-radius:4px; font-size:10px; font-weight:700;
    background:rgba(240,185,11,0.15); color:#f0b90b; margin-right:2px;
    letter-spacing:0.5px;
}

/* ====== Quant Score ====== */
.quant-score { display:inline-block; font-size:9px; padding:0 4px; border-radius:3px; margin-left:3px; vertical-align:middle; }
.quant-score.s-high { background:rgba(242,54,69,0.15); color:#f23645; }
.quant-score.s-mid { background:rgba(242,180,50,0.15); color:#f2b432; }
.quant-score.s-low { background:rgba(139,141,163,0.15); color:#8b8da3; }
.quant-signal { display:inline-block; font-size:9px; padding:0 4px; border-radius:3px; margin-left:2px; }
.quant-signal.buy { background:rgba(242,54,69,0.12); color:#f23645; }
.quant-signal.sell { background:rgba(8,153,129,0.12); color:#089981; }

/* ====== Loading & Empty ====== */
.empty-state, .loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-primary);
}

/* ====== Bar Indicator ====== */
.bar-indicator {
    display: flex; align-items: center; gap: 3px; margin-top: 1px;
}
.bar-indicator .bar-track {
    width: 32px; height: 2px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden;
}
.bar-indicator .bar-fill {
    height: 100%; border-radius: 2px; transition: width 0.3s ease;
}
.bar-indicator .bar-fill.bull { background: linear-gradient(90deg, var(--up), #ff6b81); }
.bar-indicator .bar-fill.bear { background: linear-gradient(90deg, var(--down), #20c997); }

/* ====== Filter Card ====== */
.filter-card {
    background: linear-gradient(135deg, rgba(26,26,46,0.85) 0%, rgba(30,30,52,0.85) 100%);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin: 0 16px 10px;
    padding: 14px 16px 12px;
    backdrop-filter: blur(8px);
}
.filter-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.filter-group:last-child { margin-bottom: 0; }
.filter-group-label {
    font-size: 10px;
    color: var(--text-tertiary);
    width: 100%;
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}
.filter-tags {
    display: flex;
    gap: 8px;
    position: relative;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 3px;
}
.filter-tag {
    flex: 1;
    text-align: center;
    padding: 7px 0;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    position: relative;
}
.filter-tag.active {
    background: var(--bg-card);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.filter-tag:active { transform: scale(0.96); }
.filter-cond {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    user-select: none;
}
.filter-cond:hover { border-color: var(--accent); color: var(--accent); }
.filter-cond.active {
    background: rgba(108,125,240,0.12);
    border-color: var(--accent);
    color: var(--accent);
}

/* ====== Formula Tabs ====== */
.formula-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
}
.formula-tab {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.formula-tab:active { transform: scale(0.95); }
.formula-tab.active {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
    font-weight: 600;
}

/* ====== Card Actions ====== */
.card-actions {
    display: flex; flex-direction: column; gap: 4px; margin-left: 8px; flex-shrink: 0;
}
.card-actions button {
    width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border-color);
    background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 11px; transition: all 0.12s; flex-shrink: 0; color: var(--text-secondary);
}
.card-actions button:active { transform: scale(0.85); }
.card-actions .trade-btn { border-color: var(--accent); color: var(--accent); font-size: 12px; }
.card-actions .add-btn-s.added { background: var(--accent); color: #fff; border-color: var(--accent); }
.card-actions .trade-btn:active { background: var(--accent); color: #fff; }

/* ====== Modal ====== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px 12px; overflow-y: auto;
}
.modal-content {
    background: var(--bg-card); border-radius: 16px;
    width: 100%; max-width: 600px; max-height: 85vh;
    display: flex; flex-direction: column;
    border: 1px solid var(--border-color);
    margin-top: 20px;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
    background: transparent; border: none; color: var(--text-secondary);
    font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { background: rgba(255,255,255,0.06); }
.modal-body { padding: 12px 18px 18px; overflow-y: auto; flex: 1; }

/* ====== Trade Overlay ====== */
.trade-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.trade-overlay.show { display: flex; animation: fadeIn 0.2s; }
.trade-sheet {
    width: 100%; max-width: var(--container-max, 520px);
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    padding: 20px 20px calc(20px + var(--safe-bottom));
    animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes breathe { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ====== History Detail ====== */
.history-group { margin-bottom: 16px; }
.history-group-title {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    padding: 8px 0; border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}
.history-item {
    display: grid; align-items: center;
    grid-template-columns: 1fr 70px 60px 36px;
    padding: 7px 12px; border-radius: 8px; cursor: pointer;
    transition: background 0.15s; margin-bottom: 2px;
    font-size: 12px;
}
.history-item:hover { background: rgba(255,255,255,0.04); }
.hi-date-header {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; cursor: pointer; border-radius: 8px 8px 0 0;
    transition: background 0.15s; margin-top: 6px;
    font-size: 13px; background: rgba(255,255,255,0.02);
}
.hi-date-header:hover { background: rgba(255,255,255,0.05); }
.hi-date-header .hi-date { font-weight: 700; font-size: 14px; }
.hi-date-header .hi-day {
    font-size: 11px; color: var(--accent); font-weight: 600;
    background: rgba(108,125,240,0.15); padding: 1px 6px; border-radius: 4px;
}
.hi-date-header .hi-count { color: var(--text-tertiary); font-size: 12px; }
.hi-date-header .hi-del {
    margin-left: auto; background: transparent; border: none;
    color: var(--text-secondary); font-size: 13px; cursor: pointer;
    padding: 4px 6px; border-radius: 6px; opacity: 0.4; transition: opacity 0.2s;
}
.hi-date-header .hi-del:hover { opacity: 1; color: var(--up); }
.hi-ck { display:inline-flex; width:18px; height:18px; border:2px solid var(--text-tertiary); border-radius:4px; margin-right:6px; cursor:pointer; vertical-align:middle; align-items:center; justify-content:center; font-size:11px; color:#fff; flex-shrink:0; transition:background 0.15s,border-color 0.15s; }
.hi-ck:hover { border-color:var(--accent); }
.hist-tab {
    background: rgba(255,255,255,0.04); border: 1px solid var(--border-color);
    color: var(--text-secondary); padding: 5px 14px; border-radius: 8px;
    font-size: 12px; cursor: pointer; font-family: inherit; font-weight: 500;
    transition: all 0.2s;
}
.hist-tab.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
}
.hist-tab:active { opacity: 0.8; }
.center-tab {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px 14px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}
.center-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.center-tab:active { opacity: 0.8; }

/* ====== Perf / Merge Tables ====== */
.perf-summary {
    display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px;
}
.perf-card {
    text-align: center;
    background: rgba(255,255,255,0.03); border-radius: 10px;
    padding: 12px 10px; border: 1px solid var(--border-color);
}
.perf-card .pc-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.perf-card .pc-val { font-size: 22px; font-weight: 700; }
.perf-card .pc-val.up { color: var(--up); }
.perf-card .pc-val.down { color: var(--down); }
.perf-table-wrap {
    overflow-x: auto; margin-top: 8px;
    border: 1px solid var(--border-color); border-radius: 10px;
}
.perf-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.perf-table th {
    background: rgba(255,255,255,0.04); padding: 4px 3px;
    text-align: center; font-weight: 600; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color); white-space: nowrap;
    font-size: 11px;
}
.perf-table td { padding: 3px 3px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 12px; }
.perf-table tr:last-child td { border-bottom: none; }
.perf-table .td-name { text-align: left; font-weight: 500; white-space: nowrap; padding-right: 2px; }
.perf-table .td-code { color: var(--text-secondary); font-size: 11px; margin-right: 3px; }
.row-new { background: rgba(255,200,50,0.06); }
.row-new .td-name::after { content: ' 新'; color: var(--accent); font-size: 10px; font-weight: 700; }

.merge-table-wrap { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 10px; }
.merge-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.merge-table th {
    background: rgba(255,255,255,0.04); padding: 4px 3px;
    text-align: center; font-weight: 600; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color); white-space: nowrap;
    font-size: 11px;
}
.merge-table td { padding: 4px 5px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 12px; }
.merge-table tr:last-child td { border-bottom: none; }
.merge-table .td-name { text-align: left; font-weight: 500; white-space: nowrap; padding-right: 2px; }
.merge-table .td-code { color: var(--text-secondary); font-size: 11px; white-space: nowrap; }
.merge-table tr:hover { background: rgba(255,255,255,0.03); }
.history-back {
    background: transparent; border: none; color: var(--accent);
    font-size: 13px; cursor: pointer; padding: 4px 0; margin-bottom: 12px;
    display: inline-flex; align-items: center; gap: 4px;
}
.history-back:hover { opacity: 0.8; }

/* ====== AI Analysis ====== */
.ai-analysis {
    margin-top: 14px; padding: 16px;
    background: rgba(108,125,240,0.06);
    border: 1px solid rgba(108,125,240,0.15);
    border-radius: 12px;
    font-size: 13px; line-height: 1.8;
    white-space: pre-wrap;
    color: var(--text-primary);
}
.ai-analysis h2 { font-size: 15px; font-weight: 700; margin: 12px 0 6px; color: var(--accent); }
.ai-analysis h3 { font-size: 13px; font-weight: 600; margin: 10px 0 4px; color: var(--text-primary); }
.ai-analysis strong { color: var(--accent); }

/* ====== Desktop Adaptation ====== */
@media (min-width: 640px) {
    :root { --container-max: 640px; }
    body { background: #0a0a18; }
    .header, .controls, .stats-bar, .filter-card, .formula-tabs, .stock-list {
        max-width: var(--container-max);
        margin-left: auto;
        margin-right: auto;
    }
    .bottom-nav {
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -2px 20px rgba(0,0,0,0.3);
    }
    .modal-content {
        box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    }
    .stock-list { padding: 0; }
}

@media (min-width: 900px) {
    :root { --container-max: 800px; }
    body { padding: 0 24px calc(76px + var(--safe-bottom)); }
    .header { border-radius: 16px; margin: calc(16px + var(--safe-top)) auto 0; padding: calc(16px + var(--safe-top)) 24px 14px; }
    .controls { padding: 10px 16px; }
    .formula-tabs { padding: 6px 16px 12px; gap: 8px; }
    .formula-tab { padding: 8px 16px; font-size: 13px; }
    .stock-card { padding: 4px 12px; }
    .stock-card .price-info { width: 90px; }
    .stock-card .price-info .price { font-size: 15px; }
    .stock-card .info .name { font-size: 13px; }
    .modal-content { max-width: 700px; }
}

@media (min-width: 1200px) {
    :root { --container-max: 960px; }
    body { padding: 0 40px calc(76px + var(--safe-bottom)); }
    .header { padding: calc(24px + var(--safe-top)) 28px 16px; }
    .stock-card .price-info { width: 100px; }
}

/* ====== Reduced Motion ====== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
