/* ==========================================================================
   Futu Signals — Light-Mode Futuristic Quant Terminal Theme
   ========================================================================== */
:root {
  /* Light Ice-Silver Tech Palette (Airy Luminous Glass) */
  --bg: #f1f5fb;
  --bg-subtle: rgba(226, 236, 248, 0.65);
  --panel: rgba(255, 255, 255, 0.78);
  --panel-soft: rgba(255, 255, 255, 0.54);
  --panel-solid: #ffffff;
  --surface: rgba(238, 244, 252, 0.62);
  --surface-hover: rgba(230, 240, 252, 0.92);
  --line: rgba(15, 23, 42, 0.065);
  --line-strong: rgba(15, 23, 42, 0.13);
  --line2: rgba(15, 23, 42, 0.045);

  /* Typography */
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --font-sans: "Inter", -apple-system, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", "PingFang SC", "Microsoft JhengHei", sans-serif;
  --font-display: "Space Grotesk", "Inter", "Noto Sans TC", "PingFang TC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Electric Tech Accents */
  --accent: #0284c7;
  --accent-2: #2563eb;
  --accent-cyan: #06b6d4;
  --accent-bg: rgba(14, 165, 233, 0.10);
  --accent-border: rgba(14, 165, 233, 0.32);
  --accent-glow: 0 0 0 3px rgba(14, 165, 233, 0.16);
  --grad-tech: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --grad-laser: linear-gradient(90deg, #06b6d4 0%, #0284c7 50%, #4f46e5 100%);

  /* Financial Semantics (High-Contrast Luminous Light) */
  --up: #059669;
  --up-bg: rgba(16, 185, 129, 0.11);
  --up-border: rgba(16, 185, 129, 0.28);
  --down: #e11d48;
  --down-bg: rgba(244, 63, 94, 0.09);
  --down-border: rgba(244, 63, 94, 0.25);
  --try: #b45309;
  --try-bg: rgba(245, 158, 11, 0.13);
  --try-border: rgba(245, 158, 11, 0.30);

  /* Elevation & Radius */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.03), 0 1px 3px rgba(15, 23, 42, 0.02);
  --shadow-panel: 0 10px 34px -12px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.025), inset 0 1px 0 rgba(255, 255, 255, 0.94);
  --shadow-hover: 0 14px 36px -10px rgba(2, 132, 199, 0.13), 0 2px 6px rgba(15, 23, 42, 0.035);
  --radius-sm: 10px;
  --radius: 18px;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 14px/1.55 var(--font-sans);
  /* Pure Apple / Linear minimalist luminous glass base */
  background-color: #f6f9fe;
  background-image:
    radial-gradient(ellipse 65% 50% at 12% -8%, rgba(56, 189, 248, 0.18), transparent 62%),
    radial-gradient(ellipse 55% 45% at 88% -6%, rgba(129, 140, 248, 0.16), transparent 60%),
    radial-gradient(ellipse 60% 50% at 78% 105%, rgba(45, 212, 191, 0.11), transparent 62%),
    radial-gradient(ellipse 50% 45% at 8% 92%, rgba(96, 165, 250, 0.10), transparent 60%);
  background-attachment: fixed;
}

/* ==========================================================================
   Dynamic Ambient Background (Drifting Aurora Orbs + Flowing Trend Waves)
   ========================================================================== */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(56px);
  will-change: transform, opacity;
}

.bg-orb.o1 {
  width: 42vw;
  height: 42vw;
  max-width: 640px;
  max-height: 640px;
  top: -12%;
  left: -6%;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.13) 0%, rgba(56, 189, 248, 0.04) 50%, transparent 72%);
  animation: orb-float-1 22s ease-in-out infinite alternate;
}

.bg-orb.o2 {
  width: 38vw;
  height: 38vw;
  max-width: 580px;
  max-height: 580px;
  top: 4%;
  right: -8%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.11) 0%, rgba(129, 140, 248, 0.04) 50%, transparent 72%);
  animation: orb-float-2 27s ease-in-out infinite alternate;
}

.bg-orb.o3 {
  width: 36vw;
  height: 36vw;
  max-width: 540px;
  max-height: 540px;
  bottom: -14%;
  left: 32%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.10) 0%, rgba(45, 212, 191, 0.03) 50%, transparent 72%);
  animation: orb-float-3 32s ease-in-out infinite alternate;
}

@keyframes orb-float-1 {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.85; }
  50%  { transform: translate3d(6vw, 4vh, 0) scale(1.06); opacity: 1; }
  100% { transform: translate3d(3vw, 8vh, 0) scale(0.98); opacity: 0.85; }
}

@keyframes orb-float-2 {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.85; }
  50%  { transform: translate3d(-6vw, 5vh, 0) scale(1.05); opacity: 1; }
  100% { transform: translate3d(-3vw, -3vh, 0) scale(0.97); opacity: 0.82; }
}

@keyframes orb-float-3 {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.82; }
  50%  { transform: translate3d(-5vw, -5vh, 0) scale(1.07); opacity: 1; }
  100% { transform: translate3d(5vw, -2vh, 0) scale(0.97); opacity: 0.84; }
}

/* Organic softly-undulating water canvas */
.bg-water {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  filter: blur(4px);
  transform: scale(1.02);
}

/* Top luminous tech hairline with gentle flowing shimmer */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #06b6d4 0%, #0284c7 25%, #4f46e5 50%, #0284c7 75%, #06b6d4 100%);
  background-size: 200% 100%;
  animation: laser-flow 7s linear infinite;
  z-index: 50;
  pointer-events: none;
}

@keyframes laser-flow {
  from { background-position: 0% 0%; }
  to   { background-position: 200% 0%; }
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--accent-2); }

/* Custom sleek scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.38); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.55); }

/* ==========================================================================
   Header & Glassmorphic Command Bar
   ========================================================================== */
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 32px;
  height: 60px;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 24px -10px rgba(15, 23, 42, 0.05);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.015em;
  flex-shrink: 0;
}
.brand:hover { color: var(--text); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--grad-tech);
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}

nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

nav a {
  position: relative;
  color: var(--muted);
  padding: 0 13px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  font-size: 13.5px;
  transition: color .18s ease, background .18s ease;
}

nav a:hover {
  color: var(--text);
  background: var(--surface);
}

nav a.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

.header-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-status .pill {
  height: 24px;
  padding: 0 10px;
}

main {
  position: relative;
  z-index: 1;
  padding: 26px 32px 56px;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
}

/* ==========================================================================
   Typography & Utilities
   ========================================================================== */
