/* ==========================================================================
   Sweep Signals — Terminal UI
   Quiet, precise, dense. One neutral base, one accent, semantic up/down.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* Surfaces */
  --bg-void: #0A0B0D;
  --bg-dark: #0C0D10;
  --bg-card: #111317;
  --bg-card-hover: #15171C;
  --bg-elevated: #14161A;
  --bg-surface: rgba(255, 255, 255, 0.035);
  --bg-surface-elevated: rgba(255, 255, 255, 0.055);
  --bg-input: #0D0E11;

  /* Lines */
  --line: rgba(255, 255, 255, 0.075);
  --line-soft: rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.11);
  --border-color: var(--line);
  --border-subtle: var(--line-soft);
  --border-highlight: var(--line-strong);
  --border-active: rgba(255, 255, 255, 0.18);

  /* Text */
  --text-main: #ECEDEF;
  --text-sub: #B6BAC1;
  --text-muted: #80868F;
  --text-dim: #5C626B;

  /* Semantic */
  --up: #3DD68C;
  --down: #F0616D;
  --warn: #F2B84B;
  --info: #7AB8FF;
  --violet: #A99BFF;
  --sky: #6EC1F2;

  --accent-green: var(--up);
  --accent-green-bg: rgba(61, 214, 140, 0.09);
  --accent-green-border: rgba(61, 214, 140, 0.28);
  --accent-red: var(--down);
  --accent-red-bg: rgba(240, 97, 109, 0.09);
  --accent-red-border: rgba(240, 97, 109, 0.3);
  --accent-amber: var(--warn);
  --accent-amber-bg: rgba(242, 184, 75, 0.09);
  --accent-amber-border: rgba(242, 184, 75, 0.3);
  --accent-blue: var(--info);
  --accent-purple: var(--violet);

  /* Theme accent (legacy name kept for script compatibility) */
  --accent-cyan: #4CD4B0;
  --accent-cyan-bg: color-mix(in srgb, var(--accent-cyan) 9%, transparent);
  --accent-cyan-border: color-mix(in srgb, var(--accent-cyan) 30%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent-cyan) 12%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent-cyan) 22%, transparent);
  --theme-glow: transparent;
  --theme-glow-subtle: transparent;

  /* Logo */
  --logo-bg: #0E1013;
  --logo-stroke: rgba(255, 255, 255, 0.1);
  --logo-level: rgba(255, 255, 255, 0.28);

  /* Type */
  --font-ui: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', ui-monospace, Menlo, monospace;

  /* Shape & rhythm */
  --radius-xs: 6px;
  --radius-sm: 7px;
  --radius-md: 9px;
  --radius-lg: 12px;
  --gap: 12px;

  --rail-w: 236px;
  --rail-w-collapsed: 52px;
  --gutter: 24px;
  --topbar-h: 50px;

  --shadow-pop: 0 24px 64px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Accent themes — only the accent changes; the base stays neutral. */
body[data-theme="obsidian"] { --accent-cyan: #4CD4B0; }
body[data-theme="carbon"]   { --accent-cyan: #D8B676; }
body[data-theme="amethyst"] { --accent-cyan: #A594FF; }
body[data-theme="crimson"]  { --accent-cyan: #F08A9C; }
body[data-theme="navy"]     { --accent-cyan: #6CC4F0; }

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 380px at 72% -120px, color-mix(in srgb, var(--accent-cyan) 5%, transparent), transparent 70%),
    var(--bg-void);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.5;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-ring); color: var(--text-main); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; }
img, svg { display: block; }
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-soft);
  padding: 0 4px;
  border-radius: 4px;
  color: var(--text-sub);
}
b, strong { font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; border-radius: 6px; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); background-clip: padding-box; }

/* Icons */
.i {
  width: 15px; height: 15px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.i-xs { width: 11px; height: 11px; }
.brand-mark { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; }
.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; }

/* Numbers */
.stat-value, .p-stat-val, .chip-val, .tab-price, .level-val, .trade-box-val, .pt-metric-val,
.pt-pnl-val, .rail-clock, .signals-table td, .kv-item strong, .rb-item strong {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   3. Shell
   -------------------------------------------------------------------------- */
.terminal-container { min-height: 100vh; }

.workspace-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.workspace-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0 var(--gutter) 20px;
}

/* ---------- Left rail ---------- */
.left-utility-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  width: var(--rail-w);
  flex-shrink: 0;
  display: flex;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.016), rgba(255, 255, 255, 0.006));
  z-index: 60;
  transition: width 0.22s var(--ease);
}

.rail-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.rail-brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 6px;
  margin-bottom: 6px;
}
.rail-brand-text { min-width: 0; }
.rail-brand-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-main);
  white-space: nowrap;
  line-height: 1.2;
}
.sub-logo { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; line-height: 1.3; }

.pulse-indicator {
  position: relative;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.pulse-indicator.live { background: var(--up); }
.pulse-indicator.live::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--up);
  opacity: 0;
  animation: ping 2.4s var(--ease) infinite;
}
@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.7; }
  80%, 100% { transform: scale(1.7); opacity: 0; }
}

.rail-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0 10px;
  border-top: 1px solid var(--line-soft);
}
.rail-section-lbl {
  padding: 0 8px;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.rail-clock {
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-main);
  margin-bottom: 4px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-sub);
}

/* Rail rows: status rows are tinted, action rows are quiet menu items */
.status-badge.rail-badge,
#telegramBadge {
  display: flex;
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  line-height: 1.35;
  transition: background 0.15s, color 0.15s;
}
#sessionBadge, #telegramBadge, #dashUserBadge, #viewerBadge { background: var(--bg-surface); }
.status-badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  margin: 0 3px 0 4px;
  background: var(--text-dim);
  flex-shrink: 0;
  box-shadow: none !important;
}

.rail-btn {
  color: var(--text-sub);
  border-color: transparent !important;
  background: transparent !important;
}
.rail-btn:hover { background: var(--bg-surface-elevated) !important; color: var(--text-main) !important; }
.rail-btn-icon { display: inline-grid; place-items: center; width: 15px; color: currentColor; opacity: 0.75; }
.rail-btn-danger:hover { color: var(--down) !important; }

