:root {
  --bg: #0b0e14;
  --panel: #141a24;
  --panel-2: #1b2230;
  --line: #232c3d;
  --text: #e8eef8;
  --muted: #8792a6;
  --up: #ff5d5d;
  --down: #22c98a;
  --accent: #3b7cff;
  --accent-soft: rgba(59, 124, 255, 0.14);
  --warn: #ffa940;
  --radius: 14px;
  --nav-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }

.app { max-width: 560px; margin: 0 auto; padding: 0 14px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0 10px;
  background: linear-gradient(to bottom, var(--bg) 65%, rgba(11, 14, 20, 0));
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: 0.5px; }
.chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.live { color: #79d0ff; border-color: rgba(59, 124, 255, 0.45); background: var(--accent-soft); }
.chip.closed { color: var(--muted); }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.icon-btn:active { background: var(--panel-2); }

/* --------------------------------------------------------------- indices */
.indices { display: flex; gap: 8px; margin-bottom: 16px; }
.index {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.index-name { display: block; font-size: 11px; color: var(--muted); }
.index-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.index-price { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.index-pct { font-size: 12px; font-variant-numeric: tabular-nums; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

/* --------------------------------------------------------------- section */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 10px; }
.section-head h2 { margin: 0; font-size: 16px; }
.hint { font-size: 11px; color: var(--muted); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  min-width: 108px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: left;
}
.tab .tab-name { display: block; font-size: 14px; font-weight: 600; }
.tab .tab-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.tab.active { border-color: var(--accent); background: var(--accent-soft); }
.tab.active .tab-sub { color: #9dc0ff; }
.tab.soon { opacity: 0.45; }

/* ---------------------------------------------------------------- banner */
.banner {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 124, 255, 0.35);
  color: #9dc0ff;
  font-size: 12px;
  margin-bottom: 12px;
}
.banner.warn { background: rgba(255, 169, 64, 0.12); border-color: rgba(255, 169, 64, 0.35); color: #ffc57a; }
.banner strong { font-weight: 600; }

/* ----------------------------------------------------------------- stats */
.stats {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(34, 201, 138, 0.1);
  border: 1px solid rgba(34, 201, 138, 0.28);
  margin-bottom: 10px;
}
.stats.degraded { background: rgba(255, 169, 64, 0.1); border-color: rgba(255, 169, 64, 0.3); }
.stats-main { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #b8f5dc; }
.stats.degraded .stats-main { color: #ffd8a6; }
.stats-main .dot { font-weight: 700; }
.stats-sub { margin-top: 4px; font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------------- hot */
.hot {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 169, 64, 0.09);
  border: 1px solid rgba(255, 169, 64, 0.25);
  font-size: 12px;
  color: #ffd8a6;
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.hot .hot-item { font-weight: 600; }
.hot .hot-pct { color: var(--up); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- result */
.results { display: flex; flex-direction: column; gap: 10px; }
.empty {
  padding: 36px 16px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  color: var(--muted);
}
.empty p { margin: 0 0 4px; color: var(--text); }
.empty span { font-size: 12px; }

.card {
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
  animation: rise 0.24s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.card-name .name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name .code { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.card-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-concepts { margin-top: 5px; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-mid { display: flex; align-items: center; gap: 12px; margin: 8px 0 6px; }
.price-block { flex: 0 0 auto; }
.price { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.price-sub { font-size: 12px; font-variant-numeric: tabular-nums; }
.spark { flex: 1; height: 46px; min-width: 0; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; margin-top: 8px; }
.metric {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 0;
}
.metric span { display: block; font-size: 10px; color: var(--muted); }
.metric b { display: block; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; min-width: 0; }
.tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  color: #9dc0ff;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 124, 255, 0.28);
  white-space: nowrap;
}
.tag.warn { color: #ffc57a; background: rgba(255, 169, 64, 0.12); border-color: rgba(255, 169, 64, 0.3); }
.score { font-size: 11px; color: var(--muted); white-space: nowrap; }
.score b { font-size: 15px; color: var(--warn); margin-left: 2px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- fab/nav */
.fab {
  position: fixed;
  right: max(16px, calc(50vw - 280px + 16px));
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b7cff, #2b5fd9);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(59, 124, 255, 0.38);
}
.fab:disabled { opacity: 0.65; box-shadow: none; }
.fab.loading .fab-icon { animation: spin 0.9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 25;
  width: 100%;
  max-width: 560px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: rgba(15, 20, 29, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
}
.nav-item span { font-size: 16px; }
.nav-item.active { color: var(--accent); }

/* ----------------------------------------------------------------- boot */
.boot {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--bg);
  z-index: 60;
}

/* ----------------------------------------------------------------- sheet */
.sheet, .dialog { position: fixed; inset: 0; z-index: 70; display: flex; }
.sheet { align-items: flex-end; justify-content: center; }
.sheet-mask, .dialog-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.sheet-body {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.sheet-head h3 { margin: 0; font-size: 16px; }
.sheet-scroll { overflow-y: auto; padding: 4px 16px 12px; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }

.param-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.param-row:last-child { border-bottom: none; }
.param-label { flex: 1; min-width: 0; }
.param-label b { display: block; font-size: 13px; font-weight: 500; }
.param-label small { color: var(--muted); font-size: 11px; }
.param-input { display: flex; align-items: center; gap: 6px; }
.param-input input[type="number"], .param-input input[type="text"] {
  width: 92px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.param-input select {
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}
.param-unit { font-size: 11px; color: var(--muted); min-width: 24px; }
.switch { position: relative; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); transition: background 0.15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(18px); background: var(--accent); }

/* ------------------------------------------------------------------ btns */
.btn {
  padding: 11px 16px;
  border-radius: 11px;
  font-weight: 600;
  font-size: 14px;
}
.btn.primary { background: linear-gradient(135deg, #3b7cff, #2b5fd9); color: #fff; flex: 1; }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.btn:active { transform: translateY(1px); }

/* ---------------------------------------------------------------- dialog */
.dialog { align-items: center; justify-content: center; padding: 24px; }
.dialog-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}
.dialog-icon { font-size: 26px; }
.dialog-card h3 { margin: 6px 0 8px; font-size: 16px; }
.dialog-card p { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

/* ----------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 84px);
  transform: translateX(-50%);
  z-index: 80;
  max-width: 80vw;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(28, 36, 50, 0.96);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
  animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ------------------------------------------------------------------ auth */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(59, 124, 255, 0.16), transparent 60%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo { font-size: 30px; }
.auth-brand h1 { margin: 6px 0 2px; font-size: 21px; }
.auth-sub { margin: 0; color: var(--muted); font-size: 12px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.auth-card .btn.primary { width: 100%; }
.auth-error {
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(255, 93, 93, 0.12);
  border: 1px solid rgba(255, 93, 93, 0.3);
  color: #ff9b9b;
  font-size: 12px;
}
.auth-switch { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted); }
.link-btn { color: var(--accent); font-size: 12px; padding: 2px 4px; }
.auth-foot { margin: 18px 0 0; text-align: center; font-size: 11px; color: #5d687c; }