h1 {
  margin: 0 0 3px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 .name { font-family: var(--font-sans); font-weight: 500; font-size: 17px; }
.bt-head-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bt-target {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}
.bt-target-name {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
}
h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.head-actions {
  gap: 8px;
  align-items: center;
}
.head-actions > #wlAction,
.head-actions .wl-grp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.head-actions > select,
.head-actions > button,
.head-actions > .btn,
.head-actions > .scr-nav,
.head-actions > .sig-dd > .sig-dd-btn,
.head-actions > #wlAction button,
.head-actions > #wlAction .pill,
.head-actions > #wlAction .strat-sel,
.head-actions .head-go > input,
.head-actions .head-go > button,
.head-actions .head-group > input,
.head-actions .head-group > select,
.head-actions .head-group > button {
  height: 34px !important;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.head-actions .pill {
  padding: 0 11px;
  font-family: var(--font-sans);
  font-weight: 600;
}
.head-actions .strat-sel {
  padding: 0 28px 0 10px;
  line-height: 32px;
  background-position: right 8px center;
  background-size: 13px 13px;
}
.head-actions #gosel {
  background-color: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
  max-width: 260px;
}
.head-actions .head-go,
.head-actions .head-group {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
}
.head-actions .head-go > input,
.head-actions .head-group > input,
.head-actions .head-group > select {
  background-color: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
  border-radius: 0;
  border-right: 0;
}
.head-actions .head-go > :first-child,
.head-actions .head-group > :first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.head-actions .head-go > :last-child,
.head-actions .head-group > :last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.head-actions .head-go > input:focus,
.head-actions .head-group > input:focus,
.head-actions .head-group > select:focus {
  position: relative;
  z-index: 1;
}
.head-actions #gocode {
  width: 110px;
}
.head-actions #code {
  width: 210px;
}
.head-actions > button,
.head-actions > .btn,
.head-actions > .sig-dd > .sig-dd-btn,
.head-actions > #wlAction button,
.head-actions .head-go > button,
.head-actions .head-group > button,
.sub-actions > button,
.sub-actions > .btn {
  height: 34px !important;
  font-size: 13px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.sub-actions {
  gap: 8px;
  align-items: center;
}
.chart-tb .seg {
  height: 32px;
  align-items: center;
  padding: 2px;
  border-radius: var(--radius-sm);
}
.chart-tb .seg button {
  height: 26px;
  padding: 1px 10px 0;
  font-size: 12px;
  border-radius: 6px;
}
.chart-tb .small-btn,
.chart-tb .pill {
  height: 32px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.chart-tb .pill {
  padding: 0 10px;
  font-family: var(--font-sans);
  font-weight: 600;
}
.head-actions .scr-nav {
  padding: 0 6px;
}
.head-actions .scr-nav .small-btn {
  height: 26px !important;
  font-size: 12px;
  padding: 0 8px;
}

.big {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.chg {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.small { font-size: 12px; font-weight: 400; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.c { text-align: center !important; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.nowrap { white-space: nowrap; }

.loading {
  color: var(--muted);
  padding: 44px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Frosted Glass Panels
   ========================================================================== */
.panel {
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-panel);
  transition: border-color .2s ease, box-shadow .2s ease;
}

/* Lighter secondary surface for filter bars & compact tool strips (creates clear visual hierarchy vs main data panels) */
form.panel:not(.bt-form),
.panel.plate-panel {
  background: var(--panel-soft);
  box-shadow: none;
}

details.panel summary {
  cursor: pointer;
  color: var(--text-2);
  font-weight: 600;
  user-select: none;
}
details.panel[open] summary { margin-bottom: 14px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.3;
}
.toolbar h2 .sep {
  color: var(--muted);
  font-weight: 500;
}
.toolbar h2 .pill {
  margin-left: 4px;
}

/* ==========================================================================
   Telemetry Pills, Signal Badges & Tags
   ========================================================================== */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.25;
  vertical-align: middle;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

.pill.ok {
  background: var(--up-bg);
  border-color: var(--up-border);
  color: var(--up);
}
.pill.bad {
  background: var(--down-bg);
  border-color: var(--down-border);
  color: var(--down);
}

/* Live pulsing telemetry dot on header OpenD status */
header #opend.ok::before,
header #opend.bad::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
header #opend.ok::before {
  background: var(--up);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
  animation: pulse-ok 2.4s ease-in-out infinite;
}
header #opend.bad::before {
  background: var(--down);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.22);
}

@keyframes pulse-ok {
  0%, 100% { box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.24); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.08); }
}

.pill.quota {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}
.pill.quota.low {
  background: var(--try-bg);
  border-color: var(--try-border);
  color: var(--try);
}
.pill.hold {
  background: rgba(79, 70, 229, 0.10);
  border-color: rgba(79, 70, 229, 0.28);
  color: #4338ca;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 2px 7px;
}
.pill.ft {
  background: rgba(8, 145, 178, 0.10);
  border-color: rgba(8, 145, 178, 0.30);
  color: #0e7490;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 2px 7px;
  text-decoration: none;
}
.pill.ft:hover {
  text-decoration: none;
  filter: brightness(0.95);
}
button.toggle-pill {
  font-size: 12.5px;
  padding: 0 12px;
}
button.toggle-pill.on {
  background: var(--down-bg);
  border-color: var(--down-border);
  color: var(--down);
}
button.toggle-pill.on-ok {
  background: var(--up-bg);
  border-color: var(--up-border);
  color: var(--up);
}
button.small-btn, .sig-dd-btn.small-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}
.btn.ghost-btn {
  background: rgba(255, 255, 255, 0.88);
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn.ghost-btn:hover {
  color: var(--accent);
  background: #ffffff;
  border-color: var(--accent-border);
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.14);
  filter: none;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.scr-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: 12px;
}
.ghost-lnk {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  padding: 2px 6px;
  border-radius: 6px;
}
.ghost-lnk:hover { background: rgba(255, 255, 255, 0.8); color: var(--accent); }
.strat-sel {
  height: 26px !important;
  line-height: 24px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 0 22px 0 10px;
  text-align: center;
  text-align-last: center;
  border-radius: 999px;
  background-position: right 6px center;
  background-size: 12px 12px;
  color: var(--muted);
  border-color: var(--line);
}
.strat-sel option {
  text-align: left;
}
.strat-sel.jlaw { background-color: rgba(79, 70, 229, 0.10); border-color: rgba(79, 70, 229, 0.28); color: #4338ca; }
.strat-sel.cup { background-color: rgba(8, 145, 178, 0.10); border-color: rgba(8, 145, 178, 0.30); color: #0e7490; }
.strat-sel.lei { background-color: rgba(217, 119, 6, 0.11); border-color: rgba(217, 119, 6, 0.30); color: #b45309; }
.strat-sel.combo { background-color: var(--up-bg); border-color: var(--up-border); color: var(--up); }
.strat-sel.down { background-color: var(--down-bg); border-color: var(--down-border); color: var(--down); }

.scr-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 220px;
}
.scr-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.10);
  color: var(--muted);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.scr-tag:hover {
  text-decoration: none;
  transform: translateY(-1px);
  filter: brightness(0.95);
}
.scr-tag.jlaw { background-color: rgba(79, 70, 229, 0.10); border-color: rgba(79, 70, 229, 0.28); color: #4338ca; }
.scr-tag.cup { background-color: rgba(8, 145, 178, 0.10); border-color: rgba(8, 145, 178, 0.30); color: #0e7490; }
.scr-tag.lei { background-color: rgba(217, 119, 6, 0.11); border-color: rgba(217, 119, 6, 0.30); color: #b45309; }
.scr-tag.combo { background-color: var(--up-bg); border-color: var(--up-border); color: var(--up); }
.scr-tag.down { background-color: var(--down-bg); border-color: var(--down-border); color: var(--down); }

.dash-preset-sel {
  height: 32px !important;
  font-size: 12px;
  font-weight: 600;
  padding: 0 26px 0 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.dash-preset-sel.active {
  color: var(--accent);
  border-color: var(--accent);
}

tr.mkt-sep td {
  background: rgba(148, 163, 184, 0.06);
  padding: 8px 11px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}
tr.mkt-sep:first-child td { border-top: none; }
.mkt-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--text);
  vertical-align: middle;
}
.mkt-tag::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: #64748b;
  flex-shrink: 0;
}
tr.mkt-sep td .small {
  display: inline-block;
  line-height: 1.2;
  vertical-align: middle;
}
.mode-seg button { display: inline-flex; align-items: center; gap: 2px; }
.mode-seg button .dot { width: 7px; height: 7px; margin-right: 4px; opacity: .55; }
.mode-seg button.on {
  color: var(--mc, var(--accent));
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.10), inset 0 0 0 1px color-mix(in srgb, var(--mc, var(--accent)) 28%, transparent);
}
.mode-seg button.on .dot { opacity: 1; }
.chart-tb .sig-dd-menu { left: 0; right: auto; }
.rg-block.dim-group { opacity: .62; }
.pill[hidden] { display: none; }

.sig {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid transparent;
}
.sig.buy {
  background: var(--up-bg);
  border-color: var(--up-border);
  color: var(--up);
}
.sig.sell {
  background: var(--down-bg);
  border-color: var(--down-border);
  color: var(--down);
}
.sig.try {
  background: var(--try-bg);
  border-color: var(--try-border);
  color: var(--try);
}
.sig.none { color: #cbd5e1; }

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.buy { background: var(--up-bg); border-color: var(--up-border); color: var(--up); }
.tag.sell { background: var(--down-bg); border-color: var(--down-border); color: var(--down); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

/* ==========================================================================
   Precision Data Tables
   ========================================================================== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.tbl th, .tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line2);
  text-align: right;
  white-space: nowrap;
}

.tbl tbody tr:last-child td {
  border-bottom: none;
}

.tbl td:not(.l):not(.c) {
  font-family: var(--font-mono);
  font-size: 13px;
}

.tbl th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  background: #f4f8fd;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}
.tbl thead th:first-child { border-top-left-radius: 10px; }
.tbl thead th:last-child { border-top-right-radius: 10px; }

.tbl td.l, .tbl th.l { text-align: left; }
.tbl tbody tr { transition: background .12s ease; }
.tbl tbody tr:hover { background: rgba(14, 165, 233, 0.055); }
.tbl tr.click { cursor: pointer; }
.tbl tr.sel {
  background: rgba(14, 165, 233, 0.10) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}
.tbl tr.open { background: rgba(245, 158, 11, 0.06); }

.tbl-wrap {
  max-height: 580px;
  overflow: auto;
  border: none;
  border-radius: 12px;
  background: transparent;
}

.stock-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
  line-height: 1.3;
}
.stock-cell .drag {
  margin-right: 2px;
  line-height: 1;
}
.stock-cell > b {
  line-height: 1.3;
}

.sname {
  display: inline-block;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  line-height: 1.3;
}

.drag {
  display: inline-block;
  color: #cbd5e1;
  cursor: grab;
  margin-right: 8px;
  user-select: none;
  letter-spacing: -2px;
  font-weight: 700;
  transition: color .15s;
}
.tbl tbody tr:hover .drag { color: var(--accent); }
tr.dragging { opacity: .45; }
tr.drag-above td { box-shadow: inset 0 2px 0 var(--accent); }
tr.drag-below td { box-shadow: inset 0 -2px 0 var(--accent); }

.hl-up { background: var(--up-bg); }
.hl-down { background: var(--down-bg); }
.lnk { font-size: 12.5px; font-weight: 500; margin-left: 8px; }

.scr-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-family: var(--font-sans);
}
.scr-actions .scr-act-div,
.scr-actions .scr-act-check,
.scr-actions .scr-act-wl,
.scr-actions .scr-act-ft {
  height: 24px;
  line-height: 1;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  justify-content: center;
  box-sizing: border-box;
}
.scr-actions .scr-act-check {
  min-width: 40px;
  padding: 0 7px;
}
.scr-actions .scr-act-wl {
  width: 78px;
  padding: 0 6px;
}
.scr-actions .scr-act-ft {
  width: 64px;
  padding: 0 6px;
  text-decoration: none;
}
.ft-stop-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.ft-stop-inline input {
  width: 64px;
  height: 30px;
  padding: 0 8px;
}
.ft-auto-rules {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.ft-auto-rules button.toggle-pill.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  line-height: 1;
  padding: 0 10px;
}
.ft-auto-rules button .dot {
  margin-right: 0;
  vertical-align: 0;
  flex-shrink: 0;
}
.scr-actions .lnk {
  margin-left: 3px;
}
/* Compact spacing for wide 16+ column Screener table to avoid desktop horizontal overflow */
#scrBox .tbl th,
#scrBox .tbl td {
  padding: 9px 7px;
}
#scrBox .tbl th {
  font-size: 11px;
}
#scrBox .tbl td:not(.l):not(.c) {
  font-size: 12.5px;
}
#scrBox .sname {
  max-width: 132px;
}
.scr-mtf-pills:empty {
  display: none;
}
#scrBox .scr-actions {
  gap: 4px;
}
#scrBox .scr-actions .scr-act-check {
  min-width: 36px;
  padding: 0 6px;
}
#scrBox .scr-actions .scr-act-wl {
  width: 72px;
}
#scrBox .scr-actions .scr-act-ft {
  width: 58px;
}
#scrBox .tbl .sig {
  min-width: 38px;
  padding: 3px 7px;
  font-size: 11px;
}
.tbl tr.has-other-buy td {
  border-bottom: 0;
  background: rgba(16, 185, 129, 0.032);
}
#scrBox .tbl tr.has-other-buy td {
  padding-bottom: 5px;
}
.tbl tr.has-other-buy td:first-child,
.tbl tr.scr-other-buy td:first-child {
  box-shadow: inset 3px 0 0 rgba(16, 185, 129, 0.72);
}
.tbl tr.scr-other-buy td {
  padding: 2px 10px 8px 14px;
  background: rgba(16, 185, 129, 0.032);
  border-top: 0;
  vertical-align: middle;
}
#scrBox .tbl tr.scr-other-buy td {
  padding: 2px 7px 8px 14px;
}
.tbl tr.has-other-buy:hover td,
.tbl tr.has-other-buy:hover + tr.scr-other-buy td,
.tbl tr.has-other-buy:has(+ tr.scr-other-buy:hover) td,
.tbl tr.scr-other-buy:hover td {
  background: rgba(16, 185, 129, 0.068);
}
html[data-theme="dark"] .tbl tr.has-other-buy td,
html[data-theme="dark"] .tbl tr.scr-other-buy td {
  background: rgba(16, 185, 129, 0.065);
}
html[data-theme="dark"] .tbl tr.has-other-buy:hover td,
html[data-theme="dark"] .tbl tr.has-other-buy:hover + tr.scr-other-buy td,
html[data-theme="dark"] .tbl tr.has-other-buy:has(+ tr.scr-other-buy:hover) td,
html[data-theme="dark"] .tbl tr.scr-other-buy:hover td {
  background: rgba(16, 185, 129, 0.11);
}
.div-warn {
  color: #d97706;
  font-weight: 600;
}
#scrBox .scr-actions .scr-act-div {
  min-width: 58px;
  padding: 0 7px;
}
#scrBox .scr-actions .scr-act-div.on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(14, 165, 233, 0.09);
}
.tbl tr.div-detail-row:hover {
  background: transparent;
}
body.modal-open {
  overflow: hidden;
}
.div-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.div-modal {
  width: min(1080px, 92vw);
  height: 80vh;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  font-family: var(--font-sans);
}
.div-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.div-modal-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 16px;
}
.div-modal-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  justify-content: center;
  font-size: 14px;
}
.div-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.div-drawer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  font-family: var(--font-sans);
}
.div-drawer-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-bottom: 16px;
  font-size: 13.5px;
  flex-shrink: 0;
}
.div-kpi {
  color: var(--muted);
}
.div-kpi b {
  color: var(--text);
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
.div-kpi b.up {
  color: var(--up);
}
.div-drawer-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(460px, 1.35fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .div-modal {
    height: 86vh;
  }
  .div-drawer-grid {
    grid-template-columns: 1fr;
  }
}
.div-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.div-card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
  flex-shrink: 0;
}
.div-ev-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.div-mini-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.div-mini-tbl th,
.div-mini-tbl td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.div-mini-tbl th.l,
.div-mini-tbl td.l {
  text-align: left;
}
.div-mini-tbl th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  border-bottom: 1px solid var(--line-strong);
}
.div-mini-tbl tbody tr:last-child td {
  border-bottom: 0;
}
.div-bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.div-bar-cell > span:first-child {
  min-width: 48px;
}
.div-bar {
  flex: 1;
  max-width: 110px;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  overflow: hidden;
  display: inline-block;
}
.div-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--up));
}
.div-chart-card {
  margin-bottom: 14px;
  flex-shrink: 0;
}
.div-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.div-legend {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}
.div-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.div-leg-sq {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}
.div-leg-sq.reg {
  background: #45b6c5;
}
.div-leg-sq.sp {
  background: #5ee5ee;
}
.div-leg-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #f59e0b;
  display: inline-block;
}
.div-svg {
  width: 100%;
  height: auto;
  max-height: 225px;
  display: block;
}
.div-bar-reg {
  fill: #45b6c5;
}
.div-bar-sp {
  fill: #5ee5ee;
}
.div-bar-lbl {
  fill: #0e9aa7;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.div-bar-lbl-sp {
  fill: #06b6d4;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.div-ax-l {
  fill: #0e9aa7;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.div-ax-r {
  fill: #d97706;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.div-ax-x {
  fill: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.div-sp-tag {
  display: inline-block;
  margin-left: 3px;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #0891b2;
  background: rgba(6, 182, 212, 0.14);
  vertical-align: middle;
}
.scr-ob-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-family: var(--font-sans);
}
.scr-ob-lbl {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--up);
  opacity: 0.88;
  margin-right: 2px;
}
.scr-other-buy .sig {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
}
.scr-other-buy .sig .dot {
  margin-right: 0;
  flex-shrink: 0;
}

