        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', 'SimHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 10px 12px;
        }

        /* 错误提示容器 */
        .alert-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 9999;
            max-width: 400px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        /* 错误提示框 */
        .alert {
            display: flex;
            align-items: center;
            padding: 16px 20px;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            animation: slideIn 0.3s ease-out;
            font-size: 14px;
            line-height: 1.5;
        }

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

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

        /* 错误级别样式 */
        .alert-info {
            background: #e3f2fd;
            color: #1976d2;
            border-left: 4px solid #1976d2;
        }

        .alert-warn {
            background: #fff3e0;
            color: #f57c00;
            border-left: 4px solid #f57c00;
        }

        .alert-error {
            background: #ffebee;
            color: #d32f2f;
            border-left: 4px solid #d32f2f;
        }

        .alert-fatal {
            background: #f5f5f5;
            color: #424242;
            border-left: 4px solid #424242;
        }

        /* 错误提示图标 */
        .alert-icon {
            margin-right: 12px;
            font-size: 20px;
            flex-shrink: 0;
        }

        /* 错误提示关闭按钮 */
        .alert-close {
            margin-left: 12px;
            background: none;
            border: none;
            font-size: 18px;
            cursor: pointer;
            opacity: 0.6;
            flex-shrink: 0;
        }

        .alert-close:hover {
            opacity: 1;
        }

        .container {
            max-width: 1560px;
            margin: 0 auto;
            background: white;
            border-radius: 15px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
            padding: 24px;
        }

        /* 顶部标题栏 */
        .header-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 16px;
            padding: 12px 16px;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .header-refresh-btn {
            margin-right: 16px;
            padding: 8px 15px;
            font-size: 14px;
            white-space: nowrap;
        }

        .header-right-actions {
            display: inline-flex;
            align-items: center;
            justify-content: flex-end;
            gap: 8px;
        }

        .header-quote {
            display: inline-flex;
            align-items: center;
            gap: 14px;
            padding: 0;
            border-radius: 0;
            background: transparent;
            border: none;
        }

        .header-quote-item {
            display: inline-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
            white-space: nowrap;
            min-width: 72px;
            padding: 6px 10px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.72);
            border: 1px solid rgba(0, 0, 0, 0.06);
            box-shadow: 0 8px 18px rgba(17, 17, 26, 0.08);
        }

        /* ==================== 详情页：realtime/summary 恢复 style-2 版布局（去除 grid 凸出感） ==================== */

        #detailPage .realtime-info {
            margin-bottom: 30px;
            padding: 18px 16px 16px;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border-radius: 10px;
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 16px;
            position: relative;
        }

        #detailPage .realtime-info .realtime-title {
            position: absolute;
            top: 8px;
            left: 15px;
            font-size: 12px;
            color: #888;
            font-weight: 500;
        }

        #detailPage .realtime-info .detail-summary-grid {
            flex: 1 1 auto;
            min-width: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 24px;
            flex-wrap: wrap;
            padding: 0 8px 0 0;
            background: transparent;
            border: none;
            box-shadow: none;
        }

        #detailPage .realtime-info .detail-summary-item {
            background: transparent;
            border: none;
            box-shadow: none;
            padding: 0;
            border-radius: 0;
        }

        #detailPage .realtime-info .detail-summary-label {
            font-size: 12px;
            color: #666;
            opacity: 1;
            margin-bottom: 5px;
        }

        #detailPage .realtime-info .detail-summary-value,
        #detailPage .realtime-info .realtime-value {
            font-size: 20px;
            font-weight: bold;
        }

        #detailPage .realtime-info .detail-summary-dual-label {
            font-size: 11px;
        }

        #detailPage .realtime-info .detail-summary-dual-value {
            font-size: 16px;
            font-weight: 600;
        }

        #detailPage .summary-info {
            text-align: center;
            margin-bottom: 30px;
            padding: 15px;
            background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 30px;
            flex-wrap: wrap;
            position: relative;
        }

        #detailPage .summary-info .summary-title {
            position: absolute;
            top: 8px;
            left: 15px;
            font-size: 12px;
            color: #888;
            font-weight: 500;
        }

        #detailPage .summary-info .detail-summary-grid {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 30px;
            flex-wrap: wrap;
            width: 100%;
            padding: 0;
            background: transparent;
            border: none;
            box-shadow: none;
        }

        #detailPage .summary-info .detail-summary-item {
            background: transparent;
            border: none;
            box-shadow: none;
            padding: 0;
            border-radius: 0;
        }

        #detailPage .summary-info .detail-summary-label {
            font-size: 12px;
            color: #666;
            opacity: 1;
            margin-bottom: 5px;
        }

        #detailPage .summary-info .detail-summary-value,
        #detailPage .summary-info .summary-value {
            font-size: 20px;
            font-weight: bold;
        }

        .header-quote-label {
            font-size: 12px;
            color: #666;
            margin-bottom: 2px;
            line-height: 1.1;
        }

        .header-quote-value {
            font-size: 20px;
            font-weight: bold;
            font-variant-numeric: tabular-nums;
            line-height: 1.1;
        }

        /* 顶部工具条内刷新提示：放在刷新按钮左侧 */
        .header-refresh-status {
            position: static;
            opacity: 1;
            transform: none;
            pointer-events: none;
            background: transparent;
            box-shadow: none;
            padding: 0;
            border-radius: 0;
            white-space: nowrap;
        }

        .header-bar h1 {
            text-align: left;
            margin-bottom: 5px;
            font-size: 28px;
            line-height: 1;
        }

        .header-bar .stock-info {
            text-align: left;
            margin-bottom: 0;
            font-size: 16px;
            color: #666;
        }

        .header-title {
            display: inline-flex;
            flex-direction: column;
            gap: 0;
        }

        /* 设置按钮 */
        .settings-btn {
            background: #f5f5f5;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            padding: 10px;
            cursor: pointer;
            transition: all 0.3s;
            color: #666;
        }

        .settings-btn:hover {
            background: #667eea;
            border-color: #667eea;
            color: white;
            transform: rotate(30deg);
        }

        /* 回到顶部按钮 */
        .scroll-to-top {
            position: fixed;
            right: 18px;
            bottom: 18px;
            width: 44px;
            height: 44px;
            border-radius: 999px;
            border: 1px solid rgba(102, 126, 234, 0.35);
            background: rgba(255, 255, 255, 0.92);
            box-shadow: 0 10px 24px rgba(17, 17, 26, 0.18);
            color: #4f46e5;
            font-size: 18px;
            font-weight: 800;
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            transition: transform 0.2s, opacity 0.2s, background 0.2s;
            z-index: 1200;
        }

        .scroll-to-top:hover {
            transform: translateY(-2px);
            background: rgba(102, 126, 234, 0.12);
        }

        .scroll-to-top.is-visible {
            display: inline-flex;
        }

        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 10px;
            font-size: 28px;
        }

        .stock-info {
            text-align: center;
            color: #666;
            margin-bottom: 10px;
            font-size: 16px;
        }

        .realtime-info {
            margin-bottom: 30px;
            padding: 18px 16px 16px;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border-radius: 10px;
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 16px;
            position: relative;
        }

        .realtime-content {
            flex: 1 1 auto;
            min-width: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 24px;
            flex-wrap: nowrap;
            padding-right: 8px;
        }

        .realtime-actions {
            flex: 0 0 auto;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            align-self: stretch;
            padding-top: 12px;
        }

        .realtime-title {
            position: absolute;
            top: 8px;
            left: 15px;
            font-size: 12px;
            color: #888;
            font-weight: 500;
        }

        .realtime-item {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .realtime-item-double {
            flex-direction: column;
            gap: 8px;
        }

        .realtime-sub-item {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .realtime-sub-item .realtime-label {
            font-size: 11px;
        }

        .realtime-sub-item .realtime-value {
            font-size: 16px;
        }

        .realtime-label {
            font-size: 12px;
            color: #666;
            margin-bottom: 5px;
        }

        .realtime-value {
            font-size: 20px;
            font-weight: bold;
        }

        .refresh-btn {
            padding: 8px 15px;
            background: #f5f5f5;
            color: #666;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
        }

        .refresh-btn:hover {
            background: #e0e0e0;
        }

        .sort-direction-group {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px;
            border-radius: 8px;
            background: #f3f5fb;
            border: 1px solid #dbe2f0;
        }

        .sort-direction-btn {
            width: 28px;
            height: 28px;
            border: none;
            border-radius: 6px;
            background: transparent;
            color: #667085;
            cursor: pointer;
            font-size: 14px;
            font-weight: bold;
            transition: all 0.2s;
        }

        .sort-direction-btn:hover {
            background: rgba(102, 126, 234, 0.12);
            color: #4f46e5;
        }

        .sort-direction-btn.active {
            background: #667eea;
            color: white;
            box-shadow: 0 2px 6px rgba(102, 126, 234, 0.25);
        }

        .refresh-status {
            position: absolute;
            top: 10px;
            right: 16px;
            padding: 4px 10px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.88);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
            font-size: 12px;
            color: #666;
            transition: opacity 0.2s, transform 0.2s, color 0.2s;
            opacity: 0;
            transform: translateY(-4px);
            pointer-events: none;
        }

        .refresh-status.visible {
            opacity: 1;
            transform: translateY(0);
        }

        .refresh-status.success {
            color: #2e7d32;
        }

        .refresh-status.error {
            color: #d32f2f;
        }

        .refresh-status.loading {
            color: #667eea;
        }

        .loading {
            color: #999;
            font-style: italic;
        }

        .summary-info {
            text-align: center;
            margin-bottom: 30px;
            padding: 15px;
            background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 30px;
            flex-wrap: wrap;
            position: relative;
        }

        .summary-title {
            position: absolute;
            top: 8px;
            left: 15px;
            font-size: 12px;
            color: #888;
            font-weight: 500;
        }

        .summary-item {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .summary-label {
            font-size: 12px;
            color: #666;
            margin-bottom: 5px;
        }

        .summary-value {
            font-size: 20px;
            font-weight: bold;
        }

        .card {
            background: white;
            color: #333;
            padding: 15px;
            border-radius: 10px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            border: 2px solid #e0e0e0;
        }

        .card h3 {
            font-size: 12px;
            margin-bottom: 8px;
            color: #666;
        }

        .card .value {
            font-size: 18px;
            font-weight: bold;
        }

        .card.profit {
            border-color: #f44336;
        }

        .card.profit .value {
            color: #f44336;
        }

        .card.loss {
            border-color: #4caf50;
        }

        .card.loss .value {
            color: #4caf50;
        }

        .section {
            margin-bottom: 30px;
        }

        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #667eea;
        }

        .section-header h2 {
            margin: 0;
            padding: 0;
            border: none;
        }

        .section-header-right {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .sort-select {
            padding: 6px 12px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
            background: white;
            cursor: pointer;
            outline: none;
            transition: border-color 0.3s;
        }

        .sort-select:hover {
            border-color: #667eea;
        }

        .sort-select:focus {
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
        }

        /* 视图切换按钮 */
        .btn-icon {
            padding: 6px 12px;
            background: white;
            border: 1px solid #ddd;
            border-radius: 6px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.3s;
        }

        .btn-icon:hover {
            border-color: #667eea;
            background: #f5f5f5;
        }

        .view-icon-grid, .view-icon-list {
            font-size: 16px;
            line-height: 1;
        }

        /* 列表模式容器 */
        .stock-cards-container.list-mode {
            display: flex;
            flex-direction: column;
            gap: 10px;
            overflow-x: auto;
        }

        /* 列表模式卡片 */
        .stock-card-list {
            display: flex;
            align-items: center;
            padding: 12px 16px;
            gap: 12px;
            min-width: max-content;
        }

        .stock-card-list:hover {
            transform: none;
            box-shadow: 0 2px 10px rgba(102, 126, 234, 0.15);
        }

        .stock-card-list-name {
            min-width: 150px;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .stock-card-list-title {
            font-size: 15px;
            font-weight: bold;
            color: #333;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .stock-card-list-code {
            font-size: 12px;
            color: #999;
        }

        .stock-card-list-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            min-width: 85px;
            font-variant-numeric: tabular-nums;
        }

        .stock-card-list-label {
            font-size: 12px;
            color: #999;
            margin-bottom: 2px;
        }

        .stock-card-list-value {
            font-size: 14px;
            font-weight: 500;
            color: #333;
            white-space: nowrap;
        }

        .stock-card-list-value.profit {
            color: #f44336;
        }

        .stock-card-list-value.loss {
            color: #4caf50;
        }

        .stock-card-list-actions {
            margin-left: 8px;
            display: flex;
            gap: 8px;
        }

        /* 数据统计表格 */
        .stats-table-container {
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }

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

        .stats-table td {
            padding: 12px 20px;
            border: 1px solid #e0e0e0;
        }

        .stats-label {
            background: #f5f5f5;
            color: #666;
            font-weight: 500;
            width: 25%;
        }

        .stats-value {
            color: #333;
            font-weight: bold;
            width: 25%;
        }

        .stats-value.profit {
            color: #f44336;
        }

        .stats-value.loss {
            color: #4caf50;
        }

        /* 图表区域 */
        .charts-container {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            margin-bottom: 20px;
        }

        .chart-box {
            flex: 1;
            min-width: 400px;
            height: 350px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .add-trade-form-container {
            background: #f5f5f5;
            padding: 20px;
            border-radius: 10px;
            margin-bottom: 20px;
            animation: slideDown 0.3s ease;
        }

        @keyframes slideDown {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .form-btn-group {
            display: flex;
            gap: 10px;
            white-space: nowrap;
        }

        .form-btn-group .btn {
            padding: 8px 16px;
            font-size: 13px;
            white-space: nowrap;
        }

        .section h2 {
            color: #333;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #667eea;
        }

        .form-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 15px;
            margin-bottom: 15px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
        }

        .form-group label {
            margin-bottom: 5px;
            color: #555;
            font-weight: 500;
        }

        .form-group input, .form-group select {
            padding: 10px;
            border: 2px solid #e0e0e0;
            border-radius: 5px;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        .form-group input:focus, .form-group select:focus {
            outline: none;
            border-color: #667eea;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s;
        }

        /* 股票选择器 */
        .stock-selector {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            margin-top: 15px;
            flex-wrap: wrap;
        }

        .stock-select {
            padding: 10px 20px;
            border: 2px solid #e0e0e0;
            border-radius: 5px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            background: white;
            min-width: 150px;
            transition: all 0.3s;
        }

        .stock-select:focus {
            outline: none;
            border-color: #667eea;
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        }

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

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

        .btn-warning {
            background: #ff9800;
            color: white;
        }

        .btn-warning:hover {
            background: #f57c00;
        }

        .btn-success {
            background: #4caf50;
            color: white;
        }

        .btn-success:hover {
            background: #388e3c;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 15px;
            background: white;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
            overflow: hidden;
        }

        th, td {
            padding: 12px;
            text-align: center;
            border-bottom: 1px solid #e0e0e0;
        }

        th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-weight: 500;
        }

        tr:hover {
            background: #f5f5f5;
        }

        .action-btns {
            display: flex;
            gap: 5px;
            justify-content: center;
        }

        .action-btns button {
            padding: 5px 10px;
            font-size: 12px;
        }

        .charts-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .chart-box {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .chart-box h3 {
            margin-bottom: 15px;
            color: #333;
            text-align: center;
        }

        .chart-container {
            width: 100%;
            height: 350px;
        }

        .profit {
            color: #f44336;
            font-weight: bold;
        }

        .loss {
            color: #4caf50;
            font-weight: bold;
        }

        .tooltip-container {
            position: relative;
            display: inline-block;
            margin-left: 5px;
        }

        .tooltip-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #667eea;
            color: white;
            font-size: 11px;
            font-weight: bold;
            cursor: help;
            vertical-align: middle;
        }

        .tooltip-text {
            visibility: hidden;
            opacity: 0;
            position: absolute;
            z-index: 2000;
            background-color: #333;
            color: white;
            padding: 8px 10px;
            border-radius: 6px;
            font-size: 12px;
            line-height: 1.45;
            box-sizing: border-box;
            width: auto;
            min-width: 180px;
            max-width: min(520px, 92vw);
            max-height: 60vh;
            overflow: auto;
            overflow-x: hidden;
            white-space: normal;
            /* 避免过于激进的断行（anywhere 会让很多本可同一行的内容提前断开） */
            overflow-wrap: break-word;
            word-break: normal;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            margin-left: 0;
            transition: opacity 0.3s;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        /* tooltip 内容排版：不要全局折叠 <br>，由各 tooltip 文案自行控制换行 */

        .tooltip-text::after {
            content: "";
            position: absolute;
            top: 100%;
            left: 50%;
            margin-left: -5px;
            border-width: 5px;
            border-style: solid;
            border-color: #333 transparent transparent transparent;
        }

        /* 详情页：实时持仓/汇总信息内的 tooltip 默认向下 + 向左（避免顶部/右侧裁切） */
        #detailPage .realtime-info .tooltip-text,
        #detailPage .summary-info .tooltip-text {
            top: calc(100% + 10px);
            bottom: auto;
            left: auto;
            right: 0;
            margin-left: 0;
            transform: none;
        }

        /* 详情页：持仓股数 tooltip 自适应宽度 */
        #detailPage #holdingTooltip {
            width: auto;
            min-width: 200px;
            max-width: min(520px, 92vw);
        }

        /* 详情页：持仓股数 tooltip 更容易内容过多，给更大可视高度 */
        #detailPage #holdingTooltip {
            max-height: 72vh;
        }

        /* 持仓股数 tooltip：每条记录按行展示，避免长行挤压 */
        #detailPage #holdingTooltip {
            white-space: normal;
        }

        #detailPage #holdingTooltip {
            display: block;
            text-align: left;
        }

        /* holding tooltip 已还原为 <br> 分行，无需额外行样式 */

        /* 若右对齐仍会导致左侧裁切，则切换为左对齐 */
        #detailPage .realtime-info .tooltip-text.tooltip-align-left,
        #detailPage .summary-info .tooltip-text.tooltip-align-left {
            right: auto;
            left: 0;
        }

        #detailPage .realtime-info .tooltip-text.tooltip-align-left::after,
        #detailPage .summary-info .tooltip-text.tooltip-align-left::after {
            right: auto;
            left: 10px;
        }

        #detailPage .realtime-info .tooltip-text::after,
        #detailPage .summary-info .tooltip-text::after {
            top: auto;
            bottom: 100%;
            left: auto;
            right: 10px;
            margin-left: 0;
            border-color: transparent transparent #333 transparent;
        }

        .tooltip-container:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }

        /* 持仓股数 tooltip：保留按日期换行，但压缩连续空行 */
        #holdingTooltip br + br {
            display: none;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            animation: fadeIn 0.3s;
        }

        .modal-content {
            background-color: white;
            margin: 10% auto;
            padding: 30px;
            border-radius: 10px;
            width: 90%;
            max-width: 500px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
            animation: slideIn 0.3s;
        }

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

        @keyframes slideIn {
            from { transform: translateY(-50px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        .modal-header {
            margin-bottom: 20px;
        }

        .modal-header h2 {
            margin: 0;
            color: #333;
        }

        .modal-footer {
            margin-top: 20px;
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            flex-shrink: 0;
            padding-top: 15px;
            border-top: 1px solid #e0e0e0;
            background: white;
        }

        /* 弹窗关闭按钮 */
        .modal-close-btn {
            position: absolute;
            top: 15px;
            right: 20px;
            background: none;
            border: none;
            font-size: 28px;
            color: #999;
            cursor: pointer;
            transition: color 0.3s;
        }

        .modal-close-btn:hover {
            color: #333;
        }

        /* 设置弹窗 */
        .settings-modal-content {
            position: relative;
            max-width: 500px;
            max-height: 75vh;
            display: flex;
            flex-direction: column;
        }

        .settings-body {
            padding: 10px 0;
            flex: 1;
            overflow-y: auto;
        }

        .settings-section {
            margin-bottom: 25px;
        }

        .settings-section h3 {
            font-size: 16px;
            color: #333;
            margin-bottom: 15px;
            padding-bottom: 8px;
            border-bottom: 1px solid #e0e0e0;
        }

        .settings-actions {
            display: flex;
            gap: 15px;
            margin-bottom: 10px;
        }

        .settings-hint {
            font-size: 12px;
            color: #999;
            margin-top: 10px;
        }

        .storage-info {
            background: #f5f5f5;
            padding: 15px;
            border-radius: 8px;
        }

        .storage-item {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid #e0e0e0;
        }

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

        .storage-label {
            color: #666;
        }

        .storage-value {
            color: #333;
            font-weight: 500;
        }

        /* 性能日志开关（设置弹窗） */
        .perf-switch {
            position: relative;
            display: inline-flex;
            width: 44px;
            height: 24px;
            flex: 0 0 auto;
        }

        .perf-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .perf-switch-slider {
            position: absolute;
            inset: 0;
            cursor: pointer;
            background: #d0d5dd;
            border-radius: 999px;
            transition: background 0.2s;
        }

        .perf-switch-slider::before {
            content: '';
            position: absolute;
            height: 18px;
            width: 18px;
            left: 3px;
            top: 3px;
            background: white;
            border-radius: 50%;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
            transition: transform 0.2s;
        }

        .perf-switch input:checked + .perf-switch-slider {
            background: #667eea;
        }

        .perf-switch input:checked + .perf-switch-slider::before {
            transform: translateX(20px);
        }

        /* 导入预览弹窗 */
        .import-modal-content {
            position: relative;
            max-width: 600px;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
        }

        .import-preview-body {
            flex: 1;
            overflow-y: auto;
            padding-bottom: 10px;
        }

        .import-summary {
            background: #f5f5f5;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
        }

        .import-summary-item {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid #e0e0e0;
        }

        .import-summary-item:last-child {
            border-bottom: none;
        }

        .import-summary-label {
            color: #666;
        }

        .import-summary-value {
            font-weight: 500;
        }

        .import-summary-value.highlight {
            color: #667eea;
        }

        .import-details {
            background: #fafafa;
            padding: 15px;
            border-radius: 8px;
        }

        .import-details h4 {
            font-size: 14px;
            color: #333;
            margin-bottom: 10px;
        }

        .import-detail-item {
            padding: 5px 0;
            font-size: 13px;
            color: #666;
            border-bottom: 1px dashed #e0e0e0;
        }

        .import-detail-item:last-child {
            border-bottom: none;
        }

        .import-warning {
            background: #fff3e0;
            border: 1px solid #ff9800;
            border-radius: 8px;
            padding: 12px;
            margin-top: 15px;
            font-size: 13px;
            color: #e65100;
        }

        .badge {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: bold;
        }

        .badge-buy {
            background: #e3f2fd;
            color: #1976d2;
        }

        .badge-sell {
            background: #ffebee;
            color: #d32f2f;
        }

        .badge-dividend {
            background: #e8f5e9;
            color: #388e3c;
        }

        .badge-tax {
            background: #fff3e0;
            color: #f57c00;
        }

        .badge-sold {
            background: #f5f5f5;
            color: #999;
        }

        .badge-holding {
            background: #e8f5e9;
            color: #4caf50;
        }

        .badge-partial {
            background: #fff3e0;
            color: #ff9800;
        }

        /* 持仓周期标记 */
        .cycle-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
            margin-right: 4px;
        }

        .cycle-1 { background: #e3f2fd; color: #1565c0; }
        .cycle-2 { background: #f3e5f5; color: #7b1fa2; }
        .cycle-3 { background: #e8f5e9; color: #2e7d32; }
        .cycle-4 { background: #fff3e0; color: #e65100; }
        .cycle-5 { background: #fce4ec; color: #c2185b; }
        .cycle-6 { background: #e0f7fa; color: #00838f; }
        .cycle-7 { background: #f9fbe7; color: #9e9d24; }
        .cycle-8 { background: #efebe9; color: #5d4037; }

        .cycle-tag {
            display: inline-block;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 11px;
            font-weight: 500;
        }

        .cycle-start {
            background: #4caf50;
            color: white;
        }

        .cycle-add {
            background: #2196f3;
            color: white;
        }

        .cycle-end {
            background: #f44336;
            color: white;
        }

        .cycle-reduce {
            background: #ff9800;
            color: white;
        }

        .cycle-dividend {
            background: #4caf50;
            color: white;
        }

        .cycle-tax {
            background: #9c27b0;
            color: white;
        }

        .sell-records {
            font-size: 11px;
            color: #666;
            text-align: left;
            padding: 5px;
        }

        .sell-record-item {
            margin: 3px 0;
            padding: 3px 5px;
            background: #f9f9f9;
            border-radius: 3px;
        }

        .trade-amount-inline {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .trade-amount-state-wrap {
            position: relative;
            display: inline-flex;
            align-items: center;
            cursor: help;
        }

        .trade-amount-state {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 2px 6px;
            border-radius: 999px;
            font-size: 10px;
            font-weight: 600;
            line-height: 1.2;
            white-space: nowrap;
        }

        .trade-amount-state.state-holding {
            background: #e8f5e9;
            color: #2e7d32;
        }

        .trade-amount-state.state-partial {
            background: #fff3e0;
            color: #ef6c00;
        }

        .trade-amount-state.state-sold {
            background: #eceff1;
            color: #546e7a;
        }

        .trade-amount-detail-tooltip {
            visibility: hidden;
            opacity: 0;
            transition: opacity 0.2s;
            position: absolute;
            /* 默认向上弹出；JS 会在靠近边界时自动翻转为向下 */
            bottom: calc(100% + 8px);
            top: auto;
            left: 50%;
            transform: translateX(-50%);
            min-width: 260px;
            max-width: 360px;
            /* 纯不透明底色，避免看起来“透明” */
            background-color: #14161c;
            background-image: linear-gradient(180deg, #14161c 0%, #262832 100%);
            color: #fff;
            text-align: left;
            border-radius: 8px;
            padding: 8px 10px;
            z-index: 100;
            box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
            border: 1px solid rgba(255, 255, 255, 0.10);
            pointer-events: none;
        }

        .trade-amount-state-wrap[data-tooltip-placement="bottom"] .trade-amount-detail-tooltip {
            top: calc(100% + 8px);
            bottom: auto;
        }

        .trade-amount-state-wrap:hover .trade-amount-detail-tooltip {
            visibility: visible;
            opacity: 1;
        }

        .trade-amount-detail-item {
            font-size: 12px;
            line-height: 1.6;
            white-space: nowrap;
        }

        .trade-amount-detail-item + .trade-amount-detail-item {
            margin-top: 2px;
        }

        .trade-amount-detail-item {
            font-size: 12px;
            line-height: 1.5;
            white-space: nowrap;
        }

/* ==================== 汇总页面样式 ==================== */

        /* 返回按钮 */
        #headerLeft {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .back-btn {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 8px 15px;
            background: #f5f5f5;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s;
            color: #666;
            font-size: 14px;
        }

        .back-btn:hover {
            background: #e0e0e0;
        }

        /* 页面容器 */
        .page-container {
            min-height: 400px;
        }

        /* 汇总统计区域 */
        .overview-summary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 15px;
            border: 1px solid rgba(255, 255, 255, 0.38);
            box-shadow: 0 8px 18px rgba(17, 17, 26, 0.12), 0 2px 8px rgba(17, 17, 26, 0.06);
            padding: 18px 18px 16px;
            margin-bottom: 18px;
            color: #fff;
        }

        .overview-summary-title {
            font-size: 16px;
            font-weight: 700;
            margin-bottom: 12px;
            text-align: left;
            letter-spacing: 0.2px;
        }

        .overview-summary-grid {
            display: grid;
            grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: 10px;
            width: 100%;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 12px;
            padding: 10px;
        }

        .overview-summary-item {
            min-width: 0;
            padding: 10px 8px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.09);
            border: 1px solid rgba(255, 255, 255, 0.16);
        }
        /* 参照持仓/清仓视觉，在组内用细分隔线区分卡片 */
        .overview-summary-item + .overview-summary-item::before {
            content: none;
        }

        .overview-summary-label {
            display: block;
            font-size: clamp(10px, 0.85vw, 12px);
            opacity: 0.85;
            margin-bottom: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
        }

        .overview-summary-value {
            display: block;
            font-size: clamp(16px, 1.35vw, 22px);
            font-weight: 800;
            color: #fff;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
        }

        .overview-summary-value.profit {
            color: #ffd0d6;
        }

        .overview-summary-value.loss {
            color: #c8f3d1;
        }

        /* ==================== 详情页 Summary Bar + Grid Stats ==================== */

        /* 仅复用布局与层级：不改动现有颜色体系 */
        .detail-summary-grid {
            display: grid;
            grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: 10px;
            width: 100%;
            border-radius: 12px;
            padding: 10px;
        }

        /* realtime：按汇总页策略响应式（6→3→2），共7项也按 6 列起步 */
        .realtime-info .detail-realtime-grid {
            grid-template-columns: repeat(6, minmax(0, 1fr));
        }

        /* summary-info：默认 9 个一行 */
        .summary-info .detail-summary-grid {
            grid-template-columns: repeat(9, minmax(0, 1fr));
        }

        /* summary-info：缩放时自动换行（9 → 6 → 3 → 2） */
        @media (max-width: 1400px) {
            .summary-info .detail-summary-grid {
                grid-template-columns: repeat(6, minmax(0, 1fr));
            }
        }

        @media (max-width: 1200px) {
            .summary-info .detail-summary-grid {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }
        }

        @media (max-width: 720px) {
            .summary-info .detail-summary-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
        }

        .detail-summary-label,
        .detail-summary-value {
            white-space: nowrap;
        }

        /* realtime 与 summary 共用字体适配 */
        .realtime-info .detail-summary-label,
        .summary-info .detail-summary-label {
            font-size: clamp(9px, 0.75vw, 12px);
        }

        .realtime-info .detail-summary-value,
        .summary-info .detail-summary-value {
            font-size: clamp(13px, 1.0vw, 20px);
        }

        /* 大框（Grid 面板）- 仅用中性透明层制造层次，不改变原有配色 */
        .realtime-info .detail-summary-grid,
        .summary-info .detail-summary-grid {
            background: rgba(255, 255, 255, 0.22);
            border: 1px solid rgba(0, 0, 0, 0.06);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
        }

        .detail-summary-item {
            min-width: 0;
            padding: 10px 8px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            border-radius: 10px;
            background: transparent;
            border: none;
        }

        /* realtime: 合并“每股持仓成本/每股摊薄成本”为一个卡片（上下排布） */
        .detail-summary-item-dual {
            align-items: stretch;
        }

        .detail-summary-dual {
            display: flex;
            flex-direction: column;
            gap: 4px;
            width: 100%;
        }

        .detail-summary-dual-row {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 10px;
        }

        .detail-summary-dual-label {
            font-size: 11px;
            opacity: 0.75;
            white-space: nowrap;
        }

        .detail-summary-dual-value {
            font-size: 14px;
            font-weight: 800;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* 小框（Item 卡片）- 仅用阴影/边框提升“凸出感” */
        .realtime-info .detail-summary-item,
        .summary-info .detail-summary-item {
            background: rgba(255, 255, 255, 0.72);
            border: 1px solid rgba(0, 0, 0, 0.06);
            box-shadow: 0 8px 18px rgba(17, 17, 26, 0.08);
        }

        /* realtime 区域底色更浅，卡片更突出一点（仍为中性透明，不改配色） */
        .realtime-info .detail-summary-grid {
            background: rgba(255, 255, 255, 0.28);
        }

        .realtime-info .detail-summary-item {
            background: rgba(255, 255, 255, 0.80);
        }

        .detail-summary-label {
            font-size: clamp(10px, 0.85vw, 12px);
            opacity: 0.85;
            margin-bottom: 4px;
            white-space: nowrap;
            max-width: 100%;
            color: inherit; /* 不改颜色 */
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            /* tooltip 需要溢出显示，不能 hidden */
            overflow: visible;
        }

        .detail-summary-label-text {
            flex: 1 1 auto;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* Tooltip 在 grid label 中不可被裁切 */
        .detail-summary-label .tooltip-container {
            flex: 0 0 auto;
        }

        .detail-summary-label .tooltip-text {
            bottom: calc(100% + 10px);
        }

        .detail-summary-value {
            display: block;
            font-size: clamp(16px, 1.35vw, 22px);
            font-weight: 800;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
            color: inherit; /* 不改颜色 */
        }

        @media (max-width: 1200px) {
            .detail-summary-grid {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }

            .realtime-info .detail-realtime-grid {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }
        }

        @media (max-width: 720px) {
            .detail-summary-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
                gap: 8px;
                padding: 8px;
            }
            .detail-summary-item {
                padding: 9px 6px;
            }

            .realtime-info .detail-realtime-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
        }

        /* 方案A：6列 → 3×2（中屏） */
        @media (max-width: 1200px) {
            .overview-summary-grid {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }
        }

        /* 方案A：2×3（小屏） */
        @media (max-width: 720px) {
            .overview-summary {
                padding: 16px 14px 14px;
            }
            .overview-summary-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
                gap: 8px;
                padding: 8px;
            }
            .overview-summary-item {
                padding: 9px 6px;
            }
        }

        /* 汇总统计详情 */
        .overview-summary-stats {
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
        }

        .overview-stats-row {
            display: flex;
            align-items: center;
            padding: 8px 0;
        }

        .overview-stats-label {
            width: 80px;
            font-size: 14px;
            opacity: 0.9;
        }

        .overview-stats-value {
            font-size: 16px;
            font-weight: 500;
            margin-right: 15px;
        }

        .overview-stats-value.profit {
            color: #ffcdd2;
        }

        .overview-stats-value.loss {
            color: #c8e6c9;
        }

        .overview-stats-detail {
            display: flex;
            gap: 15px;
            font-size: 14px;
        }

        .overview-stats-detail .profit {
            color: #ffcdd2;
        }

        .overview-stats-detail .loss {
            color: #c8e6c9;
        }

        /* 股票统计区域 */
        .overview-stock-stats {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
            margin-top: 16px;
            padding-top: 16px;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
        }

        .stock-stats-group {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 12px;
            padding: 12px;
        }

        .stock-stats-header {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 10px;
            margin-bottom: 12px;
            padding-bottom: 8px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }

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

        .stock-stats-count {
            font-size: 14px;
            font-weight: 500;
        }

        .stock-stats-detail {
            display: flex;
            gap: 15px;
            font-size: 13px;
            margin-left: auto;
        }

        .stock-stats-detail .profit {
            color: #ffcdd2;
        }

        .stock-stats-detail .loss {
            color: #c8e6c9;
        }

        .stock-stats-columns {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
        }

        /* 盈亏股票列表 */
        .profit-loss-column {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            padding: 10px;
        }

        .profit-loss-header {
            font-size: 13px;
            font-weight: 700;
            margin-bottom: 10px;
            padding-bottom: 6px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }

        .profit-loss-header.profit {
            color: #ffcdd2;
        }

        .profit-loss-header.loss {
            color: #c8e6c9;
        }

        .profit-loss-items {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .profit-loss-item {
            display: grid;
            grid-template-columns: 26px minmax(0, 1fr) auto;
            align-items: center;
            padding: 6px 8px;
            background: rgba(255, 255, 255, 0.10);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.2s, border-color 0.2s;
            gap: 8px;
        }

        .profit-loss-item:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .profit-loss-rank {
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            font-size: 11px;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
        }

        .profit-loss-stock {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 2px;
            padding-left: 4px;
        }

        .profit-loss-name {
            font-size: 13px;
            font-weight: 650;
            line-height: 1.25;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            word-break: break-all;
        }

        .profit-loss-code {
            font-size: 11px;
            opacity: 0.75;
        }

        .profit-loss-stats {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            gap: 2px;
            min-width: 80px;
            font-variant-numeric: tabular-nums;
        }

        .profit-loss-profit {
            font-size: 12px;
            font-weight: 700;
            text-align: right;
            white-space: nowrap;
        }

        .profit-loss-rate {
            font-size: 11px;
            text-align: right;
            opacity: 0.9;
            white-space: nowrap;
        }

        .profit-loss-profit.profit,
        .profit-loss-rate.profit {
            color: #ffcdd2;
        }

        .profit-loss-profit.loss,
        .profit-loss-rate.loss {
            color: #c8e6c9;
        }

        .profit-loss-empty {
            text-align: center;
            padding: 20px;
            opacity: 0.7;
            font-size: 14px;
        }

        /* 股票卡片容器 */
        .stock-cards-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 16px;
            margin-top: 12px;
        }

        /* 股票卡片 */
        .stock-card {
            background: white;
            border: 2px solid #e0e0e0;
            border-radius: 12px;
            overflow: hidden;
            cursor: pointer;
            transition: all 0.3s;
        }

        .stock-card:hover {
            border-color: #667eea;
            box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
            transform: translateY(-3px);
        }

        .stock-card-header {
            background: #f5f5f5;
            padding: 12px;
            display: flex;
            align-items: center;
            gap: 10px;
            border-bottom: 1px solid #e0e0e0;
        }

        .stock-card-name {
            font-size: 16px;
            font-weight: bold;
            color: #333;
        }

        .stock-card-code {
            font-size: 12px;
            color: #999;
            flex: 1;
        }

        .stock-card-actions {
            display: flex;
            gap: 5px;
            align-items: center;
        }

        .stock-card-action {
            width: 28px;
            height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            line-height: 1;
            transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
            color: white;
        }

        .stock-card-action:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
        }

        .stock-card-action-edit {
            background: linear-gradient(135deg, #ffb74d, #fb8c00);
        }

        .stock-card-action-delete {
            background: linear-gradient(135deg, #ef5350, #d32f2f);
        }

        .stock-card-body {
            padding: 12px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .stock-card-section {
            padding: 8px 10px;
            border: 1px solid #edf0f7;
            border-radius: 10px;
            background: #fafbff;
        }

        .stock-card-section-emphasis {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.05));
            border-color: rgba(102, 126, 234, 0.18);
        }

        .stock-card-section-title {
            font-size: 11px;
            font-weight: 800;
            color: #667eea;
            letter-spacing: 0.5px;
            margin-bottom: 6px;
        }

        .stock-card-quote-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px;
            margin-top: 4px;
        }

        .stock-card-metric-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px;
            margin-top: 4px;
        }

        .stock-card-metric-grid-3 {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }

        .stock-card-metric-item {
            display: flex;
            flex-direction: column;
            gap: 4px;
            padding: 8px;
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.78);
            border: 1px solid rgba(102, 126, 234, 0.08);
            min-width: 0;
        }

        .stock-card-metric-item-emphasis {
            background: rgba(255, 255, 255, 0.92);
            border-color: rgba(102, 126, 234, 0.14);
        }

        .stock-card-metric-label {
            color: #7a86a8;
            font-size: 11px;
            line-height: 1.2;
        }

        .stock-card-metric-value {
            font-size: 13px;
            font-weight: 650;
            color: #2f3b59;
            word-break: break-word;
            font-variant-numeric: tabular-nums;
        }

        .stock-card-metric-value.profit {
            color: #f44336;
        }

        .stock-card-metric-value.loss {
            color: #4caf50;
        }

        .stock-card-quote-item {
            display: flex;
            flex-direction: column;
            gap: 4px;
            padding: 8px;
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.75);
            border: 1px solid rgba(102, 126, 234, 0.08);
            min-width: 0;
        }

        .stock-card-quote-label {
            color: #7a86a8;
            font-size: 11px;
            line-height: 1.2;
        }

        .stock-card-quote-value {
            font-size: 13px;
            font-weight: 650;
            color: #2f3b59;
            word-break: break-word;
            font-variant-numeric: tabular-nums;
        }

        .stock-card-quote-value.profit {
            color: #f44336;
        }

        .stock-card-quote-value.loss {
            color: #4caf50;
        }

        .stock-card-row {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid #f0f0f0;
        }

        .stock-card-row:last-child {
            border-bottom: none;
            padding-bottom: 0;
        }

        .stock-card-section .stock-card-row:first-of-type {
            padding-top: 4px;
        }

        .stock-card-label {
            color: #666;
            font-size: 14px;
        }

        .stock-card-value {
            font-weight: 500;
            font-size: 14px;
        }

        .stock-card-value.profit {
            color: #f44336;
        }

        .stock-card-value.loss {
            color: #4caf50;
        }

        .stock-card-footer {
            padding: 10px 15px;
            background: #fafafa;
            border-top: 1px solid #e0e0e0;
        }

        .stock-card-yearly {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .yearly-stat {
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 12px;
        }

        .yearly-label {
            color: #999;
        }

        .yearly-value {
            font-weight: 500;
        }

        .yearly-value.profit {
            color: #f44336;
        }

        .yearly-value.loss {
            color: #4caf50;
        }

        .yearly-trades {
            color: #999;
            font-size: 11px;
        }

        /* 空状态提示 */
        .empty-hint {
            text-align: center;
            color: #999;
            padding: 30px;
            background: #f9f9f9;
            border-radius: 8px;
        }

        /* 小按钮 */
        .btn-sm {
            padding: 4px 10px;
            font-size: 12px;
        }

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

            .realtime-content {
                justify-content: center;
                padding-right: 0;
            }

            .realtime-actions {
                justify-content: center;
                padding-top: 0;
            }

            .refresh-status {
                right: 12px;
                top: 8px;
            }

            .stock-card-quote-grid {
                grid-template-columns: 1fr;
            }

            .stock-card-metric-grid,
            .stock-card-metric-grid-3 {
                grid-template-columns: 1fr;
            }

            .overview-stock-stats,
            .stock-stats-columns {
                grid-template-columns: 1fr;
            }

            .profit-loss-item {
                grid-template-columns: 24px minmax(0, 1fr);
                align-items: start;
            }

            .profit-loss-stats {
                grid-column: 2;
                align-items: flex-start;
                min-width: 0;
            }

            .stock-cards-container {
                grid-template-columns: 1fr;
            }

            .back-btn {
                padding: 6px 10px;
                font-size: 12px;
            }
        }

        @media (max-width: 768px) {
            body {
                padding: 6px;
            }

            .container {
                padding: 14px;
            }

            h1 {
                font-size: 22px;
            }

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

            .charts-container {
                grid-template-columns: 1fr;
            }

            table {
                font-size: 12px;
            }

            th, td {
                padding: 8px 4px;
            }

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

        /* 新增按钮样式 */
        .btn-warning {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .btn-warning:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(240, 147, 251, 0.4);
        }

        .btn-info {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .btn-info:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
        }

        /* 备份管理弹窗样式 */
        .backup-modal-content {
            position: relative;
            max-width: 700px;
            max-height: 80vh;
            overflow-y: auto;
        }

        .backup-modal-body {
            padding: 20px;
        }

        .backup-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .backup-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border-radius: 10px;
            transition: all 0.3s ease;
        }

        .backup-item:hover {
            transform: translateX(4px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .backup-info {
            flex: 1;
        }

        .backup-date {
            font-weight: 600;
            color: #333;
            margin-bottom: 4px;
        }

        .backup-meta {
            font-size: 13px;
            color: #666;
        }

        .backup-actions {
            display: flex;
            gap: 8px;
        }

        .backup-actions button {
            padding: 6px 12px;
            font-size: 13px;
            border-radius: 6px;
        }

        .empty-backup {
            text-align: center;
            padding: 40px;
            color: #999;
            font-size: 15px;
        }

        .empty-backup-icon {
            font-size: 48px;
            margin-bottom: 12px;
            opacity: 0.5;
        }

        /* 提示弹窗样式 */
        .alert-modal-content {
            position: relative;
            max-width: 400px;
            text-align: center;
        }

        .alert-modal-body {
            padding: 20px;
            font-size: 15px;
            color: #333;
            line-height: 1.6;
        }

        .alert-modal-footer {
            padding: 15px 20px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: center;
        }

        /* 分页控件样式 */
        .pagination-controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 20px;
            margin-top: 16px;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border-radius: 10px;
            flex-wrap: wrap;
            gap: 12px;
        }

        .pagination-info {
            flex: 1;
            min-width: 200px;
        }

        .pagination-text {
            color: #555;
            font-size: 14px;
            font-weight: 500;
        }

        .pagination-buttons {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .pagination-btn {
            padding: 8px 16px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
            white-space: nowrap;
        }

        .pagination-btn:hover:not(.disabled) {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        }

        .pagination-btn.disabled {
            background: #ccc;
            cursor: not-allowed;
            opacity: 0.6;
            transform: none;
        }

        .pagination-page-info {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 12px;
            background: white;
            border-radius: 6px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            min-width: 80px;
            justify-content: center;
        }

        .pagination-current {
            color: #667eea;
            font-size: 16px;
            font-weight: 700;
        }

        .pagination-separator {
            color: #999;
            font-size: 14px;
        }

        .pagination-total {
            color: #555;
            font-size: 14px;
        }

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

            .pagination-info {
                text-align: center;
                min-width: auto;
            }

            .pagination-buttons {
                justify-content: center;
            }
        }
        /*（已移除）概览页汇总统计的末尾覆盖样式：避免覆盖渐变背景下的白字与布局策略 */

/* ==================== 搜索框样式 ==================== */
/* 搜索容器 */
.search-container {
    position: relative;
    margin-right: 8px;
}

/* 搜索输入框 */
.search-input {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    width: 350px;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 搜索结果下拉列表 */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

/* 搜索结果项 */
.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item.highlight {
    background-color: #e8f4fd;
}

/* 搜索结果文本 */
.search-result-code {
    font-weight: bold;
    color: #667eea;
    margin-right: 8px;
    font-size: 14px;
}

.search-result-name {
    color: #333;
    font-size: 14px;
}

.search-result-group {
    font-size: 12px;
    color: #999;
    margin-left: auto;
}

/* mark 标签样式，确保不改变字体大小 */
.search-results mark {
    background-color: #ffeb3b;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* 无结果提示 */
.search-no-results {
    padding: 12px;
    color: #999;
    text-align: center;
    font-size: 14px;
}

/* ==================== 交易记录查询页面样式 ==================== */
.trade-records-header {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trade-records-page-title h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.trade-records-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.trade-records-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.trade-records-filter-select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    color: #666;
    outline: none;
    min-width: 120px;
    cursor: pointer;
    margin-left: 8px;
}

.trade-records-filter-input {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    color: #666;
    outline: none;
    width: 110px;
}

.trade-records-date-filters {
    display: flex;
    align-items: center;
    gap: 6px;
}

.trade-records-filter-separator {
    color: #999;
    font-size: 14px;
}

.trade-records-filter-btn {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: #667eea;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.trade-records-filter-btn:hover {
    background: #5568d3;
}

.trade-records-filter-btn:active {
    transform: scale(0.98);
}

.trade-records-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 8px;
}

.trade-records-summary-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.trade-records-summary-label {
    font-size: 12px;
    color: #888;
}

.trade-records-summary-value {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.trade-records-table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.trade-records-table {
    width: 100%;
    border-collapse: collapse;
}

.trade-records-table thead {
    background: #f5f5f5;
}

.trade-records-table th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    font-size: 14px;
    border-bottom: 2px solid #e0e0e0;
}

.trade-records-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.trade-records-table tbody tr:hover {
    background-color: #f9f9f9;
}

.trade-records-table tbody tr:last-child td {
    border-bottom: none;
}

.trade-records-empty {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

.trade-records-profit {
    font-weight: 600;
}

.trade-records-profit.profit {
    color: #f44336;
}

.trade-records-profit.loss {
    color: #4caf50;
}

.trade-records-type {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.trade-records-type.buy {
    background-color: #e3f2fd;
    color: #1976d2;
}

.trade-records-type.sell {
    background-color: #ffebee;
    color: #c62828;
}

.trade-records-type.dividend {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.trade-records-type.tax {
    background-color: #fff3e0;
    color: #e65100;
}

/* 交易记录图表样式 */

/* 图表选择控件样式 */
.trade-records-chart-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.trade-records-chart-selector .chart-selector-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.trade-records-chart-selector .chart-selector-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    color: #555;
}

.trade-records-chart-selector .chart-selector-item:hover {
    color: #667eea;
}

.trade-records-chart-selector .chart-selector-checkbox {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

/* 图表容器显示/隐藏 */
.trade-records-charts .chart-container {
    display: flex;
    flex-direction: column;
}

.trade-records-charts .chart-container.hidden {
    display: none;
}

.trade-records-charts {
    margin-bottom: 20px;
}

.trade-records-charts .chart-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.trade-records-charts .chart-row:last-child {
    margin-bottom: 0;
}

.trade-records-charts .chart-container {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 0; /* 防止flex子项溢出 */
}

.trade-records-charts .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.trade-records-charts .chart-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.trade-records-charts .chart-type-selector {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.trade-records-charts .chart-type-selector:hover {
    border-color: #667eea;
}

.trade-records-charts .chart-type-selector:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* 字段设置模态对话框样式 */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.field-settings-modal {
    z-index: 1001;
}

.field-settings-content {
    max-width: 500px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
}

.field-settings-modal .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.field-settings-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.field-settings-modal .modal-close-btn {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    transition: color 0.2s;
}

.field-settings-modal .modal-close-btn:hover {
    color: #333;
}

.field-settings-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.field-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.field-settings-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.field-settings-item:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.field-settings-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0 10px 0 0;
    cursor: pointer;
    accent-color: #667eea;
}

.field-settings-item input[type="checkbox"]:focus {
    outline: 2px solid rgba(102, 126, 234, 0.3);
    outline-offset: 2px;
}

.field-settings-label {
    font-size: 14px;
    color: #333;
    flex: 1;
    cursor: pointer;
}

.field-settings-modal .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.field-settings-modal .modal-footer .btn {
    padding: 8px 20px;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s;
}

.field-settings-modal .modal-footer .btn:hover {
    transform: translateY(-1px);
}