.rail-section-desk #telegramBadge, .rail-section-desk #dashUserBadge { margin-bottom: 2px; }
.rail-badge-user { color: var(--accent-cyan); }
.rail-badge-user::before {
  content: "";
  width: 15px; height: 15px;
  flex-shrink: 0;
  background: currentColor;
  opacity: 0.85;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M20 21a8 8 0 0 0-16 0'/%3E%3C/svg%3E") center / 14px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M20 21a8 8 0 0 0-16 0'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.rail-badge-viewer { color: var(--info); }

.tg-icon {
  display: inline-block;
  width: 15px; height: 15px;
  flex-shrink: 0;
  font-size: 0;
  background: currentColor;
  opacity: 0.8;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m22 2-7 20-4-9-9-4Z'/%3E%3Cpath d='M22 2 11 13'/%3E%3C/svg%3E") center / 14px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m22 2-7 20-4-9-9-4Z'/%3E%3Cpath d='M22 2 11 13'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.status-badge.configured, .status-badge.connected { color: var(--up); }

/* Theme swatches */
.rail-themes { display: flex; gap: 6px; padding: 0 6px; }
.theme-pill {
  position: relative;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 0;
  color: transparent;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.theme-pill::before {
  content: "";
  position: absolute; inset: 4px;
  border-radius: 50%;
  background: var(--swatch);
}
.theme-pill:hover { transform: translateY(-1px); border-color: var(--border-active); }
.theme-pill.active { border-color: transparent; box-shadow: 0 0 0 1.5px var(--swatch); }
.theme-pill[data-theme="obsidian"] { --swatch: #4CD4B0; }
.theme-pill[data-theme="carbon"]   { --swatch: #D8B676; }
.theme-pill[data-theme="amethyst"] { --swatch: #A594FF; }
.theme-pill[data-theme="crimson"]  { --swatch: #F08A9C; }
.theme-pill[data-theme="navy"]     { --swatch: #6CC4F0; }

/* Collapse tab */
.rail-collapse-tab {
  position: absolute;
  top: 20px;
  right: -11px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  color: var(--text-muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 2;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.left-utility-rail:hover .rail-collapse-tab, .rail-collapse-tab:focus-visible { opacity: 1; }
.rail-collapse-tab:hover { color: var(--text-main); border-color: var(--border-active); }
.rail-toggle-arrow {
  font-size: 0;
  width: 11px; height: 11px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.2s var(--ease);
}
.rail-vertical-label { display: none; }

/* Collapsed (desktop) */
.left-utility-rail.collapsed { width: var(--rail-w-collapsed); }
.left-utility-rail.collapsed .rail-content { display: none; }
.left-utility-rail.collapsed .rail-collapse-tab {
  position: static;
  opacity: 1;
  width: 100%; height: 100%;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding-top: 20px;
}
.left-utility-rail.collapsed .rail-collapse-tab:hover { background: rgba(255, 255, 255, 0.02); }
.left-utility-rail.collapsed .rail-toggle-arrow { transform: rotate(180deg); }
.left-utility-rail.collapsed .rail-vertical-label {
  display: flex;
  gap: 12px;
  writing-mode: vertical-rl;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.32em;
  color: var(--text-dim);
}

/* ---------- Top bar ---------- */
.main-view-switcher-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 calc(var(--gutter) - 10px);
  height: var(--topbar-h);
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 11, 13, 0.8);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
          backdrop-filter: saturate(140%) blur(14px);
}
.main-view-switcher-top-row { display: none; }

.view-toggle-group {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.view-toggle-group::-webkit-scrollbar { display: none; }

.view-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.15s;
}
.view-toggle-btn .btn-icon { width: 15px; height: 15px; opacity: 0.85; }
.view-toggle-btn:hover { color: var(--text-sub); }
.view-toggle-btn.active { color: var(--text-main); }
.view-toggle-btn.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent-cyan);
}
.view-toggle-btn.active .btn-icon { color: var(--accent-cyan); opacity: 1; }

.nav-trades-pill {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: none !important;
}
.nav-trades-pill.has-trades,
#navHlPositionsCountBadge, #navTxflowPositionsCountBadge {
  color: var(--accent-cyan) !important;
  background: var(--accent-soft) !important;
}

/* ---------- Market selector ---------- */
.ticker-nav-bar { margin-top: 14px; }
.ticker-nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.nav-lbl {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
}
.ticker-tabs {
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.ticker-tabs::-webkit-scrollbar { display: none; }

.ticker-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.ticker-tab:hover { background: rgba(255, 255, 255, 0.04); }
.tab-sym { font-size: 12.5px; font-weight: 600; color: var(--text-sub); letter-spacing: 0.01em; }
.tab-price { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.ticker-tab.active {
  border-color: var(--line-strong);
  background: var(--bg-card);
  box-shadow: inset 0 -2px 0 var(--accent-cyan);
}
.ticker-tab.active .tab-sym { color: var(--text-main); }
.ticker-tab.active .tab-price { color: var(--text-sub); }

.tab-badge:empty { display: none; }
.tab-badge {
  width: 6px; height: 6px;
  border-radius: 50%;
  font-size: 0;
  background: var(--text-dim);
}
.tab-badge.bull { background: var(--up); }
.tab-badge.bear { background: var(--down); }

.ticker-dropdown { display: none; }

/* ---------- Views ---------- */
.view-stage { margin-top: 12px; flex: 1; }
.view-stage > div > * + * { margin-top: var(--gap); }

/* --------------------------------------------------------------------------
   4. Cards & stats
   -------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}
.stats-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.stat-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 13px 16px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.stat-label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--text-main);
  overflow-wrap: anywhere;
}
.stat-sub {
  margin-top: auto;
  padding-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-card-sm { padding: 11px 13px; border-radius: var(--radius-md); background: var(--bg-surface); }
.stat-card-sm .stat-value { font-size: 16px; margin-top: 4px; }
.stat-card-sm .stat-sub { padding-top: 2px; }

.highlight-cyan { color: var(--accent-cyan); }
.highlight-pattern { color: var(--text-main); }

.bias-card .stat-value { font-size: 14px; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-bar {
  position: relative;
  height: 4px;
  margin: 10px 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}
.meter-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 999px;
  background: var(--text-muted);
  transition: left 0.5s var(--ease), width 0.5s var(--ease);
}
.meter-fill.bull { background: var(--up); }
.meter-fill.bear { background: var(--down); }
.meter-center {
  position: absolute;
  left: 50%; top: -3px;
  width: 1px; height: 10px;
  background: rgba(255, 255, 255, 0.3);
}
.meter-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}
#biasScore { color: var(--text-sub); font-weight: 500; }

/* ---------- Panels ---------- */
.panel-box {
  position: relative;
  min-width: 0;
  padding: 14px 16px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 30px;
  margin-bottom: 12px;
}
.panel-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.panel-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-box h2, .panel-box h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-main);
  line-height: 1.3;
}
.panel-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; line-height: 1.45; }
.panel-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.h-meta { font-size: 12px; font-weight: 400; color: var(--text-muted); margin-left: 6px; letter-spacing: 0; }
.panel-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.panel-icon {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-sub);
}
.panel-icon .i { width: 14px; height: 14px; }
.panel-icon-info { color: var(--sky); }
.panel-icon-warn { color: var(--warn); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.badge-accent { color: var(--accent-cyan); background: var(--accent-cyan-bg); border-color: var(--accent-cyan-border); font-family: var(--font-mono); }
.badge-live { color: var(--up); background: var(--accent-green-bg); border-color: var(--accent-green-border); }
.badge-info { color: var(--sky); background: rgba(110, 193, 242, 0.09); border-color: rgba(110, 193, 242, 0.28); }
.badge-danger { color: var(--down); background: var(--accent-red-bg); border-color: var(--accent-red-border); }
.live-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: blink 2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- Buttons ---------- */
.btn-sm, .btn-xs, .copy-trade-btn, .pt-btn, .legal-strip-btn, .chart-toggle-btn, .rail-mobile-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-sub);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-sm:hover, .btn-xs:hover, .copy-trade-btn:hover, .pt-btn:hover, .legal-strip-btn:hover,
.chart-toggle-btn:hover, .rail-mobile-open-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-active);
  color: var(--text-main);
}
.btn-sm .i, .btn-xs .i, .pt-btn .i { width: 14px; height: 14px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; }

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn-primary {
  background: #EDEEF0;
  color: #0A0B0D;
  border: 1px solid #EDEEF0;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}
.btn-primary:hover { background: #FFFFFF; border-color: #FFFFFF; }
.btn-primary:active, .btn-secondary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-main);
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--border-active); }
.btn-block { width: 100%; }
.btn-lg { height: 40px; font-size: 13.5px; }
.btn-grow { flex: 1 1 auto; }