/* ==========================================================================
   Forms, Inputs & Tech Buttons
   ========================================================================== */
input, select, button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  font: inherit;
  line-height: 1.2;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, transform .12s ease;
}

input:not([type="checkbox"]):not([type="radio"]),
select {
  height: 36px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px 14px;
}

input:hover:not(:disabled), select:hover:not(:disabled) {
  border-color: rgba(2, 132, 199, 0.45);
}

input:focus, select:focus {
  outline: none;
  background-color: #ffffff;
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}

input:disabled, select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  padding: 0;
}

button, .btn {
  background: var(--grad-tech);
  border: 1px solid rgba(2, 132, 199, 0.85);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  height: 36px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

button.small {
  height: auto;
}

button:hover:not(:disabled), .btn:hover {
  color: #fff;
  filter: brightness(1.06);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

button:active:not(:disabled), .btn:active {
  transform: translateY(0);
}

button.ghost {
  background: rgba(255, 255, 255, 0.88);
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

button.ghost:hover:not(:disabled) {
  color: var(--accent);
  background: #ffffff;
  border-color: var(--accent-border);
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.14);
  filter: none;
}

button:disabled {
  opacity: .5;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

label {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 600;
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

/* ==========================================================================
   KPI Telemetry Strips (Unified Borderless Layout)
   ========================================================================== */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpis:has(> .kpi) {
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 22px;
  gap: 16px 24px;
  box-shadow: var(--shadow-panel);
}

.kpi {
  position: relative;
  overflow: visible;
  background: transparent;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 2px 0;
  box-shadow: none;
  transition: color .18s ease;
}

.kpi::before {
  display: none;
}

.kpi:hover {
  transform: none;
  border-color: transparent;
  box-shadow: none;
}

.kpi .k {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.kpi .v {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 2px;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

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

/* Compact unified KPI strip on stock detail page — matches .panel.intel-panel */
.kpis.stock-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-panel);
}

.kpis.stock-kpis .kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  background: transparent;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  overflow: visible;
}

.kpis.stock-kpis .kpi::before {
  display: none;
}

.kpis.stock-kpis .kpi:hover {
  transform: none;
  box-shadow: none;
}

.kpis.stock-kpis .kpi .k {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.kpis.stock-kpis .kpi .v {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  line-height: 1.35;
}

.kpis.stock-kpis .kpi .v .sub-v {
  font-size: 13.5px;
}

.kpis.stock-kpis .kpi .s {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* ==========================================================================
   Charts & Floating HUD Legend
   ========================================================================== */
.chart {
  width: 100%;
  height: 460px;
  border-radius: 10px;
  overflow: hidden;
}
.chart.small { height: 150px; }
.chart-wrap {
  position: relative;
  border: 1px solid var(--line2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  overflow: hidden;
}
.chart-wrap + .chart-wrap { margin-top: 12px; }

.chart-legend {
  position: static;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 20px;
  background: rgba(246, 250, 255, 0.72);
  padding: 9px 14px;
  border-bottom: 1px solid var(--line2);
  font-variant-numeric: tabular-nums;
}
.chart-legend.small {
  padding: 5px 12px;
  font-size: 11.5px;
  line-height: 18px;
  height: 29px;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.chart-legend.small::-webkit-scrollbar { display: none; }

.lohlc {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
}

.lsigs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 23px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line2);
  font-family: var(--font-sans);
  line-height: 1;
}
.lsig { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-weight: 500; white-space: nowrap; }
.lsig .sig, .lsig-badge .sig { padding: 3px 6px; font-size: 11px; line-height: 1; min-width: 34px; }
.lsig .dot { margin-right: 0; }
.lsig.dim, .lsig-badge.dim { opacity: .68; }
.lsig.dim:hover, .lsig-badge.dim:hover { opacity: .95; }
.lsig-badge { display: inline-flex; align-items: center; flex-shrink: 0; }
.lsig-badge.gap { margin-left: 6px; }
.lsig-sep { display: inline-flex; align-items: center; flex-shrink: 0; padding-left: 10px; border-left: 1px solid var(--line2); color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.chart-legend.inline {
  position: static;
  background: none;
  border: 0;
  padding: 0;
  font-size: 12.5px;
  white-space: normal;
  overflow: visible;
}
.chart-legend .lg { margin-left: 8px; font-weight: 600; }
.chart-legend .lg-toggle {
  cursor: pointer;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 5px;
  transition: background 0.12s, opacity 0.12s;
  user-select: none;
}
.chart-legend .lg-toggle:hover { background: rgba(15, 23, 42, 0.07); }
.chart-legend .lg-off {
  color: var(--muted);
  font-weight: 500;
  opacity: 0.65;
  border: 1px dashed var(--line);
}
.chart-legend .lg-off:hover { opacity: 1; }
html[data-theme="dark"] .chart-legend .lg-toggle:hover { background: rgba(255, 255, 255, 0.09); }
.foot { font-size: 12px; margin-top: 10px; }
.tri { display: inline-block; vertical-align: -1px; margin-right: 3px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }

/* ==========================================================================
   Filter Chips & Recessed Segmented Controls
   ========================================================================== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip-grp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 999px;
}

.cg-lbl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-2);
  margin-right: 2px;
  white-space: nowrap;
}
.cg-lbl.up { background: var(--up-bg); color: var(--up); }
.cg-lbl.jlaw { background: rgba(79, 70, 229, 0.12); color: #4338ca; }
.cg-lbl.cup { background: rgba(8, 145, 178, 0.12); color: #0e7490; }
.cg-lbl.lei { background: rgba(217, 119, 6, 0.12); color: #b45309; }
.cg-lbl.down { background: var(--down-bg); color: var(--down); }

.chip {
  height: auto;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
  font-weight: 500;
  font-size: 12.5px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.chip:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--text);
  background: #fff;
  filter: none;
  transform: none;
  box-shadow: var(--shadow-sm);
}
.chip.on {
  color: var(--text);
  font-weight: 600;
  border-color: var(--rc);
  background: color-mix(in srgb, var(--rc) 10%, white);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--rc) 25%, transparent);
}
.chip:not(.on) .dot { opacity: .35; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: rgba(15, 23, 42, 0.055);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}
.seg button {
  height: auto;
  background: transparent;
  color: var(--muted);
  border: 0;
  box-shadow: none;
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 12.5px;
  line-height: 1;
  font-weight: 500;
}
.seg button:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
  filter: none;
  transform: none;
  box-shadow: none;
}
.seg button.on {
  background: #ffffff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

/* ==========================================================================
   Rule Signal Cards
   ========================================================================== */
.rule-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 22px;
  align-items: stretch;
  margin-bottom: 20px;
}

.rg-block {
  display: flex;
  flex-direction: column;
  flex: var(--rg-n, 1) 1 min(100%, calc(var(--rg-n, 1) * 300px));
  max-width: min(100%, calc(var(--rg-n, 1) * 460px));
  min-width: 0;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
  align-items: stretch;
  flex: 1;
}

.rule-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 15px 17px;
  font-size: 13px;
  min-width: 0;
  box-shadow: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
.rule-card:hover {
  transform: translateY(-1px);
  background: var(--surface-hover);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.rule-card.buy {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.09) 0%, var(--surface) 42%);
  border-color: var(--up-border);
}
.rule-card.sell {
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.08) 0%, var(--surface) 42%);
  border-color: var(--down-border);
}
.rule-card.try {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.09) 0%, var(--surface) 42%);
  border-color: var(--try-border);
}

.rc-head { display: flex; align-items: center; margin-bottom: 8px; }
.rc-idea { font-size: 12px; line-height: 1.55; margin-bottom: 10px; }
.rc-cond { display: flex; gap: 8px; align-items: flex-start; margin: 5px 0; }
.rc-cond:last-of-type { padding-bottom: 10px; }
.rc-cond .tag {
  margin-top: 2px;
  min-width: 34px;
  padding: 3px 6px;
  border-radius: 5px;
  border-color: transparent;
  text-align: center;
  flex-shrink: 0;
  white-space: nowrap;
}
.rc-cond ul { margin: 0; padding-left: 16px; color: var(--text-2); }
.rc-now {
  margin-top: auto;
  padding-top: 9px;
  border-top: 1px solid var(--line2);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-2);
}
.rc-note { font-size: 11px; margin-top: 5px; }

