:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --line: #2a3542;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9cf0;
  --ok: #3cb371;
  --bad: #e35d5d;
  --pnl-pos: #2ee59a;
  --pnl-neg: #ff5c5c;
  --radius: 10px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #1a3048, var(--bg));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.shell {
  width: 100%;
  max-width: min(1920px, 100%);
  margin: 0 auto;
  padding: 16px 24px 40px;
  box-sizing: border-box;
}

.header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.15rem;
}

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

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
}

.nav a.active,
.nav a:hover {
  color: var(--text);
  background: var(--panel);
}

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

.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: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

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

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.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: var(--panel);
  width: 100%;
}

.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 var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.monitor-table th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
  position: sticky;
  top: 0;
  z-index: 1;
}

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

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

.monitor-table tbody tr.is-running {
  box-shadow: inset 3px 0 0 rgba(60, 179, 113, 0.85);
}

.monitor-table tbody tr.is-stopped {
  box-shadow: inset 3px 0 0 rgba(227, 93, 93, 0.75);
}

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

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

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

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

.machine-name {
  font-weight: 650;
  font-size: 0.95rem;
}

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

.dot.ok {
  background: var(--ok, #3cb371);
  box-shadow: 0 0 0 2px rgba(60, 179, 113, 0.25);
}

.dot.bad {
  background: var(--bad, #e35d5d);
  box-shadow: 0 0 0 2px rgba(227, 93, 93, 0.25);
}

.dot.warn {
  background: #e6a23c;
  box-shadow: 0 0 0 2px rgba(230, 162, 60, 0.3);
}

.dot.muted {
  background: #5a6570;
  box-shadow: 0 0 0 2px rgba(90, 101, 112, 0.25);
}

.dot.pulse {
  animation: status-blink 1.4s ease-in-out infinite;
}

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

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

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

@keyframes status-blink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    filter: brightness(1.15);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.85);
    filter: brightness(0.85);
  }
}

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

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

.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: rgba(60, 179, 113, 0.85) !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;
}