.btn-danger-ghost { color: var(--down) !important; border-color: var(--accent-red-border) !important; background: transparent !important; }
.btn-danger-ghost:hover { background: var(--accent-red-bg) !important; }
.btn-link { border-color: transparent !important; background: transparent !important; color: var(--accent-cyan) !important; padding: 0 4px !important; }
.btn-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.link-btn {
  font-size: 12px;
  color: var(--text-sub);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  transition: color 0.15s, text-decoration-color 0.15s;
}
.link-btn:hover { color: var(--text-main); text-decoration-color: currentColor; }
.link-btn-muted { color: var(--text-muted); }

.copy-trade-btn.copied { color: var(--up) !important; border-color: var(--accent-green-border) !important; background: var(--accent-green-bg) !important; }
.hl-1click-exec-btn { font-weight: 600 !important; }

/* Segmented controls */
.chart-tf-picker, .leverage-btn-group, .sub-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.sub-tab-group { flex-wrap: wrap; }
.sub-tab-group-center { display: flex; width: fit-content; margin: 0 auto 16px; }
.sub-tab-group-full { width: 100%; }
.sub-tab-group-full .sub-tab-btn { flex: 1; }

.chart-tf-btn, .lev-btn, .sub-tab-btn {
  height: 24px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.chart-tf-btn { padding: 0 9px; font-family: var(--font-mono); font-size: 11.5px; }
.chart-tf-btn:hover, .lev-btn:hover, .sub-tab-btn:hover { color: var(--text-sub); }
.chart-tf-btn.active, .lev-btn.active, .sub-tab-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 2px rgba(0, 0, 0, 0.3);
}
.lev-btn { height: 26px; font-family: var(--font-mono); font-size: 12px; }
.form-group > .leverage-btn-group, .calc-input-group > .leverage-btn-group { align-self: flex-start; }
.sub-tab-btn { height: 26px; }

/* --------------------------------------------------------------------------
   5. Live terminal
   -------------------------------------------------------------------------- */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: var(--gap);
  align-items: start;
}
.feed-section { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.sidebar-section { position: sticky; top: calc(var(--topbar-h) + 12px); min-width: 0; }

/* Chart */
.chart-panel-header { margin-bottom: 10px; }
.chart-legend-pill { display: inline-flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--text-muted); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { display: inline-block; width: 10px; height: 2px; border-radius: 2px; }
.legend-entry { background: var(--info); }
.legend-sl { background: var(--down); }
.legend-tp { background: var(--up); }

#chartWrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
}
#lightweightChartContainer { width: 100%; min-height: 290px; }
#chartLoadingOverlay {
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  background: rgba(17, 19, 23, 0.72);
  font-size: 12px;
  color: var(--text-muted);
  z-index: 3;
}
.loading-inline { display: flex; align-items: center; gap: 10px; }
.spinner-inline {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent-cyan);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chart-panel-box.collapsed .chart-panel-header { margin-bottom: 0; }
.chart-panel-box.collapsed #chartWrapper { display: none; }

/* Empty states */
.empty-state {
  padding: 22px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.012);
}

/* Setup radar */
.radar-card { display: flex; flex-direction: column; gap: 10px; }
.radar-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.radar-title { font-size: 13px; font-weight: 600; color: var(--text-main); }
.radar-bias-pill {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
}
.radar-brief-box {
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.025);
  border-left: 2px solid var(--accent-cyan);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.radar-brief-box b { color: var(--text-main); }
