:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #e2e8ff;
  --border: #e2e8f0;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
  --green: #2b8a6d;
  --red: #d94b4b;
  --amber: #d97706;
  --strong-red: #d82b2b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "WenQuanYi Micro Hei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow: hidden;
}

body.tv-login {
  color-scheme: dark;
  overflow: auto;
  background: #070b16;
  color: #e2e8f0;
  --login-ink: #e2e8f0;
  --login-muted: rgba(226, 232, 240, 0.72);
  --login-panel: rgba(15, 23, 42, 0.72);
  --login-border: rgba(148, 163, 184, 0.22);
  --login-accent: #38bdf8;
  --login-accent-2: #6366f1;
}

.tv-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  padding: 0 10px 10px;
}

.dock-rail,
.rail-btn {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.panel {
  background: var(--panel);
  border-radius: 0;
  padding: 6px;
  border: none;
  /* box-shadow: var(--shadow); */
}

.tv-topbar {
  min-height: auto;
  overflow: visible;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 12px;
}

.top-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-area {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.auth-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  padding: 0;
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 65%, #1d4ed8 100%);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.auth-avatar:hover {
  filter: brightness(1.04);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.32);
}

.auth-avatar:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}

.auth-avatar-text {
  font-size: 0.92rem;
  line-height: 1;
}

.auth-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 140px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(226, 232, 240, 1);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
  z-index: 60;
}

.auth-menu[hidden] {
  display: none;
}

.auth-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.auth-menu-item:hover {
  background: #f1f5f9;
  color: var(--accent);
}

.auth-menu-item:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.brand h1 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 2.1vw, 1.9rem);
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.brand h1 img {
  height: 42px;
  width: auto;
  display: block;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 6px;
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 620px;
  font-size: 0.95rem;
}

.compact-form {
  position: relative;
  background: #fff;
  border: none;
  border-radius: 10px;
  padding: 4px 10px;
  min-width: 260px;
  max-width: 520px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  overflow: visible;
  z-index: 40;
}

#query-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-row input {
  flex: 1 1 auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 0.95rem;
  background: #f8fafc;
  color: var(--ink);
}

.input-row input:focus {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.market-select {
  min-width: 96px;
}

.target-select {
  min-width: 84px;
}

.market-select select,
.target-select select {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 0.92rem;
  cursor: pointer;
}

.market-select select:focus,
.target-select select:focus {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.market-select select option[disabled],
.target-select select option[disabled] {
  color: #a1a1aa;
}

.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 74px;
  white-space: nowrap;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.tv-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* padding: 10px; */
  /* background: #f8fafc; */
  border: none;
  border-radius: 12px;
  position: relative;
  user-select: none;
}

.tv-toolbar.hidden {
  display: none !important;
}

.tv-toolbar::after {
  display: none;
}

.toolbar.collapsed {
  padding: 14px 10px 10px;
}

.toolbar.collapsed::after {
  transform: translateX(-50%);
}

.tool-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.control-row {
  align-items: center;
}

.tool-control {
  position: relative;
}

.control-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.control-trigger.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.control-icon {
  font-size: 1rem;
  line-height: 1;
}

.control-label {
  line-height: 1;
}

.control-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 8px;
  background: #e2e8ff;
  color: #1d4ed8;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.control-caret {
  font-size: 0.8rem;
  color: #94a3b8;
}