.rg-head {
  --rg-c: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--rg-c);
  margin: 0 0 10px;
  padding: 0 2px;
  line-height: 1.3;
}
.rg-head::before {
  content: "";
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--rg-c);
  flex-shrink: 0;
}
.rg-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
  opacity: 0.5;
}
.rg-head.up { --rg-c: var(--up); }
.rg-head.jlaw { --rg-c: #4338ca; }
.rg-head.cup { --rg-c: #0e7490; }
.rg-head.lei { --rg-c: #b45309; }
.rg-head.down { --rg-c: var(--down); }

.rule-sections.compact {
  gap: 14px 18px;
  align-items: flex-start;
}
.rule-sections.compact .rg-block {
  flex: var(--rg-n, 1) 1 min(100%, calc(var(--rg-n, 1) * 250px));
  max-width: min(100%, calc(var(--rg-n, 1) * 420px));
}
.rule-sections.compact .rg-head { cursor: pointer; user-select: none; transition: opacity .15s; }
.rule-sections.compact .rg-head:hover { opacity: 0.75; }
.rule-sections.compact .rule-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 8px;
  align-items: start;
}
.rule-sections.compact .rule-card { padding: 10px 12px; cursor: pointer; }
.rule-sections.compact .rule-card:not(.open) .rc-idea,
.rule-sections.compact .rule-card:not(.open) .rc-cond,
.rule-sections.compact .rule-card:not(.open) .rc-note { display: none; }
.rule-sections.compact .rule-card:not(.open) .rc-head { margin-bottom: 4px; }
.rule-sections.compact .rule-card:not(.open) .rc-now {
  margin-top: 4px;
  padding-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

/* ==========================================================================
   Backtest Layout & Sidebar Console
   ========================================================================== */
.bt-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}
.bt-main { min-width: 0; }

.bt-form {
  position: sticky;
  top: 82px;
  max-height: calc(100vh - 102px);
  max-height: calc(100dvh - 102px);
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.bt-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
}

.bt-foot {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(248, 251, 255, 0.92);
  display: flex;
  gap: 8px;
}
.bt-foot button.wide { margin-top: 0; flex: 1; }
.bt-foot #btReset { padding: 9px 12px; white-space: nowrap; }

.bt-form input:not([type=checkbox]):not([type=radio]),
.bt-form select {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.bt-form select {
  padding-right: 28px;
}

.fgroup {
  padding: 9px 0 11px;
  border-bottom: 1px solid var(--line2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fgroup:first-child { padding-top: 0; }
.fgroup:last-child { border-bottom: 0; padding-bottom: 4px; }

.ftitle {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 6px;
}

details.fgroup summary { cursor: pointer; list-style: none; user-select: none; }
details.fgroup summary::-webkit-details-marker { display: none; }
details.fgroup summary::before { content: '▸'; font-size: 10px; transition: transform .15s; display: inline-block; }
details.fgroup[open] summary::before { transform: rotate(90deg); }
details.fgroup .f2 { margin-top: 8px; }
details.fgroup label.inline { margin-top: 8px; }

.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.risk-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.risk-presets.inline { gap: 6px; }
.risk-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11.5px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all .14s;
}
.risk-btn:hover { border-color: var(--accent-border); color: var(--accent); }
.risk-btn.on {
  background: var(--accent-soft, rgba(14, 116, 144, 0.12));
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.risk-btn.rec::before {
  content: '★';
  font-size: 10px;
  color: #d97706;
}
.risk-val { font-family: var(--font-mono); font-size: 10.5px; opacity: 0.78; }
.risk-hint { margin-top: -2px; font-size: 11.5px; }
.risk-hint a { color: var(--accent); font-weight: 600; text-decoration: none; margin-left: 4px; }
.risk-hint a:hover { text-decoration: underline; }
.rp-groups { display: flex; flex-direction: column; gap: 8px; }
.rp-grp { display: flex; flex-direction: column; gap: 5px; }

.rp-grp-head {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-2);
  align-self: flex-start;
}
.rp-grp-head.up { background: var(--up-bg); color: var(--up); }
.rp-grp-head.jlaw { background: rgba(79, 70, 229, 0.12); color: #4338ca; }
.rp-grp-head.cup { background: rgba(8, 145, 178, 0.12); color: #0e7490; }
.rp-grp-head.lei { background: rgba(217, 119, 6, 0.12); color: #b45309; }
.rp-grp-head.down { background: var(--down-bg); color: var(--down); }

.rule-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rp {
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  min-width: 0;
  transition: border-color .15s, background .15s, box-shadow .15s, color .15s;
}
.rp:hover {
  border-color: var(--accent-border);
  background: var(--surface-hover);
  color: var(--text);
}
.rp span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp .dot { flex-shrink: 0; }
.rp input { display: none; }
.rp.on {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.2);
}

.bt-idea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
}

button.wide { width: 100%; margin-top: 8px; padding: 9px; }
#btres.busy { opacity: .45; pointer-events: none; transition: opacity .2s; }

.verdict {
  position: relative;
}
.verdict.good {
  border-color: var(--up-border);
  background: linear-gradient(105deg, rgba(16, 185, 129, 0.10) 0%, var(--panel) 48%);
}
.verdict.bad {
  border-color: var(--down-border);
  background: linear-gradient(105deg, rgba(244, 63, 94, 0.09) 0%, var(--panel) 48%);
}
.vtext { font-size: 17.5px; margin-top: 5px; line-height: 1.5; }

.bar { display: grid; grid-template-columns: 1fr 1fr 68px; align-items: center; gap: 0; }
.bar > div { height: 9px; display: flex; }
.bar-neg { justify-content: flex-end; border-right: 1px solid var(--line-strong); }
.bar-neg i {
  background: linear-gradient(270deg, var(--down), #fb7185);
  opacity: .85;
  height: 100%;
  border-radius: 3px 0 0 3px;
}
.bar-pos i {
  background: linear-gradient(90deg, var(--up), #34d399);
  opacity: .85;
  height: 100%;
  border-radius: 0 3px 3px 0;
}
.bar span {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
}

.th-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px 22px;
  font-size: 13px;
}
.th-grid div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding: 4px 0;
}
.th-grid div span:last-child { font-family: var(--font-mono); font-weight: 500; }

/* ==========================================================================
   Signal Multi-Select Dropdown (Watchlist)
   ========================================================================== */
.sig-dd {
  position: relative;
  display: inline-block;
}
.sig-dd-btn {
  padding-right: 12px;
  gap: 7px;
  font-size: 13px;
}
.sig-dd-btn .dd-cnt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
}
.sig-dd-btn .dd-caret {
  width: 13px;
  height: 13px;
  color: var(--muted);
  transition: transform .16s ease;
}
.sig-dd.open .sig-dd-btn {
  border-color: var(--accent);
  color: var(--accent);
  background: #ffffff;
  box-shadow: var(--accent-glow);
}
.sig-dd.open .dd-caret {
  transform: rotate(180deg);
  color: var(--accent);
}
.sig-dd-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 500px;
  max-width: calc(100vw - 24px);
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 14px 36px -8px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.06);
  display: none;
}
.sig-dd.open .sig-dd-menu { display: block; }
.sig-dd-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-bottom: 9px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--line2);
}
.sig-dd-acts button {
  height: auto;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 6px;
}
.sig-dd-grp {
  margin-bottom: 8px;
}
.sig-dd-grp:last-child { margin-bottom: 0; }
.sig-dd-gh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 9px;
  border-radius: 999px;
  --gh-c: var(--text-2);
  background: rgba(148, 163, 184, 0.16);
  color: var(--gh-c);
  margin-bottom: 5px;
  cursor: pointer;
  user-select: none;
  border: 0;
  height: auto;
  box-shadow: none;
}
button.sig-dd-gh:hover:not(:disabled) {
  color: var(--gh-c);
  filter: brightness(0.94);
  transform: none;
  box-shadow: none;
}
.sig-dd-gh.up { background: var(--up-bg); --gh-c: var(--up); }
.sig-dd-gh.jlaw { background: rgba(79, 70, 229, 0.12); --gh-c: #4338ca; }
.sig-dd-gh.cup { background: rgba(8, 145, 178, 0.12); --gh-c: #0e7490; }
.sig-dd-gh.lei { background: rgba(217, 119, 6, 0.12); --gh-c: #b45309; }
.sig-dd-gh.down { background: var(--down-bg); --gh-c: var(--down); }
.sig-dd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 4px;
}
.sig-dd-item {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  user-select: none;
  transition: background .12s, border-color .12s;
}
.sig-dd-item:hover {
  background: var(--surface);
  border-color: var(--line);
}
.sig-dd-item input {
  margin: 0;
  flex-shrink: 0;
}
.sig-dd-item .dot {
  margin-right: 0;
  flex-shrink: 0;
}
.sig-dd-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.err {
  background: rgba(254, 242, 242, 0.95);
  border: 1px solid var(--down-border);
  border-left: 4px solid var(--down);
  color: #9f1239;
  padding: 11px 15px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-weight: 500;
}

@media (max-width: 900px) {
  .bt-layout { grid-template-columns: 1fr; }
  .bt-form { position: static; max-height: none; overflow: visible; }
  .bt-body { overflow: visible; }
  header { gap: 10px; padding: 0 12px; height: 54px; }
  .brand-tag { display: none; }
  main { padding: 14px 12px 32px; }
  .chart { height: 340px; }
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  padding: 0 0 24px;
}
footer a { color: var(--muted); text-decoration: underline; }

/* ==========================================================================
   Theme Toggle Button
   ========================================================================== */
.theme-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 48px;
  height: 24px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.85);
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.theme-btn:hover:not(:disabled) {
  background: rgba(226, 232, 240, 0.98);
  border-color: var(--accent-border);
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.16);
  filter: none;
  transform: none;
}
.theme-btn .theme-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 21px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1), background .18s ease, box-shadow .18s ease;
  pointer-events: none;
}
.theme-btn .theme-opt {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 18px;
  transition: color .18s ease, opacity .18s ease;
}
.theme-btn .theme-opt.sun { color: #d97706; opacity: 1; }
.theme-btn .theme-opt.moon { color: #64748b; opacity: 0.65; }
html[data-theme="dark"] .theme-btn .theme-thumb {
  transform: translateX(21px);
  background: #2a4470;
  box-shadow: 0 1px 4px rgba(4, 10, 24, 0.45), inset 0 0 0 1px rgba(125, 211, 252, 0.22);
}
html[data-theme="dark"] .theme-btn .theme-opt.sun { color: #94a3b8; opacity: 0.55; }
html[data-theme="dark"] .theme-btn .theme-opt.moon { color: #fcd34d; opacity: 1; }

/* ==========================================================================
   Deep-Blue Dark Mode Theme (Soft Slate-Navy Quant Terminal)
   ========================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;

  /* Soft Deep Slate-Blue Palette (Airy Luminous Glass) */
  --bg: #132038;
  --bg-subtle: rgba(24, 39, 66, 0.72);
  --panel: rgba(23, 38, 66, 0.74);
  --panel-soft: rgba(23, 38, 66, 0.48);
  --panel-solid: #1a2c4b;
  --surface: rgba(33, 54, 90, 0.48);
  --surface-hover: rgba(42, 68, 112, 0.72);
  --line: rgba(147, 197, 253, 0.09);
  --line-strong: rgba(147, 197, 253, 0.20);
  --line2: rgba(147, 197, 253, 0.065);

  /* Typography (Soft eye-friendly cool slate-blue, low glare) */
  --text: #a9b8cf;
  --text-2: #8c9fba;
  --muted: #6c809e;

  /* Electric Blue & Cyan Accents */
  --accent: #38bdf8;
  --accent-2: #60a5fa;
  --accent-cyan: #22d3ee;
  --accent-bg: rgba(56, 189, 248, 0.15);
  --accent-border: rgba(56, 189, 248, 0.36);
  --accent-glow: 0 0 0 3px rgba(56, 189, 248, 0.22);
  --grad-tech: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --grad-laser: linear-gradient(90deg, #22d3ee 0%, #38bdf8 50%, #6366f1 100%);

  /* Financial Semantics (Balanced Luminous Dark) */
  --up: #52c197;
  --up-bg: rgba(45, 168, 124, 0.13);
  --up-border: rgba(82, 193, 151, 0.26);
  --down: #fb7185;
  --down-bg: rgba(244, 63, 94, 0.16);
  --down-border: rgba(251, 113, 133, 0.34);
  --try: #d4b06a;
  --try-bg: rgba(212, 176, 106, 0.12);
  --try-border: rgba(212, 176, 106, 0.25);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(6, 12, 26, 0.28), 0 1px 3px rgba(6, 12, 26, 0.18);
  --shadow-panel: 0 14px 36px -14px rgba(4, 10, 24, 0.55), 0 1px 3px rgba(4, 10, 24, 0.28), inset 0 1px 0 rgba(191, 219, 254, 0.08);
  --shadow-hover: 0 14px 34px -10px rgba(14, 165, 233, 0.22), 0 4px 12px rgba(6, 12, 26, 0.42);
}

html[data-theme="dark"] body {
  background-color: #111d33;
  background-image:
    radial-gradient(ellipse 65% 50% at 12% -8%, rgba(37, 99, 235, 0.26), transparent 62%),
    radial-gradient(ellipse 55% 45% at 88% -6%, rgba(14, 165, 233, 0.20), transparent 60%),
    radial-gradient(ellipse 60% 50% at 78% 105%, rgba(59, 130, 246, 0.18), transparent 62%),
    radial-gradient(ellipse 50% 45% at 8% 92%, rgba(6, 182, 212, 0.13), transparent 60%);
}

html[data-theme="dark"] .bg-orb.o1 {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.16) 0%, rgba(37, 99, 235, 0.05) 50%, transparent 72%);
}
html[data-theme="dark"] .bg-orb.o2 {
  background: radial-gradient(circle, rgba(14, 165, 233, 0.14) 0%, rgba(56, 189, 248, 0.04) 50%, transparent 72%);
}
html[data-theme="dark"] .bg-orb.o3 {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(6, 182, 212, 0.04) 50%, transparent 72%);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(147, 197, 253, 0.26);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(147, 197, 253, 0.44);
}

/* Header & Theme Toggle */
html[data-theme="dark"] header {
  background: rgba(17, 29, 51, 0.72);
  box-shadow: 0 4px 24px -10px rgba(4, 10, 24, 0.42);
}

html[data-theme="dark"] .theme-btn {
  background: rgba(24, 39, 66, 0.92);
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 2px rgba(4, 10, 24, 0.45);
}
html[data-theme="dark"] .theme-btn:hover:not(:disabled) {
  background: rgba(33, 54, 90, 0.95);
  border-color: var(--accent-border);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.22);
}