.radar-targets-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.radar-target-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.015);
}
.radar-target-box > span:first-child { color: var(--text-muted) !important; }
.radar-target-box b { font-family: var(--font-mono); font-weight: 500; }
.radar-checklist { border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.radar-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
}
.radar-item:first-child { border-top: none; }
.radar-item-left { min-width: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.radar-item-name { font-size: 12.5px; font-weight: 500; color: var(--text-main); }
.radar-item-details { font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.radar-item-status {
  flex-shrink: 0;
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}
.radar-item-status.ready, .radar-item-status.clear, .radar-item-status.met, .radar-item-status.confirmed, .radar-item-status.triggered { color: var(--up); background: var(--accent-green-bg); }
.radar-item-status.caution, .radar-item-status.pending { color: var(--warn); background: var(--accent-amber-bg); }
.radar-item-status.blocked, .radar-item-status.failed, .radar-item-status.invalid { color: var(--down); background: var(--accent-red-bg); }

/* Dominant trade card */
.trade-card {
  position: relative;
  padding: 13px 14px 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.015);
  overflow: hidden;
}
.trade-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--text-dim);
}
.trade-card.long::before { background: var(--up); }
.trade-card.short::before { background: var(--down); }
.trade-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.trade-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13.5px; font-weight: 600; color: var(--text-main); letter-spacing: -0.01em;
}
.trade-title > span:last-child { font-size: 12px !important; font-weight: 500 !important; margin-left: 2px !important; }
.timeframe-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 500;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.06);
}
.trade-score-pill {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.trade-score-pill.long { color: var(--up); background: var(--accent-green-bg); border-color: var(--accent-green-border); }
.trade-score-pill.short { color: var(--down); background: var(--accent-red-bg); border-color: var(--accent-red-border); }

.trade-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin: 12px 0;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.trade-box {
  min-width: 0;
  padding: 9px 11px;
  background: var(--bg-card);
}
.trade-box-lbl { display: block; font-size: 10.5px; font-weight: 500; color: var(--text-muted); letter-spacing: 0.02em; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade-box-val { display: block; margin-top: 3px; font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-main); overflow-wrap: anywhere; }
.trade-box.entry .trade-box-val { color: var(--info); }
.trade-box.sl .trade-box-val { color: var(--down); }
.trade-box.tp1 .trade-box-val, .trade-box.tp2 .trade-box-val, .trade-box.tp3 .trade-box-val { color: var(--up); }

.trade-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.trade-footer > div:last-child { display: flex; flex-wrap: wrap; gap: 6px !important; }
.trade-confluences-row { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex; align-items: center;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.045);
}

/* ---------- Tables ---------- */
.table-container {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: max-height 0.3s var(--ease);
}
.signals-table, .history-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.signals-table th, .history-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 7px 12px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.signals-table td, .history-table td {
  padding: 7px 12px;
  color: var(--text-sub);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  vertical-align: middle;
}
.signals-table tbody tr:last-child td, .history-table tbody tr:last-child td { border-bottom: none; }
.signals-table tbody tr:hover td, .history-table tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }
.signals-table td b { color: var(--text-main); font-weight: 600; }
#signalsTableBody tr:first-child td { animation: rowIn 1.2s var(--ease); }
@keyframes rowIn { from { background: var(--accent-soft); } to { background: transparent; } }
.empty-row td { text-align: center !important; padding: 24px 16px !important; color: var(--text-muted) !important; white-space: normal !important; }
.history-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }

.direction-badge {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.05);
}
.direction-badge.bull { color: var(--up); background: var(--accent-green-bg); }
.direction-badge.bear { color: var(--down); background: var(--accent-red-bg); }

/* ---------- Inspector ---------- */
.inspector-panel { padding: 10px; }
.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.inspector-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 26px;
  border-radius: 5px;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.inspector-tab .i { width: 13px; height: 13px; }
.inspector-tab:hover { color: var(--text-sub); }
.inspector-tab.active { background: rgba(255, 255, 255, 0.1); color: var(--text-main); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.inspector-tab-content { padding: 2px 6px 2px; }

.level-group-lbl {
  padding: 12px 0 4px;
  font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim);
}
.level-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}
.levels-container > .level-row:last-child { border-bottom: none; }
.level-tag {
  font-family: var(--font-mono);
  font-size: 9.5px; font-weight: 600;
  text-align: center;
  padding: 2px 0;
  border-radius: 4px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}
.level-tag.mn-tag { color: var(--accent-cyan); background: var(--accent-soft); }
.level-name { font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-val { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; }
.level-val-accent { color: var(--accent-cyan); }

.pools-container { padding-top: 10px; }
.pool-group + .pool-group { margin-top: 14px; }
.pool-title { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.pool-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pool-title-meta { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; font-weight: 400; color: var(--text-dim); }
.pool-list { list-style: none; margin-top: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.pool-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-sub);
  border-top: 1px solid var(--line-soft);
}
.pool-item:first-child { border-top: none; }
.pool-item b { font-family: var(--font-mono); font-weight: 500; }
.pool-empty { padding: 10px; font-size: 12px; color: var(--text-muted); }

.structure-tf-list { padding-top: 6px; }
.structure-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.structure-row:last-child { border-bottom: none; }
.tf-pill {
  min-width: 34px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.06);
}
.structure-val { font-size: 12.5px; font-weight: 500; color: var(--text-sub); line-height: 1.45; }
.structure-val.bull, .structure-val.bullish { color: var(--up); }
.structure-val.bear, .structure-val.bearish { color: var(--down); }
.structure-val.ranging, .structure-val.neutral, .structure-val.range { color: var(--warn); }

/* --------------------------------------------------------------------------
   6. Backtest
   -------------------------------------------------------------------------- */
.backtest-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}
.form-group-action { align-self: end; }

.best-strategy-card {
  padding: 14px 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-cyan) 8%, transparent), transparent 55%),
    var(--bg-card);
  border-color: var(--accent-cyan-border);
}
.strategy-badge {
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-cyan);
}
.best-strategy-card h3 { font-size: 15px; margin: 5px 0 4px; }
.best-strategy-card p { font-size: 12.5px; color: var(--text-sub); line-height: 1.6; max-width: 880px; }

