:root {
  --bg: #05080f;
  --panel: rgba(10, 18, 32, 0.92);
  --line: rgba(0, 229, 255, 0.18);
  --text: #e6f7ff;
  --muted: #7a93a8;
  --accent: #00c8ff;
  --accent-2: #39ff14;
  --ok: #39ff14;
  --bad: #ff2d55;
  --pnl-pos: #39ff14;
  --pnl-neg: #ff2d55;
  --radius: 8px;
  --glow: 0 0 12px rgba(0, 200, 255, 0.35);
  --glow-ok: 0 0 10px rgba(57, 255, 20, 0.55);
  --glow-bad: 0 0 10px rgba(255, 45, 85, 0.5);
  font-family: "Consolas", "Cascadia Mono", "Segoe UI", "PingFang SC",
    "Microsoft YaHei", monospace;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 8% -8%, rgba(0, 120, 180, 0.28), transparent 55%),
    radial-gradient(700px 420px at 92% 0%, rgba(0, 255, 140, 0.08), transparent 50%),
    linear-gradient(180deg, #071018 0%, var(--bg) 40%, #04060c 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(0, 200, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 200, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
}

.shell {
  width: 100%;
  max-width: min(1920px, 100%);
  margin: 0 auto;
  /* 全屏/带鱼屏时整体略下移；宽屏左右多留边，避免贴边 */
  padding: clamp(48px, 8vh, 96px) clamp(32px, 5vw, 120px) 48px;
  box-sizing: border-box;
}

.header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0, 200, 255, 0.08);
}

.header-top {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 4px 0 2px;
}

.header-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  max-width: 100%;
}

.header-title {
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: clamp(1.85rem, 3.6vw, 2.65rem);
  line-height: 1.15;
  color: var(--accent);
  text-shadow: var(--glow);
  white-space: nowrap;
  text-align: center;
}

.header-subtitle {
  align-self: flex-end;
  margin-top: 6px;
  margin-right: -0.4em;
  padding-left: 1.2em;
  padding-bottom: 2px;
  font-size: 0.95rem;
  letter-spacing: 0.16em;
  color: var(--muted);
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(0, 200, 255, 0.45);
}

.header-beijing-time {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.header-beijing-label {
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

.header-beijing-value {
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--accent);
  text-shadow: var(--glow);
  white-space: nowrap;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  letter-spacing: 0.04em;
}

.nav a.active,
.nav a:hover {
  color: var(--accent);
  background: rgba(0, 200, 255, 0.08);
  border-color: rgba(0, 200, 255, 0.35);
  box-shadow: var(--glow);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.main h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

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

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
}

.btn {
  border: 1px solid rgba(0, 200, 255, 0.45);
  background: linear-gradient(180deg, rgba(0, 180, 255, 0.85), rgba(0, 120, 200, 0.95));
  color: #041018;
  font-weight: 650;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  box-shadow: var(--glow);
  letter-spacing: 0.03em;
}

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

.btn.ghost {
  background: rgba(0, 20, 36, 0.6);
  color: var(--accent);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.ghost:hover:not(:disabled) {
  border-color: rgba(0, 200, 255, 0.55);
  box-shadow: var(--glow);
}

.err {
  background: rgba(227, 93, 93, 0.15);
  color: #ffb4b4;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0;
}

.err.soft {
  font-size: 0.85rem;
}

.ok {
  background: rgba(60, 179, 113, 0.15);
  color: #9df0c9;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-box {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h1 {
  margin: 0;
  font-size: 1.3rem;
}

.login-box label,
.add-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  background: #10161d;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

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

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.live-pill {
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.live-pill.ok {
  color: var(--pnl-pos);
  border-color: rgba(46, 229, 154, 0.45);
  font-weight: 600;
}

.live-pill.bad {
  color: var(--pnl-neg);
  border-color: rgba(255, 92, 92, 0.45);
  font-weight: 600;
}

.monitor-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(0, 200, 255, 0.06), transparent 28%),
    var(--panel);
  width: 100%;
  box-shadow:
    0 0 0 1px rgba(0, 200, 255, 0.08),
    0 0 28px rgba(0, 140, 255, 0.12);
}

.monitor-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: auto;
}

.monitor-table th,
.monitor-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.1);
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}

.monitor-table th {
  color: var(--accent);
  font-weight: 650;
  letter-spacing: 0.06em;
  background: rgba(0, 40, 60, 0.55);
  position: sticky;
  top: 0;
  z-index: 1;
  text-shadow: 0 0 8px rgba(0, 200, 255, 0.35);
}

.monitor-table tbody tr {
  cursor: pointer;
}

.monitor-table tbody tr:hover {
  background: rgba(0, 200, 255, 0.06);
}

.monitor-table tbody tr.is-running {
  box-shadow: inset 3px 0 0 var(--ok);
  background: linear-gradient(
    90deg,
    rgba(57, 255, 20, 0.08),
    transparent 28%
  );
}

.monitor-table tbody tr.is-stopped {
  box-shadow: inset 3px 0 0 var(--bad);
  background: linear-gradient(
    90deg,
    rgba(255, 45, 85, 0.07),
    transparent 28%
  );
}

.monitor-table .col-check {
  width: 40px;
}

.monitor-table .col-status {
  width: 96px;
}

.monitor-table .col-actions {
  white-space: normal;
}

.residual-toolbar {
  margin-top: 1.5rem;
}

.monitor-table.residual-table {
  min-width: 900px;
}

.monitor-table.residual-table tbody tr {
  cursor: default;
}