/* Pills, Badges & Strategy Accents */
html[data-theme="dark"] .pill {
  background: rgba(33, 54, 90, 0.86);
}
html[data-theme="dark"] .pill.hold {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.40);
  color: #9fb0e8;
}
html[data-theme="dark"] .pill.ft {
  background: rgba(56, 163, 185, 0.14);
  border-color: rgba(123, 196, 212, 0.28);
  color: #7bc4d4;
}
html[data-theme="dark"] .strat-sel.jlaw {
  background-color: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.40);
  color: #9fb0e8;
}
html[data-theme="dark"] .strat-sel.cup {
  background-color: rgba(56, 163, 185, 0.14);
  border-color: rgba(123, 196, 212, 0.28);
  color: #7bc4d4;
}
html[data-theme="dark"] .strat-sel.lei {
  background-color: rgba(212, 176, 106, 0.12);
  border-color: rgba(212, 176, 106, 0.25);
  color: #d4b06a;
}
html[data-theme="dark"] .scr-tag.jlaw {
  background-color: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.40);
  color: #9fb0e8;
}
html[data-theme="dark"] .scr-tag.cup {
  background-color: rgba(56, 163, 185, 0.14);
  border-color: rgba(123, 196, 212, 0.28);
  color: #7bc4d4;
}
html[data-theme="dark"] .scr-tag.lei {
  background-color: rgba(212, 176, 106, 0.12);
  border-color: rgba(212, 176, 106, 0.25);
  color: #d4b06a;
}
html[data-theme="dark"] .scr-tag:hover {
  filter: brightness(1.15);
}
html[data-theme="dark"] tr.mkt-sep td {
  background: rgba(33, 54, 90, 0.32);
}
html[data-theme="dark"] .mkt-tag::before {
  background: #94a3b8;
}
html[data-theme="dark"] .sig.none { color: #546d91; }
html[data-theme="dark"] .tag {
  background: rgba(33, 54, 90, 0.88);
}
html[data-theme="dark"] .dot {
  box-shadow: 0 0 0 2px rgba(24, 39, 66, 0.90);
}

/* Buttons & Links */
html[data-theme="dark"] button:not(.ghost):not(.chip):not(.theme-btn):not(.sig-dd-gh):not(.toggle-pill),
html[data-theme="dark"] button:not(.ghost):not(.chip):not(.theme-btn):not(.sig-dd-gh):not(.toggle-pill):hover:not(:disabled),
html[data-theme="dark"] .btn:not(.ghost-btn),
html[data-theme="dark"] .btn:not(.ghost-btn):hover,
html[data-theme="dark"] .brand-mark {
  color: #c7d6eb;
}
html[data-theme="dark"] .btn.ghost-btn,
html[data-theme="dark"] button.ghost {
  background: rgba(33, 54, 90, 0.86);
  color: var(--text-2);
  border-color: var(--line-strong);
}
html[data-theme="dark"] .risk-btn {
  background: var(--surface);
  border-color: transparent;
  color: var(--text-2);
}
html[data-theme="dark"] .risk-btn.on {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}
html[data-theme="dark"] .btn.ghost-btn:hover,
html[data-theme="dark"] button.ghost:hover:not(:disabled) {
  color: var(--accent);
  background: #2a4470;
  border-color: var(--accent-border);
  box-shadow: 0 2px 12px rgba(56, 189, 248, 0.18);
}
html[data-theme="dark"] button.toggle-pill.on {
  background: var(--down-bg);
  border-color: var(--down-border);
  color: var(--down);
}
html[data-theme="dark"] button.toggle-pill.on-ok {
  background: var(--up-bg);
  border-color: var(--up-border);
  color: var(--up);
}
html[data-theme="dark"] input::placeholder {
  color: var(--muted);
  opacity: 0.78;
}
html[data-theme="dark"] .ghost-lnk:hover {
  background: rgba(42, 68, 112, 0.72);
}

/* Inputs & Selects */
html[data-theme="dark"] .head-actions #gosel,
html[data-theme="dark"] .head-actions .head-go > input,
html[data-theme="dark"] .head-actions .head-group > input,
html[data-theme="dark"] .head-actions .head-group > select {
  background-color: rgba(33, 54, 90, 0.90);
}
html[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239db2d1' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
html[data-theme="dark"] select option {
  background-color: #1a2c4b;
  color: var(--text);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus {
  background-color: #27406b;
}

/* Tables */
html[data-theme="dark"] .tbl th {
  background: #172642;
}
html[data-theme="dark"] .tbl tbody tr:hover {
  background: rgba(56, 189, 248, 0.09);
}
html[data-theme="dark"] .tbl tr.sel {
  background: rgba(56, 189, 248, 0.16) !important;
}
html[data-theme="dark"] .tbl tr.open {
  background: rgba(251, 191, 36, 0.10);
}
html[data-theme="dark"] .drag { color: #546d91; }

/* Charts & Legends */
html[data-theme="dark"] .chart-wrap {
  background: #15233d;
}
html[data-theme="dark"] .chart-legend {
  background: rgba(22, 36, 63, 0.94);
}

/* Chips, Groups & Segmented Controls */
html[data-theme="dark"] .chip-grp {
  background: var(--surface);
}
html[data-theme="dark"] .cg-lbl,
html[data-theme="dark"] .rp-grp-head,
html[data-theme="dark"] .sig-dd-gh {
  background: rgba(147, 197, 253, 0.13);
}
html[data-theme="dark"] .cg-lbl.up,
html[data-theme="dark"] .rp-grp-head.up,
html[data-theme="dark"] .sig-dd-gh.up {
  background: var(--up-bg);
  color: var(--up);
}
html[data-theme="dark"] .cg-lbl.down,
html[data-theme="dark"] .rp-grp-head.down,
html[data-theme="dark"] .sig-dd-gh.down {
  background: var(--down-bg);
  color: var(--down);
}
html[data-theme="dark"] .cg-lbl.jlaw,
html[data-theme="dark"] .rp-grp-head.jlaw,
html[data-theme="dark"] .sig-dd-gh.jlaw {
  background: rgba(99, 102, 241, 0.22);
  color: #9fb0e8;
}
html[data-theme="dark"] .cg-lbl.cup,
html[data-theme="dark"] .rp-grp-head.cup,
html[data-theme="dark"] .sig-dd-gh.cup {
  background: rgba(56, 163, 185, 0.15);
  color: #7bc4d4;
}
html[data-theme="dark"] .cg-lbl.lei,
html[data-theme="dark"] .rp-grp-head.lei,
html[data-theme="dark"] .sig-dd-gh.lei {
  background: rgba(212, 176, 106, 0.13);
  color: #d4b06a;
}
html[data-theme="dark"] button.sig-dd-gh:hover:not(:disabled) {
  filter: brightness(1.12);
}
html[data-theme="dark"] .chip {
  background: rgba(33, 54, 90, 0.84);
  color: var(--text-2);
}
html[data-theme="dark"] .chip:hover:not(:disabled) {
  background: #2a4470;
  color: var(--text);
}
html[data-theme="dark"] .chip.on {
  color: var(--text);
  background: color-mix(in srgb, var(--rc) 22%, #1d3154);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--rc) 40%, transparent);
}
html[data-theme="dark"] .seg {
  background: rgba(11, 20, 38, 0.56);
  border-color: rgba(147, 197, 253, 0.12);
  box-shadow: inset 0 1px 2px rgba(4, 10, 24, 0.35);
}
html[data-theme="dark"] .seg button {
  color: var(--muted);
}
html[data-theme="dark"] .seg button:hover:not(:disabled) {
  background: rgba(42, 68, 112, 0.58);
  color: var(--text);
}
html[data-theme="dark"] .seg button.on {
  background: #2a4470;
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(6, 12, 26, 0.36);
}
html[data-theme="dark"] .mode-seg button.on {
  color: var(--mc, var(--accent));
}

/* Rule Cards, Backtest Console & Verdicts */
html[data-theme="dark"] .rg-head { --rg-c: var(--text-2); }
html[data-theme="dark"] .rg-head.up { --rg-c: var(--up); }
html[data-theme="dark"] .rg-head.down { --rg-c: var(--down); }
html[data-theme="dark"] .rg-head.jlaw { --rg-c: #9fb0e8; }
html[data-theme="dark"] .rg-head.cup { --rg-c: #7bc4d4; }
html[data-theme="dark"] .rg-head.lei { --rg-c: #d4b06a; }
html[data-theme="dark"] .rule-card {
  background: var(--surface);
}
html[data-theme="dark"] .rule-card.buy {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.14) 0%, var(--surface) 44%);
  border-color: var(--up-border);
}
html[data-theme="dark"] .rule-card.sell {
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.14) 0%, var(--surface) 44%);
  border-color: var(--down-border);
}
html[data-theme="dark"] .rule-card.try {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14) 0%, var(--surface) 44%);
  border-color: var(--try-border);
}
html[data-theme="dark"] .bt-foot {
  background: rgba(21, 35, 61, 0.88);
}
html[data-theme="dark"] .rp {
  background: var(--surface);
}
html[data-theme="dark"] .rp.on {
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.30);
}
html[data-theme="dark"] .verdict.good {
  background: linear-gradient(105deg, rgba(16, 185, 129, 0.16) 0%, var(--panel) 48%);
}
html[data-theme="dark"] .verdict.bad {
  background: linear-gradient(105deg, rgba(244, 63, 94, 0.16) 0%, var(--panel) 48%);
}

/* Dropdown Menu & Error Banner */
html[data-theme="dark"] .sig-dd.open .sig-dd-btn {
  background: #27406b;
}
html[data-theme="dark"] .sig-dd-menu {
  background: rgba(25, 41, 70, 0.97);
  box-shadow: 0 16px 38px -8px rgba(6, 12, 26, 0.60), 0 2px 8px rgba(6, 12, 26, 0.36);
}
html[data-theme="dark"] .err {
  background: rgba(82, 22, 42, 0.88);
  color: #e69aa6;
}


/* ==========================================================================
   Popular Funds / Institutional Holdings Page
   ========================================================================== */
.ok-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--up-bg);
  border: 1px solid var(--up-border);
  color: var(--up);
  font-size: 13px;
  font-weight: 500;
}