.strategy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.strategy-grid > .empty-state { grid-column: 1 / -1; }
.strategy-rank-card {
  padding: 11px 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.018);
}
.strategy-rank-card.top { border-color: var(--accent-cyan-border); background: var(--accent-cyan-bg); }
.strat-card-title {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  font-size: 12.5px; font-weight: 600; color: var(--text-main); line-height: 1.35;
  margin-bottom: 6px;
}
.strat-card-title > span:last-child { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.strat-metric-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  border-top: 1px solid var(--line-soft);
}
.strat-metric-lbl { color: var(--text-muted); }
.strat-metric-val { font-family: var(--font-mono); color: var(--text-sub); }

/* --------------------------------------------------------------------------
   7. Portfolio / positions
   -------------------------------------------------------------------------- */
.portfolio-calc-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  padding: 11px 13px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.018);
}
.calc-input-group { display: flex; flex-direction: column; gap: 5px; }
.input-with-symbol { position: relative; width: 150px; }
.curr-prefix { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-family: var(--font-mono); font-size: 12.5px; pointer-events: none; }
.input-with-symbol .form-control { padding-left: 22px; font-family: var(--font-mono); }
.calc-summary-chip { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.chip-lbl { font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.chip-val { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-main); }

.portfolio-stats-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.p-stat-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.022);
}
.p-stat-lbl { font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-stat-val { margin-top: 4px; font-size: 15.5px; font-weight: 600; letter-spacing: -0.015em; color: var(--text-main); overflow-wrap: anywhere; }
.p-stat-sub { margin-top: 2px; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.all-trades-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 10px; }
.all-trades-grid > .empty-state { grid-column: 1 / -1; }

.portfolio-trade-card {
  position: relative;
  padding: 12px 13px 12px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.015);
  overflow: hidden;
  margin-bottom: 0 !important;
}
#hlPagePositionsList, #txflowPagePositionsList { display: grid; gap: 10px; }
.portfolio-trade-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--text-dim); }
.portfolio-trade-card.bull-pos::before { background: var(--up); }
.portfolio-trade-card.bear-pos::before { background: var(--down); }

.pt-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pt-title-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pt-title-left > span:empty { display: none; }
.pt-ticker { font-size: 13.5px; font-weight: 600; color: var(--text-main); letter-spacing: -0.01em; }
.pt-dir-badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.05); color: var(--text-sub);
}
.pt-dir-badge.long { color: var(--up); background: var(--accent-green-bg); }
.pt-dir-badge.short { color: var(--down); background: var(--accent-red-bg); }
.pt-status-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.05);
}
.pt-title-left > span[style] { font-size: 11px !important; }
.pt-pnl-right { display: flex; align-items: baseline; gap: 8px; }
.pt-pnl-val { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.pt-roe-val { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); }
.pt-roe-val.bull { color: var(--up); background: var(--accent-green-bg); }
.pt-roe-val.bear { color: var(--down); background: var(--accent-red-bg); }
.pt-header [style*="font-size: 16px"] { font-size: 14px !important; }

.pt-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pt-metric { min-width: 0; padding: 8px 10px; background: var(--bg-card); }
.pt-metric-lbl { font-size: 9.5px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-metric-val { margin-top: 3px; font-family: var(--font-mono); font-size: 12px !important; font-weight: 500; color: var(--text-main); overflow-wrap: anywhere; }
.pt-metric-val span { font-size: 11px !important; }

.pt-targets-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.pt-target-box {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap;
  padding: 6px 9px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.pt-target-box b { font-family: var(--font-mono); font-weight: 500; }
.pt-target-box.hit { border-style: solid; border-color: var(--accent-green-border); background: var(--accent-green-bg); }
.target-status { font-size: 9.5px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-dim); }
.pt-target-box.hit .target-status { color: var(--up); }

.pt-actions-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-top: 10px !important; padding-top: 10px !important;
  border-top: 1px solid var(--line-soft);
}
.pt-actions-left, .pt-actions-row > div:first-child { display: flex; flex-wrap: wrap; gap: 6px !important; }
.pt-actions-row > div:last-child:not(:first-child) { font-size: 11px !important; color: var(--text-dim) !important; }
.focus-btn { color: var(--text-main); }
.portfolio-trade-card > div[style*="margin-top: 10px"] { margin-top: 6px !important; padding: 6px 10px !important; gap: 12px !important; font-size: 11.5px !important; background: rgba(255, 255, 255, 0.02) !important; }

/* HL / TxFlow */
.panel-header-wrap { align-items: flex-start; }
.wallet-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-main);
  text-decoration: none;
  transition: border-color 0.15s;
}
.wallet-chip .i { color: var(--text-muted); width: 14px; height: 14px; }
.wallet-chip .i-xs { width: 11px; height: 11px; }
a.wallet-chip:hover { border-color: var(--accent-cyan-border); }
.wallet-chip-info { color: var(--sky); }

.hl-risk-banner { padding: 9px 12px; }
.risk-banner-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.risk-banner-title { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-sub); }
.risk-banner-title .i { color: var(--accent-cyan); width: 14px; height: 14px; }
.txflow-risk-banner .risk-banner-title .i { color: var(--sky); }
.hl-risk-banner-items { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.rb-item {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 11.5px;
}
.rb-item > span { color: var(--text-muted); }
.rb-item strong { color: var(--text-main); font-weight: 500; }

.scroll-x { overflow-x: auto; }
.scroll-y-260 { max-height: 260px; overflow-y: auto; }

/* --------------------------------------------------------------------------
   8. Footer
   -------------------------------------------------------------------------- */
.terminal-brand-footer {
  margin-top: 28px;
  padding: 16px 0 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-brand .brand-mark { width: 26px; height: 26px; border-radius: 7px; }
.footer-brand-name { font-size: 13px; font-weight: 600; color: var(--text-main); letter-spacing: -0.01em; line-height: 1.25; }
.footer-brand-tag { font-size: 11.5px; color: var(--text-muted); }
.footer-meta { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--text-dim); flex-wrap: wrap; }
.footer-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-dim); }

.legal-disclaimer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.012);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-dim);
}
.legal-disclaimer-strip b { color: var(--text-muted); }
.legal-strip-btn { flex-shrink: 0; height: 26px; font-size: 11.5px; }

