* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; background:#0f0f0f; color:#e2e8f0; min-height:100vh; }
#app { max-width:95%; margin:0 auto; padding:12px 16px; }
header { display:flex; align-items:center; justify-content:space-between; padding:12px 0; border-bottom:1px solid #1e293b; margin-bottom:12px; gap:12px; flex-wrap:wrap; position:relative; }
.balance-warning {
    font-size:22px; font-weight:700; text-align:center; flex:1; white-space:nowrap;
    animation: flashBalance 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, #ef4444, #f59e0b, #ef4444, #f97316);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
@keyframes flashBalance {
    0%, 100% { opacity:1; }
    50% { opacity:0.3; }
}
.logo { font-size:18px; font-weight:700; color:#38bdf8; letter-spacing:-0.5px; white-space:nowrap; }
.header-right { display:flex; align-items:center; gap:12px; }
.status-bar { display:flex; align-items:center; gap:8px; font-size:13px; color:#94a3b8; white-space:nowrap; }
.indicator { width:8px; height:8px; border-radius:50%; display:inline-block; }
.indicator.on { background:#22c55e; box-shadow:0 0 6px #22c55e88; }
.indicator.off { background:#ef4444; box-shadow:0 0 6px #ef444488; }

/* 齿轮按钮 + 下拉菜单 */
.settings-dropdown { position:relative; }
.btn-settings {
    width:34px; height:34px; background:transparent; border:1px solid #475569;
    color:#94a3b8; border-radius:6px; cursor:pointer; font-size:20px; line-height:1;
    transition:.15s;
}
.btn-settings:hover { background:#334155; border-color:#0ea5e9; color:#e2e8f0; }
.dropdown-menu {
    position:absolute; right:0; top:calc(100% + 4px);
    background:#1e293b; border:1px solid #334155; border-radius:6px;
    min-width:140px; overflow:hidden; z-index:100;
}
.dropdown-menu a {
    display:block; padding:10px 16px; color:#e2e8f0; font-size:13px;
    cursor:pointer; text-decoration:none; transition:.1s;
}
.dropdown-menu a:hover { background:#334155; }
.dropdown-menu a:last-child { border-top:1px solid #334155; color:#ef4444; }

.tabs { display:flex; gap:4px; margin-bottom:12px; flex-wrap:wrap; }
.tab { padding:8px 20px; border:1px solid #1e293b; background:#1e293b; color:#94a3b8; cursor:pointer; border-radius:6px; font-size:13px; transition:.15s; }
.tab:hover { background:#334155; }
.tab.active { background:#0ea5e9; color:#fff; border-color:#0ea5e9; }

.main { display:flex; gap:16px; }
.tab-content { display:none; width:100%; }
.tab-content.active { display:flex; flex-direction:column; gap:16px; }
#tab-chart { display:flex; flex-direction:column; gap:16px; }

.chart-area { display:flex; gap:16px; }
.chart-container { flex:1; min-height:82vh; height:82vh; border-radius:8px; overflow:hidden; border:1px solid #1e293b; }
#tv-chart { width:100%; height:82vh; }

.sidebar { width:280px; flex-shrink:0; }
.signal-section { flex-shrink:0; }
.panel { background:#1e293b; border-radius:8px; padding:16px; }
.panel h3 { font-size:14px; color:#38bdf8; margin-bottom:12px; font-weight:600; }
.stat-row { display:flex; justify-content:space-between; padding:6px 0; font-size:13px; border-bottom:1px solid #0f172a; }
.stat-row:last-child { border-bottom:none; }
.stat-row .label { color:#94a3b8; }
.stat-row .value { color:#e2e8f0; font-weight:500; }
.stat-row .value.green { color:#22c55e; }
.stat-row .value.red { color:#ef4444; }
.stat-row .value.orange { color:#f59e0b; }

/* 配置弹窗 */
.modal-overlay {
    position:fixed; top:0; left:0; right:0; bottom:0;
    background:rgba(0,0,0,0.6); z-index:999;
    display:flex; align-items:center; justify-content:center;
    padding:20px;
}
.modal-content {
    background:#1e293b; border-radius:12px; max-width:600px; width:100%;
    max-height:85vh; overflow-y:auto;
    border:1px solid #334155;
}
.modal-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:16px 20px; border-bottom:1px solid #334155;
}
.modal-header h2 { font-size:16px; color:#e2e8f0; }
.modal-close {
    background:none; border:none; color:#94a3b8; font-size:18px;
    cursor:pointer; padding:4px 8px; border-radius:4px;
}
.modal-close:hover { background:#334155; color:#e2e8f0; }
.modal-body { padding:20px; }
.modal-footer { padding:16px 20px; border-top:1px solid #334155; }
.config-section { margin-bottom:20px; }
.config-section h3 { font-size:14px; color:#38bdf8; margin-bottom:12px; font-weight:600; }

.form-group { margin-bottom:12px; }
.form-group label { display:block; font-size:12px; color:#94a3b8; margin-bottom:4px; }
.form-group input, .form-group textarea, .form-group select {
    width:100%; padding:8px 10px; background:#0f172a; border:1px solid #334155; border-radius:4px; color:#e2e8f0; font-size:13px; outline:none; transition:.15s;
}
.form-group input:focus, .form-group textarea:focus { border-color:#0ea5e9; }
.form-group textarea { font-family:monospace; font-size:12px; resize:vertical; }
details { margin:16px 0; }
details summary { cursor:pointer; color:#0ea5e9; font-size:13px; margin-bottom:8px; }
.hint { font-size:11px; color:#64748b; margin-top:4px; line-height:1.5; }
.btn { padding:10px 28px; background:#0ea5e9; color:#fff; border:none; border-radius:6px; cursor:pointer; font-size:14px; font-weight:600; transition:.15s; }
.btn:hover { background:#0284c7; }
#save-msg { margin-left:12px; font-size:13px; }
#save-msg.success { color:#22c55e; }
#save-msg.error { color:#ef4444; }

.signal-list { max-height:500px; overflow-y:auto; }
.signal-empty { text-align:center; color:#64748b; padding:40px 0; font-size:13px; }
.signal-item { padding:10px 12px; border-bottom:1px solid #0f172a; font-size:12px; line-height:1.6; }
.signal-item:last-child { border-bottom:none; }
.signal-item .sig-time { color:#64748b; font-family:monospace; font-size:11px; }
.signal-item .sig-action { font-weight:600; }
.signal-item .sig-action.buy { color:#22c55e; }
.signal-item .sig-action.sell { color:#ef4444; }
.signal-item .sig-detail { color:#cbd5e1; }
.signal-item .sig-status { display:inline-block; padding:1px 6px; border-radius:3px; font-size:11px; }
.signal-item .sig-status.ok { background:#22c55e22; color:#22c55e; }
.signal-item .sig-status.failed { background:#ef444422; color:#ef4444; }
.signal-item .sig-status.rejected { background:#f59e0b22; color:#f59e0b; }

.hint { font-size:11px; color:#64748b; margin-top:4px; line-height:1.5; }

@media(max-width:900px) {
    .chart-area { flex-direction:column; }
    .sidebar { width:100%; }
    .chart-container { min-height:400px; height:400px; }
    #tv-chart { height:400px; }
    .signal-list { max-height:350px; }
}
@media(max-width:600px) {
    #app { padding:8px 10px; }
    .logo { font-size:15px; }
    header { flex-direction:column; align-items:flex-start; }
    .header-right { width:100%; justify-content:space-between; }
    .tabs { gap:2px; }
    .tab { padding:6px 12px; font-size:12px; flex:1; text-align:center; }
    .chart-container { min-height:300px; height:300px; border-radius:4px; }
    #tv-chart { height:300px; }
    .sidebar { width:100%; }
    .panel { padding:12px; }
    .panel h3 { font-size:13px; }
    .stat-row { font-size:12px; padding:4px 0; }
    .signal-list { max-height:250px; }
    .signal-item { padding:8px 10px; font-size:11px; }
}
