@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  font-family: "Inter", "PingFang SC", "Helvetica", sans-serif;
  color: #e2e8f0;
  background-color: #05080f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.18), transparent 40%),
    linear-gradient(135deg, #05080f, #0f172a 60%, #05080f);
  color: #e2e8f0;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 80px 80px;
  pointer-events: none;
}

.sidebar {
  width: 230px;
  background: rgba(10, 12, 26, 0.85);
  backdrop-filter: blur(10px);
  color: white;
  padding: 36px 26px;
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar h2 {
  margin: 0 0 24px;
  font-size: 20px;
  letter-spacing: 0.05em;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-item {
  padding: 12px 14px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  transition: transform 0.2s ease, color 0.2s ease, border 0.2s ease;
  border: 1px solid transparent;
}

.nav-item:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(16, 185, 129, 0.35));
  color: #fff;
  font-weight: 600;
  border-color: rgba(148, 163, 184, 0.4);
}

.sidebar-note {
  margin-top: auto;
  padding: 14px 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.05), rgba(59, 130, 246, 0.02));
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  text-align: center;
}

.sidebar-note p {
  margin: 0;
}

.sidebar-note p+p {
  margin-top: 6px;
}

main {
  flex: 1;
  padding: 48px;
  margin-left: 230px;
}

.brand-hero {
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(15, 23, 42, 0.88);
  border-radius: 22px;
  padding: 14px 18px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.brand-hero::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.25), transparent 70%);
  right: -120px;
  top: -100px;
}

.brand-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  z-index: 1;
}

.brand-title {
  margin: 0;
  display: flex;
  justify-content: center;
}

.brand-text {
  text-align: center;
}

.brand-title-img {
  width: 460px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 30px rgba(37, 99, 235, 0.3));
}

.brand-logo {
  width: 175px;
  height: 175px;
  border-radius: 8px;
  object-fit: contain;
  image-rendering: pixelated;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.brand-subtitle {
  margin: 12px 0 0;
  color: #94a3b8;
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

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

.subtitle {
  margin: 0;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
}

h1 {
  margin: 6px 0 0;
  font-size: 30px;
}

.card-block {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 18px;
  padding: 24px 28px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.55);
  margin-bottom: 28px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.card-block h2 {
  margin-top: 0;
}

.connection-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.connection-card {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 22px;
  padding: 24px 22px;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  background: rgba(9, 13, 26, 0.8);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.connection-card>*:nth-child(1) {
  /* logo */
  margin-top: 4px;
}

.connection-card h3 {
  margin: 8px 0 8px;
  font-size: 20px;
}

.connection-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.3), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.connection-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.6);
  border-color: rgba(96, 165, 250, 0.7);
}

.connection-card:hover::before {
  opacity: 1;
}

.connection-card h3 {
  margin: 10px 0 8px;
  font-size: 20px;
}

.card-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  object-fit: contain;
  filter: drop-shadow(0 8px 25px rgba(0, 0, 0, 0.5));
}

.toggle-row {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}

.permission-warning {
  min-height: 22px;
  margin: 2px 0 12px;
  color: #fca5a5;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.toggle-switch {
  width: 62px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.7);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-switch.loading,
.toggle-switch:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.toggle-switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e2e8f0;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.5);
  transition: transform 0.2s ease;
}

.toggle-switch.active {
  background: linear-gradient(135deg, #22d3ee, #10b981);
  border-color: rgba(45, 212, 191, 0.9);
}

.toggle-switch.active span {
  transform: translateX(30px);
  background: #fff;
}

.ghost-btn,
.btn {
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  padding: 10px 16px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  color: #e2e8f0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn {
  background: linear-gradient(135deg, #2563eb, #9333ea);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn.danger {
  background: linear-gradient(135deg, #dc2626, #991b1b);
}

.btn.danger:hover {
  filter: brightness(1.2);
}

.ghost-btn:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(148, 163, 184, 0.08);
}

.config-btn {
  min-width: 80px;
  padding: 8px 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-head {
  flex-wrap: wrap;
  gap: 12px;
}

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

.history-controls label {
  color: #94a3b8;
  font-size: 14px;
}

.history-controls select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
}

.history-controls input[type="date"] {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
}

.history-date {
  position: relative;
}

#history-date-toggle {
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.calendar-icon {
  font-size: 16px;
}

.history-date-panel {
  position: absolute;
  top: 110%;
  left: 0;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1100;
}

.history-date-panel.hidden {
  display: none;
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-row label {
  min-width: 36px;
  color: #94a3b8;
}

.history-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

/* 日志查看 */
.log-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.log-auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 13px;
}

.log-panel {
  background: rgba(9, 13, 26, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  padding: 12px;
  max-height: 520px;
  overflow: auto;
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
}

#log-content {
  white-space: pre-wrap;
  margin: 0;
}

.history-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.line-long-short-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.line-long-short-container .chart-card:first-child {
  flex: 1;
  min-height: 200px;
}

.line-long-short-container .chart-card:last-child {
  flex: 1;
  min-height: 200px;
}

.history-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 18px 0 6px;
}

.metric-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  padding: 16px 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.metric-card p {
  color: #94a3b8;
  margin-bottom: 6px;
}

.metric-card h3 {
  margin: 0;
  font-size: 1.8rem;
  color: #f8fafc;
}

.chart-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  min-height: 200px;
}

#history-line-chart {
  margin-top: 25px;
}

.pie-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 16px;
  padding-bottom: 24px;
}

.pie-card canvas {
  margin-top: 32px;
  margin-bottom: 24px;
}