/* --------------------------------------------------------------------------
   9. Forms
   -------------------------------------------------------------------------- */
.form-group, .sec-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-lbl, .sec-field > label, .form-group > label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  letter-spacing: 0;
  text-transform: none;
}
.lbl-meta { font-weight: 400; color: var(--text-dim); margin-left: 4px; }

.form-control {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.form-control::placeholder { color: var(--text-dim); }
.form-control:hover { border-color: var(--border-active); }
.form-control:focus { border-color: var(--accent-cyan-border); box-shadow: 0 0 0 3px var(--accent-ring); }
.form-control[readonly] { color: var(--text-sub); }
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2380868F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 13px;
  cursor: pointer;
}
select.form-control option { background: #15171B; color: var(--text-main); }
.form-control.mono, .mono { font-family: var(--font-mono); font-size: 12.5px; }
.form-control-sm { height: 28px; width: 84px; font-family: var(--font-mono); font-size: 12.5px; }
.form-control-lg { height: 42px; font-size: 15px; letter-spacing: 0.12em; }
input[type="number"].form-control { font-variant-numeric: tabular-nums; }

.form-hint { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }
.form-error { font-size: 12px; color: var(--down); margin: 4px 0 10px; line-height: 1.5; }
.form-error-box { margin: 10px 0 0; padding: 8px 11px; border-radius: var(--radius-sm); background: var(--accent-red-bg); border: 1px solid var(--accent-red-border); text-align: center; }
.form-feedback { font-family: var(--font-mono); font-size: 11.5px; margin: 4px 0 10px; line-height: 1.5; }
#txflowConfigFeedback { margin-top: 10px; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.input-row { display: flex; gap: 6px; }
.input-row .form-control { flex: 1; min-width: 0; }
.input-row .btn-secondary, .input-row .btn-sm { height: 34px; flex-shrink: 0; }
.form-footer-link { text-align: center; margin-top: 12px; }

/* Checkbox */
.legal-consent-box input[type="checkbox"], .pnl-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 15px; height: 15px;
  margin-top: 2px;
  border-radius: 4px;
  border: 1.5px solid var(--border-active);
  background: var(--bg-input);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.legal-consent-box input[type="checkbox"]:checked, .pnl-check input[type="checkbox"]:checked {
  background: var(--accent-cyan) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A0B0D' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 10px no-repeat;
  border-color: var(--accent-cyan);
}
.legal-consent-box {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
}
.legal-consent-box label { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 12px; line-height: 1.55; color: var(--text-muted); }
.legal-consent-box b { color: var(--text-sub); }
.legal-consent-box-strong label { color: var(--text-sub); font-size: 12.5px; }
.legal-consent-box-strong b { color: var(--text-main); }
.legal-inline-link {
  display: inline;
  padding: 0;
  font-size: inherit;
  font-weight: 500;
  color: var(--accent-cyan);
  text-decoration: underline;
  text-decoration-color: var(--accent-cyan-border);
  text-underline-offset: 3px;
  margin-left: 2px;
}
.legal-inline-link:hover { text-decoration-color: currentColor; }

/* Switch */
input[type="checkbox"].switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 32px; height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
input[type="checkbox"].switch::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #D9DBDF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s var(--ease), background 0.2s;
}
input[type="checkbox"].switch:checked { background: var(--accent-cyan); }
input[type="checkbox"].switch:checked::before { transform: translateX(14px); background: #0A0B0D; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  cursor: pointer;
}
.toggle-title { display: block; font-size: 13px; font-weight: 600; color: var(--text-main); }
.toggle-desc { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

/* Callouts */
.callout {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-sub);
}
.callout b { color: var(--text-main); }
.callout a { color: var(--accent-cyan); text-underline-offset: 3px; }
.callout-accent { background: var(--accent-cyan-bg); border-color: var(--accent-cyan-border); }
.callout-info { background: rgba(110, 193, 242, 0.06); border-color: rgba(110, 193, 242, 0.22); }
.callout-success { background: var(--accent-green-bg); border-color: var(--accent-green-border); }
.callout-title { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-main); margin-bottom: 3px; }
.callout-title .i { color: var(--up); width: 14px; height: 14px; }
.callout-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* --------------------------------------------------------------------------
   10. Modals
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 7, 9, 0.72);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  overflow-y: auto;
  animation: fadeIn 0.18s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal-box, .modal-card {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  margin: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: rise 0.22s var(--ease);
}
.modal-md { max-width: 580px; }
.modal-lg { max-width: 780px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-title-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.modal-header h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-main); }
.modal-sub { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.modal-close-btn {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.modal-close-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-main); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-footer .btn-sm, .modal-footer .btn-primary { height: 32px; padding: 0 12px; }

.modal-intro { text-align: center; margin-bottom: 16px; }
.modal-intro h3 { font-size: 15px; font-weight: 600; color: var(--text-main); letter-spacing: -0.01em; }
.modal-intro p { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; max-width: 440px; margin: 4px auto 0; }
.modal-intro p b { color: var(--text-sub); }
.intro-icon {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  margin-bottom: 10px;
  color: var(--accent-cyan);
  background: var(--accent-soft);
  border: 1px solid var(--accent-cyan-border);
}
.intro-icon .i { width: 16px; height: 16px; }

.key-display {
  padding: 13px;
  margin-bottom: 14px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px dashed var(--accent-cyan-border);
  background: var(--accent-cyan-bg);
}
.key-display-info { border-color: rgba(110, 193, 242, 0.35); background: rgba(110, 193, 242, 0.06); }
.key-display-lbl { display: block; margin-bottom: 5px; font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.key-display-val { font-family: var(--font-mono); font-size: 15px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-main); user-select: all; overflow-wrap: anywhere; }

.btn-row { display: flex; gap: 6px; }
.btn-row-end { justify-content: flex-end; }
.btn-row-wrap { flex-wrap: wrap; }

.account-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.account-strip-lbl { display: block; font-size: 11px; color: var(--text-muted); }
.account-strip-name { display: block; font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text-main); }
.account-strip-actions { display: flex; align-items: center; gap: 6px; }

