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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  padding: 20px;
}

.page { display: none; }
.page.active { display: block; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

h1 {
  font-size: 24px;
  color: #00d4ff;
}

.title {
  font-size: 22px;
  font-weight: 700;
  color: #00d4ff;
}

.subtitle {
  color: #888;
  font-size: 13px;
}

.panel {
  background: #16213e;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #333;
}

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

input[type="text"], input[type="number"], input[type="password"] {
  padding: 10px 15px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #16213e;
  color: #fff;
  font-size: 14px;
}

input[type="number"] {
  width: 100px;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: #00d4ff;
}

.field.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 22px;
  color: #eee;
}

.status {
  font-size: 12px;
  color: #888;
}

.status.connected {
  color: #4ade80;
}

.refresh-btn {
  padding: 10px 20px;
  background: #00d4ff;
  color: #000;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

.refresh-btn:hover {
  background: #00b8e6;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid #333;
  background: #16213e;
  color: #eee;
}

.status-badge.connected {
  color: #4ade80;
}

.status-badge.disconnected {
  color: #f87171;
}

.status-badge.connecting {
  color: #fbbf24;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #888;
  font-size: 12px;
  margin-bottom: 10px;
}

.threshold-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.threshold-box label {
  color: #888;
}

.stats-bar {
  color: #888;
  font-size: 12px;
  margin-bottom: 12px;
}

.tabs-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.tab-btn {
  padding: 10px 14px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #16213e;
  color: #eee;
  cursor: pointer;
  font-weight: bold;
}

.tab-btn.active {
  border-color: #00d4ff;
  color: #00d4ff;
}

.tab-panel {
  display: block;
}

.bots-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: #888;
  font-size: 12px;
}

.bot-form select {
  padding: 10px 15px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #16213e;
  color: #fff;
  font-size: 14px;
}

.bot-form select:focus {
  outline: none;
  border-color: #00d4ff;
}

.bot-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.bot-form-row:last-child {
  margin-bottom: 0;
}

.bot-form-group {
  display: grid;
  gap: 6px;
}

.bot-form-label {
  font-size: 12px;
  color: #888;
}

@media (min-width: 900px) {
  .bot-form-row {
    grid-template-columns: 1.2fr 0.8fr;
  }
  .bot-form-row:nth-child(2) {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
}

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

.bot-card {
  background: #16213e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 12px;
}

.bot-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.bot-title {
  font-weight: bold;
  color: #00d4ff;
  font-size: 14px;
}

.bot-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #333;
  background: #1a1a2e;
  color: #eee;
}

.bot-status.running {
  color: #4ade80;
}

.bot-status.waiting {
  color: #fbbf24;
}

.bot-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  color: #c8c8c8;
  font-size: 12px;
  margin-bottom: 10px;
}

.bot-error {
  margin: 6px 0 10px;
  font-size: 12px;
  color: #f87171;
  white-space: pre-wrap;
}

.bot-actions {
  display: flex;
  justify-content: flex-end;
}

.bot-trading-info {
  background: rgba(0, 212, 255, 0.05);
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: 8px;
  padding: 10px;
  margin: 10px 0;
}

.bot-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
}

.bot-info-label {
  color: #888;
  font-weight: 500;
}

.bot-info-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: #eee;
}

.bot-orderbooks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.bot-ob-side {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 8px;
}

.bot-ob-title {
  font-size: 11px;
  color: #00d4ff;
  font-weight: bold;
  margin-bottom: 6px;
  text-align: center;
}

.bot-funding-borrow {
  background: rgba(250, 204, 21, 0.05);
  border: 1px solid rgba(250, 204, 21, 0.15);
  border-radius: 8px;
  padding: 8px;
  margin: 10px 0;
}

.bot-funding-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 11px;
}

.bot-funding-label {
  color: #888;
  font-weight: 500;
}

.bot-funding-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.balances-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: #888;
  font-size: 12px;
}

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

.keys-panel {
  margin-top: 16px;
}

.keys-title {
  font-size: 14px;
  font-weight: 700;
  color: #00d4ff;
  margin-bottom: 6px;
}

.keys-note {
  font-size: 12px;
  color: #888;
  margin-bottom: 10px;
}

.keys-notice {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.keys-notice.success {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.08);
}

.keys-notice.error {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.08);
}

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

.key-card {
  background: #16213e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 12px;
}

.key-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}

.key-card-title {
  font-weight: 700;
  color: #00d4ff;
  font-size: 13px;
}

.key-status {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #333;
  background: #1a1a2e;
  color: #f87171;
}

.key-status.configured {
  color: #4ade80;
}

