:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.98);
  --panel-soft: rgba(255, 255, 255, 0.98);
  --line: rgba(15, 23, 42, 0.08);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --teal: #86868b;
  --red: #ff3b30;
  --green: #1d9d5c;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --performance-panel-height: 472px;
  --strategy-panel-height: 944px;
  --positions-panel-height: 280px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(0, 113, 227, 0.08), transparent 36%),
    radial-gradient(circle at bottom right, rgba(0, 113, 227, 0.06), transparent 32%),
    var(--bg);
}

button {
  font: inherit;
  cursor: pointer;
}

.page-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 28px auto 48px;
}

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

.login-panel {
  width: min(520px, 100%);
  padding: 32px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.login-brand {
  display: flex;
  gap: 18px;
  align-items: center;
}

.login-avatar-shell {
  width: 88px;
  height: 88px;
  border-radius: 24px;
}

.login-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-form {
  margin-top: 28px;
  display: grid;
  gap: 14px;
}

.login-field {
  display: grid;
  gap: 8px;
}

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

.login-field input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(245, 245, 247, 0.92);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
}

.login-field input:focus {
  outline: 1px solid rgba(0, 113, 227, 0.35);
}

.login-button {
  margin-top: 6px;
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  color: #fff;
  background: linear-gradient(135deg, #0077ed, #0061c8);
  font-weight: 600;
  transition: transform 180ms ease, opacity 180ms ease;
}

.login-button:hover {
  transform: translateY(-1px);
}

.login-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.login-error {
  margin: 2px 0 0;
  color: #b42318;
  font-size: 13px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  padding: 28px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.98)),
    linear-gradient(120deg, rgba(0, 113, 227, 0.06), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -80px -80px auto;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(0, 113, 227, 0.10), transparent 68%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: rgba(110, 110, 115, 0.9);
}

.hero h1,
.panel h2 {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-avatar-shell {
  flex: 0 0 auto;
  width: 112px;
  height: 112px;
  padding: 8px;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(250, 250, 252, 0.98)),
    rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.brand-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 22px;
}