.control-menu .control-popover {
  display: none;
  position: absolute;
  top: 36px;
  left: 0;
  z-index: 20;
  min-width: 160px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.control-menu.open .control-popover {
  display: block;
}

.control-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.range-list,
.freq-list,
.indicator-list,
.action-list {
  min-width: 140px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 10px;
  border: none;
  background: #fff;
}

.toolbar-separator {
  width: 1px;
  height: 32px;
  align-self: center;
  background: var(--border);
  margin: 0 2px;
}

.tool-group.stretch {
  flex: 1 1 340px;
}

.tool-group.align-end {
  margin-left: auto;
  gap: 6px;
}

.tool-label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.range-bar,
.freq-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.indicator-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.range-btn,
.freq-btn {
  border: none;
  background: #fff;
  color: var(--muted);
  padding: 2px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.range-btn:hover,
.freq-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.range-btn.active,
.freq-btn.active {
  color: var(--ink);
  background: #e9f0ff;
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.indicator-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  width: 100%;
}

.tool-group .tool-label {
  display: inline-flex;
  align-items: center;
}

.icon-toggle {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  background: #fff;
  color: #94a3b8;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.icon-toggle:hover {
  color: var(--accent);
  background: #f8fbff;
}

.icon-toggle.active {
  color: #fff;
  background: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1);
}

.indicator-filters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 28px;
  font-size: 0.88rem;
  color: var(--muted);
  align-items: stretch;
}

.indicator-filters.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.indicator-toggle-btn {
  border: none;
  background: #fff;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: none;
  text-align: left;
  width: 100%;
  border: 1px solid transparent;
}

.indicator-toggle-btn:hover {
  color: var(--accent);
  background: #f8fafc;
}

.indicator-toggle-btn.active {
  color: var(--ink);
  background: #e9f0ff;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.switch {
  position: relative;
  width: 96px;
  height: 30px;
  display: inline-flex;
  align-items: center;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px 0 12px;
  gap: 4px;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 6px;
  top: 6px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.slider-text {
  position: relative;
  z-index: 1;
  font-size: 0.96rem;
  color: #f8fafc;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  padding-left: 4px;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(65px);
}

.board-shell {
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.tv-board {
  display: flex;
  gap: 12px;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.main-area {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  border-radius: 0;
}

.right-drawer {
  flex: 0 0 auto;
  width: 0;
  overflow: hidden;
  background: #fff;
  border: none;
  border-left: none;
  border-radius: 0;
  transition: width 200ms ease, opacity 150ms ease;
  display: flex;
  flex-direction: column;
}

.right-drawer.open {
  width: 360px;
}

.drawer-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 4px;
  background: #fff;
  border-left: 1px solid #e2e8f0;
}
.drawer-body,
.side-body {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.drawer-body::-webkit-scrollbar,
.side-body::-webkit-scrollbar {
  width: 4px;
}
.drawer-body::-webkit-scrollbar-thumb,
.side-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.drawer-body::-webkit-scrollbar-track,
.side-body::-webkit-scrollbar-track {
  background: transparent;
}

.drawer-view.hidden {
  display: none;
}

.right-rail {
  width: 48px;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 8px 6px;
  align-self: stretch;
  height: 100%;
  background: #fff;
  border-left: none;
  border-radius: 0;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.rail-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: #475569;
  font-weight: 700;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
  transition: all 0.15s ease;
}

.rail-btn.hidden {
  display: none;
}

.rail-btn:disabled,
.rail-btn.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  border-style: dashed;
}

.rail-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
  background: #f8fbff;
}

.rail-btn.active {
  background: #e9f0ff;
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.rail-btn[data-key="hide"] {
  color: #dc2626;
}

.rail-btn[data-key="hide"].active {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
  box-shadow: inset 0 -2px 0 #dc2626;
}

.rail-btn[data-key="download"] {
  color: #0f172a;
}

.chart-panel {
  /* padding: 16px; */
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  position: relative;
  overflow: visible;
  border-radius: 0;
}

.global-hint-popover {
  position: fixed;
  top: 0;
  left: 0;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  z-index: 99999;
  pointer-events: none;
  white-space: pre-wrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.08s ease, visibility 0.08s ease;
}

.panel-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 15, 31, 0.75);
  backdrop-filter: blur(20px);
  z-index: 90;
  pointer-events: auto;
}

.panel-mask.hidden {
  display: none;
}

.panel-mask-card {
  background: #0f172a;
  color: #e2e8f0;
  padding: 18px 20px;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 200px;
  text-align: center;
}

.panel-mask-title {
  font-weight: 800;
  font-size: 1rem;
}

.panel-mask-btn {
  border: none;
  background: #e2e8f0;
  color: #0f172a;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.panel-mask-btn:hover {
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
}

