/* ========== 全局样式 ========== */
:root {
    --primary: #dc2626;
    --primary-dark: #b91c1c;
    --primary-light: #fee2e2;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 15px rgba(0,0,0,0.1);
    --radius: 10px;
    --sidebar-width: 220px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ========== 左侧侧边栏 ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--card);
    border-right: 2px solid var(--primary);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    text-align: center;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.sidebar-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: white;
}

.sidebar-header .subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 6px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    margin: 6px 0;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    cursor: pointer;
}

.sidebar-nav-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(4px);
}

.sidebar-nav-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(220,38,38,0.3);
}

.sidebar-nav-item .nav-icon {
    font-size: 20px;
    min-width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.sidebar-footer .time {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.sidebar-footer .disclaimer {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 手机端菜单按钮 */
.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1002;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

/* ========== 主内容区 ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* 手机端：隐藏侧边栏，显示底部导航 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .main-content {
        margin-left: 0;
        padding-bottom: 70px;
    }
    .bottom-nav {
        display: flex;
    }
}

/* 桌面端：隐藏底部导航和菜单按钮 */
@media (min-width: 769px) {
    .bottom-nav {
        display: none;
    }
    .menu-toggle {
        display: none;
    }
}

/* ========== 底部导航 ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 6px 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 11px;
    transition: all 0.2s;
    border-radius: 8px;
    min-width: 55px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item .nav-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

/* ========== 页面头部 ========== */
.page-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 16px 16px 20px;
    text-align: center;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header .subtitle {
    font-size: 13px;
    opacity: 0.85;
}

/* ========== 容器 ========== */
.container {
    padding: 12px;
    max-width: 800px;
    margin: 0 auto;
}

/* ========== 卡片 ========== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text);
    background: var(--card);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }

/* ========== 表格 ========== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: #f1f5f9;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tr:hover {
    background: #f8fafc;
}

.data-table .text-red { color: var(--danger); }
.data-table .text-green { color: var(--success); }
.data-table .text-primary { color: var(--primary); font-weight: 600; }

/* ========== 指标卡片 ========== */
.metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.metric-card {
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.metric-card .metric-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.metric-card .metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ========== 进度条 ========== */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-bar .progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ========== 标签 ========== */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ========== 折叠面板 ========== */
.collapse {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}

.collapse-header {
    padding: 12px 16px;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    transition: background 0.2s;
}

.collapse-header:hover {
    background: #f1f5f9;
}

.collapse-header .arrow {
    transition: transform 0.2s;
}

.collapse-header.open .arrow {
    transform: rotate(180deg);
}

.collapse-body {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.collapse-body.open {
    display: block;
}

/* ========== 提示框 ========== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ========== 加载动画 ========== */
.loading {
    text-align: center;
    padding: 30px;
}

.spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-red { color: var(--danger); }
.text-green { color: var(--success); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-secondary); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-14 { font-size: 14px; }

/* ========== 行操作按钮 ========== */
.action-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.action-row .btn {
    flex: 1;
    min-width: 0;
}

/* ========== 搜索框 ========== */
.search-box {
    position: relative;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box .form-control {
    padding-left: 36px;
}

/* ========== 响应式 ========== */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    .card {
        padding: 12px;
    }
    .metric-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .data-table {
        font-size: 12px;
    }
    .data-table th, .data-table td {
        padding: 8px 6px;
    }
}

/* ========== K线图表容器 ========== */
.chart-container {
    width: 100%;
    height: 200px;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #fafafa;
}

/* ========== 点位卡片 ========== */
.points-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.point-card {
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.point-card.buy { background: #dcfce7; }
.point-card.sell { background: #fee2e2; }
.point-card.stop { background: #fef3c7; }

.point-card .point-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.point-card .point-value {
    font-size: 16px;
    font-weight: 700;
    margin-top: 2px;
}

/* ========== 密码输入 ========== */
.password-input {
    position: relative;
}

.password-input .toggle-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
}
