/* （仁杰提醒你投资有风险理财需谨慎，估值仅供参考，实际净值以基金公司公布为准。） */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "微软雅黑", sans-serif;
}

body {
    max-width: 800px;
    margin: 10px auto;
    padding: 0 15px;
    background: #f5f5f5;
}

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

h1 {
    text-align: center;
    color: #165DFF;
    margin-bottom: 20px;
}

/* 选项卡 */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 4px;
}

.tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 14px;
}

.tab.active {
    background: white;
    color: #165DFF;
    box-shadow: 0 2px 8px rgba(22, 93, 255, 0.1);
}

/* 分组选项卡 */
.group-tabs {
    display: flex;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 5px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.group-tabs::-webkit-scrollbar {
    display: none;
}

.group-tab {
    padding: 10px 15px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s;
    flex-shrink: 0;
    min-width: 80px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.group-tab.active {
    background: white;
    color: #165DFF;
    box-shadow: 0 2px 8px rgba(22, 93, 255, 0.1);
}

.add-group-tab {
    background: transparent;
    color: #165DFF;
    padding: 0;
    border-radius: 6px;
    min-width: 32px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-left: 10px;
    margin-top: 8px;
}

.add-group-tab:hover {
    background: rgba(22, 93, 255, 0.05);
    transform: scale(1.05);
}

.add-group-tab i {
    font-size: 18px;
}

/* 搜索框 */
.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

#fundCode {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
}

#searchBtn {
    padding: 0 16px;
    background: #165DFF;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    white-space: nowrap;
}

#searchBtn:hover {
    background: #0E48D9;
}

/* 功能按钮组 */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.action-btn {
    flex: 1;
    padding: 10px 8px;
    border: 1px solid #165DFF;
    border-radius: 6px;
    background: white;
    color: #165DFF;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    text-align: center;
}

.action-btn:hover {
    background: #165DFF;
    color: white;
}

.action-btn.remove {
    border-color: #F53F3F;
    color: #F53F3F;
}

.action-btn.remove:hover {
    background: #F53F3F;
    color: white;
}

/* 查询结果 */
.result {
    display: none;
    margin-top: 20px;
}

.fund-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.data-item {
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
}

.label {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

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

.rise {
    color: #F53F3F;
}

.fall {
    color: #00B42A;
}

.neutral {
    color: #86909C;
}

/* 自选和持仓页面 */
.watchlist-container, .position-container {
    display: none;
}

/* 表头 */
.list-header {
    display: flex;
    align-items: center;
    padding: 10px 4px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 4px;
    font-weight: 600;
    color: #333;
    font-size: 12px;
}

.header-cell {
    padding: 0 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: none;
}

.header-cell.right {
    justify-content: flex-end;
    text-align: right;
}

.sort-icon {
    font-size: 12px;
    color: #999;
}

/* 基金列表 */
.fund-list {
    max-height: 400px;
    overflow-y: auto;
}

.fund-item {
    display: flex;
    align-items: center;
    padding: 10px 4px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
    cursor: pointer;
    position: relative;
    font-size: 12px;
    user-select: none;
}

.fund-item:hover {
    background: #f8f9fa;
}

.fund-item.active {
    background: #f0f7ff;
}

.fund-cell {
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fund-code {
    font-weight: bold;
    color: #165DFF;
}

.fund-name-text {
    font-weight: 500;
}

.fund-value {
    text-align: right;
    justify-content: flex-end;
    font-weight: bold;
}

.profit-positive {
    color: #F53F3F;
}

.profit-negative {
    color: #00B42A;
}

/* 浮窗操作界面 */
.action-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 999;
}

.action-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 4px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    width: 90%;
    max-width: 280px;
    border: 1px solid #e0e0e0;
}

.action-panel-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    color: #1a1a1a;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    line-height: 1.3;
}

.position-info {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 16px;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    min-height: 80px;
    align-items: center;
    gap: 12px;
}

.position-info span {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    text-align: center;
    position: relative;
    padding-top: 22px;
}

.position-info [data-label] {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
}

.position-info [data-label]:before {
    content: attr(data-label);
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: #f8fafc;
    padding: 0 8px;
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    font-weight: 500;
    line-height: 1;
}

.position-amount {
    color: #334155;
}

.position-cost {
    color: #059669;
}

.position-rate {
    font-weight: 600;
    font-size: 15px;
}

.action-buttons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 8px 0;
    width: 100%;
    box-sizing: border-box;
}

