: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 {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.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;
}

.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;
}

.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;
}

.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;
  max-width: 520px;
}

.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;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 14, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-panel.running {
  border-color: rgba(60, 179, 113, 0.65);
  box-shadow: 0 0 0 1px rgba(60, 179, 113, 0.2);
}

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

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

.modal-section h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.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;
}