.settings-card {
  margin-bottom: 14px;
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
}
.settings-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.settings-card-title { font-size: 12px; font-weight: 600; color: var(--text-sub); }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.kv-item { padding: 7px 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.03); min-width: 0; }
.kv-item > span { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 1px; }
.kv-item strong { display: block; font-size: 12.5px !important; font-weight: 600; color: var(--text-main); overflow-wrap: anywhere; }
.accent-text { color: var(--accent-cyan); }
.info-text { color: var(--sky); }

.section-divider {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 2px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.section-divider > span { font-size: 12px; font-weight: 600; color: var(--text-sub); }
.section-divider-plain { border-top: none; padding-top: 0; margin-top: 0; }

/* Security modal */
.sec-sec-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13.5px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.sec-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 999px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em;
  color: var(--text-sub); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
}
.sec-badge.protected { color: var(--up); background: var(--accent-green-bg); border-color: var(--accent-green-border); }
.sec-badge.open { color: var(--warn); background: var(--accent-amber-bg); border-color: var(--accent-amber-border); }
.sec-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.sec-desc b { color: var(--text-sub); }
.sec-form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.security-section + .security-section { padding-top: 16px; border-top: 1px solid var(--line); }
.sec-share-box { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.022); }
.sec-share-box-info { border-color: rgba(122, 184, 255, 0.25); background: rgba(122, 184, 255, 0.05); }
.sec-share-lbl { font-size: 12px; font-weight: 600; color: var(--text-sub); }
.sec-share-note { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }
.sec-tip-box { padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.018); font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.sec-tip-box > b { color: var(--text-sub); }
.sec-tip-box ol { margin: 4px 0 0 18px; }
.sec-tip-box li { margin: 2px 0; }
.tg-bot-brand-preview { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); }
.tg-bot-avatar-circle { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-strong); }
.tg-bot-text { flex: 1; min-width: 180px; }
.tg-bot-title { font-size: 12.5px; font-weight: 600; color: var(--text-main); }
.tg-bot-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* PnL modal */
.pnl-modal-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap;
  padding: 9px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
}
.pnl-control { display: flex; align-items: center; gap: 8px; }
.pnl-check { cursor: pointer; font-size: 12.5px; color: var(--text-sub); }
.pnl-canvas-frame { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #050607; }
#pnlCanvas { display: block; width: 100%; height: auto; }

/* Legal */
.legal-terms-scroll {
  max-height: 46vh;
  overflow-y: auto;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
}
.legal-terms-scroll-tall { max-height: 55vh; }
.legal-terms-scroll p { font-size: 12.5px; line-height: 1.7; color: var(--text-muted); }
.legal-terms-scroll p + p { margin-top: 10px; }
.legal-terms-scroll b { color: var(--text-sub); }
.legal-version { font-size: 11.5px !important; color: var(--text-dim) !important; }

/* Guide */
.guide-modal { max-height: calc(100dvh - 48px); }
.guide-scroll-container { padding: 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
.guide-step-card { margin-top: 8px; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.018); }
.guide-step-title { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-main); letter-spacing: -0.01em; }
.guide-step-num {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600;
  color: var(--accent-cyan);
  background: var(--accent-soft);
  border: 1px solid var(--accent-cyan-border);
}
.guide-step-body { margin: 8px 0 0 32px; font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }
.guide-step-body ul { margin: 4px 0 0 16px; }
.guide-step-body li { margin: 2px 0; }
.guide-step-body b { color: var(--text-sub); }
.guide-step-body a { color: var(--accent-cyan); text-underline-offset: 3px; }

/* Auth (dashboard login) */
.modal-overlay-auth {
  background:
    radial-gradient(700px 380px at 50% 0%, color-mix(in srgb, var(--accent-cyan) 9%, transparent), transparent 70%),
    rgba(8, 9, 11, 0.94);
  -webkit-backdrop-filter: blur(16px);
          backdrop-filter: blur(16px);
}
.auth-card { max-width: 400px; border-radius: 16px; }
.auth-hero {
  position: relative;
  height: 104px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 100% 26px,
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  overflow: hidden;
}
.auth-hero-chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-hero-line { fill: none; stroke: var(--accent-cyan); stroke-width: 1.75; vector-effect: non-scaling-stroke; }
.auth-hero-level { fill: none; stroke: rgba(255, 255, 255, 0.22); stroke-width: 1; stroke-dasharray: 2 5; vector-effect: non-scaling-stroke; }
.auth-hero-dot { fill: var(--bg-elevated); stroke: var(--accent-cyan); stroke-width: 2; vector-effect: non-scaling-stroke; }
.auth-header {
  flex-direction: column;
  gap: 0;
  padding: 0 22px 2px;
  margin-top: -27px;
  border-bottom: none;
  text-align: center;
  position: relative;
}
.auth-header .brand-mark { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 4px var(--bg-elevated); }
.auth-header h2 { margin-top: 12px; font-size: 18px; letter-spacing: -0.02em; }
.auth-sub { margin-top: 1px; font-size: 12.5px; color: var(--text-muted); }
.auth-card .modal-body { padding: 18px 22px 20px; }
.auth-card .sub-tab-group-center { margin-bottom: 16px; }
.auth-notes { display: grid; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.auth-note { display: flex; gap: 9px; font-size: 11.5px; line-height: 1.55; color: var(--text-muted); }
.auth-note .i { width: 13px; height: 13px; margin-top: 2px; color: var(--text-dim); }
.auth-note b { color: var(--text-sub); }
.auth-note-legal { display: block; padding-left: 22px; font-size: 11px; color: var(--text-dim); }

/* --------------------------------------------------------------------------
   11. Utilities
   -------------------------------------------------------------------------- */
.bull-text { color: var(--up); }
.bear-text { color: var(--down); }
.mt-2 { margin-top: 6px; }
.mt-3 { margin-top: 10px; }
.mt-4 { margin-top: 14px; }
.mb-2 { margin-bottom: 6px; }
.mb-3 { margin-bottom: 12px; }

body.viewer-readonly-mode .hl-1click-exec-btn { display: none !important; }

/* --------------------------------------------------------------------------
   12. Script-generated markup refinements
   (inline styles come from app.js templates — normalise shape, not meaning)
   -------------------------------------------------------------------------- */
#hlPagePositionsList > div[style*="dashed"],
#txflowPagePositionsList > div[style*="dashed"],
#hlPageExecutionsList > div[style*="dashed"],
#txflowPageExecutionsList > div[style*="dashed"],
#allTradesContainer > .empty-state {
  border-radius: var(--radius-md) !important;
  border-color: var(--line-strong) !important;
  background: rgba(255, 255, 255, 0.012) !important;
  padding: 26px 18px !important;
}
#hlPagePositionsList > div:not([class]):not([style*="dashed"]),
#hlPageExecutionsList > div:not([class]):not([style*="dashed"]),
#txflowPageExecutionsList > div:not([class]):not([style*="dashed"]),
#hlPositionsContainer > div:not([class]),
#txflowPositionsContainer > div:not([class]) {
  font-size: 12.5px !important;
}
.pt-actions-row .btn-xs,
.portfolio-trade-card .btn-xs,
#hlPagePositionsList .btn-xs,
#txflowPagePositionsList .btn-xs {
  height: 28px !important;
  padding: 0 10px !important;
  border-radius: var(--radius-sm) !important;
  font-family: var(--font-ui) !important;
  font-size: 12px !important;
}
.signals-table td span[style*="border-radius"] { border-radius: 5px !important; letter-spacing: 0.02em; }
#hlExecTableContainer, #txflowExecTableContainer { max-height: 380px !important; }
.portfolio-trade-card [style*="font-size: 20px"]:empty { display: none; }
#hlPositionsContainer > div[style*="background"], #txflowPositionsContainer > div[style*="background"] { border-radius: var(--radius-md) !important; }

