:root {
  --bg: #05070b;
  --bg-elevated: #090c12;
  --bg-panel: #0d121a;
  --bg-panel-2: #111824;
  --border: rgba(126, 152, 208, 0.14);
  --border-strong: rgba(126, 152, 208, 0.28);
  --text-main: #eef2fb;
  --text-soft: #afb8cb;
  --text-faint: #7d879c;
  --brand-start: #5d92ff;
  --brand-end: #72b7ff;
  --success: #53d18b;
  --warning: #f3c96b;
  --danger: #ff7f96;
  --info: #6ec8ff;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

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

html, body {
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(70, 103, 255, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(114, 183, 255, 0.08), transparent 20%),
    linear-gradient(180deg, #06080d 0%, #05070b 38%, #04060a 100%);
}

button, input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: linear-gradient(135deg, rgba(14, 20, 31, 0.96), rgba(8, 11, 17, 0.99));
  padding: 22px 30px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid rgba(126, 152, 208, 0.12);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
}

.header-kicker,
.section-title,
.hero-kicker,
.card-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-kicker {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.app-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tagline {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.header-actions {
  display: flex;
  gap: 12px;
}

main {
  flex: 1;
  padding: 24px 28px 40px;
}

.workbench-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.surface-card {
  background: linear-gradient(180deg, rgba(14, 19, 28, 0.94), rgba(9, 12, 18, 0.98));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.workbench-sidebar,
.workspace-panel {
  padding: 22px;
}

.sidebar-title-row,
.workspace-panel-header,
.card-title-row,
.strategy-nav-topline,
.sidebar-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-summary-panel,
.strategy-group-items,
.results-stack,
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-section {
  margin-top: 22px;
}

.section-title {
  font-size: 12px;
  color: var(--text-faint);
}

.summary-card,
.detail-card {
  border: 1px solid rgba(126, 152, 208, 0.12);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 18px;
  padding: 16px;
}

.summary-label,
.detail-label {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
}

.compact-value {
  font-size: 22px;
  line-height: 1.25;
}

.summary-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-faint);
}

.accent-blue {
  background: linear-gradient(180deg, rgba(16, 31, 54, 0.78), rgba(10, 17, 30, 0.92));
}

.accent-green {
  background: linear-gradient(180deg, rgba(16, 40, 32, 0.78), rgba(10, 18, 16, 0.92));
}

.strategy-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 18px;
  padding: 15px 16px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.strategy-nav-item:hover {
  border-color: var(--border-strong);
  background: rgba(93, 146, 255, 0.08);
}

.strategy-nav-item.active {
  border-color: rgba(83, 209, 139, 0.42);
  background: linear-gradient(180deg, rgba(18, 40, 32, 0.9), rgba(11, 19, 18, 0.95));
  box-shadow: inset 0 0 0 1px rgba(83, 209, 139, 0.12);
}

.strategy-nav-item.running .strategy-nav-rail,
.strategy-nav-item.normal .strategy-nav-rail,
.strategy-nav-item.active .strategy-nav-rail {
  background: rgba(83, 209, 139, 0.9);
  box-shadow: 0 0 14px rgba(83, 209, 139, 0.28);
}

.strategy-nav-item.warning .strategy-nav-rail {
  background: rgba(243, 201, 107, 0.9);
  box-shadow: 0 0 14px rgba(243, 201, 107, 0.22);
}

.strategy-nav-item.danger .strategy-nav-rail {
  background: rgba(255, 127, 150, 0.9);
  box-shadow: 0 0 14px rgba(255, 127, 150, 0.22);
}

.strategy-nav-rail {
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand-start), var(--brand-end));
  opacity: 0.82;
}

.strategy-nav-main {
  min-width: 0;
  flex: 1;
  padding-left: 8px;
}

.strategy-nav-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.strategy-nav-name,
.workspace-panel h2,
.panel-card h3 {
  font-size: 20px;
  font-weight: 700;
}

.strategy-nav-name {
  font-size: 15px;
  margin-bottom: 2px;
}

.strategy-nav-meta,
.card-kicker {
  font-size: 12px;
  color: var(--text-soft);
}

.hero-kicker {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.strategy-nav-statuses {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.mini-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
}

.mini-status.on {
  color: #dfffea;
  border-color: rgba(83, 209, 139, 0.28);
  background: rgba(83, 209, 139, 0.1);
}

.mini-status.off {
  color: #ffd8de;
  border-color: rgba(255, 127, 150, 0.22);
  background: rgba(255, 127, 150, 0.08);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #52607a;
  box-shadow: 0 0 0 4px rgba(82, 96, 122, 0.14);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(83, 209, 139, 0.12);
}

.status-dot.idle {
  background: #7f91b4;
  box-shadow: 0 0 0 4px rgba(127, 145, 180, 0.12);
}

.inline-badges,
.form-actions,
.mode-switch-row,
.inline-radio-row,
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-note {
  font-size: 12px;
  color: var(--warning);
  line-height: 1.7;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(243, 201, 107, 0.22);
  background: rgba(45, 34, 14, 0.45);
}

.inline-pill,
.health-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid rgba(126, 152, 208, 0.18);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
}

.health-chip.info { color: var(--info); }
.health-chip.warning { color: var(--warning); }
.health-chip.success { color: var(--success); }
.health-chip.danger { color: var(--danger); }
.health-chip.mini { padding: 4px 8px; font-size: 11px; }