.funds-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 1080px) {
  .funds-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .funds-grid { grid-template-columns: 1fr; }
}

.panel.fund-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 0;
  padding: 18px 20px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.panel.fund-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-border);
}

.panel.fund-card.active {
  border-color: var(--accent);
  box-shadow: var(--accent-glow), var(--shadow-hover);
}

.fund-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fund-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: contain;
  flex-shrink: 0;
  padding: 3px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.fund-avatar-txt {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

.fund-title-wrap {
  min-width: 0;
  flex: 1;
}

.fund-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fund-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.fund-mkt-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}

.fund-sec {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.fund-sec-lbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.fund-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.fund-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-family: var(--font-mono);
  transition: border-color 0.14s ease, background 0.14s ease;
}

.fund-chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}

.fund-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fund-open-lnk {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

.panel.fund-card:hover .fund-open-lnk {
  text-decoration: underline;
}

.fund-kpis,
.fund-kpis-skel {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

@media (max-width: 1120px) {
  .fund-kpis,
  .fund-kpis-skel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .fund-kpis,
  .fund-kpis-skel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.kpi.fund-kpi-click {
  cursor: pointer;
  padding: 8px 12px;
  margin: -8px -12px;
  border-radius: var(--radius-sm);
  transition: background 0.14s ease;
}

.kpi.fund-kpi-click:hover {
  transform: none;
  box-shadow: none;
  background: var(--surface);
}

.fund-tabs-bar {
  margin-bottom: 14px;
}

.fund-switcher-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.fund-switcher-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

button.fund-sw-pill {
  padding: 5px 11px;
  height: auto;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

button.fund-sw-pill:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent);
  transform: none;
}

button.fund-sw-pill.on {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.fund-subbar {
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.fund-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fund-sub-sec {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-stats-box {
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.fund-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px 9px;
}

.fund-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}

.fund-stat b {
  font-size: 13.5px;
  color: var(--text);
}

.fund-ratio-bar {
  display: flex;
  height: 3px;
  background: var(--line2);
}

.fund-ratio-bar i.buy {
  background: var(--up);
}

.fund-ratio-bar i.sell {
  background: var(--down);
  opacity: 0.72;
}

.fund-top-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fund-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 12.5px;
  transition: background 0.14s ease;
}

.fund-top-row:hover {
  background: var(--surface);
}

.fund-top-l {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.fund-top-l b {
  font-size: 12px;
  flex-shrink: 0;
}

.fund-top-nm {
  color: var(--text-2);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-top-r {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.fund-top-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.fund-top-pct {
  font-size: 11.5px;
  min-width: 38px;
  text-align: right;
}

.fund-top-bar {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--line2);
  overflow: hidden;
}

.fund-top-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.fund-chg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fund-chg-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-size: 11.5px;
  font-family: var(--font-mono);
  transition: border-color 0.14s ease, transform 0.12s ease;
}

.fund-chg-chip:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.fund-chg-chip.up {
  background: var(--up-bg);
  border-color: var(--up-border);
}

.fund-chg-chip.up span {
  color: var(--up);
  font-weight: 600;
}

.fund-chg-chip.down {
  background: var(--down-bg);
  border-color: var(--down-border);
}

.fund-chg-chip.down span {
  color: var(--down);
  font-weight: 600;
}

.fund-chip-nm {
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--text-2);
  max-width: 78px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-holders-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.fund-inst-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.fund-inst-pill:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent);
}

.fund-wt {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 64px;
}

.fund-wt-bar {
  width: 64px;
  height: 4px;
  border-radius: 999px;
  background: var(--line2);
  overflow: hidden;
}

.fund-wt-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.fund-sig-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.fund-row-acts {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.fund-detail-secs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.fund-sec-grid {
  align-items: start;
}

.fund-sec-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.fund-sec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fund-sec-row {
  cursor: pointer;
  padding: 11px 14px;
}

.fund-sec-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.fund-sec-title {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}

.fund-sec-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  min-width: 22px;
}

.fund-sec-flow {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line2);
}

.fund-sec-val {
  font-size: 13px;
  white-space: nowrap;
}

.fund-sec-bar {
  margin-top: 7px;
  height: 5px;
  border-radius: 999px;
  background: var(--line2);
  overflow: hidden;
}

.fund-sec-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--grad-tech);
}

.fund-sec-stocks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.fund-sec-stk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--panel);
  border: 1px solid var(--line2);
  color: var(--text);
  text-decoration: none;
  font-size: 11.5px;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.fund-sec-stk span {
  color: var(--text-2);
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-sec-stk:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}

.fund-ov-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fund-ov-card {
  padding: 12px 14px;
}

.fund-ov-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.fund-ov-lnk {
  color: var(--text);
  text-decoration: none;
}

.fund-ov-lnk:hover {
  color: var(--accent);
}

.fund-ov-sig {
  flex-shrink: 0;
}

/* ==========================================================================
   Futu REST Stock Intelligence Bar
   ========================================================================== */
.panel.intel-panel {
  padding: 12px 16px;
  margin-bottom: 18px;
  min-height: 150px;
  box-sizing: border-box;
}

.intel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 30px;
}

.intel-skel {
  display: inline-block;
  border-radius: 5px;
  background: var(--line2);
  animation: intel-pulse 1.4s ease-in-out infinite;
}
.intel-skel.lg { width: 92px; height: 18px; }
.intel-skel.sm { width: 132px; height: 13px; margin-top: 2px; }

@keyframes intel-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}

.intel-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.intel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line2);
}

.intel-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.intel-k {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.intel-v {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.intel-s {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.intel-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1.3;
}

.intel-badge.up {
  color: var(--up);
  background: rgba(5, 150, 105, 0.12);
  border: 1px solid rgba(5, 150, 105, 0.28);
}

.intel-badge.down {
  color: var(--down);
  background: rgba(225, 29, 72, 0.12);
  border: 1px solid rgba(225, 29, 72, 0.28);
}

.intel-badge.flat {
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}

.intel-badge.warn {
  color: #d97706;
  background: rgba(217, 119, 6, 0.14);
  border: 1px solid rgba(217, 119, 6, 0.35);
}

[data-theme="dark"] .intel-badge.warn {
  color: #d4b06a;
  background: rgba(212, 176, 106, 0.12);
  border-color: rgba(212, 176, 106, 0.26);
}

.intel-plates {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.intel-plate {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
}

.pill.warn {
  color: #b45309;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.38);
  font-weight: 600;
}

[data-theme="dark"] .pill.warn {
  color: #d4b06a;
  background: rgba(212, 176, 106, 0.12);
  border-color: rgba(212, 176, 106, 0.26);
}

[hidden] {
  display: none !important;
}

.page-head.stock-head {
  align-items: flex-start;
  gap: 14px 20px;
}

.stock-hero {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.stock-hero h1 {
  margin: 0;
  line-height: 1.2;
}

.stock-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.stock-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.meta-sep {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
  opacity: 0.7;
}

.snap-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--text);
  box-shadow: none;
}

.snap-tag .k {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.snap-kvs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.snap-kv {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12px;
}

.snap-kv .k {
  color: var(--muted);
  font-weight: 500;
}

.snap-kv b {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-2);
}

/* Hot Sector / Plate Rankings Panel */
.panel.plate-panel {
  padding: 12px 16px;
  margin-bottom: 16px;
}

.plate-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.plate-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: none;
  cursor: pointer;
}

button.plate-pill:hover:not(:disabled),
button.plate-pill.on {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
  transform: none;
  filter: none;
  box-shadow: none;
}

button.plate-pill:hover:not(:disabled) .plate-nm,
button.plate-pill.on .plate-nm {
  color: var(--accent);
}

.plate-drawer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line2);
}

.plate-drawer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.plate-drawer-head button {
  margin-left: auto;
}

.plate-stocks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.plate-stk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  transition: border-color .14s ease, background .14s ease;
}

.plate-stk:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}

.plate-stk .sname {
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Daily Records Table Enhancements
   ========================================================================== */
.tbl-tb {
  gap: 10px;
  flex-wrap: wrap;
}

.tbl-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 9px 14px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid transparent;
  font-size: 12.5px;
}

.tbl-summary .ts-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tbl-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ev-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 240px;
}

.ev-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: #f1f5f9;
  color: var(--muted);
}

.ev-tag.ev-up {
  background: var(--up-bg);
  border-color: var(--up-border);
  color: var(--up);
}

.ev-tag.ev-dn {
  background: var(--down-bg);
  border-color: var(--down-border);
  color: var(--down);
}

.ev-tag.ev-now {
  background: rgba(14, 165, 233, 0.10);
  border-color: rgba(14, 165, 233, 0.28);
  color: var(--accent);
  font-size: 10px;
  padding: 1px 6px;
}

.sig.sig-fresh.buy {
  background: var(--up-bg);
  border-color: var(--up-border);
  color: var(--up);
  box-shadow: 0 1px 2px rgba(5, 150, 105, 0.08);
}

.sig.sig-fresh.sell {
  background: var(--down-bg);
  border-color: var(--down-border);
  color: var(--down);
  box-shadow: 0 1px 2px rgba(225, 29, 72, 0.07);
}

.sig.sig-fresh.try {
  background: var(--try-bg);
  border-color: var(--try-border);
  color: var(--try);
  box-shadow: 0 1px 2px rgba(180, 83, 9, 0.07);
}

.sig-cont {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
  opacity: 0.42;
  user-select: none;
}

.sig-cont.buy { color: var(--up); }
.sig-cont.sell { color: var(--down); }
.sig-cont.try { color: var(--try); }

.tbl tbody tr.row-fresh-buy {
  background: rgba(5, 150, 105, 0.045);
}

[data-theme="dark"] .ev-tag {
  background: rgba(148, 163, 184, 0.12);
}

[data-theme="dark"] .tbl-summary {
  background: var(--surface);
}

/* Auto-Screener Digest Panel */
.auto-scr-body {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line2);
}

.auto-scr-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.auto-scr-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.inline-chk {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.inline-chk input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.auto-scr-picks {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line2);
}

/* Automation Center (#/automation) */
.auto-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.auto-group-global {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.auto-group-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.auto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 960px) {
  .auto-grid {
    grid-template-columns: 1fr;
  }
}

.auto-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
  min-width: 0;
}

.auto-card .intel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.auto-section {
  flex: 1;
  padding: 8px 0 4px;
  border-top: 1px solid var(--line2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auto-subcard {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.auto-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.auto-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.2;
}

.auto-inline > * {
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.auto-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  font-size: 11.5px !important;
  line-height: 1.25 !important;
  padding: 1px 9px 0 !important;
  height: 22px;
  box-sizing: border-box;
  vertical-align: middle;
}

.auto-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  display: inline-block;
}

.auto-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.auto-item {
  padding: 7px 0;
  border-bottom: 1px dashed var(--line2);
  font-size: 13px;
}

.auto-item:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.auto-item-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.4;
}