.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
  position: relative;
}

.hint::after {
  display: none;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.chart-header.sticky {
  position: sticky;
  top: 0;
  padding-bottom: 10px;
  background: var(--panel);
  z-index: 5;
}

.chart-panel .toolbar {
  /* margin-top: 10px; */
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 6;
}

.toolbar.collapsed .tool-row {
  display: none;
}

.toolbar.collapsible {
  cursor: pointer;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.title-line h2,
.title-line h3 {
  margin: 0;
  line-height: 1.2;
}

.title-meta {
  font-size: 0.9rem;
  color: var(--muted);
}
.chart-header .title-meta {
  display: none;
}

.adjust-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #0f172a;
  padding: 4px 10px;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  width: fit-content;
}

.adjust-badge::before {
  content: "模式";
  font-weight: 800;
  color: #0369a1;
  letter-spacing: 0.02em;
}

.chart {
  margin-top: 0;
  flex: 1 1 auto;
  min-height: 520px;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(22px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.chart-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #0f172a;
  font-weight: 700;
  letter-spacing: 0.02em;
  z-index: 6;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.chart-empty::before {
  content: "";
  position: absolute;
  inset: 12%;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.94), rgba(241, 245, 249, 0.9));
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  z-index: -1;
}

.chart-empty.hidden {
  opacity: 0;
  visibility: hidden;
}

.overlay-content {
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  padding: 16px 18px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
  text-align: center;
}

.chart-panel.is-fullscreen {
  height: 100%;
  min-height: 0;
  position: relative;
  padding: 2px;
  background: var(--panel);
}

.chart-panel.is-fullscreen .chart {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.board-shell.is-fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 0;
}

.board-shell.is-fullscreen .tv-board {
  height: 100%;
  display: flex;
}

.board-shell.is-fullscreen .panel {
  border-radius: 0;
}

.fullscreen-scope {
  display: flex;
  gap: 2px;
  min-height: 0;
}

.fullscreen-scope.is-fullscreen {
  position: fixed;
  inset: 0;
  padding: 12px;
  background: #fff;
  z-index: 9999;
  height: 100vh;
  width: 100vw;
}

.chart-panel.is-fullscreen .chart-header.sticky {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  z-index: 45;
}

.chart-panel.is-fullscreen .toolbar {
  position: sticky;
  /* top: 64px; */
  z-index: 50;
  /* background: rgba(255, 255, 255, 0.9); */
  backdrop-filter: blur(8px);
  /* padding: 10px 12px; */
  /* margin-top: 6px; */
  /* border-radius: 12px; */
  /* border: 1px solid var(--border); */
  /* box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12); */
}

.chart-panel.is-fullscreen #chart {
  position: relative;
  z-index: 1;
}

.chart-panel.is-fullscreen #chart-overlay {
  z-index: 40;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(18px) saturate(110%);
}

.chart-panel.is-fullscreen .panel-mask {
  position: absolute;
  inset: 0;
}

.fullscreen-scope.is-fullscreen .chart-panel,
.fullscreen-scope.is-fullscreen .tv-side {
  height: 100%;
  min-height: 0;
}

.fullscreen-scope.is-fullscreen .tv-side .side-body {
  overflow: auto;
}

.fullscreen-scope.is-fullscreen .chart {
  flex: 1 1 auto;
  min-height: 0;
}

.tip-title {
  font-weight: 800;
  margin-bottom: 8px;
  color: #0b1224;
}

.tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  color: #1e293b;
}

.tip-row span:last-child {
  color: #0b1224;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tip-row.actions span:last-child {
  color: #1e293b;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 2px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ghost-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

#hide-chart-btn {
  color: var(--red);
  border-color: var(--red);
  background: #fff5f5;
}

#hide-chart-btn:hover {
  color: #fff;
  background: var(--red);
  box-shadow: 0 8px 18px rgba(217, 75, 75, 0.3);
}

.stat {
  text-align: right;
  color: var(--muted);
}

.stat span {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
}

.stat.compact {
  text-align: center;
}