.chart-card-title {
  margin-bottom: 10px;
  font-weight: 600;
  color: #e2e8f0;
}

.history-charts .chart-card.bar-card {
  grid-column: span 2;
  min-height: unset !important;
  display: flex;
  flex-direction: column;
}

.bar-chart-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  padding-bottom: 8px;
  scrollbar-color: rgba(59, 130, 246, 0.45) rgba(15, 23, 42, 0.5);
  max-height: 400px;
}

.bar-chart-wrapper canvas {
  width: 100% !important;
  display: block;
  margin-top: 10px;
}

.bar-chart-wrapper::-webkit-scrollbar {
  width: 6px;
}

.bar-chart-wrapper::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
}

.bar-chart-wrapper::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.8), rgba(16, 185, 129, 0.8));
  border-radius: 999px;
}

.long-short-chart-wrapper {
  width: 100%;
  overflow: hidden;
  padding: 0;
}

.long-short-chart-wrapper canvas {
  width: 100% !important;
  display: block;
  margin-top: 25px;
  height: auto !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: #f1f5f9;
  min-width: 760px;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  text-align: center;
  vertical-align: middle;
  font-size: 13px;
}

th {
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-size: 12px;
}

td.empty {
  text-align: center;
  color: #94a3b8;
}

.direction-long {
  color: #34d399;
  font-weight: 600;
}

.direction-short {
  color: #f87171;
  font-weight: 600;
}

.exchange-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: 2px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 20, 0.75);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 16px;
  backdrop-filter: blur(8px);
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: rgba(10, 15, 30, 0.95);
  border-radius: 18px;
  padding: 28px;
  width: min(520px, 95%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
}

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 6px;
}

.toggle-field label {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.table-actions button {
  margin-right: 6px;
}

#status-message {
  min-height: 20px;
}

#status-message.success {
  color: #34d399;
}

#status-message.error {
  color: #f87171;
}

.page-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-section.hidden {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.summary-card {
  background: rgba(9, 13, 26, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
}

.summary-card p {
  margin: 0;
  color: #94a3b8;
  font-size: 14px;
}

.summary-card h3 {
  margin: 10px 0 0;
  font-size: 30px;
}

.subtle-tip {
  color: #94a3b8;
  font-size: 14px;
}

.card-block.inner {
  margin-top: 12px;
}

.table-wrapper {
  overflow-x: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge.hit {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
}

.badge.tp {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.5);
}

.plan-item {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-width: 96px;
  border-radius: 999px;
  overflow: visible;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: inset 0 0 6px rgba(59, 130, 246, 0.1);
  position: relative;
}

.plan-item.active {
  border-color: rgba(16, 185, 129, 0.65);
  background: rgba(16, 185, 129, 0.15);
  box-shadow: inset 0 0 8px rgba(16, 185, 129, 0.2);
}

.plan-item.hit {
  border-color: rgba(52, 211, 153, 0.65);
  background: rgba(52, 211, 153, 0.18);
  box-shadow: inset 0 0 10px rgba(52, 211, 153, 0.25);
}

.plan-list {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.plan-index {
  min-width: 22px;
  padding: 3px 0;
  text-align: center;
  font-size: 11px;
  color: #e2e8f0;
  border-right: 1px solid rgba(148, 163, 184, 0.35);
}

.plan-value {
  flex: 1;
  padding: 4px 10px;
  font-size: 12px;
  color: #e2e8f0;
  text-align: center;
}

.pnl-text {
  transition: color 0.2s ease;
}

.pnl-positive {
  color: #34d399;
}

.pnl-negative {
  color: #f87171;
}

.status-label {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.status-label.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.45);
}

.plan-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.edit-pill-btn {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  padding: 5px 6px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.edit-pill-btn:hover {
  border-color: rgba(16, 185, 129, 0.7);
  color: #34d399;
}

.price-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 4px;
}

.price-modal-body label {
  font-size: 13px;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.price-modal-body input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
  color: #e2e8f0;
}

.price-modal-body input:disabled {
  color: #94a3b8;
  border-style: dashed;
  background: rgba(100, 116, 139, 0.15);
}

/* 操作按钮样式 */
.action-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.action-btn:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: #60a5fa;
  transform: translateY(-1px);
}

.close-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.close-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}

.cancel-btn {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border-color: rgba(249, 115, 22, 0.3);
}

.cancel-btn:hover {
  background: rgba(249, 115, 22, 0.3);
  border-color: #f97316;
}

/* 编辑图标样式 */
.edit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 6px;
  background: rgba(34, 211, 153, 0.2);
  border: 1px solid rgba(34, 211, 153, 0.4);
  border-radius: 4px;
  color: #22d3ee;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: bold;
}

.edit-icon:hover {
  background: rgba(34, 211, 153, 0.4);
  border-color: #22d3ee;
  transform: scale(1.1);
}

/* Latency Status */
.latency-status {
  position: absolute;
  top: 111px;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
  white-space: nowrap;
}

.latency-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #64748b;
  transition: all 0.3s ease;
}

.latency-status.good {
  color: #34d399;
}

.latency-status.good::before {
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}

.latency-status.warning {
  color: #facc15;
}

.latency-status.warning::before {
  background: #facc15;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
}

.latency-status.bad {
  color: #f87171;
}

.latency-status.bad::before {
  background: #f87171;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.6);
}

/* Modern Input Style (Matching Login Page) */
.form-control {
  background: rgba(5, 8, 15, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  color: #fff;
  font-size: 1rem;
  transition: all 0.2s ease;
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
  background: rgba(5, 8, 15, 0.8);
}