.auto-item-sub {
  margin-top: 3px;
  line-height: 1.45;
}

.auto-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line2);
  min-height: 42px;
}

.auto-foot .inline-chk {
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.auto-foot > button {
  margin-left: auto;
  height: 30px;
  padding: 0 12px;
}

.auto-mini {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  margin: 0 !important;
  white-space: nowrap;
}

.auto-mini input:not([type="checkbox"]):not([type="radio"]),
.auto-mini select {
  width: 62px;
  height: 30px;
  min-height: 30px;
  line-height: 28px;
  padding: 0 8px;
  font-size: 12.5px;
  box-sizing: border-box;
  margin: 0;
}

.auto-mini select {
  width: auto;
  min-width: 72px;
  padding-right: 26px;
}

/* ==========================================================================
   Home / Market Overview (#/) — native CatchTrend layout helpers
   ========================================================================== */
.hm-idx-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.hm-grp-lbl {
  margin-bottom: 8px;
}

.hm-idx-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hm-idx-grid.single {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.hm-idx-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 11px 13px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.hm-idx-tile:hover {
  background: var(--surface-hover);
  border-color: var(--accent-border);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.hm-idx-lbl {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.hm-idx-tile .auto-kv:first-child .mono {
  font-size: 10.5px;
  opacity: 0.72;
}

.hm-idx-px {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

.hm-idx-chg {
  font-size: 13.5px;
  font-weight: 700;
}

.hm-spark-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.hm-spark {
  flex: 1;
  min-width: 0;
  height: 26px;
  display: block;
  overflow: visible;
}

.hm-spark-base {
  stroke: var(--line-strong);
  stroke-width: 0.8;
  stroke-dasharray: 2 2;
  opacity: 0.65;
}

.hm-spark-line {
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hm-spark.up .hm-spark-line { stroke: var(--up); }
.hm-spark.down .hm-spark-line { stroke: var(--down); }

.hm-spark-area { stroke: none; }
.hm-spark.up .hm-spark-area { fill: var(--up-bg); }
.hm-spark.down .hm-spark-area { fill: var(--down-bg); }

.hm-spark.up .hm-spark-dot { fill: var(--up); }
.hm-spark.down .hm-spark-dot { fill: var(--down); }

.hm-idx-1m {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.9;
}

.hm-rg-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.hm-rg-px {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.hm-rg-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.hm-rg-mas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hm-hw-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.hm-hw-tile {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  text-decoration: none;
  color: inherit;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.hm-hw-tile:hover {
  background: var(--surface-hover);
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.hm-hw-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.hm-hw-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-hw-chg {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.hm-hw-px {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.hm-hw-fh {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
}

.hm-hw-bar {
  height: 3px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  margin-top: 1px;
}

.hm-hw-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--grad-laser);
  opacity: 0.7;
}

.hm-rg-ma {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
}

.hm-rg-ma.above {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, var(--surface) 100%);
}

.hm-rg-ma.below {
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.055) 0%, var(--surface) 100%);
}

.hm-ma-head,
.hm-ma-mid {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.hm-ma-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.hm-ma-st {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.4;
}

.hm-ma-st.up {
  background: var(--up-bg);
  color: var(--up);
}

.hm-ma-st.down {
  background: var(--down-bg);
  color: var(--down);
}

.hm-rg-maval {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.hm-ma-gap {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.hm-ma-meter {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  margin-top: 1px;
}

.hm-ma-zero {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: var(--line-strong);
  transform: translateX(-50%);
  z-index: 2;
}

.hm-ma-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
}

.hm-ma-fill.up {
  background: var(--up);
  opacity: 0.85;
}

.hm-ma-fill.down {
  background: var(--down);
  opacity: 0.82;
}

.hm-rg-52w {
  margin-top: 2px;
}

.hm-52w-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.hm-52w-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: var(--grad-laser);
  opacity: 0.72;
}

.hm-52w-pin {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--panel-solid);
  border: 2px solid var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.35);
}

.hm-rg-breadth {
  margin-top: 2px;
}

.hm-breadth-bar {
  display: flex;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line2);
  gap: 2px;
}

.hm-breadth-up {
  background: var(--up);
  opacity: 0.85;
}

.hm-breadth-down {
  background: var(--down);
  opacity: 0.78;
}

.hm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hm-kpi {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 11px 14px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.hm-kpi:hover {
  background: var(--surface-hover);
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.hm-kpi-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  margin: 2px 0;
  color: var(--text);
}

.hm-sec-lbl {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  margin: 4px 0 6px;
}
.hm-sec-lbl.up { color: var(--up); }
.hm-sec-lbl.down { color: var(--down); }

.hm-tbl th, .hm-tbl td {
  padding: 7px 9px;
}

.hm-sig-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.hm-movers-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hm-plate-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.hm-plate-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(260px, 400px));
  gap: 12px;
}

.hm-plate-card {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.hm-pl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.hm-pl-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hm-pl-title b {
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-pl-chg {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 13px;
}

.hm-pl-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.hm-pl-meta .auto-badge {
  font-family: var(--font-sans);
  padding: 1px 9px 0 !important;
  height: 22px;
  line-height: 1.25 !important;
}
.hm-pl-m1 {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding-top: 1px;
  line-height: 1.25;
  font-size: 12px;
  color: var(--muted);
}

.hm-pl-leaders {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line2);
}

.hm-pl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
}
.hm-pl-item:first-child { padding-top: 0; }
.hm-pl-item:last-child { padding-bottom: 0; }

.hm-pl-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hm-pl-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.hm-pl-right > :last-child {
  min-width: 46px;
  text-align: right;
}

.hm-pl-s2 {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
  color: var(--up);
  background: color-mix(in srgb, var(--up) 12%, transparent);
  flex-shrink: 0;
}

.hm-pl-1m {
  font-size: 11px;
  opacity: 0.78;
}

.hm-pl-lnk {
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hm-pl-lnk:hover { color: var(--accent); text-decoration: underline; }

.hm-empty {
  padding: 14px 4px;
  text-align: center;
}

/* Home Market Sentiment (CNN Fear & Greed), News & Macro Calendar */
.hm-fg-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line2);
  min-height: 38px;
}

.hm-fg-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hm-fg-score {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.hm-fg-meter {
  position: relative;
  flex: 1 1 180px;
  min-width: 140px;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--down) 0%, var(--try) 35%, #94a3b8 50%, var(--up) 80%, #059669 100%);
  opacity: 0.85;
}

.hm-fg-pin {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--panel-solid);
  border: 2.5px solid var(--text);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.35);
}

.hm-fg-hist {
  white-space: nowrap;
  flex-shrink: 0;
}

.hm-intel-skel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 0;
}

.hm-news-list {
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

.hm-news-item {
  display: block;
  padding: 8px 6px;
  border-radius: 10px;
  border-bottom: 1px dashed var(--line2);
  color: inherit;
  text-decoration: none;
  transition: background .14s ease;
}

.hm-news-item:last-child {
  border-bottom: none;
}

.hm-news-item:hover {
  background: var(--surface);
}

.hm-news-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hm-news-item:hover .hm-news-title {
  color: var(--accent);
}

.hm-news-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.hm-news-src {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
}

.hm-ctry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}

.hm-ctry.us {
  background: var(--accent-bg);
  color: var(--accent);
}

.hm-ctry.cn {
  background: var(--down-bg);
  color: var(--down);
}

.hm-imp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--down);
  flex-shrink: 0;
}

.hm-macro-ttl {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
}

.hm-kol-panel {
  margin-top: 22px;
}

.hm-kol-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.hm-kol-fcard {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hm-kol-fcard.on {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.hm-kol-fhead {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hm-kol-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hm-kol-link {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-subtle);
  border: 1px solid var(--line2);
  border-radius: 999px;
  padding: 2px 9px;
  text-decoration: none;
  transition: color .14s ease, border-color .14s ease, background .14s ease;
}

.hm-kol-link:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-bg);
}

.hm-kol-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hm-kol-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid transparent;
  color: inherit;
  text-decoration: none;
  transition: border-color .14s ease, transform .14s ease, background .14s ease;
}

.hm-kol-card:hover {
  border-color: var(--line);
  transform: translateY(-1px);
}

.hm-kol-card.hm-kol-skel {
  pointer-events: none;
}

.hm-kol-thumb {
  width: 112px;
  height: 63px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-subtle);
}

.hm-kol-thumb-pod {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line2);
}

.hm-kol-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hm-kol-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hm-kol-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hm-kol-card:hover .hm-kol-title {
  color: var(--accent);
}

@media (max-width: 1200px) {
  .hm-idx-groups { grid-template-columns: 1fr; }
  .hm-idx-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hm-plate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .hm-kol-strip,
  .hm-kol-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .hm-idx-grid,
  .hm-idx-grid.single,
  .hm-hw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-movers-grid,
  .hm-plate-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Stock Detail Header Reorganization & Chart Layers Popover
   ========================================================================== */
.page-head.stock-head {
  align-items: stretch;
  gap: 14px 24px;
}

.stock-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-left: auto;
}

.stock-nav-row,
.stock-act-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.stock-nav-row .scr-nav {
  height: 34px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
}

.stock-nav-row .scr-nav .small-btn {
  height: 26px !important;
  font-size: 12px;
  padding: 0 8px;
}

.stock-act-row > #wlAction,
.stock-act-row .wl-grp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stock-act-row > button,
.stock-act-row > .btn,
.stock-act-row > #wlAction button,
.stock-act-row > #wlAction .pill,
.stock-act-row > #wlAction .strat-sel {
  height: 34px !important;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.stock-act-row > button,
.stock-act-row > .btn,
.stock-act-row > #wlAction button {
  padding: 0 12px;
  white-space: nowrap;
}

.stock-act-row .pill {
  padding: 1px 11px 0;
  font-family: var(--font-sans);
  font-weight: 600;
}

.stock-act-row .strat-sel {
  padding: 0 28px 0 10px;
  line-height: 32px;
  background-position: right 8px center;
  background-size: 13px 13px;
}

.act-sep {
  width: 1px;
  height: 20px;
  background: var(--line-strong);
  opacity: 0.7;
  margin: 0 2px;
}

/* Unified Stock Switcher Combobox */
.stock-switcher {
  position: relative;
  width: 248px;
  max-width: 100%;
}

.switcher-box {
  display: flex;
  align-items: center;
  height: 34px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 0 4px 0 10px;
  gap: 6px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.stock-switcher.open .switcher-box,
.switcher-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
  background: #ffffff;
}

.switcher-ico {
  color: var(--muted);
  flex-shrink: 0;
  pointer-events: none;
}

.switcher-box input {
  flex: 1;
  min-width: 0;
  height: 100% !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  font-size: 13px;
  color: var(--text);
  outline: none;
}

.switcher-box input::placeholder {
  color: var(--muted);
}

button.switcher-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 6px;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--muted) !important;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .16s ease, color .15s ease, background .15s ease;
}

button.switcher-caret:hover {
  color: var(--text);
  background: rgba(15, 23, 42, 0.05) !important;
}

.stock-switcher.open button.switcher-caret svg {
  transform: rotate(180deg);
  color: var(--accent);
}

.switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 45;
  width: 300px;
  max-width: calc(100vw - 24px);
  max-height: 360px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 14px 36px -8px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.06);
  display: none;
}

.stock-switcher.open .switcher-menu {
  display: block;
}

.switcher-sec {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 8px 4px;
  letter-spacing: 0.02em;
}

