:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #334155;
    --border: #475569;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.2);
}

[data-theme="light"] {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #e2e8f0;
    --border: #cbd5e1;
    --text: #1e293b;
    --text-dim: #64748b;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

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

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

/* ============ 登录/注册页 ============ */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.auth-card h1 {
    text-align: center;
    font-size: 28px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 32px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-input::placeholder {
    color: #64748b;
}

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

select.form-input {
    cursor: pointer;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

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

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

.btn-warning {
    background: var(--warning);
    color: #1a1a1a;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    width: auto;
    padding: 6px 14px;
    font-size: 13px;
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.auth-error.show {
    display: block;
}

/* ============ 主应用布局 ============ */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    padding: 0 24px 20px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.nav-item {
    padding: 12px 24px;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-item.active {
    background: var(--surface-2);
    color: var(--primary);
    border-left-color: var(--primary);
}

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

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    bottom: 0;
}

.support-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
    font-weight: 600;
}
.support-link:hover {
    text-decoration: underline;
}

.sidebar-user {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.logout-btn {
    color: var(--danger);
    cursor: pointer;
    font-size: 13px;
    background: none;
    border: none;
    padding: 0;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    max-width: 1200px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-dim);
    font-size: 14px;
}

/* ============ 卡片 ============ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============ 统计卡片 ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
}

.stat-card .label {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
}

.stat-card .value.green { color: var(--success); }
.stat-card .value.red { color: var(--danger); }
.stat-card .value.blue { color: var(--info); }
.stat-card .value.orange { color: var(--warning); }

/* 倒计时数字等宽：秒数变化时字符宽度不变，不再左右抖动（仪表盘 + 挂机控制共用 .countdown-display） */
.countdown-display {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* 挂机控制顶部统计条：自适应网格，尽量一行、卡片矮而紧凑，减少纵向占用 */
.bot-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.bot-stats-grid .stat-card {
    min-width: 0;
    padding: 10px 12px;
}
.bot-stats-grid .stat-card .label {
    font-size: 11px;
    margin-bottom: 4px;
}
.bot-stats-grid .stat-card .value {
    font-size: clamp(14px, 1.4vw, 18px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============ 状态徽章 ============ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-info { background: rgba(14,165,233,0.15); color: var(--info); }
.badge-dim { background: var(--surface-2); color: var(--text-dim); }

/* ============ 表格 ============ */
.table-container {
    overflow-x: auto;
}

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

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background: var(--surface-2);
}

/* ============ 群组列表 ============ */
.group-list {
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
}

.group-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    gap: 12px;
}

.group-item:hover {
    background: var(--surface-2);
}

.group-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.group-item .group-name {
    font-size: 14px;
}

.group-item .group-id {
    font-size: 12px;
    color: var(--text-dim);
}

/* ============ 开奖表格 ============ */
.lottery-table-wrap {
    max-height: calc(10 * 34px + 36px + 4px);
    overflow-y: auto;
    text-align: left;
}

/* ============ 投注日志表格 ============ */
.log-table th,
.log-table td {
    text-align: center;
}

.log-table th:first-child,
.log-table td:first-child {
    width: 1px;
    white-space: nowrap;
}

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

.lottery-table th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    padding: 8px 10px;
    text-align: center;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    z-index: 1;
    height: 36px;
    box-sizing: border-box;
    vertical-align: middle;
}

.lottery-table th:first-child,
.lottery-table td:first-child {
    width: 1px;
    white-space: nowrap;
    text-align: center;
}

.lottery-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    height: 34px;
    box-sizing: border-box;
    vertical-align: middle;
    text-align: center;
}

.lottery-table td.col-result {
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: center;
}

.lottery-table tr:hover td {
    background: var(--surface-2);
}

/* ============ 开关 ============ */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-2);
    border-radius: 24px;
    transition: 0.3s;
}

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

input:checked + .slider {
    background: var(--primary);
}

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

/* ============ 配置网格 ============ */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.config-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.config-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 10px 0;
}

.config-grid.compact {
    gap: 5px;
}
.config-grid.compact .config-row {
    padding: 3px 0;
}
.config-grid.compact .config-row label {
    font-size: 12px;
}

.config-hint {
    flex-basis: 100%;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    line-height: 1.4;
}

.config-row label {
    font-size: 13px;
    color: var(--text-dim);
}

.config-row input,
.config-row select {
    width: 120px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
}

/* ============ Toast ============ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 14px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

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

/* ============ 弹窗 ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 500px;
    border: 1px solid var(--border);
}

.modal h3 {
    font-size: 20px;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* ============ 大按钮控制区 ============ */
.bot-control {
    display: flex;
    gap: 16px;
    align-items: center;
}

.bot-control .btn {
    width: auto;
    padding: 14px 40px;
    font-size: 16px;
}

.control-toggles {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============ USDT 支付 ============ */
.payment-address-box {
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    margin: 16px 0;
}

.payment-address-box .address {
    font-family: 'Courier New', monospace;
    font-size: 15px;
    color: var(--warning);
    word-break: break-all;
    user-select: all;
}

.payment-plan {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.plan-card {
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.plan-card:hover {
    border-color: var(--primary);
}

.plan-card.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.plan-card .days {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.plan-card .price {
    font-size: 14px;
    color: var(--text-dim);
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-logo, .nav-item span:not(.icon), .sidebar-footer {
        display: none;
    }
    .main-content {
        margin-left: 60px;
        padding: 16px;
    }
    .payment-plan {
        grid-template-columns: 1fr;
    }
    .theme-toggle {
        right: 12px;
        top: 12px;
    }
}

/* ============ 日夜模式切换 ============ */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    background: var(--surface-2);
    transform: scale(1.05);
}

/* ============ 加载动画 ============ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--surface-2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============ 日志列表 ============ */
.log-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--surface-2);
    font-size: 13px;
}

.log-item .log-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.log-item .log-term {
    font-weight: 600;
}

.log-item .log-profit {
    font-weight: 700;
}

.log-item .log-profit.positive { color: var(--danger); }
.log-item .log-profit.negative { color: var(--success); }

.log-item .log-detail {
    color: var(--text-dim);
    font-size: 12px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

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

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