.key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.key-row label {
  width: 86px;
  color: #888;
  font-size: 12px;
}

.key-row input {
  flex: 1;
}

.key-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.key-clear-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: transparent;
  color: #f87171;
  cursor: pointer;
  font-weight: bold;
}

.key-clear-btn:hover {
  background: rgba(248, 113, 113, 0.12);
}

.key-hint {
  margin-top: 6px;
  font-size: 11px;
  color: #888;
  min-height: 14px;
}

.balance-card {
  background: #16213e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 12px;
}

.balance-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.balance-title {
  font-weight: bold;
  color: #00d4ff;
  font-size: 14px;
}

.balance-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #333;
  background: #1a1a2e;
  color: #eee;
}

.balance-status.connected {
  color: #4ade80;
}

.balance-status.disconnected {
  color: #f87171;
}

.balance-error {
  margin: 6px 0 10px;
  font-size: 12px;
  color: #f87171;
  white-space: pre-wrap;
}

.balances-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #f87171;
  padding: 12px;
  border-radius: 8px;
}

.balance-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.balance-section-title {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}

.balance-table {
  display: grid;
  gap: 6px;
}

.balance-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  padding: 4px 0;
}

.balance-asset {
  color: #ddd;
}

.balance-amt {
  color: #eee;
}

.ob-stats {
  color: #888;
  font-size: 12px;
  margin-bottom: 12px;
}

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

.ob-card {
  background: #16213e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 12px;
}

.ob-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ob-card-title {
  font-weight: bold;
  color: #00d4ff;
  font-size: 14px;
}

.ob-card-meta {
  font-size: 12px;
  color: #888;
}

.ob-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ob-side-title {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
}

.ob-level {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  padding: 2px 0;
}

.ob-bid {
  color: #4ade80;
}

.ob-ask {
  color: #f87171;
}

.inline-ob {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.inline-ob-level {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.35;
}

.inline-ob-level.inline-bid {
  color: #4ade80;
}

.inline-ob-level.inline-ask {
  color: #f87171;
}

.no-data {
  text-align: center;
  padding: 40px;
  color: #666;
}

.config-form { max-width: 600px; margin: 0 auto; }
.required { color: #f87171; }
.hint { font-size: 12px; color: #888; margin-top: 4px; }
.error-message { background: rgba(248, 113, 113, 0.1); color: #f87171; padding: 12px; border-radius: 6px; margin: 15px 0; border: 1px solid rgba(248, 113, 113, 0.3); }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.btn { border: none; border-radius: 8px; padding: 10px 14px; cursor: pointer; font-weight: bold; }
.btn.primary { background: #00d4ff; color: #000; }

/* 套利表格样式 */
.arb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.arb-table th, .arb-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #333;
}

.arb-table th {
  background: #0f3460;
  color: #00d4ff;
  font-weight: bold;
}

.arb-table tr:hover {
  background: rgba(255,255,255,0.05);
}

.arb-spread {
  color: #4ade80;
  font-weight: bold;
}

.arb-buy {
  color: #4ade80;
}

.arb-sell {
  color: #f87171;
}

.blacklist-btn {
  cursor: pointer;
  text-align: center;
  font-size: 16px;
}

.token-clickable {
  cursor: pointer;
}

.token-clickable:hover {
  text-decoration: underline;
}

/* 黑名单 */
.blacklist-badge {
  padding: 6px 12px;
  background: #0f3460;
  border: 1px solid #333;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #00d4ff;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 20px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.modal-header h3 {
  color: #00d4ff;
}

.modal-close {
  cursor: pointer;
  font-size: 18px;
  color: #888;
}

.hidden {
  display: none !important;
}

.blacklist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #16213e;
  border-radius: 4px;
  margin-bottom: 8px;
}

.blacklist-item-path {
  font-size: 13px;
  color: #ccc;
}

.blacklist-remove {
  cursor: pointer;
  margin-left: 10px;
}

/* History Modal */
.modal-wide {
  max-width: 900px;
}

.history-controls {
  margin-bottom: 15px;
}

.history-path {
  font-size: 14px;
  color: #00d4ff;
  margin-bottom: 10px;
  font-weight: bold;
}

.history-options {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-options label {
  font-size: 13px;
  color: #888;
}

.history-options select {
  padding: 6px 10px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #16213e;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.history-options select:focus {
  outline: none;
  border-color: #00d4ff;
}

#historyChartContainer {
  background: #16213e;
  border-radius: 8px;
  padding: 15px;
  min-height: 300px;
}

.history-btn {
  padding: 6px 10px;
  background: #00d4ff;
  color: #000;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  margin-left: 6px;
}

.history-btn:hover {
  background: #00b8d9;
}