.tv-side {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 320px;
  min-height: 0;
  height: 100%;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
}

.side-head.sticky {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 4;
}

.side-toggle {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}

.side-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.side-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 4px 4px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}

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

.info-section h3,
.info-section h4 {
  margin: 0;
  line-height: 1.3;
}

.section-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  padding: 4px;
  background: linear-gradient(#fff, rgba(255, 255, 255, 0.9));
  z-index: 2;
}

.info-groups,
.info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fdfefe;
}

.group-card[open] {
  box-shadow: inset 0 1px 0 rgba(37, 99, 235, 0.06);
}

.group-card summary {
  list-style: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f8fafc;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  transition: background 0.15s ease;
}

.group-card summary::-webkit-details-marker {
  display: none;
}

.group-card summary:hover {
  background: #eef2ff;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.group-body {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  font-variant-numeric: tabular-nums;
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-label,
.kv-k {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.kv-value,
.kv-v {
  color: var(--ink);
  font-weight: 600;
  text-align: right;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  line-height: 1.4;
  text-align: left;
  word-break: break-all;
}

.index-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.index-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.index-chip.active {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.16);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #eef2ff;
  color: #1e3a8a;
}

.badge.state {
  background: #e0f2fe;
  color: #075985;
}

.badge.state-scan { background: #e2e8f0; color: #475569; }
.badge.state-setup { background: #fef9c3; color: #92400e; }
.badge.state-entry { background: #e0f2fe; color: #075985; }
.badge.state-hold { background: #ecfdf3; color: #166534; }
.badge.state-pause { background: #fff4e6; color: #9a3412; }
.badge.state-exit { background: #fee2e2; color: #991b1b; }

.badge.bucket-setup { background: #fef9c3; color: #92400e; }
.badge.bucket-entry { background: #e0f2fe; color: #075985; }
.badge.bucket-trend { background: #ecfdf3; color: #166534; }
.badge.bucket-risk { background: #fff4e6; color: #9a3412; }

.badge.action-buy { background: #e0f2fe; color: #075985; }
.badge.action-add { background: #fee2e2; color: #991b1b; }
.badge.action-sell { background: #fee2e2; color: #991b1b; }
.badge.action-remove { background: #f1f5f9; color: #475569; }
.badge.action-hold { background: #ecfdf3; color: #166534; }
.badge.action-watch { background: #f8fafc; color: #475569; }
.kv-row.flag-true {
  background: rgba(216, 43, 43, 0.08);
}
.kv-row.flag-false {
  background: rgba(43, 138, 109, 0.08);
}

.num-pos {
  color: var(--strong-red);
}
.num-neg {
  color: var(--green);
}

.highlight.important {
  color: #fff;
  background: var(--strong-red);
  border-radius: 8px;
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.star {
  color: var(--amber);
  margin-right: 2px;
}

.badge.bucket {
  background: #ecfdf3;
  color: #166534;
}

.badge.action {
  background: #fff7ed;
  color: #9a3412;
}

.badge.subtle {
  background: #f1f5f9;
  color: var(--muted);
}

.snapshot-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.snap-tab {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.snap-tab.active {
  background: #e9f0ff;
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.snap-group.hidden {
  display: none;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: #cbd5e1;
}

.dot.on {
  background: var(--strong-red);
  box-shadow: 0 0 0 4px rgba(216, 43, 43, 0.12);
}

.dot.off {
  background: #cbd5e1;
}

.dot.ok {
  background: var(--strong-red);
  box-shadow: 0 0 0 4px rgba(216, 43, 43, 0.12);
}

.dot.no {
  background: #cbd5e1;
}

.weight-bar {
  position: relative;
  background: #e2e8f0;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
}

.weight-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
}

.weight-value {
  font-weight: 700;
  margin-left: 8px;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
  max-height: 220px;
  overflow: auto;
  display: none;
  z-index: 120;
}

.suggestions.active {
  display: block;
}

.suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.95rem;
}

.suggestion-item:hover {
  background: #f1f5f9;
}

.info-list.empty,
.info-groups.empty {
  color: var(--muted);
  font-style: italic;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 1200px) {
  .tv-board {
    flex-direction: column;
  }
  .main-area {
    min-width: 0;
    flex-basis: auto;
  }
}

body.side-collapsed .tv-side {
  padding: 10px 8px;
}

body.side-collapsed .tv-side .side-body,
body.side-collapsed .tv-side .info-section,
body.side-collapsed .tv-side .section-head {
  display: none;
}

body.side-collapsed .tv-side .title-line {
  display: none;
}

body.side-collapsed .side-toggle {
  transform: rotate(180deg);
}

@media (max-width: 720px) {
  .tv-topbar {
    border-radius: 0;
  }

  .tool-group.align-end {
    margin-left: 0;
    gap: 4px;
  }

  .chart {
    min-height: 460px;
  }
}

.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1100px 520px at 10% 10%, rgba(56, 189, 248, 0.20), transparent 60%),
    radial-gradient(1000px 520px at 88% 18%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(900px 520px at 40% 90%, rgba(34, 197, 94, 0.16), transparent 60%),
    radial-gradient(1200px 600px at 50% 50%, rgba(2, 6, 23, 0.75), rgba(2, 6, 23, 0.95));
}

.login-grid {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0) 62%);
}

.login-orb {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.65;
  animation: login-float 9s ease-in-out infinite;
}

.login-orb.orb-1 {
  top: -240px;
  left: -180px;
  background: radial-gradient(circle at 30% 30%, rgba(56, 189, 248, 0.85), transparent 60%);
}

.login-orb.orb-2 {
  top: -220px;
  right: -240px;
  width: 560px;
  height: 560px;
  animation-delay: -3s;
  background: radial-gradient(circle at 50% 40%, rgba(99, 102, 241, 0.85), transparent 60%);
}

.login-orb.orb-3 {
  bottom: -260px;
  left: 30%;
  width: 620px;
  height: 620px;
  animation-delay: -6s;
  background: radial-gradient(circle at 50% 50%, rgba(34, 197, 94, 0.78), transparent 60%);
}

@keyframes login-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, 18px, 0);
  }
}

.login-shell {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  min-height: 100vh;
  max-width: 1320px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 24px 56px;
}

.login-stage {
  position: relative;
  width: min(1180px, 100%);
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(420px, 0.8fr);
}

.login-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

.stage-left,
.stage-right {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-left {
  padding: 44px 46px;
  background: transparent;
}

.stage-art {
  width: 100%;
  max-width: 760px;
}

.stage-art svg {
  width: 100%;
  height: auto;
  display: block;
}

.stage-right {
  flex-direction: column;
  padding: 44px 44px 40px;
  background: transparent;
  align-items: center;
}

.stage-right::before {
  content: "";
  position: absolute;
  inset: -140px -120px -140px -220px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(520px 420px at 62% 30%, rgba(2, 6, 23, 0.78), transparent 70%),
    radial-gradient(640px 520px at 62% 82%, rgba(2, 6, 23, 0.66), transparent 74%),
    radial-gradient(560px 460px at 32% 55%, rgba(99, 102, 241, 0.10), transparent 72%);
}

.stage-right > * {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.stage-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.stage-mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.stage-mark img {
  height: 32px;
  width: auto;
  display: block;
  opacity: 0.92;
  filter: invert(1) brightness(1.08) contrast(1.06) drop-shadow(0 6px 12px rgba(2, 6, 23, 0.55));
}

.stage-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.stage-brand-name {
  font-weight: 900;
  letter-spacing: 0.04em;
  font-size: 1.06rem;
  color: rgba(226, 232, 240, 0.94);
}

.stage-brand-sub {
  margin-top: 4px;
  color: rgba(226, 232, 240, 0.62);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

body.tv-login .stage-brand-sub {
  display: none;
}

body.tv-login .login-header {
  display: none;
}

.login-card-title {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.login-sub {
  margin: 6px 0 0;
  color: var(--login-muted);
  font-size: 0.95rem;
}

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

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

.login-label {
  color: rgba(226, 232, 240, 0.75);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

body.tv-login .login-form {
  gap: 12px;
}

body.tv-login .login-field {
  gap: 0;
}

body.tv-login .login-label {
  display: none;
}

.login-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.login-control:focus-within {
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.10),
    0 10px 28px rgba(2, 6, 23, 0.42);
  background: rgba(255, 255, 255, 0.08);
}

.field-icon {
  width: 20px;
  height: 20px;
  color: rgba(226, 232, 240, 0.62);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.tv-login .field-icon {
  display: none;
}

.field-icon svg {
  width: 20px;
  height: 20px;
}

.field-action {
  height: 38px;
  width: 38px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(226, 232, 240, 0.65);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.field-action:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(148, 163, 184, 0.18);
  color: rgba(226, 232, 240, 0.9);
}

.field-action svg {
  width: 20px;
  height: 20px;
}

.login-input {
  border: 0;
  outline: none;
  background: transparent;
  color: var(--login-ink);
  padding: 12px 0;
  font-size: 0.98rem;
  flex: 1 1 auto;
  min-width: 0;
}

.login-input::placeholder {
  color: rgba(226, 232, 240, 0.42);
}

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

.captcha-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.captcha-image-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.captcha-img {
  width: 220px;
  height: 72px;
  border-radius: 16px;
  border: 0;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  user-select: none;
}

.captcha-img.is-loading {
  opacity: 0.75;
  filter: saturate(0.8);
}

.captcha-tip {
  font-size: 0.82rem;
  color: rgba(226, 232, 240, 0.6);
}

body.tv-login .captcha-tip {
  display: none;
}

.captcha-refresh {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.captcha-refresh:hover {
  background: rgba(255, 255, 255, 0.10);
  box-shadow:
    0 10px 26px rgba(2, 6, 23, 0.40);
  transform: translateY(-1px);
}

.captcha-refresh:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.captcha-refresh:active {
  transform: translateY(0);
}

.refresh-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.refresh-icon svg {
  width: 18px;
  height: 18px;
}

body.tv-login .primary {
  width: 100%;
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 60%, #1d4ed8 100%);
  box-shadow: 0 18px 46px rgba(56, 189, 248, 0.18);
}

body.tv-login .primary:hover {
  filter: none;
  box-shadow: 0 24px 54px rgba(56, 189, 248, 0.22);
}

.login-btn {
  margin-top: 6px;
  position: relative;
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.95);
  margin-left: 10px;
  vertical-align: -3px;
  animation: login-spin 0.9s linear infinite;
}

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

#login-btn[data-state="loading"] {
  cursor: wait;
}

#login-btn[data-state="loading"] .btn-spinner {
  display: inline-block;
}

.login-msg {
  min-height: 0;
  font-size: 0.92rem;
  color: rgba(226, 232, 240, 0.82);
}

.login-msg:not(:empty) {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.22);
}

.login-msg[data-type="error"]:not(:empty) {
  border-color: rgba(248, 113, 113, 0.25);
  background: rgba(248, 113, 113, 0.10);
  color: rgba(254, 202, 202, 0.95);
}

.login-msg[data-type="warn"]:not(:empty) {
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.12);
  color: rgba(254, 243, 199, 0.95);
}

.login-footer {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: -18px auto 0;
  padding: 0 24px 22px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-muted {
  color: rgba(226, 232, 240, 0.55);
  font-size: 0.85rem;
}

@media (max-width: 980px) {
  .login-shell {
    padding: 96px 18px 34px;
  }

  .login-stage {
    grid-template-columns: 1fr;
    width: min(560px, 100%);
  }

  .stage-left {
    display: none;
  }

  .stage-right {
    padding: 34px 22px 28px;
  }

  .login-footer {
    margin-top: 0;
  }
}

@media (max-width: 520px) {
  .login-shell {
    padding: 92px 14px 28px;
  }

  .stage-right {
    padding: 30px 18px 24px;
  }

  .stage-mark img {
    height: 30px;
  }

  .captcha-img {
    width: min(100%, 320px);
  }
}