.status-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.machine-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: #dff6ff;
  text-shadow: 0 0 8px rgba(0, 200, 255, 0.25);
}

/* 中控模式列：期期高亮，永期保持弱化 */
.mode-hedge-oo {
  color: #ffb020;
  text-shadow: 0 0 8px rgba(255, 176, 32, 0.45);
  font-weight: 700;
}

.mode-hedge-po {
  color: var(--muted);
}

.mode-hedge-semi {
  color: #5ec8ff;
  font-weight: 700;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--muted);
}

.dot.ok {
  background: var(--ok);
  box-shadow: var(--glow-ok);
}

.dot.bad {
  background: var(--bad);
  box-shadow: var(--glow-bad);
}

.dot.warn {
  background: #ffcc33;
  box-shadow: 0 0 10px rgba(255, 204, 51, 0.55);
}

.dot.muted {
  background: #4a5a68;
  box-shadow: 0 0 6px rgba(120, 140, 160, 0.35);
}

/* 柔和呼吸闪：约 1s，交错相位，避免晃眼 */
.dot.pulse {
  animation: status-breathe 1.05s ease-in-out infinite;
}

.dot.pulse.d1 {
  animation-delay: 0s;
}

.dot.pulse.d2 {
  animation-delay: 0.2s;
}

.dot.pulse.d3 {
  animation-delay: 0.4s;
}

@keyframes status-breathe {
  0%,
  100% {
    opacity: 1;
    filter: brightness(1.1);
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    filter: brightness(0.9);
    transform: scale(0.94);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot.pulse {
    animation: none;
  }
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.stats-section {
  margin-top: 28px;
}

.stats-toolbar {
  margin-bottom: 10px;
}

.stats-table tfoot .stats-total-row td {
  border-top: 1px solid rgba(0, 229, 255, 0.35);
  background: rgba(0, 40, 60, 0.45);
  font-weight: 650;
  color: var(--accent);
}

.stats-table tfoot .stats-total-row td.pnl-pos {
  color: var(--pnl-pos);
}

.stats-table tfoot .stats-total-row td.pnl-neg {
  color: var(--pnl-neg);
}

.stats-table tfoot .stats-total-row td.pnl-flat {
  color: var(--text);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.78rem;
  min-height: 28px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.node-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.node-card:hover {
  border-color: #3d5a73;
}

.node-card.offline {
  opacity: 0.85;
}

.node-card.running {
  background: linear-gradient(160deg, rgba(46, 140, 90, 0.28), rgba(26, 34, 44, 0.95));
  border-color: rgba(60, 179, 113, 0.65);
  box-shadow: 0 0 0 1px rgba(60, 179, 113, 0.15);
}

.btn-running {
  background: linear-gradient(180deg, rgba(57, 255, 20, 0.95), rgba(20, 160, 40, 0.95)) !important;
  border-color: rgba(57, 255, 20, 0.65) !important;
  color: #041208 !important;
  box-shadow: var(--glow-ok) !important;
  cursor: default;
}

.node-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(60, 179, 113, 0.4);
}

.pill.bad {
  color: var(--bad);
  border-color: rgba(227, 93, 93, 0.4);
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.kv dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.kv dd {
  margin: 2px 0 0;
  font-size: 0.92rem;
}

.risk-box {
  border: 1px solid rgba(46, 229, 154, 0.45);
  background: rgba(46, 229, 154, 0.08);
  border-radius: 8px;
  padding: 10px 12px;
}

.risk-box-title {
  font-size: 0.78rem;
  color: var(--pnl-pos);
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.risk-kv {
  margin: 0;
}

.risk-kv dd {
  color: var(--pnl-pos);
  font-weight: 700;
}

.node-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.add-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 10px;
  margin: 16px 0;
  width: 100%;
  box-sizing: border-box;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.token-box {
  background: #132033;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 8px;
  margin: 12px 0;
  word-break: break-all;
  width: 100%;
  box-sizing: border-box;
}

.token-box code {
  user-select: all;
  display: block;
  padding: 8px;
  background: #0d1520;
  border-radius: 6px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.settings-tabs .tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.settings-tabs .tab.active,
.settings-tabs .tab:hover {
  color: var(--text);
  background: var(--panel);
  border-color: #3d5a73;
}

.switch-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.switch-hint {
  display: block;
  margin-top: 4px;
  font-weight: 400;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: #3a4654;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.switch.on {
  background: var(--ok);
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch.on .switch-knob {
  transform: translateX(20px);
}

/* 全屏：≤1920 铺满；带鱼屏内容限宽 1920，两侧留空 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: var(--bg, #04080e);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
  margin: 0;
  z-index: 50;
  overflow: hidden;
  box-sizing: border-box;
}

.modal-panel {
  width: 100%;
  max-width: 1920px;
  height: 100%;
  max-height: none;
  overflow: auto;
  background: var(--panel);
  border: none;
  border-radius: 0;
  padding: 20px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.modal-panel.running {
  box-shadow: inset 0 0 0 2px rgba(60, 179, 113, 0.45);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.pager-meta {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.pager-actions {
  display: flex;
  gap: 8px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-shrink: 0;
}

.modal-head h3 {
  margin: 0 0 2px;
}

.modal-section h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.detail-kv {
  grid-template-columns: 1fr 1fr;
}

.detail-kv .span-2 {
  grid-column: 1 / -1;
}

.legs-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.legs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.legs-table th,
.legs-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.pnl-pos {
  color: var(--pnl-pos);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pnl-neg {
  color: var(--pnl-neg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pnl-flat {
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