button.switcher-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px !important;
  height: auto !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text) !important;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
}

button.switcher-item:hover,
button.switcher-item.active {
  background: var(--accent-bg) !important;
  color: var(--accent) !important;
}

button.switcher-item.current {
  background: rgba(15, 23, 42, 0.04) !important;
}

button.switcher-item.current:hover,
button.switcher-item.current.active {
  background: var(--accent-bg) !important;
}

.sw-main {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}

.sw-main b {
  flex-shrink: 0;
  font-size: 12.5px;
}

.sw-name {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sw-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.sw-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
}

.sw-cur {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
}

.sw-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.switcher-go {
  border-bottom: 1px solid var(--line) !important;
  border-radius: 8px !important;
  margin-bottom: 4px;
}

.switcher-empty {
  padding: 12px 10px;
  text-align: center;
}

/* Chart Layers Dropdown */
.layer-dd-menu {
  width: 272px;
  padding: 8px;
}

.layer-dd-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
  padding: 2px 8px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.layer-dd-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease;
}

.layer-dd-item:hover {
  background: rgba(15, 23, 42, 0.045);
}

.layer-dd-item input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.layer-dd-txt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.layer-dd-txt b {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.layer-dd-txt .small {
  font-size: 11px;
  line-height: 1.3;
}

/* Dark theme overrides for Stock Switcher & Layers Dropdown */
html[data-theme="dark"] .switcher-box {
  background: rgba(25, 41, 70, 0.78);
  border-color: var(--line-strong);
}

html[data-theme="dark"] .stock-switcher.open .switcher-box,
html[data-theme="dark"] .switcher-box:focus-within {
  background: rgba(31, 51, 86, 0.96);
  border-color: var(--accent);
}

html[data-theme="dark"] button.switcher-caret:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text);
}

html[data-theme="dark"] .switcher-menu {
  background: rgba(25, 41, 70, 0.97);
  box-shadow: 0 16px 38px -8px rgba(6, 12, 26, 0.60), 0 2px 8px rgba(6, 12, 26, 0.36);
}

html[data-theme="dark"] button.switcher-item.current {
  background: rgba(255, 255, 255, 0.06) !important;
}

html[data-theme="dark"] .sw-tag {
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .layer-dd-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 900px) {
  .stock-side {
    align-items: flex-start;
    margin-left: 0;
    width: 100%;
  }
  .stock-nav-row,
  .stock-act-row {
    justify-content: flex-start;
  }
  .stock-switcher {
    width: 260px;
  }
  .switcher-menu {
    left: 0;
    right: auto;
  }
  .act-sep {
    display: none;
  }
}

/* ==========================================================================
   Watchlist Header & Table Cell Reorganization
   ========================================================================== */
.page-head.dash-head {
  align-items: stretch;
  gap: 14px 24px;
}

.dash-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

.dash-add-form {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
}

.dash-add-form > input,
.dash-add-form > select,
.dash-add-form > button {
  height: 34px !important;
  font-size: 13px;
}

.dash-add-form > input,
.dash-add-form > select {
  background-color: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
  border-radius: 0;
  border-right: 0;
}

.dash-add-form > input {
  width: 215px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.dash-add-form > button {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0 14px;
  white-space: nowrap;
}

.dash-add-form > input:focus,
.dash-add-form > select:focus {
  position: relative;
  z-index: 1;
}

.dash-tools-row {
  justify-content: flex-end;
}

html[data-theme="dark"] .dash-add-form > input,
html[data-theme="dark"] .dash-add-form > select {
  background-color: rgba(25, 41, 70, 0.82);
}

/* Clean 2-line Stock Cell in Watchlist Table */
.dash-stock-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 165px;
}

.dash-stock-cell .drag {
  margin-right: 2px;
  flex-shrink: 0;
}

.dash-stock-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.dash-stock-top {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.25;
  white-space: nowrap;
}

.dash-stock-top .pill {
  font-size: 10.5px;
  padding: 2px 6px;
  line-height: 1.2;
  flex-shrink: 0;
}

.dash-stock-top b {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.dash-stock-top .sname {
  max-width: 150px;
  font-size: 12.5px;
}

.stock-sub-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.stock-sub-pills .pill {
  font-size: 10.5px;
  padding: 2px 6px;
  line-height: 1.2;
}

/* Screener Condition Tags — show all cleanly with comfortable wrapping */
.scr-tags {
  max-width: 280px;
}

/* Extended-hours subtle price sub-line */
.ext-sub {
  font-size: 11px;
  line-height: 1.25;
  margin-top: 2px;
  opacity: 0.85;
}

  @media (max-width: 960px) {
    .dash-side {
      align-items: flex-start;
      margin-left: 0;
      width: 100%;
    }
    .dash-tools-row {
      justify-content: flex-start;
    }
  }

/* ==========================================================================
   Mobile & Tablet Responsive Layout (Two-Row Command Header + Phone Grids)
   ========================================================================== */
.bt-mob-head {
  display: none;
}

.header-status #logoutBtn {
  height: 24px;
  padding: 0 9px;
  font-size: 11.5px;
  border-radius: 999px;
  flex-shrink: 0;
}

@media (max-width: 960px) {
  header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    height: auto;
    padding: 8px 12px 0;
    gap: 6px 8px;
  }

  .brand {
    font-size: 15px;
    gap: 7px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
  }

  .brand-tag {
    display: none;
  }

  .header-status {
    margin-left: 0;
    justify-self: end;
    min-width: 0;
    gap: 6px;
  }

  .header-status #opend {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  header nav {
    grid-column: 1 / -1;
    order: 3;
    margin: 0 -12px;
    padding: 5px 12px 7px;
    border-top: 1px solid var(--line2);
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  header nav::-webkit-scrollbar {
    display: none;
  }

  header nav a {
    flex-shrink: 0;
    white-space: nowrap;
    height: 30px;
    padding: 0 11px;
    font-size: 13px;
  }
}

@media (max-width: 900px) {
  .bt-mob-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: var(--text) !important;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  .bt-mob-head:hover:not(:disabled) {
    transform: none !important;
    filter: none !important;
    box-shadow: none !important;
  }

  .bt-mob-l {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .bt-mob-caret {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
  }

  .bt-form:not(.mob-open) .bt-body,
  .bt-form:not(.mob-open) .bt-foot {
    display: none;
  }

  .bt-form.mob-open .bt-mob-head {
    border-bottom: 1px solid var(--line) !important;
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

@media (max-width: 680px) {
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  .header-status .pill.quota,
  .header-status .opend-ver {
    display: none !important;
  }

  .header-status #opend {
    max-width: 176px;
    padding: 0 8px;
    font-size: 10.5px;
  }

  main {
    padding: 12px 10px 36px;
  }

  .panel {
    padding: 14px 13px;
    margin-bottom: 14px;
    border-radius: 14px;
  }

  .panel.intel-panel,
  .panel.plate-panel {
    padding: 12px 13px;
    margin-bottom: 14px;
  }

  .page-head {
    gap: 10px;
    margin-bottom: 14px;
  }

  h1 {
    font-size: 20px;
  }

  h1 .name {
    font-size: 14.5px;
  }

  h2 {
    font-size: 14.5px;
  }

  .big {
    font-size: 24px;
  }

  .chg {
    font-size: 14.5px;
  }

  .toolbar {
    gap: 8px;
    margin-bottom: 10px;
  }

  .row {
    min-width: 0;
    max-width: 100%;
  }

  /* Prevent multi-tab segmented bars from crushing text vertically */
  .seg {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .seg::-webkit-scrollbar {
    display: none;
  }

  .seg button {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Page-head inputs, Watchlist add bar & Stock switcher */
  .head-actions {
    width: 100%;
    gap: 6px;
  }

  .head-actions .head-go,
  .head-actions .head-group {
    flex: 1 1 100%;
    display: flex;
    min-width: 0;
  }

  .head-actions .head-go > input,
  .head-actions .head-group > input,
  .head-actions #gocode,
  .head-actions #code {
    flex: 1 1 auto;
    width: auto !important;
    min-width: 0;
  }

  .dash-add-form {
    width: 100%;
    display: flex;
  }

  .dash-add-form > input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .dash-add-form > select {
    max-width: 112px;
    flex-shrink: 0;
  }

  .dash-preset-sel {
    width: 100%;
  }

  .stock-nav-row,
  .stock-act-row {
    width: 100%;
    gap: 6px;
  }

  .stock-nav-row .scr-nav {
    width: 100%;
    justify-content: space-between;
  }

  .stock-switcher {
    width: 100%;
  }

  .switcher-menu {
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
  }

  /* Compact 2-column KPI & Form grids instead of tall single-column towers */
  .kpis:has(> .kpi) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 14px;
    gap: 12px 14px;
    margin-bottom: 14px;
  }

  .kpi .v {
    font-size: 18px;
  }

  .kpis.stock-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 11px 13px;
    gap: 10px 12px;
  }

  .kpis.stock-kpis .kpi:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .intel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
  }

  .intel-grid .intel-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .kpis.form-grid,
  .auto-scr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px 10px !important;
  }

  #scrForm .kpis.form-grid > label:nth-child(2),
  #scrForm .kpis.form-grid > label:last-child,
  #posForm .kpis.form-grid > label:nth-child(5),
  #posForm .kpis.form-grid > label:last-child {
    grid-column: 1 / -1;
  }

  #oauthCallbackInput,
  #autoOauthCbInput {
    min-width: 0 !important;
    width: 100%;
  }

  /* Home overview cards */
  .hm-idx-tile {
    padding: 10px 11px;
  }

  .hm-idx-px {
    font-size: 16px;
  }

  .hm-idx-chg {
    font-size: 12.5px;
  }

  .hm-rg-mas {
    gap: 6px;
  }

  .hm-rg-ma {
    padding: 8px 8px;
  }

  .hm-rg-maval {
    font-size: 13px;
  }

  .hm-ma-gap {
    font-size: 11px;
  }

  .hm-plate-grid,
  .hm-plate-grid.compact {
    grid-template-columns: 1fr;
  }

  .hm-kol-thumb {
    width: 92px;
    height: 52px;
  }

  .hm-fg-meter {
    flex: 1 1 100%;
    order: 3;
  }

  /* Charts, bottom-sheet popovers, tables & modals */
  .chart {
    height: 290px;
  }

  .chart.small {
    height: 118px;
  }

  .chart-legend {
    padding: 7px 10px;
    font-size: 11.5px;
  }

  .sig-dd-menu,
  .layer-dd-menu {
    position: fixed;
    left: 10px !important;
    right: 10px !important;
    bottom: 12px;
    top: auto;
    width: auto !important;
    max-width: none !important;
    max-height: 72dvh;
    z-index: 85;
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
  }

  .tbl th,
  .tbl td {
    padding: 8px 8px;
  }

  .tbl td:not(.l):not(.c) {
    font-size: 12px;
  }

  .tbl-wrap {
    -webkit-overflow-scrolling: touch;
    max-height: 68dvh;
  }

  .dash-stock-cell {
    min-width: 136px;
  }

  .sname {
    max-width: 96px;
  }

  .div-modal-backdrop {
    padding: 8px;
  }

  .div-modal {
    width: 96vw;
    height: 90dvh;
    max-height: 92dvh;
    border-radius: 14px;
  }

  .div-modal-head {
    padding: 12px 14px;
  }

  .div-modal-body {
    padding: 12px 14px 16px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .drag {
    display: none;
  }
}