.page-panel {
  display: none;
}

.page-panel.active {
  display: block;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.panel-grid.single-column {
  grid-template-columns: 1fr;
}

.panel-card {
  border: 1px solid rgba(126, 152, 208, 0.12);
  background: rgba(255, 255, 255, 0.022);
  border-radius: 18px;
  padding: 18px;
}

.form-grid,
.summary-grid,
.detail-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.workspace-summary-grid {
  margin-top: 18px;
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workbench-detail-grid {
  margin-top: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 13px;
  color: var(--text-soft);
}

.field input {
  width: 100%;
  border: 1px solid rgba(126, 152, 208, 0.16);
  background: rgba(6, 10, 18, 0.92);
  color: var(--text-main);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus {
  border-color: rgba(93, 146, 255, 0.52);
  box-shadow: 0 0 0 3px rgba(93, 146, 255, 0.12);
}

.range-preview {
  align-self: end;
  border: 1px solid rgba(83, 209, 139, 0.22);
  background: rgba(83, 209, 139, 0.06);
  color: var(--text-soft);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}

.mode-chip {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(126, 152, 208, 0.18);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

/* range-preview 在 form-grid 内自动跨双列 */
.range-preview {
  grid-column: 1 / -1;
}

/* chip 行之间的分隔点 */
.mode-divider {
  color: var(--text-soft);
  opacity: 0.4;
  font-size: 16px;
  line-height: 1;
  align-self: center;
  user-select: none;
}

.mode-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-chip span {
  display: inline-flex;
  padding: 10px 14px;
  color: var(--text-soft);
  font-size: 13px;
}

.mode-chip input:checked + span {
  color: #061018;
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
}

.primary-btn,
.danger-btn,
.ghost-btn {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.primary-btn:hover,
.danger-btn:hover,
.ghost-btn:hover {
  opacity: 0.92;
}

.primary-btn:active,
.danger-btn:active,
.ghost-btn:active {
  transform: translateY(1px);
}

.primary-btn {
  color: #061018;
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
}

.danger-btn {
  color: #200b11;
  background: linear-gradient(135deg, #ff8ea2, #ff6e87);
}

.ghost-btn {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(126, 152, 208, 0.16);
}

.primary-btn:disabled,
.danger-btn:disabled,
.ghost-btn:disabled,
.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-btn.danger-text {
  color: var(--danger);
}
.ghost-btn.danger-text:hover {
  background: rgba(255, 127, 150, 0.08);
  border-color: var(--danger);
}

/* card-title-row 右侧多个元素并排 */
.title-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 标题栏里的小按钮 */
.mini-action-btn {
  padding: 5px 12px;
  font-size: 0.78rem;
  border-radius: 999px;
}

/* 实例详情容器 */
#live-instance-detail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.alert {
  margin-top: 18px;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.alert-error {
  border: 1px solid rgba(255, 127, 150, 0.34);
  background: rgba(61, 20, 29, 0.92);
  color: #ffc6d1;
}

.alert-warning {
  border: 1px solid rgba(243, 201, 107, 0.32);
  background: rgba(45, 34, 14, 0.92);
  color: #ffe1a0;
}

.detail-value {
  font-size: 14px;
  color: var(--text-main);
}

.detail-value.multiline {
  white-space: pre-line;
  line-height: 1.7;
}

.detail-stat-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-stat-list.compact {
  gap: 10px;
}

.detail-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(126, 152, 208, 0.08);
  font-size: 13px;
  color: var(--text-soft);
}

.detail-stat-row strong {
  color: var(--text-main);
  font-size: 13px;
}

.note-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  color: var(--text-soft);
  line-height: 1.7;
  font-size: 13px;
}

.chart-shell {
  height: 320px;
  margin-top: 14px;
}

.chart-meta {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.table-shell {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr {
  background: rgba(255, 255, 255, 0.03);
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(126, 152, 208, 0.1);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.empty-cell {
  text-align: center !important;
  color: var(--text-faint);
  padding: 24px 12px;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: #0b1320;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
  .workbench-layout {
    grid-template-columns: 1fr;
  }

  .workbench-sidebar {
    order: 2;
  }

  .workbench-main {
    order: 1;
  }
}

@media (max-width: 860px) {
  .panel-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding: 18px 18px 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  main {
    padding: 18px 16px 28px;
  }
}

/* ─── Auth overlay ──────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(10, 14, 20, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  background: linear-gradient(180deg, rgba(14, 19, 28, 0.97), rgba(9, 12, 18, 0.99));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 6px 0 4px;
}

.auth-logo .tagline {
  color: var(--text-soft);
  font-size: 0.8rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form .form-actions {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.full-width-btn {
  width: 100%;
  justify-content: center;
}

.auth-qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 16px 0 20px;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: 8px;
  border: 1px solid var(--border);
}

#auth-qr-container img,
#auth-qr-container canvas {
  border-radius: 6px;
  background: #fff;
  padding: 6px;
  display: block;
}

.auth-secret-label {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 4px;
}

.auth-secret-text {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-main);
  word-break: break-all;
  text-align: center;
  letter-spacing: 0.05em;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  user-select: all;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.user-chip::before {
  content: '●';
  color: var(--success);
  font-size: 0.6rem;
}
