:root {
  --bg: #0a0e14;
  --bg-2: #0d1117;
  --panel: #141a22;
  --panel-2: #182029;
  --panel-soft: #1d2530;
  --border: #283039;
  --border-soft: #20272f;
  --text: #eef3f8;
  --muted: #93a0ad;
  --accent: #5cb8ff;
  --accent-2: #38e1c4;
  --accent-strong: #1f6feb;
  --green: #44d07b;
  --red: #ff6b62;
  --yellow: #e3b341;
  --shadow: rgba(1, 4, 9, 0.55);
  --shadow-lg: rgba(1, 4, 9, 0.7);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark; /* 优化: 原生控件/滚动条采用暗色，避免亮色系统默认 */
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(56, 225, 196, 0.07), transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, rgba(92, 184, 255, 0.08), transparent 58%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
  background-attachment: fixed;
}

/* 优化: 环境层——极淡的网格 + 顶部光晕，固定不随滚动，营造“活的”交易终端质感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* 优化: 键盘可达性——所有交互元素统一的焦点环 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 40px;
}

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

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(27px, 4vw, 44px);
  line-height: 1.04;
  letter-spacing: -0.025em;
  font-weight: 800;
  color: #f4f8fc;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 6px 34px rgba(56, 225, 196, 0.14);
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.time-panel,
.stat,
.controls,
.panel,
.footer {
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 42%),
    var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.time-panel {
  position: relative;
  min-width: 140px;
  padding: 11px 13px 12px;
  overflow: hidden;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.time-panel:hover {
  border-color: rgba(92, 184, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 16px 36px var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* 优化: 时间块左上 accent 眉标 + 标题下分隔线，做成“仪表读数”质感 */
.time-panel::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 0;
  width: 3px;
  height: 11px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0.9;
}