/* --------------------------------------------------------------------------
   13. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1360px) {
  .main-grid { grid-template-columns: minmax(0, 1fr) 296px; }
  .all-trades-grid { grid-template-columns: 1fr; }
}

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

@media (max-width: 1100px) {
  :root { --gutter: 18px; }

  .left-utility-rail {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(280px, 86vw);
    background: var(--bg-elevated);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease), box-shadow 0.25s;
    z-index: 200;
  }
  .left-utility-rail.collapsed { width: min(280px, 86vw); }
  .left-utility-rail.collapsed .rail-content { display: flex; }
  .left-utility-rail.mobile-open {
    transform: none;
    box-shadow: 0 0 0 100vmax rgba(4, 5, 7, 0.6), 24px 0 60px rgba(0, 0, 0, 0.5);
  }
  .rail-collapse-tab,
  .left-utility-rail.collapsed .rail-collapse-tab {
    position: absolute;
    top: 14px; right: 10px;
    opacity: 1;
    width: 30px; height: 30px;
    padding: 0;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    box-shadow: none;
  }
  .left-utility-rail.collapsed .rail-toggle-arrow { transform: none; }
  .left-utility-rail.collapsed .rail-vertical-label { display: none; }
  .rail-brand-block { padding-right: 40px; }

  .main-view-switcher-bar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 0 var(--gutter);
  }
  .main-view-switcher-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
  }
  .mobile-brand-heading { display: flex; align-items: center; gap: 9px; }
  .mobile-brand-heading .brand-mark { width: 26px; height: 26px; border-radius: 7px; }
  .mobile-brand-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
  .view-toggle-group { height: 40px; margin: 0 calc(var(--gutter) * -1); padding: 0 calc(var(--gutter) - 10px); border-top: 1px solid var(--line-soft); }
  .view-toggle-btn { font-size: 12.5px; }

  .main-grid { grid-template-columns: minmax(0, 1fr); }
  .sidebar-section { position: static; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  :root { --gutter: 14px; --gap: 10px; }

  .ticker-nav-bar { margin-top: 10px; }
  .nav-lbl { display: none; }
  .ticker-nav-left { margin: 0 calc(var(--gutter) * -1); }
  .ticker-tabs { padding: 1px var(--gutter); }

  .stats-grid { gap: 8px; }
  .stat-card { padding: 11px 12px 10px; border-radius: 10px; }
  .stat-label { font-size: 9.5px; }
  .stat-value { font-size: 15px; margin-top: 4px; }
  .bias-card .stat-value { font-size: 12.5px; }
  .stat-sub { font-size: 11px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .meter-labels { font-size: 9.5px; }

  .panel-box { padding: 12px; border-radius: 10px; }
  .panel-header { margin-bottom: 10px; }
  .panel-icon { display: none; }
  .panel-sub { display: none; }
  .chart-legend-pill { display: none; }

  .trade-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trade-box.entry { grid-column: 1 / -1; }
  .radar-targets-row { grid-template-columns: 1fr; }
  .radar-item-left { flex-direction: column; gap: 0; }
  .pt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-targets-row { grid-template-columns: 1fr; }
  .all-trades-grid { grid-template-columns: 1fr; }
  .backtest-form { grid-template-columns: 1fr 1fr; }
  .form-group-action { grid-column: 1 / -1; }
  .form-group-action .btn-primary { width: 100%; }
  .portfolio-calc-bar { flex-direction: column; align-items: stretch; }
  .input-with-symbol { width: 100%; }
  .calc-summary-chip { margin-left: 0; align-items: flex-start; }
  .portfolio-stats-ribbon { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .p-stat-val { font-size: 14px; }

  .form-row-2, .sec-form-row { grid-template-columns: 1fr; }

  .terminal-brand-footer { flex-direction: column; align-items: flex-start; margin-top: 22px; }
  .legal-disclaimer-strip { flex-direction: column; align-items: flex-start; gap: 8px; }

  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal-box, .modal-card { max-height: calc(100dvh - 20px); border-radius: 14px; }
  .modal-overlay-auth { align-items: center; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 11px 14px; }
  .auth-card .modal-body { padding: 16px 16px 18px; }
  .guide-step-body { margin-left: 0; }
  .btn-row { flex-wrap: wrap; }
  .btn-row > * { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  .backtest-form { grid-template-columns: 1fr; }
  .trade-footer > div:last-child { width: 100%; }
  .trade-footer > div:last-child > * { flex: 1 1 auto; }
  .kv-grid { grid-template-columns: 1fr; }
  .chart-tf-btn { padding: 0 7px; }
  .hl-risk-banner-items .rb-item { flex: 1 1 calc(50% - 4px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
