/* Tailwind CSS CDN */
@import url('https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css');

/* ===== 设计变量：白色系极简金融风 ===== */
:root {
  --primary: #F0B90B;
  --ink: #181A20;
  --bg: #FFFFFF;
  --bg-soft: #F7F8FA;
  --text: #1E2026;
  --text-2: #707A8A;
  --line: #EAECEF;
  --up: #0ECB81;
  --down: #F6465D;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(24, 26, 32, 0.05), 0 4px 16px rgba(24, 26, 32, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-family: 'PingFang SC', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶部标题栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px 10px;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.5px;
}
.logo-dot {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, #d9a50a 100%);
  box-shadow: 0 2px 6px rgba(240, 185, 11, 0.35);
  position: relative;
}
.logo-dot::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 2px;
  background: #fff;
  opacity: 0.85;
}
.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c2c7cf;
  transition: background 0.3s;
}
.conn-dot.on { background: var(--up); animation: pulse 2s infinite; }
.conn-dot.off { background: var(--down); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(14, 203, 129, 0.4); }
  50% { box-shadow: 0 0 0 5px rgba(14, 203, 129, 0); }
}
.conn-text { font-size: 12px; color: var(--text-2); }
.topbar-sub {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}

/* ===== 容器 ===== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== 骨架屏 ===== */
.skeleton-card {
  height: 180px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #f1f2f4 25%, #fafbfc 50%, #f1f2f4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== 交易员卡片 ===== */
.trader-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fadeUp 0.35s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 0;
}
.trader-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  background: linear-gradient(135deg, #fff6d6, #ffe9a8);
  border: 1px solid #f5e29a;
  flex-shrink: 0;
}
.trader-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trader-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-2);
}
.trader-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.trader-link:active { opacity: 0.7; }

/* ===== 通知开关组 ===== */
.notify-panel {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  margin-top: 12px;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.switch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.switch-label {
  font-size: 12px;
  color: var(--text-2);
  transition: color 0.2s;
}
.switch-item.on .switch-label { color: var(--text); font-weight: 500; }
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #d5d9e0;
  transition: background 0.25s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.switch-item.on .switch { background: var(--up); }
.switch-item.on .switch::after { transform: translateX(18px); }

/* ===== 持仓列表 ===== */
.position-list { padding: 4px 16px 12px; }
.position-empty {
  padding: 18px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}
.position-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.8fr;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.position-row:last-child { border-bottom: none; }
.pos-head {
  padding: 8px 0 4px;
  font-size: 11px;
  color: #a3a9b3;
  border-bottom: 1px solid var(--line);
}
.sym-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.symbol { font-weight: 600; font-size: 14px; color: var(--ink); }
.side-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}
.side-tag.long { color: var(--up); background: rgba(14, 203, 129, 0.1); }
.side-tag.short { color: var(--down); background: rgba(246, 70, 93, 0.1); }
.price-cell {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lever-badge {
  justify-self: end;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 卡片错误/加载态 */
.card-note {
  margin: 0 16px 14px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
}
.card-note.err { background: rgba(246, 70, 93, 0.08); color: var(--down); }
.card-note.loading { background: var(--bg-soft); color: var(--text-2); }

/* ===== Toast 弹窗 ===== */
.toast-wrap {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(24, 26, 32, 0.92);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  animation: slideIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  backdrop-filter: blur(8px);
}
.toast.out { animation: slideOut 0.3s ease both; }
.toast .t-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.toast.open .t-tag { color: #fff; background: var(--up); }
.toast.close .t-tag { color: #fff; background: var(--down); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(12px); }
}

/* ===== 桌面端 ===== */
@media (min-width: 768px) {
  body { font-size: 15px; }
  .container { padding: 24px; gap: 20px; }
  .topbar { padding: 18px 24px 12px; }
  .topbar-inner { max-width: 720px; margin: 0 auto; }
  .topbar-sub { max-width: 720px; margin: 6px auto 0; }
  .topbar-title h1 { font-size: 22px; }
  .toast-wrap { max-width: 480px; left: 50%; transform: translateX(-50%); }
}