.time-panel .muted {
  display: block;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.time-panel strong {
  display: block;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* 优化: 数据状态块——“在线”脉动点，更像实时监控仪表 */
.refresh-status-panel .status-dot {
  box-shadow: 0 0 0 0 currentColor;
}
.refresh-status.ok .status-dot {
  animation: livePing 2.4s var(--ease) infinite;
}
@keyframes livePing {
  0% { box-shadow: 0 0 0 0 rgba(68, 208, 123, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(68, 208, 123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(68, 208, 123, 0); }
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

/* Refresh status */
.refresh-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.refresh-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.refresh-status.ok { color: var(--green); }
.refresh-status.ok .status-dot { background: var(--green); }

.refresh-status.syncing { color: var(--yellow); }
.refresh-status.syncing .status-dot {
  background: var(--yellow);
  animation: pulse 1.5s ease-in-out infinite;
}

.refresh-status.error { color: var(--red); }
.refresh-status.error .status-dot { background: var(--red); }

.refresh-status.stale { color: var(--red); } /* 优化: 数据陈旧（>15min）必须一眼可见，不能显示为“正常” */
.refresh-status.stale .status-dot { background: var(--red); }
.refresh-status.stale .status-age { color: var(--red); }

.refresh-status .status-age {
  color: var(--muted);
  font-size: 11px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Export buttons */
.export-group {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.export-group .btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.btn,
.tab,
.sort-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-soft);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease),
    color 0.18s var(--ease), transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}

.btn:hover,
.tab:hover {
  border-color: rgba(92, 184, 255, 0.45);
  background: var(--panel-2);
  transform: translateY(-1px);
}

.btn:active,
.tab:active {
  transform: translateY(0);
}

.btn {
  min-height: 42px;
  padding: 0 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.btn.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(180deg, #2f86ff, var(--accent-strong));
  box-shadow: 0 6px 18px rgba(31, 111, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn.primary:hover {
  border-color: transparent;
  background: linear-gradient(180deg, #4493ff, #2477f0);
  box-shadow: 0 8px 24px rgba(31, 111, 235, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
  padding-left: 36px;
}

.btn.loading::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.btn.ghost[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(92, 184, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(92, 184, 255, 0.25);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.stat {
  position: relative;
  padding: 17px 18px 18px;
  overflow: hidden;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.stat:hover {
  transform: translateY(-3px);
  border-color: rgba(92, 184, 255, 0.3);
  box-shadow: 0 18px 40px var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* 优化: 每张统计卡顶部的彩色强调条，赋予四宫格节奏与身份 */
.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.85;
}
.stat:nth-child(2)::before { background: linear-gradient(90deg, var(--green), var(--accent-2)); }
.stat:nth-child(3)::before { background: linear-gradient(90deg, var(--yellow), var(--red)); }
.stat:nth-child(4)::before { background: linear-gradient(90deg, var(--accent-2), var(--green)); }

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.stat strong {
  display: block;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* 优化: 统计卡首屏逐张错落上浮淡入，赋予页面“启动”的生命感 */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat {
  animation: cardIn 0.5s var(--ease) both;
}
.stats-grid .stat:nth-child(1) { animation-delay: 0.04s; }
.stats-grid .stat:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat:nth-child(3) { animation-delay: 0.16s; }
.stats-grid .stat:nth-child(4) { animation-delay: 0.22s; }

.controls {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

.view-tabs,
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 600;
}

.tab.active {
  border-color: rgba(92, 184, 255, 0.5);
  color: var(--accent);
  background: rgba(92, 184, 255, 0.1);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px rgba(92, 184, 255, 0.6);
}

.tab-icon {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 5px;
  background: rgba(139, 148, 158, 0.12);
}

.tab-icon::before,
.tab-icon::after {
  content: "";
  position: absolute;
  display: block;
}

.icon-arbitrage::before {
  left: 4px;
  bottom: 4px;
  width: 10px;
  height: 8px;
  border-left: 2px solid var(--red);
  border-bottom: 2px solid var(--red);
  transform: skewX(-24deg);
}

.icon-arbitrage::after {
  right: 3px;
  top: 3px;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--green);
  border-right: 2px solid var(--green);
  transform: rotate(8deg);
}

.icon-rates::before {
  left: 4px;
  top: 4px;
  width: 10px;
  height: 10px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 0 4px / 100% 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 0 8px / 100% 2px no-repeat;
}

.icon-rates::after {
  right: 3px;
  bottom: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: -7px -4px 0 var(--green);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  background: var(--bg-2);
  color: var(--text);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

input:hover,
select:hover {
  border-color: var(--border-soft);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(92, 184, 255, 0.18);
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

.panel-head h2 {
  position: relative;
  padding-left: 12px;
}

.panel-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.12em;
  bottom: 0.12em;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: relative;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

tbody tr {
  transition: background 0.15s var(--ease);
}

/* 注: 表格行不做入场错落动画——行在每次刷新/WS tick 都会重建 DOM，入场动画会反复重放造成闪烁；
   行的“生命感”改由 hover 左侧光条、cell-flash、趋势箭头承担。仅统计卡做首屏入场(不常重渲染)。 */

tbody tr:hover {
  background: rgba(92, 184, 255, 0.07);
  box-shadow: inset 3px 0 0 var(--accent); /* 优化: 行悬停左侧光条，不改布局 */
}

tbody tr:hover td:first-child {
  background: var(--panel-2); /* 优化: 粘滞首列随悬停同步着色，避免“悬停时首列不变”的破绽 */
}

/* Sticky first column for mobile/tablet horizontal scroll */
.table-wrap th:first-child,
.table-wrap td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--panel);
}

.table-wrap td:first-child {
  box-shadow: 12px 0 14px -12px rgba(0, 0, 0, 0.6); /* 优化: 粘滞列右侧投影，提示可横向滚动 */
}

.table-wrap th:first-child {
  z-index: 11;
  background: var(--bg-2);
}

tr.row-highlight {
  animation: rowPulse 2.4s ease;
}

@keyframes rowPulse {
  0%,
  100% {
    background: transparent;
  }
  20%,
  70% {
    background: rgba(210, 153, 34, 0.18);
  }
}

.sort-btn {
  color: inherit;
  padding: 4px 8px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-btn:hover {
  color: var(--text);
  background: rgba(92, 184, 255, 0.08);
  transform: none;
  border-color: transparent;
}

.sort-indicator {
  font-size: 10px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
  min-width: 10px;
}

.sort-btn.active .sort-indicator {
  opacity: 1;
}

.symbol-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: color 0.15s var(--ease), text-shadow 0.15s var(--ease);
}

.symbol-link:hover {
  color: #fff;
  text-shadow: 0 0 14px rgba(92, 184, 255, 0.55);
}

/* 优化: 置信徽章——描边环 + 状态点，紧贴币种名，标识该机会数据是否可信 */
.conf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid transparent;
}
.conf-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.conf-badge.high {
  color: var(--green);
  background: rgba(68, 208, 123, 0.1);
  border-color: rgba(68, 208, 123, 0.32);
}
.conf-badge.low {
  color: var(--red);
  background: rgba(255, 107, 98, 0.1);
  border-color: rgba(255, 107, 98, 0.32);
}

.rate {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 86px;
  justify-content: flex-end;
  border-radius: 999px;
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: rgba(147, 160, 173, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.rate.positive {
  color: var(--green);
  background: rgba(68, 208, 123, 0.12);
  box-shadow: inset 0 0 0 1px rgba(68, 208, 123, 0.22);
}

.rate.negative {
  color: var(--red);
  background: rgba(255, 107, 98, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 98, 0.22);
}

.trend {
  font-family: var(--mono);
  font-size: 12px;
}

.trend.up {
  color: var(--green);
}

.trend.down {
  color: var(--red);
}

.trend.flat {
  color: var(--muted);
}

.direction {
  max-width: 320px;
  white-space: normal;
  line-height: 1.4;
}

.range-cell {
  min-width: 180px;
}

.range-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.range-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--range-width, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  box-shadow: 0 0 10px rgba(68, 208, 123, 0.25);
  transition: width 0.4s var(--ease);
}

.range-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  border: 1.5px solid var(--panel);
  cursor: help;
  transition: transform 0.14s var(--ease), box-shadow 0.14s var(--ease);
}

.range-dot:hover {
  transform: translate(-50%, -50%) scale(1.6);
  box-shadow: 0 0 8px currentColor;
}

.range-dot.positive { background: var(--green); color: var(--green); }
.range-dot.negative { background: var(--red); color: var(--red); }

.range-zero {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 1px;
  background: var(--muted);
  opacity: 0.35;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 14px;
}

.status-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.015);
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.status-pill.ok { color: var(--green); border-color: rgba(68, 208, 123, 0.3); }
.status-pill.ok .status-dot {
  background: var(--green);
  box-shadow: 0 0 7px rgba(68, 208, 123, 0.7);
}

.status-pill.ws {
  border-color: rgba(88, 166, 255, 0.5);
  color: var(--accent);
}

.status-pill.ws .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.12);
}

.status-pill.connecting {
  color: var(--accent);
}

.status-pill.connecting .status-dot {
  background: var(--accent);
  animation: statusPulse 1.2s ease-in-out infinite;
}

.status-pill.error .status-dot {
  background: var(--red);
  box-shadow: 0 0 7px rgba(255, 107, 98, 0.7);
}

.status-pill.prefetch .status-dot {
  background: var(--yellow);
}

.status-pill.fallback {
  border-color: rgba(227, 179, 65, 0.45);
  color: var(--yellow);
  background: rgba(227, 179, 65, 0.06);
}

.status-pill.fallback .status-dot {
  background: var(--yellow);
  box-shadow: 0 0 7px rgba(227, 179, 65, 0.6);
}

@keyframes statusPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* Cell flash animations for rate changes */
@keyframes flashCell {
  0%   { background: var(--flash-color); }
  100% { background: transparent; }
}

.cell-flash-green {
  --flash-color: rgba(63, 185, 80, 0.35);
  animation: flashCell 1.2s ease-out;
}

.cell-flash-red {
  --flash-color: rgba(248, 81, 73, 0.35);
  animation: flashCell 1.2s ease-out;
}

/* Settings panel */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 90vw);
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 40px var(--shadow);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 24px;
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.6);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.settings-overlay.open {
  opacity: 1;
  visibility: visible;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.settings-head h3 {
  margin: 0;
  font-size: 18px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h4 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.settings-row label {
  font-size: 14px;
  flex-shrink: 0;
}

.settings-row input[type="number"],
.settings-row input[type="text"] {
  width: 120px;
  text-align: right;
  font-family: var(--mono);
}

.settings-row .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Notification toggle */
.notify-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.notify-toggle input {
  appearance: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.notify-toggle input::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s;
}

.notify-toggle input:checked {
  background: var(--accent-strong);
}

.notify-toggle input:checked::after {
  transform: translateX(16px);
}

/* Position simulator */
.simulator {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel-soft);
  margin-bottom: 14px;
}

.simulator h4 {
  margin: 0 0 12px;
  font-size: 14px;
}

.sim-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sim-row label {
  font-size: 13px;
  color: var(--muted);
  min-width: 60px;
}

.sim-row input {
  width: 100px;
}

.sim-result {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.sim-result .sim-item {
  text-align: center;
}

.sim-result .sim-item span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.sim-result .sim-item strong {
  display: block;
  font-family: var(--mono);
  font-size: 18px;
  margin-top: 4px;
}

/* Chart Modal */
.chart-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(800px, 94vw);
  max-height: 80vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px var(--shadow);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chart-modal.open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.chart-body {
  padding: 20px;
  flex: 1;
  overflow: auto;
  min-height: 300px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Sparkline in table */
.sparkline {
  width: 60px;
  height: 24px;
}

.sparkline path {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast-host {
  position: fixed;
  right: 18px;
  top: 18px; /* 优化: 移到右上，避免遮住表格右下“操作”列 */
  display: grid;
  gap: 10px;
  z-index: 120;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--panel);
  box-shadow: 0 10px 32px var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast.success {
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.08);
}

.toast.error {
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.08);
}

.toast.info {
  border-color: rgba(88, 166, 255, 0.4);
  background: rgba(88, 166, 255, 0.08);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.toast.success .toast-icon { background: rgba(63, 185, 80, 0.2); color: var(--green); }
.toast.error  .toast-icon { background: rgba(248, 81, 73, 0.2); color: var(--red); }
.toast.info   .toast-icon { background: rgba(88, 166, 255, 0.2); color: var(--accent); }

.tooltip {
  position: fixed;
  z-index: 30;
  max-width: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #010409;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding: 18px 0;
  }

  .header,
  .controls,
  .panel-head,
  .footer {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: stretch;
  }

  .time-panel,
  .header-actions .btn {
    flex: 1;
  }

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

  .filter-row,
  .view-tabs {
    width: 100%;
  }

  .search,
  .search input,
  .search select,
  .filter-row .btn {
    width: 100%;
  }
}

/* 优化: 暗色细滚动条，贴合交易终端质感 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
  background-clip: padding-box;
}

/* 优化: 尊重“减少动态”系统偏好——关闭所有装饰性动画/过渡 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