/* 确保移动端始终保持三列布局 */
@media screen and (max-width: 768px) {
    .action-buttons-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    
    .action-panel-btn {
        min-width: 0 !important;
        flex-shrink: 1 !important;
    }
}

.action-panel-btn {
    padding: 8px 6px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    position: relative;
}

.action-panel-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.action-panel-btn i {
    font-size: 18px;
    margin-bottom: 4px;
}



.action-panel-btn-text {
    font-weight: 500;
    line-height: 1.2;
}

/* 持仓统计卡片 */
.position-summary-card {
    background: white;
    border-radius: 2px;
    padding: 4px;
    margin-top: 6px;
    border: 1px solid #f0f0f0;
}

.position-summary-card.editing-breathing-bg {
    border-color: #165DFF;
}

.summary-grid {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    text-align: center;
}

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

.summary-label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
}

.summary-value {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.1;
    word-break: break-all;
}

/* 设置页面 */
.settings-container {
    display: none;
}

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

.settings-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.settings-section h4 {
    margin: 15px 0 10px 0;
    color: #666;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.settings-label {
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 24px;
}

.toggle-checkbox {
    display: none;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

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

.toggle-checkbox:checked + .toggle-slider {
    background-color: #165DFF;
}

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

/* 对话框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-size: 14px;
}

.form-input, .form-file {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

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

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.loading {
    text-align: center;
    padding: 20px;
    display: none;
}

.loading i {
    color: #165DFF;
    font-size: 20px;
    margin-right: 8px;
}

.tips {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #999;
}

.error-tip {
    color: #F53F3F;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

/* 分组管理样式 */
.group-management {
    margin-bottom: 20px;
}

.group-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.group-item:hover {
    background: #f8fafc;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.group-item.active {
    border-color: #165DFF;
    background: #f0f7ff;
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
}

.group-item.dragging {
    opacity: 0.8;
    background: #f0f7ff;
    position: absolute;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: rotate(2deg);
}

.group-item-info {
    flex: 1;
    min-width: 0;
}

.group-item-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 16px;
    margin-bottom: 4px;
}

.group-item-count {
    font-size: 13px;
    color: #6b7280;
}

.group-item-actions {
    display: flex;
    gap: 8px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.group-item:hover .group-item-actions {
    opacity: 1;
}

/* 编辑状态呼吸动画 */
@keyframes breathing {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(22, 93, 255, 0.2);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(22, 93, 255, 0);
    }
}

.group-item.editing-breathing-bg {
    border-color: #165DFF;
    background: #f0f7ff;
    animation: breathing 2s ease-in-out infinite;
    position: relative;
}

.group-item.editing-breathing-bg::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 14px;
    background: linear-gradient(45deg, #165DFF, #7b61ff, #165DFF);
    z-index: -1;
    opacity: 0.3;
    animation: breathing 2s ease-in-out infinite;
}

/* 拖拽手柄样式优化 */
.drag-handle {
    margin-right: 16px;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    cursor: grab;
    color: #9ca3af;
}

.drag-handle:hover {
    background-color: #f3f4f6;
    color: #6b7280;
}

.drag-handle:active {
    cursor: grabbing;
    color: #165DFF;
}

.drag-handle i {
    font-size: 16px;
}

.empty-tip {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.icon-btn {
    padding: 5px 10px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: #165DFF;
}

/* 历史记录 */
.history-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

/* 快速操作按钮 */
.quick-buttons {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.quick-buttons .btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 14px;
}

/* 通知弹窗 */
.notification {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s;
}

.notification.show {
    opacity: 1;
    pointer-events: auto;
}

.notification-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    padding: 24px;
    max-width: 400px;
    width: 90%;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.notification.show .notification-content {
    transform: scale(1);
}

.notification-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.notification-content p {
    color: #666;
}

/* Gist配置 */
.gist-info {
    border-top: 1px solid #eee;
    padding-top: 16px;
}

.gist-info h4 {
    font-weight: 500;
    margin-bottom: 8px;
}

.help-text {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}

/* 导入选项 */
.import-options {
    margin-top: 10px;
}

.import-options label {
    display: block;
    margin-bottom: 8px;
}

/* 响应式调整 */
@media (max-width: 600px) {
    .summary-grid {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .summary-item {
        flex: 1 1 calc(50% - 5px);
        min-width: calc(50% - 5px);
    }
    
    .summary-label {
        font-size: 12px;
    }
    
    .summary-value {
        font-size: 14px;
    }
    
    .action-buttons-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quick-buttons {
        flex-wrap: wrap;
    }
    
    .quick-buttons .btn {
        flex: 1 1 calc(50% - 5px);
    }
}