.zebra-avatar {
  background: linear-gradient(180deg, #f8f9fb, #eef2f7);
  filter: grayscale(0.92) saturate(0.55) brightness(1.04) contrast(1.03);
}

.hero h1 {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
}

.hero-text {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: start;
  justify-content: end;
}

.ghost-button,
.danger-button,
.pill-button {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  padding: 12px 18px;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.ghost-button {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.92);
}

.danger-button {
  color: #ffffff;
  background: linear-gradient(135deg, #0077ed, #0061c8);
  border-color: transparent;
  font-weight: 600;
}

.pill-button {
  color: #ffffff;
  background: linear-gradient(135deg, #0071e3, #0068d1);
  border-color: transparent;
}

.ghost-button:hover,
.danger-button:hover,
.pill-button:hover {
  transform: translateY(-1px);
}

.ghost-button.toggle-on {
  color: #ffffff;
  background: linear-gradient(135deg, #0077ed, #0061c8);
  border-color: transparent;
  font-weight: 600;
}

.panel {
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.status-bar {
  margin-top: 18px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(245, 245, 247, 0.92);
  color: var(--muted);
  font-size: 13px;
}

.status-chip.tone-healthy .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(29, 157, 92, 0.10);
}

.status-chip.tone-degraded .status-dot,
.status-chip.tone-recovering .status-dot {
  background: #ff9f0a;
  box-shadow: 0 0 0 6px rgba(255, 159, 10, 0.12);
}

.status-chip.tone-stopped .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(255, 59, 48, 0.10);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(0, 113, 227, 0.08);
}

.status-clock {
  text-align: right;
  font-size: 13px;
  color: var(--muted);
}

.status-clock strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-top: 4px;
}

.status-alert {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 243, 242, 0.95);
  border: 1px solid rgba(255, 59, 48, 0.18);
  color: #6b1f1a;
  box-shadow: 0 12px 30px rgba(255, 59, 48, 0.08);
}

.status-alert strong {
  display: block;
  margin-bottom: 6px;
  color: #8f211c;
}

.status-alert span {
  display: block;
  line-height: 1.6;
}

.is-hidden {
  display: none;
}

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

.summary-card {
  padding: 20px;
  border-radius: 24px;
  background: var(--panel-soft);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.summary-card .label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(110, 110, 115, 0.9);
}

.summary-card .value {
  margin: 12px 0 6px;
  font-size: 28px;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.summary-card .subvalue {
  color: var(--muted);
  font-size: 13px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.dashboard-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
}

.performance-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.bottom-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.chart-panel,
.control-panel,
.panel {
  padding: 22px;
}

.chart-panel,
.strategy-panel {
  height: var(--performance-panel-height);
  min-height: var(--performance-panel-height);
  max-height: var(--performance-panel-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.strategy-panel {
  height: var(--strategy-panel-height);
  min-height: var(--strategy-panel-height);
  max-height: var(--strategy-panel-height);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 26px;
}

.chart-caption {
  font-size: 28px;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.chart-caption-stack {
  text-align: right;
}

.chart-caption-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.sparkline-shell {
  height: 280px;
  min-height: 280px;
  max-height: 280px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(0, 113, 227, 0.06), rgba(255, 255, 255, 0.85)),
    rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.05);
  padding: 14px;
}

#pnlSparkline {
  width: 100%;
  height: 100%;
}

.chart-legend {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 92px;
  overflow: auto;
  padding-right: 4px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(245, 245, 247, 0.92);
  color: var(--muted);
  font-size: 13px;
}

.legend-chip strong {
  color: var(--text);
  font-weight: 600;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.strategy-summary {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.strategy-activity-list {
  margin-top: 6px;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.strategy-activity-card {
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.activity-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.activity-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.activity-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.activity-badge.best {
  background: rgba(0, 113, 227, 0.12);
  color: #0071e3;
}

.activity-badge.worst {
  background: rgba(255, 59, 48, 0.12);
  color: #d2413a;
}

.strategy-card {
  border-radius: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.strategy-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

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

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

.control-copy {
  color: var(--muted);
  line-height: 1.7;
}

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

.executor-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
}

.executor-settings {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.setting-field {
  display: grid;
  gap: 8px;
}

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

.setting-field input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(245, 245, 247, 0.92);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.setting-field input:focus {
  outline: 1px solid rgba(0, 113, 227, 0.35);
  border-color: rgba(0, 113, 227, 0.35);
}

.setting-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.compact-head {
  margin-top: 18px;
  margin-bottom: 14px;
}

.control-list {
  display: grid;
  gap: 12px;
}

.hint-card {
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.hint-card strong {
  display: block;
  margin-bottom: 6px;
}

.positions-list,
.orders-list,
.event-feed {
  display: grid;
  gap: 12px;
}

.positions-list,
.orders-list {
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.positions-list {
  max-height: var(--positions-panel-height);
}

.position-card,
.order-card,
.event-card {
  border-radius: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.position-top,
.order-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.symbol-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.direction-badge,
.mode-badge,
.event-level {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.direction-badge.long {
  background: rgba(29, 157, 92, 0.12);
  color: var(--green);
}

.direction-badge.short {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}

.mode-badge {
  background: rgba(0, 113, 227, 0.12);
  color: #0071e3;
}

.event-level.info {
  background: rgba(0, 113, 227, 0.10);
  color: #0071e3;
}

.event-level.warn {
  background: rgba(255, 59, 48, 0.12);
  color: #d2413a;
}

.event-level.neutral {
  background: rgba(245, 245, 247, 0.92);
  color: var(--muted);
}

.position-grid,
.order-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mini-stat {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(245, 245, 247, 0.92);
}

.mini-stat span {
  display: block;
  font-size: 12px;
  color: rgba(110, 110, 115, 0.9);
}

.mini-stat strong {
  display: block;
  margin-top: 6px;
  line-height: 1.45;
  word-break: break-word;
}

.position-actions {
  margin-top: 14px;
  display: flex;
  justify-content: end;
}

.table-shell {
  max-height: 560px;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.05);
  background: rgba(255, 255, 255, 0.98);
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(249, 249, 251, 0.98);
  backdrop-filter: blur(8px);
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  text-align: left;
  white-space: nowrap;
}

th {
  color: rgba(110, 110, 115, 0.95);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.trade-note {
  max-width: 220px;
  white-space: normal;
  color: var(--muted);
}

.event-card {
  display: grid;
  gap: 10px;
}

.event-feed {
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.event-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.event-time {
  color: rgba(29, 29, 31, 0.42);
  font-size: 12px;
  font-weight: 500;
}

.event-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.full-span {
  width: 100%;
}

.empty-state {
  padding: 28px;
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.98);
}

button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 1160px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .performance-grid,
  .dashboard-grid,
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  :root {
    --performance-panel-height: 420px;
    --strategy-panel-height: 720px;
    --positions-panel-height: 240px;
  }

  .page-shell {
    width: min(100vw - 16px, 100%);
    margin-top: 14px;
  }

  .hero,
  .panel,
  .chart-panel,
  .control-panel {
    padding: 18px;
    border-radius: 22px;
  }

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

  .hero-brand {
    align-items: flex-start;
  }

  .brand-avatar-shell {
    width: 84px;
    height: 84px;
    border-radius: 22px;
  }

  .position-grid,
  .order-grid,
  .executor-summary,
  .strategy-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setting-form {
    grid-template-columns: 1fr;
  }

  .table-shell {
    max-height: 420px;
  }

  .positions-list,
  .orders-list,
  .event-feed {
    max-height: 420px;
  }

  .status-bar,
  .panel-head,
  .strategy-card-top,
  .position-top,
  .order-top {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-caption-stack {
    text-align: left;
  }
}
