/*
 * TradePulse — Design System + Application Shell
 * ==============================================
 *
 * Loaded AFTER the legacy inline <style> blocks in index.html, so
 * everything here wins by source order without needing !important.
 *
 * Structure:
 *   1. Tokens
 *   2. Reset / base
 *   3. Layout shell (topbar, sidebar, bottom nav, views)
 *   4. Primitives (card, panel, button, input, badge, table, tabs,
 *      modal, drawer, tooltip, empty/loading state)
 *   5. Feature blocks (scanner, KPI strip, positions, reports, AI)
 *   6. Responsive
 *   7. RTL
 *
 * Maintenance rule: add to a primitive, do not invent a one-off.
 */

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  /* Surfaces — four steps, no more. */
  --tp-bg:            #0C1019;
  --tp-surface:       #111722;
  --tp-surface-2:     #181F2E;
  --tp-surface-3:     #202A3A;

  /* Borders */
  --tp-border:        #1e2739;
  --tp-border-2:      #2a3549;
  --tp-border-strong: #3a4863;

  /* Text */
  --tp-text:          #e8eef9;
  --tp-text-2:        #b3c0d6;
  --tp-text-3:        #7c8aa3;
  --tp-text-dim:      #5a6880;
  --tp-text-secondary:var(--tp-text-2);
  --tp-text-muted:    var(--tp-text-3);
  --tp-positive:      var(--tp-long);
  --tp-negative:      var(--tp-short);
  --tp-accent:        var(--tp-info);
  --tp-chart-bg:      #0b1220;
  --tp-chart-grid:    #172236;

  /* Trading state — used to communicate state, never decoration. */
  --tp-long:          #10b981;
  --tp-long-dim:      #0b7a5a;
  --tp-long-bg:       rgba(16,185,129,.10);
  --tp-short:         #f43f5e;
  --tp-short-dim:     #9f1239;
  --tp-short-bg:      rgba(244,63,94,.10);
  --tp-warn:          #f59e0b;
  --tp-warn-bg:       rgba(245,158,11,.10);
  --tp-info:          #3b82f6;
  --tp-info-bg:       rgba(59,130,246,.10);
  --tp-neutral:       #64748b;

  /* Radius — small and consistent; terminals are not rounded. */
  --tp-r-sm: 3px;
  --tp-r:    5px;
  --tp-r-lg: 7px;

  /* Spacing scale */
  --tp-s1: 4px;
  --tp-s2: 8px;
  --tp-s3: 12px;
  --tp-s4: 16px;
  --tp-s5: 24px;

  /* Public design-system scale. Keep the legacy aliases above so existing
     production views inherit the same rhythm without a migration. */
  --tp-space-1: 4px;
  --tp-space-2: 8px;
  --tp-space-3: 12px;
  --tp-space-4: 16px;
  --tp-space-5: 20px;
  --tp-space-6: 24px;

  /* Typography */
  --tp-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --tp-mono: 'SF Mono', 'JetBrains Mono', 'Roboto Mono', ui-monospace, monospace;

  --tp-fs-xs: 11px;
  --tp-fs-sm: 12px;
  --tp-fs-md: 14px;
  --tp-fs-lg: 16px;
  --tp-fs-xl: 20px;
  --tp-fs-2xl: 26px;
  --tp-font-xs: 11px;
  --tp-font-sm: 13px;
  --tp-font-md: 14px;
  --tp-font-lg: 16px;
  --tp-font-xl: 24px;
  --tp-line-tight: 1.25;
  --tp-line-normal: 1.5;
  --tp-control-sm: 36px;
  --tp-control-md: 40px;
  --tp-control-lg: 44px;
  --tp-icon-sm: 16px;
  --tp-icon-md: 20px;
  --tp-icon-lg: 24px;
  --tp-radius-sm: 4px;
  --tp-radius-md: 6px;

  /* Semantic aliases used by application-level components. */
  --tp-text-primary: var(--tp-text);
  --tp-surface-raised: var(--tp-surface-2);
  --tp-hover: var(--tp-surface-2);
  --tp-selected: var(--tp-info-bg);
  --tp-warning: var(--tp-warn);

  --tp-shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --tp-shadow-2: 0 4px 16px rgba(0,0,0,.5);
  --tp-shadow-3: 0 12px 40px rgba(0,0,0,.6);
  --tp-backdrop: rgba(3,6,12,.68);

  /* Shell metrics */
  --tp-topbar-h: 56px;
  --tp-sidebar-w: 228px;
  --tp-bottomnav-h: 58px;

  --bg:var(--tp-bg);--surface:var(--tp-surface);--surface-elevated:var(--tp-surface-2);--surface-muted:var(--tp-surface-3);
  --border:var(--tp-border);--text-primary:var(--tp-text);--text-secondary:var(--tp-text-2);--text-muted:var(--tp-text-3);
  --accent:var(--tp-info);--success:var(--tp-long);--warning:var(--tp-warn);--danger:var(--tp-short);--info:var(--tp-info);
}

/* Persian needs a font stack that actually has the glyphs. */
html[lang="fa"] {
  --tp-font: 'IRANSans', 'Vazirmatn', 'Noto Sans Arabic', Tahoma, 'Segoe UI', system-ui, sans-serif;
}

/* Comfortable density bumps the vertical rhythm only. */
body.tp-density-comfortable {
  --tp-s2: 10px;
  --tp-s3: 15px;
  --tp-s4: 20px;
}

html[data-theme="light"],
body.tp-theme-light {
  --tp-bg: #F4F6F9;
  --tp-surface: #FFFFFF;
  --tp-surface-2: #EDF1F7;
  --tp-surface-3: #DDE4EC;
  --tp-border: #C1CBD8;
  --tp-border-2: #B3BFCE;
  --tp-border-strong: #8C9AAF;
  --tp-text: #1A2536;
  --tp-text-2: #3B4A5E;
  --tp-text-3: #58697D;
  --tp-text-dim: #8897AB;
  --tp-text-primary: #1A2536;
  --tp-text-secondary: #3B4A5E;
  --tp-text-muted: #58697D;
  --tp-surface-raised: #FFFFFF;
  --tp-hover: #D8E2EE;
  --tp-selected: #D4E2F8;
  --tp-long: #15803D;
  --tp-short: #B91C1C;
  --tp-info: #2563EB;
  --tp-chart-bg: #F4F6F9;
  --tp-chart-grid: #CBD5E1;
  --tp-shadow-1: 0 1px 3px rgba(15,23,42,.07);
  --tp-shadow-2: 0 4px 14px rgba(15,23,42,.09);
  --tp-shadow-3: 0 10px 32px rgba(15,23,42,.13);
  --tp-backdrop: rgba(15,23,42,.45);
}

/* ============================================================
   2. RESET / BASE
   ============================================================ */
html, body {
  background: var(--tp-bg);
  color: var(--tp-text);
  font-family: var(--tp-font);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  padding: 0;
}

*, *::before, *::after { box-sizing: border-box; }

body.tp-app {
  /* The shell owns scrolling per-view, not the document. */
  min-height: 100vh;
  overflow-x: hidden;
}

.tp-num,
.tp-table td,
.tp-kpi-value,
:root { --tp-scan-columns: minmax(132px,1.55fr) 74px minmax(82px,1fr) 82px 82px 86px minmax(108px,.95fr) repeat(4,minmax(86px,1fr)) 52px 28px; }

.tp-scan-row {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--tp-surface); }
::-webkit-scrollbar-thumb {
  background: var(--tp-border-2);
  border-radius: var(--tp-r-sm);
}
::-webkit-scrollbar-thumb:hover { background: var(--tp-border-strong); }

:focus-visible {
  outline: 2px solid var(--tp-info);
  outline-offset: 1px;
}

/* ============================================================
   3. LAYOUT SHELL
   ============================================================ */

/* --- Topbar --- */
.tp-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--tp-topbar-h);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: var(--tp-s3);
  padding: 0 var(--tp-s3);
  background: var(--tp-surface);
  border-bottom: 1px solid var(--tp-border);
}

.tp-topbar-logo,
.tp-logo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--tp-fs-lg);
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--tp-text);
  text-decoration: none;
  white-space: nowrap;
}
.tp-topbar-logo span { color: var(--tp-long); }
.tp-logo-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--tp-info), var(--tp-long));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  box-shadow: 0 5px 16px rgba(20,184,166,.18);
}
.tp-logo-text { color: var(--tp-text); }

.tp-topbar-spacer { flex: 1; }

.tp-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--tp-s2);
}

.tp-global-theme{display:flex;align-items:center;gap:1px;padding:1px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-2)}
.tp-global-theme button{display:inline-flex;align-items:center;justify-content:center;gap:3px;height:26px;padding:0 5px;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--tp-text-secondary);font:600 11px/1 var(--tp-font);cursor:pointer}
.tp-global-theme button:hover{background:var(--tp-hover);color:var(--tp-text-primary)}
.tp-global-theme button.is-active{border-color:color-mix(in srgb,var(--tp-accent) 45%,var(--tp-border));background:var(--tp-selected);color:var(--tp-accent)}
.tp-global-theme svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* Live status pill */
.tp-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--tp-border-2);
  border-radius: 999px;
  font-size: var(--tp-fs-sm);
  color: var(--tp-text-2);
  background: var(--tp-surface-2);
  white-space: nowrap;
}
.tp-status-dot,
.tp-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--tp-neutral);
  flex: none;
}
.tp-dot.is-ok { background: var(--tp-long); }
.tp-status.is-live .tp-status-dot { background: var(--tp-long); }
.tp-status.is-error .tp-status-dot { background: var(--tp-short); }

/* Hamburger — mobile only */
.tp-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px; height: 36px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r);
  cursor: pointer;
}
.tp-hamburger span {
  display: block;
  height: 1.5px;
  background: var(--tp-text-2);
  border-radius: 2px;
}

/* --- Account menu --- */
.tp-account { position: relative; }

.tp-account-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r);
  color: var(--tp-text-2);
  cursor: pointer;
  font-size: var(--tp-fs-sm);
  font-family: inherit;
}
.tp-account-btn:hover { border-color: var(--tp-border-strong); }

.tp-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tp-info), var(--tp-long));
  color: #fff;
  font-size: var(--tp-fs-xs);
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}

.tp-account-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 220px;
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r-lg);
  box-shadow: var(--tp-shadow-3);
  padding: var(--tp-s1);
  z-index: 300;
  display: none;
}
.tp-account-menu.is-open { display: block; }

.tp-account-head {
  padding: var(--tp-s2) var(--tp-s3);
  border-bottom: 1px solid var(--tp-border);
  margin-bottom: var(--tp-s1);
}
.tp-account-name { font-size: var(--tp-fs-md); font-weight: 600; }
.tp-account-sub  { font-size: var(--tp-fs-sm); color: var(--tp-text-3); }

.tp-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tp-s2);
  width: 100%;
  padding: 7px var(--tp-s3);
  background: none;
  border: 0;
  border-radius: var(--tp-r);
  color: var(--tp-text-2);
  font-size: var(--tp-fs-md);
  font-family: inherit;
  text-align: start;
  cursor: pointer;
}
.tp-menu-item:hover { background: var(--tp-surface-3); color: var(--tp-text); }
.tp-menu-item.is-danger { color: var(--tp-short); }
.tp-menu-sep { height: 1px; background: var(--tp-border); margin: var(--tp-s1) 0; }
.tp-menu-value { font-size: var(--tp-fs-sm); color: var(--tp-text-3); }

/* --- Sidebar ---
   The scrim sits between the page and the off-canvas sidebar on
   narrow viewports. It is inert (display:none) at desktop widths,
   where the sidebar is permanently docked and must not be dimmed. */
.tp-scrim {
  position: fixed;
  inset: var(--tp-topbar-h) 0 0 0;
  background: var(--tp-backdrop);
  z-index: 140;
  display: none;
}

.tp-side {
  position: fixed;
  top: var(--tp-topbar-h);
  inset-inline-start: 0;
  bottom: 0;
  width: var(--tp-sidebar-w);
  z-index: 150;
  background: var(--tp-surface);
  border-inline-end: 1px solid var(--tp-border);
  padding: var(--tp-space-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--tp-s3);
}

.tp-side-group-title {
  font-size: var(--tp-fs-xs);
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--tp-text-dim);
  padding: 0 var(--tp-s2) var(--tp-s1);
}

.tp-side-link {
  display: flex;
  align-items: center;
  gap: var(--tp-s2);
  min-height: 44px;
  padding: 6px 12px;
  border-radius: var(--tp-r);
  color: var(--tp-text-2);
  font-size: var(--tp-fs-md);
  text-decoration: none;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  font-family: inherit;
  text-align: start;
}
.tp-side-link:hover { background: var(--tp-surface-2); color: var(--tp-text); }

.tp-side-link.is-active {
  background: var(--tp-info-bg);
  color: var(--tp-text);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--tp-info);
}
[dir="rtl"] .tp-side-link.is-active {
  box-shadow: inset -2px 0 0 var(--tp-info);
}

.tp-side-ico,
.tp-side-ic {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 6px;
  color: var(--tp-icon-accent, var(--tp-info));
  background: color-mix(in srgb, var(--tp-icon-accent, var(--tp-info)) 9%, transparent);
  opacity: 1;
}
.tp-icon-sprite{position:absolute;width:0;height:0;overflow:hidden;pointer-events:none}
.tp-side-ic svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tp-side-ic--blue{--tp-icon-accent:#2563EB}.tp-side-ic--cyan{--tp-icon-accent:#0891B2}.tp-side-ic--violet{--tp-icon-accent:#7C3AED}.tp-side-ic--teal{--tp-icon-accent:#0F766E}.tp-side-ic--green{--tp-icon-accent:#15803D}.tp-side-ic--amber{--tp-icon-accent:#B45309}.tp-side-ic--indigo{--tp-icon-accent:#4F46E5}.tp-side-ic--purple{--tp-icon-accent:#9333EA}.tp-side-ic--slate{--tp-icon-accent:#64748B}
.tp-side-link:hover .tp-side-ic,.tp-side-link.is-active .tp-side-ic{background:color-mix(in srgb,var(--tp-icon-accent,var(--tp-info)) 14%,transparent)}

.tp-side-foot {
  margin-top: auto;
  padding: var(--tp-s2);
  border-top: 1px solid var(--tp-border);
}

/* --- Content region --- */
.tp-main {
  padding-top: var(--tp-topbar-h);
  padding-inline-start: var(--tp-sidebar-w);
  min-height: 100vh;
}

.tp-view {
  display: none;
  padding: var(--tp-space-2) var(--tp-space-3) var(--tp-space-3);
  max-width: 1800px;
  margin: 0 auto;
}
.tp-view.is-active { display: block; }

.tp-view-head {
  display: flex;
  align-items: center;
  gap: var(--tp-s3);
  margin-bottom: var(--tp-space-2);
  flex-wrap: wrap;
}
.tp-view-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -.3px;
}
.tp-view-sub {
  font-size: var(--tp-fs-sm);
  color: var(--tp-text-3);
}

/* --- Bottom navigation (mobile) --- */
.tp-bottomnav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tp-bottomnav-h);
  z-index: 200;
  background: var(--tp-surface);
  border-top: 1px solid var(--tp-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tp-bottomnav {
  grid-template-columns: repeat(5, minmax(0,1fr));
}
.tp-bottomnav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: var(--tp-bottomnav-h);
}
.tp-bottom-link,
.tp-bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: 0;
  color: var(--tp-text-3);
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  padding: 0 2px;
}
.tp-bottom-link .tp-side-ico,
.tp-bn-ic { font-size: 17px; line-height: 1; }
.tp-bottom-link.is-active,
.tp-bn-item.is-active { color: var(--tp-info); }

/* ============================================================
   4. PRIMITIVES
   ============================================================ */

/* --- Grid helpers --- */
.tp-grid { display: grid; gap: var(--tp-s3); }
.tp-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.tp-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.tp-grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.tp-grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
/* The workspace split: chart-priority left, rail right. */
.tp-split-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--tp-s3);
  align-items: start;
}

/* Markets launches the single analytical workspace; this is deliberately a
   compact hand-off card rather than a second chart-sized placeholder. */
.tp-markets-launch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--tp-space-3);
  min-height: 0;
}
.tp-markets-launch .tp-c-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}
.tp-markets-launch .tp-chart-note {
  color: var(--tp-text-secondary);
  font-size: var(--tp-font-md);
  line-height: var(--tp-line-normal);
}
.tp-markets-launch > .tp-btn { min-height: var(--tp-control-md); }

@media (max-width: 600px) {
  .tp-markets-launch { grid-template-columns: 1fr; }
  .tp-markets-launch > .tp-btn { width: 100%; min-height: var(--tp-control-lg); }
}

/* --- Card / panel --- */
.tp-c {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r-lg);
  padding: var(--tp-s3);
}
.tp-c-flush { padding: 0; overflow: hidden; }

.tp-c-head {
  display: flex;
  align-items: center;
  gap: var(--tp-s2);
  padding-bottom: var(--tp-s2);
  margin-bottom: var(--tp-s2);
  border-bottom: 1px solid var(--tp-border);
}
.tp-c-flush > .tp-c-head {
  padding: var(--tp-s2) var(--tp-s3);
  margin-bottom: 0;
}
.tp-c-title {
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--tp-text-2);
  margin: 0;
}
.tp-c-actions { margin-inline-start: auto; display: flex; gap: var(--tp-s1); }

/* --- Buttons --- */
.tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r);
  color: var(--tp-text-2);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.tp-btn:hover:not(:disabled) {
  background: var(--tp-hover);
  border-color: var(--tp-border-strong);
  color: var(--tp-text);
}
.tp-btn:disabled { opacity: .62; cursor: not-allowed; color:var(--tp-text-muted); }

.tp-btn-primary {
  background: var(--tp-info);
  border-color: var(--tp-info);
  color: #fff;
  font-weight: 600;
}
.tp-btn-primary:hover:not(:disabled) { filter: brightness(1.1); background: var(--tp-info); }

.tp-btn-long  { background: var(--tp-long-bg);  border-color: var(--tp-long-dim);  color: var(--tp-long); }
.tp-btn-short { background: var(--tp-short-bg); border-color: var(--tp-short-dim); color: var(--tp-short); }
.tp-btn-ghost { background: transparent; border-color: transparent; }
.tp-btn-danger { background: var(--tp-short-bg); border-color: var(--tp-short-dim); color: var(--tp-short); font-weight:650; }
.tp-btn-danger:hover:not(:disabled) { background: color-mix(in srgb,var(--tp-short) 18%,var(--tp-surface)); border-color:var(--tp-short); color:var(--tp-short); }
.tp-btn-sm { padding: 3px 7px; font-size: var(--tp-fs-sm); }
.tp-btn-icon { padding: 5px 7px; }

/* --- Segmented control --- */
.tp-seg {
  display: inline-flex;
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r);
  padding: 2px;
  gap: 2px;
}
.tp-seg button {
  padding: 4px 10px;
  background: none;
  border: 0;
  border-radius: var(--tp-r-sm);
  color: var(--tp-text-3);
  font-family: inherit;
  font-size: var(--tp-fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tp-seg button:hover { color: var(--tp-text-2); }
.tp-seg button.is-active { background: var(--tp-surface-3); color: var(--tp-text); }
.tp-seg button.is-active[data-side="LONG"]  { background: var(--tp-long-bg);  color: var(--tp-long); }
.tp-seg button.is-active[data-side="SHORT"] { background: var(--tp-short-bg); color: var(--tp-short); }

/* --- Inputs --- */
.tp-in, .tp-sel {
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r);
  color: var(--tp-text);
  font-family: inherit;
  font-size: 14px;
  min-height: 40px;
  padding: 8px 11px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .12s ease;
}
.tp-in:hover, .tp-sel:hover { border-color: var(--tp-border-strong); }
.tp-in:focus, .tp-sel:focus {
  border-color: var(--tp-info);
  background: var(--tp-surface-3);
  outline: none;
}
.tp-in::placeholder { color: var(--tp-text-dim); }
.tp-sel { cursor: pointer; }
textarea.tp-in { min-height: 62px; resize: vertical; }

.tp-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tp-label {
  font-size: var(--tp-fs-xs);
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--tp-text-3);
}

/* Switch */
.tp-switch {
  position: relative;
  display: inline-block;
  width: 34px; height: 18px;
  flex: none;
}
.tp-switch input { opacity: 0; width: 0; height: 0; }
.tp-switch-track {
  position: absolute;
  inset: 0;
  background: var(--tp-surface-3);
  border: 1px solid var(--tp-border-2);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease;
}
.tp-switch-track::before {
  content: '';
  position: absolute;
  top: 2px; inset-inline-start: 2px;
  width: 12px; height: 12px;
  background: var(--tp-text-3);
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease;
}
.tp-switch input:checked + .tp-switch-track {
  background: var(--tp-info-bg);
  border-color: var(--tp-info);
}
.tp-switch input:checked + .tp-switch-track::before {
  background: var(--tp-info);
  transform: translateX(16px);
}
[dir="rtl"] .tp-switch input:checked + .tp-switch-track::before {
  transform: translateX(-16px);
}

.tp-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tp-s3);
  padding: 7px 0;
  border-bottom: 1px solid var(--tp-border);
}
.tp-switch-row:last-child { border-bottom: 0; }
.tp-switch-label { font-size: var(--tp-fs-md); color: var(--tp-text-2); }
/* Button-based switch (reusable compact pill toggle) */
.tp-switch-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 36px;
  height: 20px;
  padding: 2px;
  background: var(--tp-surface-3);
  border: 1px solid var(--tp-border-2);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
  flex: none;
  vertical-align: middle;
}
.tp-switch-btn:hover {
  border-color: var(--tp-border-strong);
}
.tp-switch-btn:focus-visible {
  outline: 2px solid var(--tp-info);
  outline-offset: 2px;
}
.tp-switch-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.tp-switch-knob {
  display: block;
  width: 14px;
  height: 14px;
  background: var(--tp-text-3);
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  pointer-events: none;
}
.tp-switch-btn.is-on {
  background: var(--tp-info);
  border-color: var(--tp-info);
}
.tp-switch-btn.is-on .tp-switch-knob {
  background: #fff;
  transform: translateX(16px);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
[dir="rtl"] .tp-switch-btn.is-on .tp-switch-knob {
  transform: translateX(-16px);
}
body.tp-theme-light .tp-switch-btn {
  background: var(--tp-surface-3);
  border-color: var(--tp-border-2);
}
body.tp-theme-light .tp-switch-btn:hover {
  border-color: var(--tp-border-strong);
}
body.tp-theme-light .tp-switch-btn.is-on {
  background: var(--tp-info);
  border-color: var(--tp-info);
}
body.tp-theme-light .tp-switch-btn.is-on .tp-switch-knob {
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.18);
}

/* --- Badges / status --- */
.tp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--tp-r-sm);
  font-size: var(--tp-fs-xs);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: none;
  white-space: normal;
  overflow-wrap:normal;
  word-break:normal;
  border: 1px solid transparent;
}
.tp-badge-long    { background:#0b3b2c; color:#b7f7dc; border-color:#15805d; }
.tp-badge-short   { background:#541827; color:#ffd2da; border-color:#a72a48; }
.tp-badge-neutral { background: var(--tp-surface-3); color: var(--tp-text-3); border-color: var(--tp-border-2); }
.tp-badge-warn    { background:#49350b; color:#ffe29a; border-color:#9d7417; }
.tp-badge-info    { background:#12365d; color:#d0e8ff; border-color:#286ca6; }

.tp-pnl-pos { color: var(--tp-long); }
.tp-pnl-neg { color: var(--tp-short); }
.tp-position-entry { color: var(--tp-info); }
.tp-position-risk { color: var(--tp-short); }
.tp-position-target { color: var(--tp-long); }
.tp-position-missing { color: var(--tp-text-muted); }
.tp-pnl-flat { color: var(--tp-text-3); }

body.tp-theme-light .tp-badge-long{background:#d9fbe9;color:#07583d;border-color:#49a984}
body.tp-theme-light .tp-badge-short{background:#ffe0e5;color:#8b1530;border-color:#d2647c}
body.tp-theme-light .tp-badge-warn{background:#fff0bd;color:#694500;border-color:#bd8b19}
body.tp-theme-light .tp-badge-info{background:#dceeff;color:#084f85;border-color:#4d94c5}
html[lang="fa"] .tp-num,html[lang="fa"] .tp-t-num,html[lang="fa"] [data-symbol],html[lang="fa"] .tp-chart-symbol-picker{direction:ltr;unicode-bidi:isolate;font-family:var(--tp-mono)}

/* Score bar */
.tp-score {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 62px;
}
.tp-score-track {
  flex: 1;
  height: 3px;
  background: var(--tp-surface-3);
  border-radius: 2px;
  overflow: hidden;
  min-width: 26px;
}
.tp-score-fill { height: 100%; border-radius: 2px; }
.tp-score-fill.is-long  { background: var(--tp-long); }
.tp-score-fill.is-short { background: var(--tp-short); }
.tp-score-fill.is-flat  { background: var(--tp-neutral); }
.tp-score-val { font-size: var(--tp-fs-sm); color: var(--tp-text-2); min-width: 18px; text-align: end; }

/* --- KPI --- */
.tp-kpi {
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r);
  padding: var(--tp-s2) var(--tp-s3);
  min-width: 0;
}
.tp-kpi-label {
  font-size: var(--tp-fs-xs);
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--tp-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tp-kpi-value {
  font-size: var(--tp-fs-xl);
  font-weight: 650;
  margin-top: 2px;
  letter-spacing: -.3px;
  line-height: 1.15;
}
.tp-kpi-sub { font-size: var(--tp-fs-sm); color: var(--tp-text-3); margin-top: 1px; }
.tp-kpi-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: var(--tp-s2);
  margin-bottom: var(--tp-s3);
}

/* --- Table --- */
.tp-table { width: 100%; border-collapse: collapse; font-size: var(--tp-fs-md); }
.tp-table thead th {
  text-align: start;
  padding: 7px var(--tp-s2);
  font-size: var(--tp-fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--tp-text-dim);
  background: var(--tp-surface-2);
  border-bottom: 1px solid var(--tp-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.tp-table tbody td {
  padding: 6px var(--tp-s2);
  border-bottom: 1px solid var(--tp-border);
  color: var(--tp-text-2);
  white-space: nowrap;
}
.tp-table tbody tr:hover td { background: var(--tp-surface-2); }
.tp-table tbody tr:last-child td { border-bottom: 0; }
.tp-table .tp-t-num { text-align: end; font-variant-numeric: tabular-nums; }
.tp-table .tp-t-sym { color: var(--tp-text); font-weight: 600; }

.tp-scroll-y { overflow-y: auto; }
.tp-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- Tabs --- */
.tp-tabs {
  display: flex;
  gap: var(--tp-s1);
  border-bottom: 1px solid var(--tp-border);
  margin-bottom: var(--tp-s3);
  overflow-x: auto;
  scrollbar-width: none;
}
.tp-tabs::-webkit-scrollbar { display: none; }
.tp-tab {
  padding: 7px var(--tp-s3);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--tp-text-3);
  font-family: inherit;
  font-size: var(--tp-fs-md);
  cursor: pointer;
  white-space: nowrap;
}
.tp-tab:hover { color: var(--tp-text-2); }
.tp-tab.is-active { color: var(--tp-text); border-bottom-color: var(--tp-info); font-weight: 600; }
.tp-tabpane { display: none; }
.tp-tabpane.is-active { display: block; }

/* --- Modal --- */
.tp-modal-back {
  position: fixed;
  inset: 0;
  background: var(--tp-backdrop);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--tp-s4);
}
.tp-modal-back.is-open { display: flex; }
.tp-modal {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r-lg);
  box-shadow: var(--tp-shadow-3);
  width: min(560px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.tp-modal-head {
  display: flex;
  align-items: center;
  padding: var(--tp-s3);
  border-bottom: 1px solid var(--tp-border);
}
.tp-modal-body { padding: var(--tp-s3); overflow-y: auto; }
.tp-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--tp-s2);
  padding: var(--tp-s3);
  border-top: 1px solid var(--tp-border);
}

/* --- Drawer --- */
.tp-drawer-back {
  position: fixed;
  inset: 0;
  background: var(--tp-backdrop);
  z-index: 350;
  display: none;
}
.tp-drawer-back.is-open { display: block; }
.tp-drawer {
  position: fixed;
  top: 0; bottom: 0;
  inset-inline-end: 0;
  width: min(420px, 92vw);
  background: var(--tp-surface);
  border-inline-start: 1px solid var(--tp-border-2);
  box-shadow: var(--tp-shadow-3);
  z-index: 360;
  transform: translateX(100%);
  transition: transform .2s ease;
  display: flex;
  flex-direction: column;
}
[dir="rtl"] .tp-drawer { transform: translateX(-100%); }
.tp-drawer.is-open { transform: translateX(0); }
.tp-drawer-head {
  display: flex;
  align-items: center;
  gap: var(--tp-s2);
  padding: var(--tp-s3);
  border-bottom: 1px solid var(--tp-border);
}
.tp-drawer-body { padding: var(--tp-s3); overflow-y: auto; flex: 1; }
.tp-chart-quick-settings{display:grid;gap:var(--tp-space-3)}
.tp-chart-quick-settings section{display:grid;gap:var(--tp-space-1);padding:var(--tp-space-2);border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-raised)}
.tp-chart-quick-settings h4{margin:0 0 var(--tp-space-1);color:var(--tp-text-secondary);font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}
.tp-chart-quick-settings .tp-setting-row{padding-block:7px}
.tp-chart-quick-settings-actions{display:flex;justify-content:flex-end;gap:var(--tp-space-2);padding-top:var(--tp-space-1)}

/* --- Tooltip --- */
.tp-tip { position: relative; }
.tp-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 5px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--tp-surface-3);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r);
  padding: 4px 8px;
  font-size: var(--tp-fs-sm);
  color: var(--tp-text);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  z-index: 100;
}
.tp-tip:hover::after { opacity: 1; }

/* --- Empty / loading / alert --- */
.tp-empty {
  padding: var(--tp-s5) var(--tp-s3);
  text-align: center;
  color: var(--tp-text-dim);
  font-size: var(--tp-fs-md);
}
.tp-empty-ico { font-size: 22px; opacity: .4; display: block; margin-bottom: var(--tp-s2); }

.tp-skel {
  background: linear-gradient(90deg, var(--tp-surface-2) 25%, var(--tp-surface-3) 50%, var(--tp-surface-2) 75%);
  background-size: 200% 100%;
  animation: tp-shimmer 1.3s linear infinite;
  border-radius: var(--tp-r-sm);
  height: 11px;
}
@keyframes tp-shimmer { to { background-position: -200% 0; } }

.tp-alert {
  padding: var(--tp-s2) var(--tp-s3);
  border-radius: var(--tp-r);
  border: 1px solid var(--tp-border-2);
  background: var(--tp-surface-2);
  font-size: var(--tp-fs-md);
  color: var(--tp-text-2);
}
.tp-alert-warn { border-color: var(--tp-warn); background: var(--tp-warn-bg); color: var(--tp-warn); }
.tp-alert-err  { border-color: var(--tp-short-dim); background: var(--tp-short-bg); color: var(--tp-short); }
.tp-alert-info { border-color: var(--tp-info); background: var(--tp-info-bg); color: var(--tp-info); }

/* Toast */
.tp-toast-host {
  position: fixed;
  bottom: var(--tp-s4);
  inset-inline-end: var(--tp-s4);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--tp-s2);
}
.tp-toast {
  background: var(--tp-surface-3);
  border: 1px solid var(--tp-border-2);
  border-radius: var(--tp-r);
  box-shadow: var(--tp-shadow-2);
  padding: var(--tp-s2) var(--tp-s3);
  font-size: var(--tp-fs-md);
  color: var(--tp-text);
  animation: tp-toast-in .18s ease;
}
@keyframes tp-toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ============================================================
   5. FEATURE BLOCKS
   ============================================================ */

/* --- Scanner --- */
.tp-scan-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--tp-s2) var(--tp-s3);
  padding: 0 0 var(--tp-s3);
  margin-bottom: var(--tp-s2);
  border-bottom: 1px solid var(--tp-border);
}
.tp-scan-controls-primary,.tp-scan-controls-options {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: var(--tp-s2);
}
.tp-scan-controls-primary { flex: 1 1 460px; }
.tp-scan-controls-options { flex: 0 1 auto; justify-content: flex-end; }
.tp-scan-search { width: clamp(180px,22vw,290px); height: var(--tp-control-sm); }
.tp-scan-direction { flex: 0 0 auto; }
.tp-scan-controls-options .tp-inline-field { display:flex; align-items:center; gap:var(--tp-s1); }
.tp-scan-controls-options .tp-label { white-space: nowrap; }
.tp-scan-controls-options .tp-sel,.tp-scan-controls-options .tp-in { width:auto; min-width:82px; height:var(--tp-control-sm); }
.tp-scan-controls-options .tp-check,.tp-scan-controls-options .tp-btn { min-height:var(--tp-control-sm); white-space:nowrap; }
.tp-scan-bar .tp-field { flex: 0 0 auto; }
.tp-scan-bar .tp-field-grow { flex: 1 1 150px; min-width: 130px; }
.tp-scan-bar .tp-field-grow .tp-in { width: 100%; }
@media (max-width: 1180px) {
  .tp-scan-bar { align-items: stretch; }
  .tp-scan-controls-primary,.tp-scan-controls-options { flex: 1 1 100%; justify-content:flex-start; }
}
@media (max-width: 680px) {
  .tp-scan-controls-primary,.tp-scan-controls-options { flex-wrap:wrap; }
  .tp-scan-search { flex:1 1 100%; width:100%; }
}

.tp-scan-meta {
  display: flex;
  align-items: center;
  gap: var(--tp-s2);
  font-size: var(--tp-fs-sm);
  color: var(--tp-text-3);
  margin-bottom: var(--tp-s2);
  flex-wrap: wrap;
}

.tp-scan-group-head {
  display: flex;
  align-items: center;
  gap: var(--tp-s2);
  padding: 5px var(--tp-s2);
  background: var(--tp-surface-2);
  border-top: 1px solid var(--tp-border);
  border-bottom: 1px solid var(--tp-border);
  font-size: var(--tp-fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--tp-text-3);
  cursor: pointer;
  user-select: none;
}
.tp-scan-group-head .tp-count {
  margin-inline-start: auto;
  color: var(--tp-text-dim);
  font-weight: 600;
}
.tp-scan-group-head .tp-caret { transition: transform .15s ease; font-size: 9px; }
.tp-scan-group.is-collapsed .tp-caret { transform: rotate(-90deg); }
[dir="rtl"] .tp-scan-group.is-collapsed .tp-caret { transform: rotate(90deg); }
.tp-scan-group.is-collapsed .tp-scan-group-body { display: none; }

.tp-scan { overflow-x: auto; }
.tp-scan-row {
  display: grid;
  grid-template-columns: var(--tp-scan-columns);
  min-width: 1080px;
  align-items: center;
  gap: var(--tp-s2);
  padding: 5px var(--tp-s2);
  border-bottom: 1px solid var(--tp-border);
  cursor: pointer;
  font-size: var(--tp-fs-md);
}
.tp-scan-row:hover { background: var(--tp-surface-2); }
.tp-scan-row.is-actionable { box-shadow: inset 2px 0 0 var(--tp-border-strong); }
.tp-scan-row.is-long  { box-shadow: inset 2px 0 0 var(--tp-long); }
.tp-scan-row.is-short { box-shadow: inset 2px 0 0 var(--tp-short); }
[dir="rtl"] .tp-scan-row.is-long  { box-shadow: inset -2px 0 0 var(--tp-long); }
[dir="rtl"] .tp-scan-row.is-short { box-shadow: inset -2px 0 0 var(--tp-short); }

.tp-scan-head {
  display: grid;
  /*
   * Must repeat the .tp-scan-row track list verbatim rather than
   * inherit it: the head is a SIBLING of the rows, not a child, so
   * `inherit` resolved against the non-grid .tp-scan wrapper and the
   * header cells silently fell out of alignment above 1180px (the
   * narrower breakpoints happened to set the columns explicitly and
   * so looked correct, which masked the bug).
   */
  grid-template-columns: var(--tp-scan-columns);
  min-width: 1080px;
  gap: var(--tp-s2);
  font-size: var(--tp-fs-xs);
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--tp-text-dim);
  padding: 5px var(--tp-s2);
  border-bottom: 1px solid var(--tp-border);
  background: var(--tp-surface-2);
  cursor: default;
}
.tp-scan-head:hover { background: var(--tp-surface-2); }

.tp-scan-sym {
  font-weight: 600;
  color: var(--tp-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tp-scan-num { text-align: end; font-variant-numeric: tabular-nums; color: var(--tp-text-2); }
/*
 * The mobile condensed line is a 14th child of the 13-column row
 * grid. Without this base rule it stays in flow at desktop widths and
 * wraps onto a phantom second grid row, doubling the height of every
 * scanner row. The <=720px block re-enables it as a flex line.
 */
.tp-scan-mobile { display: none; }
.tp-scan-fav {
  background: none;
  border: 0;
  color: var(--tp-text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 2px;
  line-height: 1;
}
.tp-scan-fav.is-on { color: var(--tp-warn); }

/* Compact mode drops the planning columns, keeping decision columns. */
.tp-scan.is-compact .tp-scan-row,
.tp-scan.is-compact .tp-scan-head {
  grid-template-columns:
    minmax(84px,1.3fr) 72px minmax(70px,1fr) 64px 64px 58px 46px 30px;
}
.tp-scan.is-compact .tp-col-ext { display: none; }

/* --- Positions rows --- */
.tp-pos-row {
  display: grid;
  grid-template-columns: minmax(90px,1.2fr) 62px repeat(4, minmax(64px,1fr)) 80px;
  align-items: center;
  gap: var(--tp-s2);
  padding: 7px var(--tp-s2);
  border-bottom: 1px solid var(--tp-border);
  font-size: var(--tp-fs-md);
}
.tp-pos-row:last-child { border-bottom: 0; }
.tp-pos-row:hover { background: var(--tp-surface-2); }
.tp-pos-row > .tp-pos-cell { min-width: 0; }
.tp-pos-row > .tp-pos-cell small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Reports charts (pure CSS/SVG, no library) --- */
.tp-spark { width: 100%; height: 92px; display: block; }
.tp-bars { display: flex; align-items: flex-end; gap: 3px; height: 92px; }
.tp-bar { flex: 1; border-radius: 2px 2px 0 0; min-height: 2px; }
.tp-bar.is-pos { background: var(--tp-long); }
.tp-bar.is-neg { background: var(--tp-short); }

.tp-dist-row {
  display: grid;
  grid-template-columns: minmax(90px,1fr) 1fr 62px;
  align-items: center;
  gap: var(--tp-s2);
  padding: 4px 0;
  font-size: var(--tp-fs-md);
}
.tp-dist-track {
  height: 6px;
  background: var(--tp-surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.tp-dist-fill { height: 100%; }

/* --- AI assistant --- */
.tp-ai {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.tp-ai-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--tp-s2);
  padding: var(--tp-s1) 0;
  min-height: 0;
}
.tp-ai-msg {
  padding: var(--tp-s2) var(--tp-s3);
  border-radius: var(--tp-r-lg);
  font-size: var(--tp-fs-md);
  line-height: 1.55;
  max-width: 92%;
  white-space: pre-wrap;
  word-break: break-word;
}
.tp-ai-msg.is-user {
  align-self: flex-end;
  background: var(--tp-info-bg);
  border: 1px solid var(--tp-info);
  color: var(--tp-text);
}
.tp-ai-msg.is-bot {
  align-self: flex-start;
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border);
  color: var(--tp-text-2);
}
.tp-ai-msg h4 {
  margin: 0 0 4px;
  font-size: var(--tp-fs-md);
  color: var(--tp-text);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.tp-ai-msg ul { margin: 4px 0; padding-inline-start: 16px; }
.tp-ai-msg li { margin: 2px 0; }
.tp-ai-chips { display: flex; flex-wrap: wrap; gap: var(--tp-s1); margin-bottom: var(--tp-s2); }
.tp-ai-chip {
  padding: 4px 9px;
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border-2);
  border-radius: 999px;
  color: var(--tp-text-2);
  font-family: inherit;
  font-size: var(--tp-fs-sm);
  cursor: pointer;
}
.tp-ai-chip:hover { border-color: var(--tp-info); color: var(--tp-text); }
.tp-ai-form { display: flex; gap: var(--tp-s2); margin-top: var(--tp-s2); }
.tp-ai-verdict {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--tp-r-sm);
  font-weight: 700;
  font-size: var(--tp-fs-xs);
  letter-spacing: .5px;
  margin-bottom: var(--tp-s2);
}

/* --- Chart --- */
.tp-chart-wrap {
  position: relative;
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-r-lg);
  overflow: hidden;
}
.tp-chart-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
/* Single source of truth for chart height per breakpoint. */
.tp-chart-wrap { height: 620px; }

/* Chart chrome must not flip; LWC positions its canvas in LTR pixels. */
[dir="rtl"] .tp-chart-wrap { direction: ltr; }

/* --- Indicator registry UI --- */
.tp-ind-row {
  display: flex;
  align-items: center;
  gap: var(--tp-space-2);
  min-height: 50px;
  padding: 6px var(--tp-space-2);
  border-bottom: 1px solid var(--tp-border);
}
.tp-ind-row:last-child { border-bottom: 0; }
.tp-ind-row:hover { background:var(--tp-hover); }
.tp-ind-meta { flex: 1; min-width: 0; }
.tp-ind-name { display:block;font-size: var(--tp-font-md); font-weight: 650; color: var(--tp-text); }
.tp-ind-desc { display:block;font-size: var(--tp-font-sm); line-height:var(--tp-line-normal);color: var(--tp-text-secondary); margin-top: 1px; }
.tp-ind-row>.tp-ind-swatch,.tp-ind-active-row>.tp-ind-swatch{flex:0 0 8px;width:8px;height:24px;border-radius:4px}
.tp-ind-row .tp-ind-params{display:none}
.tp-ind-add{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-width:68px;min-height:32px;flex:0 0 auto;border:1px solid color-mix(in srgb,var(--tp-accent) 48%,var(--tp-border));background:transparent;color:var(--tp-accent);font-weight:650}
.tp-ind-add:hover:not(:disabled){background:color-mix(in srgb,var(--tp-accent) 10%,var(--tp-surface));border-color:var(--tp-accent)}
.tp-ind-add:focus-visible,#tpIndReset:focus-visible,.tp-ind-active-row .tp-icon-btn:focus-visible{outline:2px solid var(--tp-accent);outline-offset:2px}
.tp-ind-add.is-added{background:var(--tp-surface-2);color:var(--tp-positive);border-color:color-mix(in srgb,var(--tp-positive) 35%,var(--tp-border));opacity:1}
#tpIndReset{border-color:var(--tp-border);background:transparent;color:var(--tp-text-secondary);font-weight:550}
#tpIndReset:hover{background:var(--tp-hover);color:var(--tp-text)}
.tp-ind-category{padding:0!important;margin-bottom:var(--tp-space-2)!important;overflow:hidden}
.tp-ind-category-head{display:grid;grid-template-columns:1fr auto 18px;align-items:center;gap:8px;width:100%;min-height:40px;padding:6px 12px;border:0;background:var(--tp-surface-2);color:var(--tp-text);font:650 var(--tp-font-sm)/var(--tp-line-normal) inherit;text-align:start;cursor:pointer}
.tp-ind-category-head small{color:var(--tp-text-muted)}
.tp-ind-category-head i{font-style:normal;transition:transform .15s ease}
.tp-ind-category.is-collapsed .tp-ind-category-head i{transform:rotate(-90deg)}
.tp-ind-category.is-collapsed .tp-ind-category-list{display:none}
.tp-ind-active-list{max-height:190px;overflow:auto;border:1px solid var(--tp-border);border-radius:var(--tp-radius-sm)}
.tp-ind-active-row{display:grid;grid-template-columns:8px minmax(0,1fr) repeat(3,36px);align-items:center;gap:5px;min-height:42px;padding:3px 6px;border-bottom:1px solid var(--tp-border);color:var(--tp-text)}
.tp-ind-active-row:last-child{border-bottom:0}.tp-ind-active-meta{min-width:0}.tp-ind-active-meta strong,.tp-ind-active-meta small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-ind-active-meta strong{font-size:var(--tp-font-sm)}.tp-ind-active-meta small{font-size:var(--tp-font-xs);color:var(--tp-text-muted)}
.tp-ind-active-row .tp-icon-btn{display:grid;place-items:center;width:36px;height:36px;min-height:36px;padding:0;border:1px solid var(--tp-border);border-radius:var(--tp-radius-sm);background:var(--tp-surface-2);color:var(--tp-text-secondary);opacity:1}.tp-ind-active-row .tp-icon-btn:hover{background:var(--tp-hover);color:var(--tp-text)}
.tp-ind-action-icon{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tp-ind-active-row .tp-ind-visibility.is-visible{border-color:color-mix(in srgb,var(--tp-accent) 42%,var(--tp-border));background:color-mix(in srgb,var(--tp-accent) 12%,var(--tp-surface));color:var(--tp-accent)}
.tp-ind-active-row .tp-ind-visibility.is-muted{background:var(--tp-surface-2);color:var(--tp-text-muted)}
.tp-ind-active-row .tp-ind-remove{background:transparent;color:var(--tp-text-muted)}.tp-ind-active-row .tp-ind-remove:hover{border-color:color-mix(in srgb,var(--tp-negative) 45%,var(--tp-border));background:color-mix(in srgb,var(--tp-negative) 10%,var(--tp-surface));color:var(--tp-negative)}
.tp-ind-params { display: flex; flex-wrap: wrap; gap: var(--tp-s2); margin-top: var(--tp-s2); }
.tp-ind-params .tp-field { width: 96px; }
.tp-ind-params .tp-in { padding: 4px 7px; }

/* --- Settings --- */
.tp-set-layout {
  display: grid;
  grid-template-columns: 190px minmax(0,1fr);
  gap: var(--tp-s3);
  align-items: start;
}
.tp-set-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: calc(var(--tp-topbar-h) + var(--tp-s3));
}
.tp-set-nav button {
  padding: 7px var(--tp-s3);
  background: none;
  border: 0;
  border-radius: var(--tp-r);
  color: var(--tp-text-3);
  font-family: inherit;
  font-size: var(--tp-fs-md);
  text-align: start;
  cursor: pointer;
}
.tp-set-nav button:hover { background: var(--tp-surface-2); color: var(--tp-text-2); }
.tp-set-nav button.is-active { background: var(--tp-surface-2); color: var(--tp-text); font-weight: 600; }
.tp-set-sec { display: none; }
.tp-set-sec.is-active { display: block; }
.tp-set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: var(--tp-s3);
}

/* --- Journal --- */
.tp-journal-row { cursor: pointer; }
.tp-journal-note {
  font-size: var(--tp-fs-sm);
  color: var(--tp-text-3);
  white-space: normal;
  max-width: 260px;
}

/* ============================================================
   6. RESPONSIVE
   ============================================================ */

/* Tablet */
@media (max-width: 1180px) {
  .tp-split-main { grid-template-columns: minmax(0,1fr); }
  .tp-kpi-strip { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .tp-chart-wrap { height: 460px; }
  .tp-scan-row, .tp-scan-head {
    grid-template-columns: var(--tp-scan-columns);
    min-width: 1080px;
  }
}

@media (max-width: 1100px) {
  :root { --tp-sidebar-w: 0px; }

  .tp-hamburger { display: flex; }

  .tp-side {
    width: 240px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--tp-shadow-3);
  }
  [dir="rtl"] .tp-side { transform: translateX(100%); }
  .tp-side.is-open { transform: translateX(0); }
  .tp-scrim.is-open { display: block; }

  .tp-main { padding-inline-start: 0; }
  .tp-grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tp-grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tp-set-layout { grid-template-columns: minmax(0,1fr); }
  .tp-set-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: var(--tp-s2);
    border-bottom: 1px solid var(--tp-border);
  }
  .tp-set-nav button { white-space: nowrap; }
}

/* Mobile — an intentionally different layout, not a squeezed desktop. */
@media (max-width: 720px) {
  .tp-bottomnav { display: grid; }

  .tp-topbar {
    gap: 7px;
    padding-inline: 8px;
  }
  .tp-logo { margin-inline-end: auto; min-width: 0; }
  .tp-status { padding: 4px 6px; }
  .tp-status > span:not(.tp-dot):not(.tp-status-dot) { display: none; }
  .tp-topbar-refresh { display: none; }
  .tp-global-theme button{width:30px;padding:0}
  .tp-global-theme button span{display:none}
  .tp-account-btn { padding: 3px; border-radius: 50%; }
  .tp-account-btn .tp-account-name { display: none; }
  .tp-avatar { width: 28px; height: 28px; }

  .tp-c-head {
    flex-wrap: wrap;
    min-width: 0;
  }
  .tp-c-head > .tp-seg {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
  .tp-c-head > .tp-c-title { flex: 0 1 auto; }
  .tp-c-head > .tp-scan-sym { margin-inline-end: auto; min-width: 0; }

  .tp-main { padding-bottom: calc(var(--tp-bottomnav-h) + 8px); }

  .tp-view { padding: var(--tp-s2); }
  .tp-view-title { font-size: var(--tp-fs-lg); }

  .tp-kpi-strip {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: var(--tp-s2);
  }
  .tp-kpi-value { font-size: var(--tp-fs-lg); }

  .tp-grid, .tp-grid-2, .tp-grid-3, .tp-grid-4, .tp-grid-auto {
    grid-template-columns: minmax(0,1fr);
    gap: var(--tp-s2);
  }

  .tp-c { padding: var(--tp-s2); border-radius: var(--tp-r); }

  .tp-chart-wrap { height: clamp(340px, 105vw, 440px); min-width: 0; }
  .tp-chart-frame { min-width: 0; max-width: 100%; }

  /*
   * Scanner on mobile is a two-line row, not a table and not a
   * tall card: symbol + direction + price on line 1, the decision
   * numbers on line 2. 40 symbols stay scannable in a few screens.
   */
  .tp-scan-head { display: none; }

  .tp-scan-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "sym  dir"
      "nums fav";
    gap: 3px var(--tp-s2);
    padding: var(--tp-s2);
    border-bottom: 1px solid var(--tp-border);
  }
  .tp-scan-row > .tp-scan-sym { grid-area: sym; font-size: var(--tp-fs-lg); }
  .tp-scan-row > .tp-scan-dir { grid-area: dir; justify-self: end; }
  .tp-scan-row > .tp-scan-fav { grid-area: fav; justify-self: end; }
  .tp-scan-row > .tp-scan-mobile { grid-area: nums; }
  .tp-scan-row > .tp-scan-cell { display: none; }

  .tp-scan-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 3px var(--tp-s3);
    font-size: var(--tp-fs-sm);
    color: var(--tp-text-3);
  }
  .tp-scan-mobile b {
    color: var(--tp-text-2);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .tp-scan-bar { gap: var(--tp-s2); }
  .tp-scan-bar .tp-field-grow { flex: 1 1 100%; }
  .tp-scan-bar .tp-sel, .tp-scan-bar .tp-in { min-width: 0; width: 100%; }
  .tp-scan-bar .tp-field { flex: 1 1 calc(50% - var(--tp-s2)); }

  /* Positions collapse to label:value pairs. */
  .tp-pos-row {
    grid-template-columns: 1fr 1fr;
    gap: 4px var(--tp-s2);
    padding: var(--tp-s2);
  }
  .tp-pos-row .tp-pos-cell::before {
    content: attr(data-label);
    display: block;
    font-size: var(--tp-fs-xs);
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--tp-text-dim);
  }
  .tp-pos-row .tp-pos-sym { grid-column: 1 / -1; }

  /* Comfortable touch targets. */
  .tp-btn, .tp-in, .tp-sel {
    min-height: 40px;
    font-size: var(--tp-fs-lg);
  }
  .tp-btn-sm { min-height: 32px; font-size: var(--tp-fs-md); }
  .tp-seg button { min-height: 34px; padding: 6px 12px; }
  .tp-side-link { padding: 11px var(--tp-s2); font-size: var(--tp-fs-lg); }
  .tp-menu-item { padding: 11px var(--tp-s3); }

  .tp-drawer { width: 100vw; }
  .tp-modal { width: 100%; max-height: 92vh; }
  .tp-toast-host { inset-inline: var(--tp-s2); bottom: calc(var(--tp-bottomnav-h) + 8px); }

  .tp-table thead { display: none; }
  .tp-journal-note { max-width: none; }
}

@media (max-width: 380px) {
  .tp-kpi-strip { gap: 6px; }
  .tp-kpi { padding: 6px 8px; }
  .tp-bottom-link, .tp-bn-item { font-size: 8px; }
  .tp-logo-text { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   7. RTL
   ============================================================
   Most mirroring is handled by logical properties above
   (inset-inline-*, padding-inline-*, text-align:start/end).
   Only genuinely physical things need an override.
   ============================================================ */
[dir="rtl"] .tp-table thead th,
[dir="rtl"] .tp-table tbody td { text-align: right; }
[dir="rtl"] .tp-table .tp-t-num,
[dir="rtl"] .tp-scan-num { text-align: left; }

/* Symbols and prices are LTR tokens even inside an RTL sentence. */
[dir="rtl"] .tp-scan-sym,
[dir="rtl"] .tp-t-sym,
[dir="rtl"] .tp-num,
[dir="rtl"] .tp-kpi-value,
[dir="rtl"] .tp-scan-num,
[dir="rtl"] .tp-scan-mobile b {
  direction: ltr;
  unicode-bidi: isolate;
}

[dir="rtl"] .tp-ai-msg.is-user { align-self: flex-start; }
[dir="rtl"] .tp-ai-msg.is-bot  { align-self: flex-end; }
/* PWA connectivity and update surfaces */
.tp-offline-banner,.tp-update-notice{position:fixed;inset-inline:0;top:0;z-index:10000;min-height:42px;padding:10px 18px;text-align:center;font-size:13px;font-weight:700;box-shadow:0 4px 18px rgba(0,0,0,.35)}
.tp-offline-banner{background:#7f1d1d;color:#fff}
.tp-update-notice{background:#17365f;color:#f1f7ff;display:flex;align-items:center;justify-content:center;gap:14px}
.tp-offline-banner[hidden],.tp-update-notice[hidden]{display:none}
.tp-is-offline .tp-topbar{top:42px}
.tp-is-offline .tp-side{top:calc(var(--tp-topbar-h,56px) + 42px)}
.tp-is-offline .tp-main{padding-top:42px}
.tp-is-offline .tp-view:not([data-view="settings"]):not([data-view="account"]){position:relative;pointer-events:none;user-select:none;filter:saturate(.25)}
.tp-is-offline .tp-view:not([data-view="settings"]):not([data-view="account"])::before{content:"OFFLINE · LIVE DATA UNAVAILABLE";position:sticky;display:block;top:52px;z-index:30;margin:0 0 12px;padding:12px;border:1px solid #ef4444;border-radius:8px;background:rgba(54,12,17,.96);color:#fecaca;text-align:center;font-weight:800;direction:ltr}
html[lang="fa"] .tp-is-offline .tp-view:not([data-view="settings"]):not([data-view="account"])::before{content:"آفلاین · داده زنده در دسترس نیست";direction:rtl}
body.tp-standalone{overscroll-behavior:none}
@media (display-mode:standalone){body{min-height:100dvh;padding-bottom:env(safe-area-inset-bottom)}.tp-topbar{padding-top:env(safe-area-inset-top);height:calc(var(--tp-topbar-h,56px) + env(safe-area-inset-top))}.tp-side{top:calc(var(--tp-topbar-h,56px) + env(safe-area-inset-top))}.tp-main{min-height:100dvh}.tp-bottomnav{padding-bottom:env(safe-area-inset-bottom)}}

.tp-notification-btn{position:relative;flex:0 0 auto}
.tp-notification-count{position:absolute;inset-block-start:-4px;inset-inline-end:-5px;min-width:17px;height:17px;padding:0 4px;border-radius:10px;background:var(--tp-short);color:#fff;font-size:10px;line-height:17px;text-align:center;font-weight:700}
.tp-notice-actions{display:flex;gap:8px;justify-content:flex-end;position:sticky;top:0;z-index:1;padding-block:4px 10px;background:var(--tp-bg-1)}
.tp-notice-list{display:grid;gap:8px}
.tp-notice{border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-bg-2);padding:10px;overflow-wrap:anywhere}
.tp-notice.is-unread{border-inline-start:3px solid var(--tp-accent);background:color-mix(in srgb,var(--tp-accent) 8%,var(--tp-bg-2))}
.tp-notice-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
.tp-notice-head time{color:var(--tp-text-3);font-size:var(--tp-fs-xs);white-space:nowrap}
.tp-notice p{margin:5px 0 0;color:var(--tp-text-2);line-height:1.5}
@media(max-width:480px){.tp-notice-actions{justify-content:stretch}.tp-notice-actions .tp-btn{flex:1}.tp-notice-head{align-items:flex-start}.tp-notice-head time{white-space:normal;text-align:end}}

/* Action-first dashboard and professional workspace */
.tp-now{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 16px;margin-bottom:12px;background:linear-gradient(100deg,var(--tp-surface-2),rgba(16,185,129,.08));border:1px solid var(--tp-border);border-inline-start:3px solid var(--tp-long);border-radius:var(--tp-r-lg)}
.tp-now.is-risk{background:linear-gradient(100deg,var(--tp-surface-2),rgba(244,63,94,.09));border-inline-start-color:var(--tp-short)}.tp-now>div:first-child{display:grid;gap:2px}.tp-now strong{font-size:var(--tp-fs-xl)}.tp-now small,.tp-action-position small,.tp-closed-row small{color:var(--tp-text-3)}.tp-eyebrow{font-size:var(--tp-fs-xs);font-weight:700;letter-spacing:.08em;color:var(--tp-text-3);text-transform:uppercase}.tp-now-counts{display:flex;gap:14px;flex-wrap:wrap}.tp-now-counts span{color:var(--tp-text-2);white-space:nowrap}.tp-now-counts b{font-size:var(--tp-fs-lg);color:var(--tp-text)}
#tpDashboardAttention{margin-bottom:12px;border:1px solid rgba(244,63,94,.35);border-radius:var(--tp-r-lg);overflow:hidden;background:var(--tp-short-bg)}.tp-attention-head{padding:8px 12px;font-size:var(--tp-fs-xs);font-weight:800;color:var(--tp-short);letter-spacing:.08em}.tp-attention-item{display:flex;width:100%;gap:10px;align-items:center;padding:9px 12px;border:0;border-top:1px solid rgba(244,63,94,.18);background:transparent;color:var(--tp-text);font:inherit;text-align:start;cursor:pointer}.tp-attention-item span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--tp-text-2)}
.tp-dashboard-grid{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(280px,.75fr);gap:12px;margin-bottom:12px}.tp-dashboard-secondary{grid-template-columns:minmax(0,1.2fr) minmax(240px,.8fr) minmax(240px,.8fr)}.tp-dashboard-grid>.tp-c,.tp-summary-card{margin:0}.tp-summary-card{margin-bottom:12px}.tp-summary-card .tp-kpi-strip{border:0;background:transparent}
.tp-action-position{padding:11px 0;border-bottom:1px solid var(--tp-border)}.tp-action-position:last-child{border-bottom:0}.tp-action-position-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.tp-action-position-head>div{display:grid}.tp-action-position-head strong{font-size:var(--tp-fs-lg)}.tp-position-numbers{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:9px}.tp-position-numbers span{display:grid}.tp-position-numbers small{font-size:var(--tp-fs-xs);color:var(--tp-text-3)}.tp-position-numbers b{font-family:var(--tp-mono);font-size:var(--tp-fs-md)}.tp-action-position p{margin:9px 0 3px;color:var(--tp-text-2);line-height:1.45}.tp-position-actions{display:flex;gap:6px;margin-top:9px}.tp-useful-empty{display:grid;gap:9px;padding:18px 8px;color:var(--tp-text-2)}.tp-useful-empty strong{color:var(--tp-text);font-size:var(--tp-fs-lg)}
.tp-activity-row,.tp-closed-row,.tp-session-row{display:flex;align-items:center;gap:9px;padding:9px 0;border-bottom:1px solid var(--tp-border)}.tp-activity-row:last-child,.tp-closed-row:last-child,.tp-session-row:last-child{border-bottom:0}.tp-activity-row>div,.tp-closed-row>div,.tp-session-row>div{display:grid;min-width:0;flex:1}.tp-activity-row span,.tp-session-row small{color:var(--tp-text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-activity-row time,.tp-closed-row time{color:var(--tp-text-3);font-size:var(--tp-fs-xs);white-space:nowrap}.tp-event-dot{width:6px;height:6px;border-radius:50%;background:var(--tp-info);flex:none}.tp-closed-row>span{font-family:var(--tp-mono);font-weight:700}
.tp-quick-chart .tp-chart-wrap{height:360px}.tp-chart-card{min-width:0}.tp-workspace-view{padding:0}.tp-workspace-top{height:48px;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:7px 10px;background:var(--tp-surface);border-bottom:1px solid var(--tp-border)}.tp-workspace-top>div:first-child{display:grid}.tp-workspace-top strong{font-family:var(--tp-mono)}.tp-workspace-shell{display:grid;grid-template-columns:minmax(0,1fr) 300px;min-height:480px}.tp-workspace-chart{min-width:0;background:var(--tp-bg)}.tp-workspace-chart .tp-chart-wrap{height:100%}.tp-workspace-chart .tp-chart-card{height:100%;display:flex;flex-direction:column}.tp-workspace-chart .tp-chart-wrap{flex:1}.tp-workspace-side{padding:10px;background:var(--tp-surface);border-inline-start:1px solid var(--tp-border)}.tp-workspace-side .tp-c{margin-bottom:10px}.tp-workspace-view:fullscreen{background:var(--tp-bg);padding-top:env(safe-area-inset-top)}
@media(max-width:900px){.tp-dashboard-grid,.tp-dashboard-secondary{grid-template-columns:1fr}.tp-workspace-chart .tp-c-head{overflow-x:auto;flex-wrap:nowrap}.tp-quick-chart .tp-chart-wrap{height:300px}}
@media(max-width:520px){.tp-now{align-items:flex-start;flex-direction:column;padding:11px 12px}.tp-now-counts{gap:10px}.tp-position-numbers{grid-template-columns:repeat(2,minmax(0,1fr))}.tp-position-actions{overflow-x:auto}.tp-dashboard-grid{gap:8px;margin-bottom:8px}.tp-dashboard-grid>.tp-c{padding:10px}.tp-summary-card .tp-kpi-strip{display:flex;overflow-x:auto;scroll-snap-type:x proximity}.tp-summary-card .tp-kpi{min-width:125px;scroll-snap-align:start}.tp-quick-chart .tp-chart-wrap{height:270px}.tp-workspace-top .tp-eyebrow{display:none}.tp-workspace-top .tp-seg{overflow-x:auto}}

.tp-dashboard-grid.is-single{grid-template-columns:1fr}.tp-dashboard-secondary.no-activity{grid-template-columns:minmax(0,1.2fr) minmax(240px,.8fr)}.tp-c.is-empty-compact{padding-block:8px}.tp-empty-inline{min-height:0!important;padding:5px 0!important;margin:0!important}.tp-useful-empty{padding-block:9px}.tp-opportunity-loading{padding:8px;color:var(--tp-text-3)}
.tp-opportunity-error{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px;color:var(--tp-text-2)}
.tp-opportunity-row{display:grid;grid-template-columns:minmax(105px,.8fr) auto minmax(250px,1.6fr);align-items:center;gap:10px;width:100%;padding:10px 4px;border:0;border-bottom:1px solid var(--tp-border);background:transparent;color:var(--tp-text);font:inherit;text-align:start;cursor:pointer}.tp-opportunity-row:last-child{border-bottom:0}.tp-opportunity-id{display:grid}.tp-opportunity-id strong{font-size:var(--tp-fs-lg)}.tp-opportunity-id small{color:var(--tp-text-3)}.tp-opportunity-levels{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}.tp-opportunity-levels span{display:grid;color:var(--tp-text-3);font-size:var(--tp-fs-xs)}.tp-opportunity-levels b{color:var(--tp-text);font-family:var(--tp-mono);font-size:var(--tp-fs-sm);white-space:nowrap}
@media(max-width:700px){.tp-dashboard-secondary.no-activity{grid-template-columns:1fr}.tp-opportunity-row{grid-template-columns:1fr auto;gap:5px 8px;padding:8px 0}.tp-opportunity-levels{grid-column:1/-1;grid-template-columns:repeat(4,minmax(0,1fr))}.tp-workspace-bottom>.tp-chip{white-space:nowrap}.tp-workspace-view .tp-workspace-chart{width:100%}}
@media(max-width:520px){.tp-dashboard-grid>.tp-c[hidden]{display:none}.tp-c.is-empty-compact .tp-c-head{margin-bottom:2px}.tp-kpi-label{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25;min-height:2.5em}.tp-summary-card .tp-kpi{min-width:104px;padding:7px 8px}.tp-summary-card .tp-kpi-value{font-size:15px}.tp-action-position{padding:8px 0}.tp-action-position p{margin-top:6px}.tp-opportunity-row>.tp-badge{max-width:145px;white-space:normal;text-align:center;line-height:1.2}.tp-opportunity-levels{gap:4px}.tp-opportunity-levels b{font-size:10px}.tp-closed-row{align-items:flex-start;display:grid;grid-template-columns:minmax(0,1fr) auto}.tp-closed-row time{grid-column:2;text-align:end}.tp-closed-row>div small{white-space:normal}.tp-quick-chart .tp-chart-wrap{height:250px}.tp-workspace-shell{min-height:470px}.tp-workspace-top{padding-inline:7px}.tp-workspace-top #tpWorkspaceFullscreen{padding-inline:7px}}
@media(orientation:landscape) and (max-height:520px){.tp-workspace-shell{min-height:320px}.tp-workspace-top{height:40px}.tp-workspace-chart .tp-chart-wrap{min-height:300px}}

/* Theme coverage and dense chart/mobile corrections. */
.tp-workspace-chart,.tp-chart-frame{background:var(--tp-bg)}
.tp-theme-light .tp-logo-mark{box-shadow:0 4px 12px rgba(15,23,42,.14)}
.tp-theme-swatch{display:inline-block;width:18px;height:18px;border:1px solid var(--tp-border-2);border-radius:50%;vertical-align:middle;margin-inline-end:7px;background:linear-gradient(135deg,var(--tp-bg) 50%,var(--tp-long) 50%)}
.tp-chart-symbol-picker{font-weight:800;letter-spacing:.02em;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-symbol-picker{display:grid;grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:8px;max-height:min(55vh,440px);overflow:auto;padding:4px}.tp-symbol-choice{justify-content:flex-start;min-height:44px}.tp-position-analysis-card{display:grid;gap:8px;color:var(--tp-text);background:var(--tp-surface-2);border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);padding:14px}.tp-position-analysis-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.tp-position-analysis-head time{margin-inline-start:auto;color:var(--tp-text-3);font-size:11px}.tp-position-analysis-card details{border-top:1px solid var(--tp-border);padding-top:10px}.tp-position-analysis-card summary{cursor:pointer;font-weight:700}@media(max-width:600px){.tp-chart-symbol-picker{max-width:128px}.tp-symbol-picker{grid-template-columns:1fr 1fr}.tp-position-analysis-head time{width:100%;margin:0}.tp-quick-chart .tp-chart-wrap{min-height:380px}}
.tp-opportunity-levels span{min-width:0;overflow-wrap:anywhere}.tp-opportunity-levels b{max-width:100%;overflow:hidden;text-overflow:ellipsis}
@media(min-width:521px) and (max-width:900px){.tp-opportunity-row{grid-template-columns:minmax(95px,.7fr) auto minmax(190px,1.3fr)}.tp-opportunity-levels{grid-template-columns:repeat(2,minmax(82px,1fr))}.tp-opportunity-levels b{white-space:normal}}
@media(max-width:520px){.tp-opportunity-levels{grid-template-columns:repeat(2,minmax(0,1fr))}.tp-opportunity-levels b{white-space:normal;font-size:11px}}

/* Fullscreen retains the proven application fallback; only its outer
   duplicate market/symbol controls are collapsed. The embedded chart
   remains the single compact control surface. */
.tp-app-fullscreen .tp-workspace-top>div,.tp-app-fullscreen .tp-workspace-top>.tp-seg,.tp-workspace-view:fullscreen .tp-workspace-top>div,.tp-workspace-view:fullscreen .tp-workspace-top>.tp-seg{display:none!important}
.tp-app-fullscreen .tp-workspace-top,.tp-workspace-view:fullscreen .tp-workspace-top{position:absolute!important;inset-block-start:env(safe-area-inset-top);inset-inline-end:env(safe-area-inset-right);height:auto!important;background:transparent!important;border:0!important;padding:6px!important;z-index:10;pointer-events:none}
.tp-app-fullscreen #tpWorkspaceFullscreen,.tp-workspace-view:fullscreen #tpWorkspaceFullscreen{pointer-events:auto;background:var(--tp-surface-2);box-shadow:var(--tp-shadow-2)}

/* iOS-safe chart fullscreen and final responsive chart contracts. */
body.tp-fullscreen-active{overflow:hidden!important;overscroll-behavior:none}
.tp-view.tp-app-fullscreen,.tp-workspace-view:fullscreen{display:flex!important;flex-direction:column;position:fixed!important;inset:0!important;z-index:5000!important;width:100vw!important;height:100dvh!important;max-width:none!important;margin:0!important;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)!important;background:var(--tp-bg)!important}
.tp-app-fullscreen .tp-workspace-top,.tp-workspace-view:fullscreen .tp-workspace-top{flex:0 0 44px}
.tp-app-fullscreen .tp-workspace-shell,.tp-workspace-view:fullscreen .tp-workspace-shell{flex:1 1 auto;height:auto!important;min-height:0!important;grid-template-columns:1fr!important}
.tp-app-fullscreen .tp-workspace-chart,.tp-app-fullscreen .tp-chart-card,.tp-app-fullscreen .tp-chart-wrap,.tp-app-fullscreen .tp-chart-frame,.tp-workspace-view:fullscreen .tp-workspace-chart,.tp-workspace-view:fullscreen .tp-chart-card,.tp-workspace-view:fullscreen .tp-chart-wrap,.tp-workspace-view:fullscreen .tp-chart-frame{width:100%!important;height:100%!important;min-height:0!important}
.tp-app-fullscreen .tp-workspace-side,.tp-app-fullscreen .tp-workspace-bottom,.tp-workspace-view:fullscreen .tp-workspace-side,.tp-workspace-view:fullscreen .tp-workspace-bottom{display:none!important}
.tp-app-fullscreen #tpWorkspaceFullscreen{position:relative;z-index:2}
.tp-fullscreen-active .tp-topbar,.tp-fullscreen-active .tp-side,.tp-fullscreen-active .tp-scrim,.tp-fullscreen-active .tp-bottomnav{display:none!important}
@media(max-width:720px){
  .tp-main{padding-top:calc(var(--tp-topbar-h) + env(safe-area-inset-top));padding-bottom:calc(var(--tp-bottomnav-h) + env(safe-area-inset-bottom) + 18px)}
  .tp-topbar{top:0;padding-top:env(safe-area-inset-top);height:calc(var(--tp-topbar-h) + env(safe-area-inset-top))}
  .tp-view{scroll-margin-top:calc(var(--tp-topbar-h) + env(safe-area-inset-top) + 8px)}
  .tp-bottomnav{height:calc(var(--tp-bottomnav-h) + env(safe-area-inset-bottom))}
  .tp-summary-card .tp-kpi-strip{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));overflow:visible;gap:7px}
  .tp-summary-card .tp-kpi{min-width:0!important;width:auto;padding:8px}
  .tp-quick-chart .tp-chart-wrap{height:clamp(330px,74vw,430px)}
  .tp-workspace-shell{height:auto;min-height:0}
  .tp-workspace-chart .tp-chart-wrap{height:clamp(500px,68dvh,760px);min-height:500px}
}
@media(max-width:340px){.tp-summary-card .tp-kpi-strip{grid-template-columns:1fr}}
@media(min-width:721px){.tp-summary-card .tp-kpi-strip{grid-template-columns:repeat(auto-fit,minmax(145px,1fr))}.tp-dashboard-secondary{align-items:start}}

/* One chart control surface: the embedded canonical engine owns
   symbol/timeframe/market/tools in Dashboard, Workspace and fullscreen. */
#tpChartCard>.tp-c-head,.tp-workspace-top>.tp-seg{display:none!important}
@media(max-width:720px){
  .tp-quick-chart .tp-chart-wrap{height:clamp(360px,84vw,440px)}
}

/* Mobile indicator host: the iframe is elevated to the visual viewport while
 * its internal sheet is open, so the sheet is never clipped by Quick View. */
@media(max-width:720px){
  body.tp-indicator-host-open{overflow:hidden!important;overscroll-behavior:none}
  body.tp-indicator-host-open::before{content:"";position:fixed;inset:0;z-index:640;background:var(--tp-backdrop)}
  body.tp-indicator-host-open #tpChartCard{display:flex!important;flex-direction:column;position:fixed!important;z-index:650!important;inset:max(6px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left))!important;width:auto!important;height:auto!important;min-height:0!important;margin:0!important;border:1px solid var(--tp-border-2)!important;border-radius:12px!important;background:var(--tp-bg)!important;box-shadow:var(--tp-shadow-3)!important;overflow:hidden!important}
  body.tp-indicator-host-open #tpChartCard>.tp-c-head{display:none!important}
  body.tp-indicator-host-open #tpChartCard>.tp-chart-wrap,body.tp-indicator-host-open #tpChartCard .tp-chart-frame{flex:1 1 auto!important;width:100%!important;height:100%!important;min-height:0!important}
  body.tp-indicator-host-open .tp-bottomnav{display:none!important}
}

/* Compact mobile Reports: KPI density and trade-card journal. */
@media(max-width:600px){
  [data-view="reports"] .tp-grid-4{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:7px!important}
  [data-view="reports"] .tp-kpi{min-height:0!important;padding:8px 9px!important}
  [data-view="reports"] .tp-kpi-label{min-height:0!important;font-size:10px!important;line-height:1.25!important}
  [data-view="reports"] .tp-kpi-value{font-size:15px!important;margin-top:3px!important}
  #tpJournalBody .tp-table,#tpJournalBody .tp-table tbody,#tpJournalBody .tp-table tr,#tpJournalBody .tp-table td{display:block;width:100%}
  #tpJournalBody .tp-table thead{display:none}
  #tpJournalBody .tp-journal-row{margin-bottom:9px;padding:9px 10px;border:1px solid var(--tp-border);border-radius:8px;background:var(--tp-surface)}
  #tpJournalBody .tp-journal-row td{display:flex!important;align-items:center;justify-content:space-between;gap:12px;min-height:30px;padding:4px 0!important;border:0!important;text-align:end!important;white-space:normal!important;overflow-wrap:anywhere}
  #tpJournalBody .tp-journal-row td::before{content:attr(data-label);flex:0 0 42%;color:var(--tp-text-2);font-size:10px;font-weight:650;text-align:start}
  #tpJournalBody .tp-journal-row .tp-t-sym{font-size:13px;font-weight:800}
}
@media(max-width:380px){
  .tp-topbar .tp-logo-text{display:none!important;}
  .tp-topbar-context{flex-basis:112px;max-width:120px;}
  .tp-topbar-context .tp-sel{max-width:120px;}
}

/* Distinct completed-cycle accounting metrics. */
.tp-trade-review-metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 12px;min-width:0}
.tp-trade-review-metrics>div{display:grid;gap:2px;min-width:0}
.tp-trade-review-metrics small{color:var(--tp-text-muted);font-size:10px}
.tp-trade-review-metrics strong{font:650 11px/1.3 var(--tp-mono);overflow-wrap:anywhere}
.tp-capital-unavailable{grid-column:1/-1;display:grid!important;gap:3px;justify-items:start;align-content:center;min-height:54px;padding:10px 12px!important;text-align:start}
.tp-capital-unavailable strong{font-size:12px;color:var(--tp-text-primary)}
.tp-capital-unavailable span{font-size:11px;color:var(--tp-text-muted)}

/* Smaller safe-area-aware navigation without decorative underlines. */
@media(max-width:720px){
  body{--tp-bottomnav-h:48px}
  .tp-bottomnav{height:calc(var(--tp-bottomnav-h) + env(safe-area-inset-bottom))!important;padding-bottom:env(safe-area-inset-bottom)!important}
  .tp-bn-item{gap:1px!important;padding:2px!important;font-size:8px!important;border:0!important;text-decoration:none!important}
  .tp-bn-ic{font-size:15px!important}
  .tp-bn-item.is-active{background:var(--tp-info-bg);color:var(--tp-info);box-shadow:inset 0 2px 0 var(--tp-info)}
  .tp-main{padding-bottom:calc(var(--tp-bottomnav-h) + env(safe-area-inset-bottom) + 12px)!important}
}

/* Explicit semantic contrast for Light/System-Light application surfaces. */
body.tp-theme-light .tp-label,body.tp-theme-light .tp-kpi-label,body.tp-theme-light .tp-view-sub,
body.tp-theme-light .tp-status,body.tp-theme-light .tp-empty,body.tp-theme-light .tp-bn-item,
body.tp-theme-light small{color:var(--tp-text-3)!important;opacity:1!important}
body.tp-theme-light input,body.tp-theme-light select,body.tp-theme-light textarea,
body.tp-theme-light .tp-modal,body.tp-theme-light .tp-drawer,body.tp-theme-light .tp-menu,
body.tp-theme-light .tp-c,body.tp-theme-light .tp-table{color:var(--tp-text)!important}
body.tp-theme-light input::placeholder,body.tp-theme-light textarea::placeholder{color:var(--tp-text-3)!important;opacity:1!important}

/* Active Dashboard preview and Trading Workspace terminal layout. */
.tp-quick-chart{overflow:hidden}.tp-quick-chart>.tp-c-head{min-height:46px;padding:10px 14px}.tp-quick-chart #tpChartCard>.tp-c-head{display:none!important}.tp-quick-chart .tp-chart-wrap{height:clamp(330px,42vh,440px)}
.tp-workspace-view{--tp-hover:var(--tp-surface-3);--tp-selected:var(--tp-info-bg)}
body.tp-theme-dark .tp-workspace-view{--tp-bg:#080F14;--tp-surface:#111827;--tp-surface-2:#1A2230;--tp-surface-3:#202B3A;--tp-border:#2F4053;--tp-border-2:#40556C;--tp-text:#E5E7EB;--tp-text-2:#CBD5E1;--tp-text-3:#94A3B8;--tp-text-dim:#64748B;--tp-info:#60A5FA;--tp-long:#22C55E;--tp-short:#F87171;--tp-warn:#FBBF24;--tp-hover:#29384A;--tp-selected:#243B5A}
.tp-workspace-view{padding:0!important;overflow:visible}.tp-workspace-top{height:40px;min-height:40px}.tp-workspace-shell{display:grid;grid-template-columns:minmax(0,1fr) clamp(300px,22vw,340px);height:clamp(560px,72vh,760px);min-height:540px}.tp-workspace-chart{min-width:0;min-height:0;overflow:hidden;background:var(--tp-bg)}.tp-workspace-chart #tpChartCard,.tp-workspace-chart .tp-chart-wrap,.tp-workspace-chart .tp-chart-frame{width:100%;height:100%;min-height:0}.tp-workspace-chart #tpChartCard{display:flex;flex-direction:column}.tp-workspace-chart .tp-chart-wrap{flex:1 1 auto}
.tp-workspace-side{display:flex;flex-direction:column;min-width:0;overflow:hidden;padding:0;background:var(--tp-surface);border-inline-start:1px solid var(--tp-border)}
.tp-terminal-tabs{display:grid;grid-template-columns:repeat(3,1fr);flex:0 0 auto;border-bottom:1px solid var(--tp-border);background:var(--tp-surface-2)}.tp-terminal-tabs button,.tp-terminal-subtabs button,.tp-terminal-mode button{min-height:38px;border:0;background:transparent;color:var(--tp-text-2);font:600 12px/1.2 inherit;cursor:pointer;opacity:1}.tp-terminal-tabs button:hover,.tp-terminal-subtabs button:hover,.tp-terminal-mode button:hover{background:var(--tp-hover);color:var(--tp-text)}.tp-terminal-tabs button.is-active,.tp-terminal-subtabs button.is-active,.tp-terminal-mode button.is-active{color:var(--tp-info);background:var(--tp-selected);box-shadow:inset 0 -2px 0 var(--tp-info)}.tp-terminal-tabs button:disabled,.tp-terminal-subtabs button:disabled,.tp-terminal-mode button:disabled{color:var(--tp-text-dim);opacity:1;cursor:not-allowed}
.tp-terminal-side-panel{display:none;min-height:0;overflow:auto;padding:14px;color:var(--tp-text);overscroll-behavior:contain}.tp-terminal-side-panel > *,.tp-terminal-side-panel #tpWorkspaceSignal{min-width:0;max-width:100%;overflow-wrap:anywhere}.tp-terminal-side-panel .tp-analysis-board,.tp-terminal-side-panel .tp-analysis-grid,.tp-terminal-side-panel .tp-analysis-scores{min-width:0}.tp-terminal-side-panel .tp-analysis-grid{grid-template-columns:repeat(auto-fit,minmax(0,1fr))}.tp-terminal-side-panel.is-active{display:block}.tp-terminal-status{display:grid;gap:3px;margin-bottom:12px;padding:9px 10px;border:1px solid var(--tp-border);border-inline-start:2px solid var(--tp-info);border-radius:8px;background:var(--tp-surface-2);font-size:11px;color:var(--tp-text-2)}.tp-terminal-status strong{color:var(--tp-text);font-size:12px;text-align:start}.tp-trade-direction{display:grid!important;grid-template-columns:1fr 1fr;width:100%;margin-bottom:10px}.tp-trade-direction .tp-seg-btn{min-height:38px}.tp-terminal-subtabs{display:grid;grid-template-columns:repeat(2,1fr);margin-bottom:12px;border-bottom:1px solid var(--tp-border)}.tp-terminal-subtabs button{padding-inline:3px;font-size:11px}
.tp-trade-form{display:grid;gap:9px}.tp-trade-form label{display:grid;grid-template-columns:minmax(74px,.7fr) minmax(0,1fr);align-items:center;gap:8px;color:var(--tp-text-2);font-size:12px}.tp-trade-form input{width:100%;min-height:38px;padding:7px 9px;border:1px solid var(--tp-border-2);border-radius:7px;background:var(--tp-surface-2);color:var(--tp-text);font:600 12px/1.2 var(--tp-mono);text-align:end}.tp-trade-form input:hover:not(:disabled){border-color:var(--tp-border-strong)}.tp-trade-form input:focus{border-color:var(--tp-info);outline:0;box-shadow:0 0 0 3px color-mix(in srgb,var(--tp-info) 18%,transparent)}.tp-terminal-section-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:15px 0 9px;color:var(--tp-text);font-size:13px}.tp-terminal-mode{display:flex;border:1px solid var(--tp-border);border-radius:7px;overflow:hidden}.tp-terminal-mode button{min-height:30px;padding:5px 8px;font-size:10px}.tp-terminal-mode button.is-active{background:var(--tp-info-bg);box-shadow:none}.tp-trade-risk-grid{grid-template-columns:1fr 1fr}.tp-trade-risk-grid label{display:grid;grid-template-columns:1fr;gap:4px}.tp-trade-risk-grid .tp-trade-wide{grid-column:1/-1}.tp-suggested-levels{display:grid;grid-template-columns:repeat(4,1fr);gap:5px;margin:12px 0}.tp-suggested-levels div{display:grid;gap:2px;min-width:0;padding:7px 5px;border:1px solid var(--tp-border);border-radius:7px;background:var(--tp-surface-2);text-align:center}.tp-suggested-levels span{font-size:9px;color:var(--tp-text-3)}.tp-suggested-levels b{overflow:hidden;color:var(--tp-text);font:650 10px/1.2 var(--tp-mono);text-overflow:ellipsis}.tp-terminal-submit{width:100%;min-height:42px}.tp-workspace-side #tpWorkspaceSignal .tp-kpi{padding:8px}.tp-workspace-side #tpWorkspaceSignal .tp-switch-row{padding-block:7px}.tp-workspace-side .tp-ai-brief{font-size:12px;line-height:1.5}.tp-workspace-side .tp-ai-brief p{margin:7px 0}.tp-workspace-side .tp-ai-brief details{margin-top:9px}.tp-advisor-action{margin-bottom:10px;padding:10px;border:1px solid color-mix(in srgb,var(--tp-info) 45%,var(--tp-border));border-radius:8px;background:var(--tp-info-bg);color:var(--tp-info);font-size:15px;font-weight:850;letter-spacing:.08em;text-align:center}
.tp-workspace-bottom{min-height:260px;overflow:visible;padding:0;background:var(--tp-surface);border-top:1px solid var(--tp-border);transition:min-height .18s ease}.tp-workspace-bottom-tabs{display:flex;gap:3px;align-items:center;overflow-x:auto;padding:7px 10px;background:var(--tp-surface);border-bottom:1px solid var(--tp-border)}.tp-workspace-bottom-tabs .tp-chip{flex:0 0 auto;min-height:34px;padding:4px 10px;border:1px solid transparent;border-radius:var(--tp-radius-md);background:transparent;color:var(--tp-text-2);font-size:12px;font-weight:600;opacity:1;transition:background .12s ease,border-color .12s ease,color .12s ease}.tp-workspace-bottom-tabs .tp-chip:hover{background:var(--tp-hover);border-color:var(--tp-border-2);color:var(--tp-text)}.tp-workspace-bottom-tabs .tp-chip:focus-visible{outline:2px solid var(--tp-info);outline-offset:2px}.tp-workspace-bottom-tabs .tp-chip.is-active{background:var(--tp-selected);border-color:var(--tp-info);color:var(--tp-info);font-weight:700}.tp-workspace-bottom-toggle{margin-inline-start:auto;display:flex;align-items:center;justify-content:center;gap:5px;flex:0 0 auto;min-width:86px;height:34px;padding:0 10px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-2);color:var(--tp-text-2);font:600 11px/1 inherit;cursor:pointer;transition:background .12s ease,border-color .12s ease,color .12s ease}.tp-workspace-bottom-toggle:hover{background:var(--tp-hover);border-color:var(--tp-border-strong);color:var(--tp-text)}.tp-workspace-bottom-toggle:focus-visible{outline:2px solid var(--tp-info);outline-offset:2px}.tp-workspace-bottom #tpWorkspaceBottomBody{min-height:210px;padding:14px 16px;overflow:visible}.tp-workspace-bottom.is-collapsed{min-height:49px;height:49px;overflow:hidden}.tp-workspace-bottom.is-collapsed .tp-workspace-bottom-toggle>span:last-child{transform:rotate(180deg)}.tp-workspace-bottom.is-collapsed #tpWorkspaceBottomBody{display:none}.tp-workspace-bottom .tp-empty{min-height:120px;padding:24px}.tp-workspace-position-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(340px,100%),1fr));gap:12px}.tp-workspace-position-grid .tp-action-position{min-width:0;padding:14px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-2)}.tp-workspace-notification-link{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:100px;padding:12px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-2)}
.tp-analysis-board{display:grid;gap:12px;min-width:0}.tp-analysis-head{display:flex;align-items:center;gap:12px;padding-bottom:10px;border-bottom:1px solid var(--tp-border)}.tp-analysis-head>div{display:grid;gap:2px}.tp-analysis-head small{color:var(--tp-text-3);font-size:10px}.tp-analysis-price{margin-inline-start:auto;color:var(--tp-text);font:750 18px/1.2 var(--tp-mono)}.tp-analysis-scores{display:grid;grid-template-columns:repeat(4,minmax(120px,1fr));gap:8px}.tp-analysis-grid{display:grid;grid-template-columns:repeat(5,minmax(120px,1fr));gap:8px}.tp-analysis-metric{display:grid;gap:5px;min-width:0;padding:10px 11px;border:1px solid var(--tp-border);border-radius:8px;background:var(--tp-surface-2)}.tp-analysis-metric small{color:var(--tp-text-3);font-size:10px}.tp-analysis-metric strong{overflow-wrap:anywhere;color:var(--tp-text);font:650 12px/1.35 var(--tp-mono)}.tp-analysis-reasons{padding:12px 14px;border:1px solid var(--tp-border);border-radius:8px;background:var(--tp-surface-2);color:var(--tp-text)}.tp-analysis-reasons ul{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 22px;margin:8px 0 0;padding-inline-start:20px;color:var(--tp-text-2);line-height:1.5}.tp-analysis-reasons p{margin:8px 0 0;color:var(--tp-text-3)}
.tp-trade-form label>span{display:flex;align-items:center;justify-content:space-between;gap:8px}.tp-trade-form label>span small{color:var(--tp-text-muted);font:600 10px/1 var(--tp-mono)}.tp-balance-row{display:grid;gap:7px;padding:9px 0;border-bottom:1px solid var(--tp-border)}.tp-balance-row>span{color:var(--tp-text-muted);font-size:10px}.tp-size-shortcuts{display:grid;grid-template-columns:repeat(5,1fr);gap:4px}.tp-size-shortcuts button{min-height:30px;padding:0;border:1px solid var(--tp-border);border-radius:5px;background:var(--tp-surface-2);color:var(--tp-text-secondary);font:650 10px/1 var(--tp-font);cursor:pointer}.tp-size-shortcuts button:hover:not(:disabled){border-color:var(--tp-info);background:var(--tp-selected);color:var(--tp-text-primary)}.tp-size-shortcuts button:disabled{opacity:.42;cursor:not-allowed}.tp-order-preview{margin-top:10px;padding:10px;border:1px solid var(--tp-border);border-radius:8px;background:var(--tp-surface-2)}.tp-order-preview-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.tp-order-preview-grid>span{display:grid;gap:3px;min-width:0}.tp-order-preview-grid small{color:var(--tp-text-muted);font-size:9px}.tp-order-preview-grid b{overflow-wrap:anywhere;color:var(--tp-text-primary);font:650 10px/1.3 var(--tp-mono)}.tp-order-missing{margin:9px 0 0;color:var(--tp-warning);font-size:10px;line-height:1.4}.tp-order-review{display:grid;gap:12px}.tp-order-review .tp-order-preview-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.tp-terminal-submit:disabled{opacity:.5;cursor:not-allowed}.tp-workspace-table-wrap{max-width:100%;overflow-x:auto;border:1px solid var(--tp-border);border-radius:8px}.tp-workspace-table{width:100%;min-width:1180px;border-collapse:collapse;background:var(--tp-surface)}.tp-workspace-table th,.tp-workspace-table td{padding:9px 10px;border-bottom:1px solid var(--tp-border);color:var(--tp-text-secondary);font-size:10px;text-align:start;white-space:nowrap}.tp-workspace-table th{position:sticky;top:0;background:var(--tp-surface-2);color:var(--tp-text-muted);font-weight:750;text-transform:uppercase;letter-spacing:.04em}.tp-workspace-table td strong{color:var(--tp-text-primary)}.tp-table-actions{display:flex;gap:4px}.tp-workspace-table tr:last-child td{border-bottom:0}.tp-workspace-table tbody tr:hover{background:var(--tp-hover)}
@media(max-width:1050px){.tp-workspace-shell{grid-template-columns:minmax(0,1fr) 300px}.tp-workspace-side{font-size:12px}}
@media(max-width:900px){.tp-workspace-view{overflow:visible}.tp-workspace-shell{display:block;height:auto;min-height:0}.tp-workspace-chart .tp-chart-wrap{height:clamp(480px,64dvh,680px);min-height:480px}.tp-workspace-side{display:block;position:static;max-height:none;border-inline-start:0;border-top:1px solid var(--tp-border)}.tp-terminal-side-panel{max-height:none;overflow:visible}.tp-workspace-bottom{min-height:240px}.tp-analysis-scores{grid-template-columns:repeat(2,minmax(0,1fr))}.tp-analysis-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.tp-quick-chart .tp-chart-wrap{height:clamp(320px,48vh,410px)}}
@media(max-width:700px){.tp-analysis-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.tp-analysis-metric{padding:8px}.tp-analysis-metric small{font-size:10px;white-space:normal;line-height:1.25}.tp-analysis-metric strong{font-size:11px;overflow-wrap:anywhere}.tp-dashboard-review-grid{grid-template-columns:minmax(0,1fr);gap:8px}.tp-trade-review-row{grid-template-columns:minmax(105px,1.2fr) minmax(78px,.8fr) minmax(84px,.85fr);gap:7px}.tp-trade-review-row .tp-review-entry,.tp-trade-review-row .tp-review-exit{display:none}.tp-trade-review-row time{font-size:10px}}
@media(max-width:360px){.tp-analysis-grid{grid-template-columns:minmax(0,1fr)}.tp-trade-review-row{grid-template-columns:minmax(0,1fr) auto}.tp-trade-review-pnl{text-align:start}.tp-trade-review-row time{grid-column:2;grid-row:1;align-self:start}}
@media(max-width:600px){.tp-workspace-top{padding-inline:8px}.tp-workspace-chart .tp-chart-wrap{height:clamp(430px,62dvh,620px);min-height:430px}.tp-terminal-tabs{position:sticky;top:0;z-index:3}.tp-terminal-tabs button{min-height:44px}.tp-terminal-side-panel{padding:12px}.tp-terminal-subtabs button,.tp-trade-direction .tp-seg-btn{min-height:44px}.tp-trade-form input{min-height:44px}.tp-workspace-bottom-tabs .tp-chip,.tp-workspace-bottom-toggle{min-height:40px}.tp-workspace-bottom{padding-bottom:env(safe-area-inset-bottom)}.tp-workspace-bottom-toggle{min-width:42px}.tp-workspace-toggle-label{display:none}.tp-workspace-bottom #tpWorkspaceBottomBody{padding:12px;min-height:200px}.tp-analysis-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.tp-analysis-reasons ul{grid-template-columns:1fr}.tp-analysis-head{flex-wrap:wrap}.tp-analysis-price{width:100%;margin:0}.tp-workspace-notification-link{align-items:stretch;flex-direction:column}.tp-quick-chart .tp-chart-wrap{height:clamp(300px,78vw,390px);min-height:300px}.tp-quick-chart>.tp-c-head{align-items:flex-start;gap:8px}.tp-quick-chart>.tp-c-head .tp-btn{white-space:normal;text-align:center}}
@media(max-width:600px){.tp-order-preview-grid,.tp-order-review .tp-order-preview-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.tp-workspace-table-wrap{border:0;overflow:visible}.tp-workspace-table,.tp-workspace-table tbody{display:grid;min-width:0;gap:10px}.tp-workspace-table thead{display:none}.tp-workspace-table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;padding:11px;border:1px solid var(--tp-border);border-radius:8px;background:var(--tp-surface-2)}.tp-workspace-table td{display:grid;gap:2px;padding:0;border:0;white-space:normal}.tp-workspace-table td::before{content:attr(data-label);color:var(--tp-text-muted);font-size:9px}.tp-table-actions{grid-column:1/-1;flex-wrap:wrap}}

/* Dashboard overview: lightweight previews, never professional chart hosts. */
.tp-dashboard-opportunities,.tp-market-overview{margin-bottom:12px}.tp-market-overview-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(210px,100%),1fr));gap:10px;padding:0 14px 14px}.tp-market-card{display:grid;gap:8px;min-width:0;min-height:148px;padding:12px;border:1px solid var(--tp-border);border-radius:var(--tp-r-lg);background:var(--tp-surface-2);color:var(--tp-text);font:inherit;text-align:start;cursor:pointer;transition:border-color .15s ease,transform .15s ease}.tp-market-card:hover{border-color:var(--tp-border-strong);transform:translateY(-1px)}.tp-market-card:focus-visible{outline:2px solid var(--tp-info);outline-offset:2px}.tp-market-card-head,.tp-market-card-price{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}.tp-market-card-head>span:first-child{display:grid}.tp-market-card-head strong{font-size:14px}.tp-market-card-head small{color:var(--tp-text-3);font-size:10px}.tp-mini-signal{padding:3px 6px;border-radius:4px;background:var(--tp-info-bg);color:var(--tp-info);font-size:9px;font-weight:750}.tp-market-card-price>strong{font:700 14px/1.2 var(--tp-mono)}.tp-market-card-price>span{font-size:11px;font-weight:700}.tp-mini-chart-host{height:68px;min-width:0}.tp-mini-chart{display:block;width:100%;height:68px;overflow:visible}.tp-mini-chart polyline{fill:none;stroke:currentColor;stroke-width:2;vector-effect:non-scaling-stroke}.tp-mini-chart.is-positive{color:var(--tp-long)}.tp-mini-chart.is-negative{color:var(--tp-short)}.tp-mini-chart-empty{display:grid;place-items:center;height:68px;color:var(--tp-text-3);font-size:10px}

/* User-first account performance dashboard. */
.tp-summary-card{margin-bottom:var(--tp-space-3)}.tp-summary-card .tp-c-head{justify-content:space-between}.tp-summary-card #tpDashboardAccountNotice:empty{display:none}.tp-summary-card #tpDashboardAccountNotice{margin-bottom:var(--tp-space-2)}.tp-summary-card .tp-kpi-strip{grid-template-columns:repeat(5,minmax(112px,1fr))}.tp-performance-strip{display:grid;grid-template-columns:repeat(auto-fit,minmax(118px,1fr));gap:1px;margin-top:var(--tp-space-2);overflow:visible;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-border)}.tp-performance-strip>div{display:grid;gap:3px;min-width:104px;padding:var(--tp-space-2);background:var(--tp-surface-raised)}.tp-performance-strip small{color:var(--tp-text-muted);font-size:var(--tp-font-xs)}.tp-performance-strip strong{color:var(--tp-text-primary);font:650 var(--tp-font-sm)/var(--tp-line-tight) var(--tp-mono)}.tp-dashboard-review-grid{display:grid;grid-template-columns:minmax(0,1.65fr) minmax(260px,1fr);gap:var(--tp-space-3);margin-bottom:var(--tp-space-3)}.tp-dashboard-review-grid>.tp-c{min-width:0}.tp-trade-review-list{display:grid}.tp-trade-review-row{display:grid;grid-template-columns:minmax(120px,1.25fr) minmax(80px,.8fr) minmax(80px,.8fr) minmax(88px,.85fr) minmax(68px,.65fr) minmax(108px,.9fr);align-items:center;gap:10px;min-height:50px;padding:7px 2px;border-bottom:1px solid var(--tp-border)}.tp-trade-review-row:last-child{border-bottom:0}.tp-trade-review-row small,.tp-trade-review-row b,.tp-trade-review-row strong{display:block}.tp-trade-review-row small,.tp-trade-review-row time{color:var(--tp-text-muted);font-size:10px}.tp-trade-review-row b,.tp-trade-review-row strong{color:var(--tp-text-primary);font:600 11px/1.3 var(--tp-mono)}.tp-trade-review-symbol strong{font-family:var(--tp-font);font-size:12px}.tp-trade-review-pnl{text-align:end}.tp-trade-review-pnl strong{font-size:12px}.tp-trade-review-row time{text-align:end}.tp-quality-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);overflow:hidden;background:var(--tp-border)}.tp-quality-grid>div{display:grid;gap:4px;min-height:56px;padding:9px;background:var(--tp-surface-raised)}.tp-quality-grid small{color:var(--tp-text-muted);font-size:10px}.tp-quality-grid strong{color:var(--tp-text-primary);font:650 12px/1.3 var(--tp-mono)}.tp-quality-note{margin:8px 0 0;color:var(--tp-text-muted);font-size:10px}.tp-dashboard-lifecycle,.tp-dashboard-primary{margin-bottom:var(--tp-space-3)}
.tp-performance-strip.is-empty{display:block;overflow:hidden;background:var(--tp-surface-raised)}.tp-performance-empty{display:flex!important;align-items:center;justify-content:center;min-width:0!important;min-height:56px;padding:var(--tp-space-3)!important;background:var(--tp-surface-raised)!important;color:var(--tp-text-secondary);font-size:var(--tp-font-md);line-height:var(--tp-line-normal);text-align:center}.tp-performance-empty:hover{background:var(--tp-surface-raised)!important;color:var(--tp-text-secondary)}.tp-ind-library-head{margin:var(--tp-space-3) 0 var(--tp-space-2);padding:0 2px}.tp-seg-btn:hover:not(:disabled),.tp-chip:hover:not(:disabled),.tp-menu-item:hover,.tp-side-link:hover,.tp-set-nav button:hover,.tp-account-nav button:hover,.tp-terminal-tabs button:hover,.tp-terminal-subtabs button:hover,.tp-workspace-bottom-tabs button:hover{background:var(--tp-hover);color:var(--tp-text-primary)}.tp-seg-btn.is-active,.tp-chip.is-active,.tp-menu-item.is-active,.tp-side-link.is-active,.tp-set-nav button.is-active,.tp-account-nav button.is-active,.tp-terminal-tabs button.is-active,.tp-terminal-subtabs button.is-active,.tp-workspace-bottom-tabs button.is-active{background:var(--tp-selected);color:var(--tp-text-primary)}
.tp-mini-scores{display:flex;gap:var(--tp-space-3);margin-top:2px;color:var(--tp-text-muted);font-size:var(--tp-font-xs)}.tp-mini-scores b{color:var(--tp-text-secondary);font-family:var(--tp-mono)}.tp-ind-active-row .tp-icon-btn.is-muted{color:var(--tp-text-muted);background:var(--tp-surface-2)}
/* Real cells own their borders. Using the separator color as the grid
   background painted the unoccupied tail of the final auto-fit row. */
.tp-performance-strip:not(.is-empty){border:0;background:transparent}
.tp-performance-strip:not(.is-empty)>div{border:1px solid var(--tp-border);border-radius:var(--tp-radius-sm)}
.tp-more-statistics{margin-top:8px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-sm);background:var(--tp-surface-raised)}.tp-more-statistics summary{cursor:pointer;padding:9px 10px;color:var(--tp-text-secondary);font-size:var(--tp-font-xs);font-weight:650;list-style:none}.tp-more-statistics summary::-webkit-details-marker{display:none}.tp-more-statistics summary:before{content:'+';display:inline-block;width:16px;color:var(--tp-text-muted)}.tp-more-statistics[open] summary:before{content:'−'}.tp-more-statistics .tp-quality-grid{margin:0;border:0;border-top:1px solid var(--tp-border);border-radius:0}
@media(max-width:1050px){.tp-summary-card .tp-kpi-strip{grid-template-columns:repeat(3,minmax(112px,1fr))}.tp-dashboard-review-grid{grid-template-columns:1fr}}
@media(max-width:760px){.tp-trade-review-row{grid-template-columns:minmax(110px,1fr) minmax(80px,.8fr) minmax(72px,.7fr) minmax(100px,.8fr)}.tp-review-entry,.tp-review-exit{display:none}}
@media(max-width:600px){.tp-dashboard-review-grid{gap:var(--tp-space-2)}.tp-summary-card .tp-c-head{align-items:flex-start}.tp-summary-card #tpDashboardPerformanceMode{margin-inline-start:auto}.tp-trade-review-row{grid-template-columns:minmax(105px,1fr) minmax(78px,.75fr) minmax(88px,.8fr)}.tp-trade-review-duration{display:none}.tp-quality-grid>div{min-height:52px;padding:8px}}

/* Professional market/account strip. */
.tp-workspace-top{height:40px;min-height:40px;padding:2px 8px}.tp-market-strip{display:flex!important;align-items:center;gap:10px;min-width:0;overflow-x:auto;scrollbar-width:thin}.tp-market-strip>span{display:grid;flex:0 0 auto;gap:1px}.tp-market-strip small{color:var(--tp-text-3);font-size:8px;line-height:1;text-transform:uppercase}.tp-market-strip strong{color:var(--tp-text-2);font:600 10px/1.2 var(--tp-mono)}.tp-market-symbol{flex:0 0 auto;min-height:28px;padding:3px 7px;border:1px solid var(--tp-border-2);border-radius:6px;background:var(--tp-surface-2);color:var(--tp-text);font:700 12px/1 var(--tp-mono);cursor:pointer}.tp-market-live{display:flex!important;align-items:center!important;gap:4px!important;color:var(--tp-long)}.tp-market-live i{width:6px;height:6px;border-radius:50%;background:var(--tp-long);box-shadow:0 0 0 2px var(--tp-long-bg)}.tp-market-live strong{color:var(--tp-long)}
#tpWorkspaceFullscreen{display:inline-flex;align-items:center;justify-content:center;min-height:30px;height:30px;padding:0 8px;border:1px solid var(--tp-border);border-radius:6px;background:var(--tp-surface-2);color:var(--tp-text-2);font-size:11px;font-weight:600;white-space:nowrap}
#tpWorkspaceFullscreen:hover{background:var(--tp-hover);color:var(--tp-text);border-color:var(--tp-border-2)}
#tpWorkspaceFullscreen:focus-visible{outline:2px solid var(--tp-info);outline-offset:2px}

/* Settings route presents as a focused right-side drawer. */
.tp-view[data-view="settings"]{position:relative;padding-bottom:var(--tp-space-5);background:transparent}.tp-view[data-view="settings"] .tp-set-layout{grid-template-columns:190px minmax(0,760px);gap:var(--tp-space-3);align-items:start}.tp-view[data-view="settings"] .tp-set-nav{position:sticky;top:calc(var(--tp-topbar-h) + var(--tp-space-2));padding:var(--tp-space-2);border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface)}.tp-view[data-view="settings"] .tp-set-nav button{min-height:38px;color:var(--tp-text-secondary);border:1px solid transparent}.tp-view[data-view="settings"] .tp-set-nav button:hover{color:var(--tp-text);background:var(--tp-hover)}.tp-view[data-view="settings"] .tp-set-nav button.is-active{color:var(--tp-text);background:var(--tp-selected);border-color:var(--tp-border)}.tp-view[data-view="settings"] .tp-set-body>.tp-c{padding:var(--tp-space-3)}

/* Account is a local settings workspace, not a stack of dashboard cards. */
.tp-account-layout{display:grid;grid-template-columns:210px minmax(0,1fr);gap:var(--tp-space-3);align-items:start}.tp-account-nav{position:sticky;top:calc(var(--tp-topbar-h) + var(--tp-space-2));max-height:calc(100dvh - var(--tp-topbar-h) - 20px);overflow-y:auto;padding:var(--tp-space-2);border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface)}.tp-account-nav-group+ .tp-account-nav-group{margin-top:var(--tp-space-3)}.tp-account-nav-title{padding:var(--tp-space-1) var(--tp-space-2);color:var(--tp-text-muted);font-size:var(--tp-font-xs);font-weight:750;letter-spacing:.07em;text-transform:uppercase}.tp-account-nav button{display:flex;align-items:center;width:100%;min-height:var(--tp-control-md);padding:var(--tp-space-1) var(--tp-space-2);border:0;border-radius:var(--tp-radius-md);background:transparent;color:var(--tp-text-secondary);font:600 var(--tp-font-sm)/var(--tp-line-tight) var(--tp-font);text-align:start;cursor:pointer}.tp-account-nav button:hover{background:var(--tp-hover);color:var(--tp-text-primary)}.tp-account-nav button.is-active{background:var(--tp-selected);color:var(--tp-text-primary);box-shadow:inset 2px 0 0 var(--tp-accent)}[dir="rtl"] .tp-account-nav button.is-active{box-shadow:inset -2px 0 0 var(--tp-accent)}.tp-account-content{min-width:0}.tp-account-content>.tp-c{padding:var(--tp-space-3)}.tp-account-content .tp-table-wrap{overflow-x:auto}.tp-account-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--tp-space-2);margin-bottom:var(--tp-space-3)}.tp-account-summary>div{padding:var(--tp-space-2);border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-raised)}.tp-account-summary small,.tp-account-summary strong{display:block}.tp-account-summary small{color:var(--tp-text-muted);font-size:var(--tp-font-xs)}.tp-account-summary strong{margin-top:2px;color:var(--tp-text-primary);font:650 var(--tp-font-md)/var(--tp-line-tight) var(--tp-mono)}
.tp-payment-steps{display:grid;gap:var(--tp-space-3)}.tp-payment-address{min-height:64px;padding:var(--tp-space-3);border:1px dashed var(--tp-border-strong);border-radius:var(--tp-radius-md);background:var(--tp-surface-raised);color:var(--tp-text-secondary);line-height:var(--tp-line-normal)}.tp-payment-quote{display:grid;gap:var(--tp-space-2)}.tp-payment-quote strong{color:var(--tp-text-primary);font:700 var(--tp-font-lg)/var(--tp-line-tight) var(--tp-mono)}.tp-payment-quote code{overflow-wrap:anywhere;color:var(--tp-text-primary)}.tp-payment-quote img{padding:5px;border-radius:var(--tp-radius-md);background:#fff}.tp-payment-actions{display:flex;gap:var(--tp-space-2);flex-wrap:wrap}.tp-payment-actions>.tp-btn{min-height:var(--tp-control-md)}

body.tp-theme-light .tp-workspace-top,body.tp-theme-light .tp-workspace-side,body.tp-theme-light .tp-workspace-bottom,body.tp-theme-light .tp-terminal-tabs,body.tp-theme-light .tp-settings-drawer{background:var(--tp-surface);color:var(--tp-text);border-color:var(--tp-border)}body.tp-theme-light .tp-terminal-tabs button,body.tp-theme-light .tp-terminal-subtabs button,body.tp-theme-light .tp-terminal-mode button{color:var(--tp-text-2);opacity:1}body.tp-theme-light .tp-terminal-tabs button.is-active,body.tp-theme-light .tp-terminal-subtabs button.is-active,body.tp-theme-light .tp-terminal-mode button.is-active{color:var(--tp-info)}body.tp-theme-light .tp-market-card{background:var(--tp-surface-2);color:var(--tp-text);border-color:var(--tp-border)}body.tp-theme-light .tp-market-card-head small,body.tp-theme-light .tp-mini-chart-empty{color:var(--tp-text-2)!important}body.tp-theme-light .tp-market-symbol{background:var(--tp-surface-3);color:var(--tp-text);border-color:var(--tp-border-2)}
body.tp-theme-light .tp-market-strip,body.tp-theme-light .tp-market-strip strong,body.tp-theme-light .tp-market-symbol{opacity:1;color:var(--tp-text-primary)}body.tp-theme-light .tp-market-strip small{opacity:1;color:var(--tp-text-muted)}body.tp-theme-light .tp-market-live,body.tp-theme-light .tp-market-live strong{opacity:1;color:var(--tp-positive)}body.tp-theme-light #tpWorkspaceChange.tp-pnl-pos{color:var(--tp-positive)}body.tp-theme-light #tpWorkspaceChange.tp-pnl-neg{color:var(--tp-negative)}

@media(max-width:900px){.tp-market-strip{gap:11px}.tp-workspace-top{align-items:flex-start}.tp-workspace-top #tpWorkspaceFullscreen{flex:0 0 auto}}
@media(max-width:700px){.tp-account-layout{grid-template-columns:1fr}.tp-account-nav{position:static;display:flex;gap:4px;max-height:none;overflow-x:auto}.tp-account-nav-group{display:flex;gap:4px;flex:0 0 auto}.tp-account-nav-group+ .tp-account-nav-group{margin-top:0}.tp-account-nav-title{display:none}.tp-account-nav button{min-height:44px;white-space:nowrap}.tp-account-summary{grid-template-columns:1fr}.tp-view[data-view="settings"] .tp-set-layout{display:flex;flex-direction:column}.tp-view[data-view="settings"] .tp-set-nav{position:static;flex-direction:row;max-width:100%;overflow-x:auto}.tp-view[data-view="settings"] .tp-set-nav button{min-height:44px;white-space:nowrap}.tp-ind-row{min-height:54px}.tp-ind-active-row{grid-template-columns:8px minmax(0,1fr) 40px 40px 40px;min-height:44px}}
@media(max-width:600px){.tp-market-overview-grid{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;padding-inline:10px}.tp-market-card{flex:0 0 min(84vw,330px);scroll-snap-align:start;min-height:150px}.tp-market-strip>span:nth-of-type(1),.tp-market-strip>span:nth-of-type(5),.tp-market-strip>span:nth-of-type(7){display:none}.tp-market-symbol{min-height:40px}}
.tp-market-card.is-stale{border-style:dashed}.tp-market-card.is-stale .tp-mini-signal{background:var(--tp-surface-3);color:var(--tp-text-muted)}
.tp-topbar-context{display:flex;align-items:center;gap:6px;color:var(--tp-text-muted);font-size:11px}.tp-topbar-context .tp-sel{min-width:104px}
.tp-quick-settings-wrap{position:relative}.tp-quick-settings-wrap>.tp-icon-btn svg,.tp-notification-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8}
.tp-quick-settings{position:absolute;z-index:160;top:calc(100% + 8px);inset-inline-end:0;display:grid;gap:8px;width:230px;padding:10px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-raised);box-shadow:var(--tp-shadow-lg)}.tp-quick-settings[hidden]{display:none}.tp-quick-settings>strong{font-size:13px}.tp-quick-settings label{display:flex;align-items:center;justify-content:space-between;gap:10px;color:var(--tp-text-secondary);font-size:12px}.tp-quick-settings .tp-sel{min-width:118px}
.tp-market-explorer-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:0 0 var(--tp-space-3)}.tp-market-explorer-bar .tp-in{width:min(260px,40vw)}.tp-market-explorer-empty{grid-column:1/-1;margin:0 14px 14px}
.tp-risk-summary{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:8px;padding:8px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-2);color:var(--tp-text-secondary);font-size:11px}.tp-risk-summary>span{display:grid;gap:2px}.tp-risk-summary small{color:var(--tp-text-muted)}.tp-risk-summary b{color:var(--tp-text-primary);font-family:var(--tp-mono);font-size:11px}
@media(max-width:900px){.tp-topbar-context>span{display:none}.tp-topbar-context .tp-sel{min-width:88px}.tp-market-explorer-bar{align-items:stretch}.tp-market-explorer-bar .tp-in{width:100%}}
@media(max-width:600px){.tp-topbar-context{order:8}.tp-market-explorer-bar{flex-direction:column}.tp-risk-summary{grid-template-columns:1fr}.tp-quick-settings{position:fixed;top:calc(var(--tp-topbar-h) + 6px);inset-inline:8px;width:auto}}

.tp-exchange-card{margin-top:16px;padding:14px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-raised)}.tp-exchange-status{display:grid;grid-template-columns:minmax(120px,1.2fr) repeat(3,minmax(100px,1fr));gap:12px;align-items:center}.tp-exchange-status>span{display:grid;gap:4px;min-width:0}.tp-exchange-status strong,.tp-exchange-status b{font-size:20px}.tp-exchange-status small{font-size:13px;color:var(--tp-text-muted)}.tp-exchange-readonly-list{display:grid;gap:10px;margin-top:14px;padding:12px;border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface-raised);font-size:13px}.tp-exchange-readonly-list>strong{font-size:14px}@media(max-width:700px){.tp-exchange-status{grid-template-columns:repeat(2,minmax(0,1fr))}.tp-exchange-status>span:first-child{grid-column:1/-1}}

.tp-market-card{position:relative;padding:0;overflow:hidden}.tp-market-card-select{display:grid;gap:8px;width:100%;min-height:148px;padding:12px;border:0;background:transparent;color:inherit;font:inherit;text-align:start;cursor:pointer}.tp-market-favorite{position:absolute;top:7px;right:7px;width:25px;height:25px;border:0;background:transparent;color:var(--tp-warning);font-size:18px;line-height:1;cursor:pointer}.tp-market-open{position:absolute;right:8px;bottom:8px;min-height:24px;padding:2px 6px;border:1px solid var(--tp-border);border-radius:4px;background:var(--tp-surface);color:var(--tp-text);font:600 10px/1 system-ui;cursor:pointer}.tp-market-card-select:focus-visible,.tp-market-favorite:focus-visible,.tp-market-open:focus-visible{outline:2px solid var(--tp-info);outline-offset:-2px}


/* Scoped viewport containment for Markets and Scanner. */
.tp-view[data-view="markets"],
.tp-view[data-view="scanner"] {
  width: 100%;
  max-width: 1800px;
  min-width: 0;
  box-sizing: border-box;
}
.tp-view[data-view="markets"] .tp-split-main,
.tp-view[data-view="markets"] .tp-split-a,
.tp-view[data-view="markets"] .tp-split-b {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.tp-view[data-view="markets"] .tp-split-main {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}
.tp-view[data-view="markets"] .tp-split-b,
.tp-view[data-view="markets"] #tpSignalPanelMarkets {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.tp-view[data-view="scanner"] .tp-scan {
  width: min(100%, 1400px);
  max-width: 100%;
  min-width: 0;
  margin-inline: auto;
  box-sizing: border-box;
  overflow-x: auto;
}
@media (max-width: 1280px) {
  .tp-view[data-view="markets"] .tp-split-main {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 32%);
  }
}
@media (max-width: 1180px) {
  .tp-view[data-view="markets"] .tp-split-main {
    grid-template-columns: minmax(0, 1fr);
  }
}


.tp-view[data-view="scanner"] .tp-scan-row > * { min-width: 0; align-self: center; }
.tp-view[data-view="scanner"] .tp-scan-dir,
.tp-view[data-view="scanner"] .tp-scan-dir .tp-badge { white-space: nowrap; }
.tp-view[data-view="scanner"] .tp-scan-dir .tp-badge { line-height: 1.1; }
.tp-view[data-view="scanner"] .tp-score { line-height: 1; }

/* Scanner table presentation: one track model for every desktop row. */
.tp-view[data-view="scanner"] .tp-scan {
  width: min(100%, 1420px);
  padding-inline: 0;
}
.tp-view[data-view="scanner"] .tp-scan-head,
.tp-view[data-view="scanner"] .tp-scan-row {
  grid-template-columns: var(--tp-scan-columns);
  min-width: 1180px;
}
.tp-view[data-view="scanner"] .tp-scan-row { min-height: 38px; padding-block: 4px; line-height: 1.2; }
.tp-view[data-view="scanner"] .tp-scan-group,
.tp-view[data-view="scanner"] .tp-scan-group-head,
.tp-view[data-view="scanner"] .tp-scan-group-body {
  min-width: 1180px;
}
.tp-view[data-view="scanner"] .tp-scan-head > :nth-child(3),
.tp-view[data-view="scanner"] .tp-scan-head > :nth-child(n+8):nth-child(-n+12),
.tp-view[data-view="scanner"] .tp-scan-row > :nth-child(3),
.tp-view[data-view="scanner"] .tp-scan-row > :nth-child(n+8):nth-child(-n+12) {
  text-align: end;
}
.tp-view[data-view="scanner"] .tp-scan-head > :nth-child(n+4):nth-child(-n+6),
.tp-view[data-view="scanner"] .tp-scan-row > :nth-child(n+4):nth-child(-n+6) {
  justify-self: stretch;
}
.tp-view[data-view="scanner"] .tp-scan-head > :nth-child(7),
.tp-view[data-view="scanner"] .tp-scan-status {
  white-space: nowrap;
  overflow: hidden;
}
.tp-view[data-view="scanner"] .tp-scan-status .tp-badge {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 1.2;
}
.tp-view[data-view="scanner"] .tp-score {
  width: 100%;
  min-width: 0;
  gap: 4px;
}
.tp-view[data-view="scanner"] .tp-score-track { min-width: 20px; }
.tp-view[data-view="scanner"] .tp-score-val { min-width: 18px; }
.tp-view[data-view="scanner"] .tp-scan.is-compact .tp-scan-row,
.tp-view[data-view="scanner"] .tp-scan.is-compact .tp-scan-head {
  grid-template-columns: var(--tp-scan-columns);
}
.tp-view[data-view="scanner"] .tp-scan.is-compact .tp-col-ext { display: inline; }
@media (max-width: 1180px) {
  .tp-view[data-view="scanner"] .tp-scan-head,
  .tp-view[data-view="scanner"] .tp-scan-row,
  .tp-view[data-view="scanner"] .tp-scan-group,
  .tp-view[data-view="scanner"] .tp-scan-group-head,
  .tp-view[data-view="scanner"] .tp-scan-group-body { min-width: 1180px; }
}


/* Scanner final presentation cleanup: score bars remain secondary to values. */
.tp-view[data-view="scanner"] .tp-score { gap: 3px; }
.tp-view[data-view="scanner"] .tp-score-track { height: 2px; opacity: .55; }
.tp-view[data-view="scanner"] .tp-score-fill { opacity: .78; }
.tp-view[data-view="scanner"] .tp-score-val { color: var(--tp-text); font-weight: 650; }


/* Workspace bottom controls share the chart toolbar's compact glass shell. */
.tp-workspace-bottom-tabs{gap:4px;padding:6px 12px;background:var(--tp-surface);border-bottom:1px solid var(--tp-border);box-shadow:0 1px 8px rgba(2,6,23,.08)}
.tp-workspace-bottom-tabs .tp-chip{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;min-height:32px;padding:5px 11px;border:1px solid transparent;border-radius:var(--tp-radius-md);background:transparent;color:var(--tp-text-2);font:500 12px/1 var(--tp-font);letter-spacing:.01em;transition:background .12s ease,border-color .12s ease,color .12s ease,box-shadow .12s ease}
.tp-workspace-bottom-tabs .tp-chip:hover:not(:disabled){background:var(--tp-hover);border-color:var(--tp-border-2);color:var(--tp-text)}
.tp-workspace-bottom-tabs .tp-chip:active:not(:disabled){transform:scale(.98)}
.tp-workspace-bottom-tabs .tp-chip:focus-visible,.tp-workspace-bottom-toggle:focus-visible{outline:2px solid var(--tp-info);outline-offset:2px}
.tp-workspace-bottom-tabs .tp-chip.is-active{background:var(--tp-selected);border-color:color-mix(in srgb,var(--tp-info) 62%,var(--tp-border));color:var(--tp-info);font-weight:700;box-shadow:0 0 0 1px color-mix(in srgb,var(--tp-info) 14%,transparent)}
.tp-workspace-bottom-tabs .tp-chip:disabled,.tp-workspace-bottom-toggle:disabled{opacity:.5;cursor:not-allowed}
.tp-workspace-bottom-toggle{min-height:32px;height:32px;padding:0 10px;border-radius:var(--tp-radius-md);background:var(--tp-surface-2);color:var(--tp-text-2);box-shadow:0 1px 3px rgba(2,6,23,.08);transition:background .12s ease,border-color .12s ease,color .12s ease,transform .12s ease}
.tp-workspace-bottom-toggle:hover:not(:disabled){background:var(--tp-hover);border-color:var(--tp-border-strong);color:var(--tp-text)}
.tp-workspace-bottom-toggle:active:not(:disabled){transform:scale(.98)}
.tp-workspace-bottom-toggle>span:last-child{display:inline-flex;align-items:center;justify-content:center;width:12px;line-height:1;transition:transform .18s ease}
body.tp-theme-light .tp-workspace-bottom-tabs{box-shadow:0 1px 8px rgba(15,23,42,.05)}
@media(max-width:600px){.tp-workspace-bottom-tabs{padding:6px 8px}.tp-workspace-bottom-tabs .tp-chip{min-height:40px}.tp-workspace-bottom-toggle{min-height:40px;height:40px}}


/* Position detail card overlay */
.tp-position-detail-host{position:absolute;z-index:1610;top:54px;right:12px;pointer-events:none}
.tp-position-detail-card{pointer-events:auto;position:relative;width:220px;max-width:calc(100vw - 28px);padding:9px;border:1px solid var(--tp-border);border-radius:7px;background:var(--tp-surface);color:var(--tp-text);box-shadow:0 10px 28px rgba(2,6,23,.22);font:500 11px/1.3 var(--tp-font)}
.tp-position-detail-card>strong{display:block;padding-right:18px;font-size:11px}
.tp-position-detail-card>small{display:block;color:var(--tp-text-3);margin-bottom:6px}
.tp-position-detail-close{position:absolute;top:5px;right:6px;width:20px;height:20px;border:0;border-radius:5px;background:transparent;color:var(--tp-text-3);cursor:pointer}
.tp-position-detail-close:hover{background:var(--tp-hover);color:var(--tp-text)}
.tp-position-detail-card dl{display:grid;gap:3px;margin:0}
.tp-position-detail-card dl div{display:grid;grid-template-columns:64px 1fr;gap:6px}
.tp-position-detail-card dt{color:var(--tp-text-3)}
.tp-position-detail-card dd{margin:0;text-align:right;font-family:var(--tp-mono)}
body.tp-theme-light .tp-position-detail-card{background:rgba(255,255,255,.95);color:var(--tp-text);border-color:var(--tp-border);box-shadow:0 10px 26px rgba(15,23,42,.12)}
body.tp-theme-light .tp-position-detail-card dt,body.tp-theme-light .tp-position-detail-card>small{color:var(--tp-text-3)}
@media(max-width:700px){.tp-position-detail-host{top:92px;right:8px}.tp-position-detail-card{width:200px}}


/* ============================================================
   8. DESIGN SYSTEM FOUNDATION (final cascade layer)
   One source of truth for typography, state color, and theme
   contract. Feature rules above retain layout behavior; these
   declarations reconcile their presentation without business
   changes.
   ============================================================ */
:root {
  --surface-1: var(--tp-surface);
  --surface-2: var(--tp-surface-2);
  --surface-3: var(--tp-surface-3);
  --border: var(--tp-border);
  --border-strong: var(--tp-border-strong);
  --text-primary: var(--tp-text);
  --text-secondary: var(--tp-text-secondary);
  --text-muted: var(--tp-text-muted);
  --accent: var(--tp-info);
  --accent-hover: color-mix(in srgb, var(--tp-info) 82%, var(--tp-surface));
  --accent-soft: var(--tp-info-bg);
  --positive: var(--tp-long);
  --positive-soft: var(--tp-long-bg);
  --negative: var(--tp-short);
  --negative-soft: var(--tp-short-bg);
  --warning: var(--tp-warn);
  --warning-soft: var(--tp-warn-bg);
  --info: var(--tp-info);
  --info-soft: var(--tp-info-bg);
  --neutral: var(--tp-neutral);
  --tp-font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  --tp-font-numeric: 'SF Mono', 'Cascadia Mono', 'JetBrains Mono', ui-monospace, monospace;
  --tp-text-caption: 11px;
  --tp-text-body: 14px;
  --tp-text-heading: 16px;
  --tp-text-display: 24px;
  --tp-font-weight-label: 650;
  --tp-font-weight-title: 700;
  --tp-line-caption: 1.25;
  --tp-line-body: 1.5;
  --tp-letter-label: .02em;
}

html[lang="fa"] {
  --tp-font-ui: 'IRANSans', 'Vazirmatn', 'Noto Sans Arabic', Tahoma, system-ui, sans-serif;
}

body,
button,
input,
select,
textarea,
.tp-btn,
.tp-in,
.tp-sel,
.tp-table,
.tp-c,
.tp-c-title,
.tp-label,
.tp-view-title,
.tp-side-link,
.tp-bn-item,
.tp-tab,
.tp-seg button,
.tp-chip,
.tp-badge,
.tp-notice,
.tp-alert,
.tp-popover,
.tp-menu,
.tp-drawer,
.tp-modal,
.tp-quick-settings {
  font-family: var(--tp-font-ui);
  letter-spacing: 0;
}

body { font: 400 var(--tp-text-body)/var(--tp-line-body) var(--tp-font-ui); }
button,
input,
select,
textarea { font: inherit; }

.tp-view-title,
.tp-topbar-logo,
.tp-logo {
  color: var(--text-primary);
  font-size: var(--tp-text-display);
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.15;
}
.tp-c-title {
  color: var(--text-secondary);
  font-size: var(--tp-text-heading);
  font-weight: var(--tp-font-weight-title);
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: none;
}
.tp-label,
.tp-field label,
.tp-kpi-label,
.tp-table thead th,
.tp-workspace-table th,
.tp-account-nav-title {
  color: var(--text-muted);
  font-size: var(--tp-text-caption);
  font-weight: var(--tp-font-weight-label);
  letter-spacing: var(--tp-letter-label);
  line-height: var(--tp-line-caption);
  text-transform: uppercase;
}
.tp-side-link,
.tp-bn-item,
.tp-tab,
.tp-seg button,
.tp-chip,
.terminal-tabs button,
.tp-terminal-tabs button,
.tp-terminal-subtabs button,
.tp-workspace-bottom-tabs button {
  font-size: var(--tp-text-body);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
}

.tp-num,
.tp-t-num,
.tp-kpi-value,
.tp-table td,
.tp-workspace-table td,
.tp-position-numbers b,
.tp-performance-strip strong,
.tp-trade-review-row b,
.tp-trade-review-row strong,
.tp-quality-grid strong,
.tp-market-card-price > strong,
.tp-analysis-price,
.tp-analysis-metric strong,
.tp-order-preview-grid b,
.tp-account-summary strong,
input[type="number"],
.tp-in[type="number"] {
  color: inherit;
  font-family: var(--tp-font-numeric);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0;
  line-height: 1.25;
}
.tp-num,
.tp-t-num,
.tp-kpi-value,
.tp-performance-strip strong,
.tp-market-card-price > strong,
.tp-analysis-price {
  font-weight: 680;
}

/* Financial semantics: color reinforces, never replaces, labels/text. */
.tp-pnl-pos,
.tp-position-target,
.tp-position-entry { color: var(--positive); }
.tp-pnl-neg,
.tp-position-risk { color: var(--negative); }
.tp-pnl-flat,
.tp-position-missing { color: var(--text-muted); }
.tp-pnl-pos,
.tp-position-target,
.tp-position-entry,
.tp-pnl-neg,
.tp-position-risk { font-weight: 700; }
.tp-pnl-pos::before,
.tp-pnl-neg::before,
.tp-position-target::before,
.tp-position-risk::before { content: none; }

.tp-advisor-action,
.tp-badge { font-weight: var(--tp-font-weight-label); }
.tp-advisor-action.is-position { color: var(--positive); }
.tp-advisor-action:not(.is-position) { color: var(--info); }

.tp-pnl-pos,
.tp-pnl-neg,
.tp-position-entry,
.tp-position-risk,
.tp-position-target { color: inherit; }
.tp-pnl-pos,
.tp-pnl-neg,
.tp-position-entry,
.tp-position-risk,
.tp-position-target { font-weight: 750; }
body.tp-theme-dark .tp-pnl-pos,
body.tp-theme-dark .tp-position-target,
body.tp-theme-light .tp-pnl-pos,
body.tp-theme-light .tp-position-target { color: var(--positive); }
body.tp-theme-dark .tp-pnl-neg,
body.tp-theme-dark .tp-position-risk,
body.tp-theme-light .tp-pnl-neg,
body.tp-theme-light .tp-position-risk { color: var(--negative); }
body.tp-theme-dark .tp-position-entry,
body.tp-theme-light .tp-position-entry { color: var(--accent); }
body:not(.tp-theme-light) .tp-pnl-pos,
body:not(.tp-theme-light) .tp-position-target { color: var(--positive); }
body:not(.tp-theme-light) .tp-pnl-neg,
body:not(.tp-theme-light) .tp-position-risk { color: var(--negative); }
body:not(.tp-theme-light) .tp-position-entry { color: var(--accent); }

/* Shared control and floating-surface states. */
.tp-btn,
.tp-in,
.tp-sel,
.tp-seg,
.tp-chip,
.tp-menu,
.tp-popover,
.tp-quick-settings,
.tp-position-detail-card,
.tp-drawer,
.tp-modal,
.tp-settings-drawer,
.tp-terminal-side-panel,
.tp-workspace-side,
.tp-workspace-bottom-tabs {
  background: var(--tp-surface);
  border-color: var(--tp-border);
  color: var(--tp-text);
  box-shadow: none;
}
.tp-btn:hover:not(:disabled),
.tp-seg button:hover:not(:disabled),
.tp-chip:hover:not(:disabled),
.tp-menu-item:hover,
.tp-side-link:hover,
.terminal-tabs button:hover:not(:disabled),
.tp-terminal-tabs button:hover:not(:disabled),
.tp-terminal-subtabs button:hover:not(:disabled),
.tp-workspace-bottom-tabs button:hover:not(:disabled) {
  background: var(--tp-hover);
  border-color: var(--tp-border-strong);
  color: var(--tp-text);
}
.tp-btn:disabled,
.tp-in:disabled,
.tp-sel:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .58;
}
.tp-in,
.tp-sel { border-color: var(--tp-border-strong); }
.tp-in:hover:not(:disabled),
.tp-sel:hover:not(:disabled) { border-color: var(--border-strong); }
.tp-in:focus,
.tp-sel:focus {
  background: var(--tp-surface);
  border-color: var(--tp-info);
  box-shadow: 0 0 0 3px var(--tp-info-bg);
}
.tp-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tp-btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); filter: none; }
.tp-seg button.is-active,
.tp-chip.is-active,
.tp-side-link.is-active,
.tp-tab.is-active,
.tp-menu-item.is-active,
.terminal-tabs button.is-active,
.tp-terminal-tabs button.is-active,
.tp-terminal-subtabs button.is-active,
.tp-workspace-bottom-tabs button.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  color: var(--accent);
}
.tp-seg button.is-active[data-side="LONG"],
body.tp-theme-light .tp-seg button.is-active[data-side="LONG"],
body:not(.tp-theme-light) .tp-seg button.is-active[data-side="LONG"] {
  background: var(--positive-soft);
  border-color: color-mix(in srgb, var(--positive) 44%, var(--border));
  color: var(--positive);
}
.tp-seg button.is-active[data-side="SHORT"],
body.tp-theme-light .tp-seg button.is-active[data-side="SHORT"],
body:not(.tp-theme-light) .tp-seg button.is-active[data-side="SHORT"] {
  background: var(--negative-soft);
  border-color: color-mix(in srgb, var(--negative) 44%, var(--border));
  color: var(--negative);
}

body.tp-theme-light .tp-modal-back,
body.tp-theme-light .tp-drawer-back { background: var(--tp-backdrop); }
body.tp-theme-light .tp-badge-neutral { background: #E8EEF5; color: #3B4A5E; border-color: #B3BFCE; }
body.tp-theme-light .tp-offline-banner { background: #B91C1C; color: #fff; }
body.tp-theme-light .tp-status { background: #fff; color: #334155; border-color: #CBD5E1; }
body.tp-theme-light .tp-alert { background: #fff; color: #334155; border-color: #CBD5E1; }
body.tp-theme-light .tp-alert-warn { background: var(--warning-soft); color: #92400E; border-color: #F59E0B; }
body.tp-theme-light .tp-alert-err { background: var(--negative-soft); color: #991B1B; border-color: #DC2626; }
body.tp-theme-light .tp-alert-info { background: var(--info-soft); color: #1D4ED8; border-color: #2563EB; }
body:not(.tp-theme-light) .tp-c,
body:not(.tp-theme-light) .tp-kpi,
body:not(.tp-theme-light) .tp-performance-strip > div { background: var(--surface-1); }
body:not(.tp-theme-light) .tp-kpi { background: var(--surface-2); }
body:not(.tp-theme-light) .tp-performance-strip > div { background: var(--surface-1); }

/* Numeric tokens stay LTR and isolated in Persian. */
html[lang="fa"] .tp-num,
html[lang="fa"] .tp-t-num,
html[lang="fa"] [data-symbol],
html[lang="fa"] .tp-chart-symbol-picker,
html[lang="fa"] input[type="number"] {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--tp-font-numeric);
}
[dir="rtl"] .tp-table .tp-t-num,
[dir="rtl"] .tp-scan-num { text-align: left; }

/* Stable compact dimensions and readable focus targets. */
.tp-btn-sm,
.tp-chip,
.tp-seg-btn { min-height: 32px; }
@media (hover:none) {
  .tp-btn,
  .tp-in,
  .tp-sel,
  .tp-btn-sm,
  .tp-chip { min-height: 40px; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Dashboard product hierarchy: current state and risk precede history. */
.tp-summary-card{padding-block:14px}
.tp-capital-primary,.tp-capital-secondary{display:contents}
.tp-capital-primary .tp-kpi{background:var(--surface-raised);border-color:var(--border-strong)}
.tp-capital-secondary .tp-kpi{background:transparent;border-color:var(--border);min-height:0}
.tp-kpi-primary.tp-pnl-pos .tp-kpi-value,.tp-kpi-primary.tp-pnl-neg .tp-kpi-value{color:inherit}
.tp-capital-secondary .tp-kpi.tp-pnl-pos .tp-kpi-value{color:var(--positive)}
.tp-capital-secondary .tp-kpi.tp-pnl-neg .tp-kpi-value{color:var(--negative)}
.tp-now{margin-bottom:10px}
.tp-dashboard-primary{margin-bottom:10px}
.tp-dashboard-primary .tp-action-position:first-child{padding-block-start:2px}


/* Chart UX stage 017: quiet workspace chrome, unchanged chart area. */
.tp-workspace-view .tp-workspace-top{height:38px;min-height:38px;padding-block:5px;border-bottom-color:color-mix(in srgb,var(--tp-border) 70%,transparent)}
.tp-workspace-view .tp-workspace-top small{font-size:10px;color:var(--tp-text-3)}
.tp-workspace-view .tp-workspace-top strong{font-size:12px}
.tp-workspace-view .tp-workspace-chart{border-inline-end:1px solid color-mix(in srgb,var(--tp-border) 45%,transparent)}
.tp-workspace-view .tp-workspace-side{padding:8px;border-inline-start-color:color-mix(in srgb,var(--tp-border) 70%,transparent)}
.tp-workspace-view .tp-workspace-bottom-tabs{min-height:38px;padding:4px 8px;gap:5px;border-top-color:color-mix(in srgb,var(--tp-border) 70%,transparent)}
@media(max-width:900px){.tp-workspace-view .tp-workspace-chart{border-inline-end:0}.tp-workspace-view .tp-workspace-side{padding:0;border-top-color:color-mix(in srgb,var(--tp-border) 70%,transparent)}}


/* TradePulse full UI polish stage 019: presentation-only final layer. */
:root{--tp-ui-max:1680px;--tp-ui-gap:10px;--tp-ui-radius:7px;--tp-ui-label:#3E4F64;--tp-ui-muted:#5A6B80;--tp-ui-heading:#172033;--tp-ui-control:#EDF1F7}
body.tp-theme-dark{--tp-ui-label:#C0CCDA;--tp-ui-muted:#A0B0C4;--tp-ui-heading:#F0F4FA;--tp-ui-control:#171E2C}
body.tp-theme-light{--tp-ui-label:#3E4F64;--tp-ui-muted:#5A6B80;--tp-ui-heading:#172033;--tp-ui-control:#EDF1F7}

body,.tp-view,.tp-main{font-family:var(--tp-font-ui)!important;color:var(--tp-ui-heading)}
.tp-view:not(.tp-workspace-view){width:min(100%,var(--tp-ui-max));margin-inline:auto;padding-inline:clamp(10px,1.6vw,20px)}
.tp-view-head{min-height:42px;margin:0 0 10px;padding:0 2px;display:flex;align-items:center;gap:8px;flex-wrap:wrap;border-bottom:1px solid color-mix(in srgb,var(--tp-border) 50%,transparent)}
.tp-view-title{margin:0;color:var(--tp-ui-heading)!important;font-size:20px!important;font-weight:700!important;line-height:1.2!important;letter-spacing:0!important}
.tp-view-meta,.tp-view-sub{color:var(--tp-ui-muted)!important;font-size:12px!important;line-height:1.35}
.tp-view-head>.tp-view-meta{margin-inline-start:auto}

/* Cards: consistent radius and subtle depth */
.tp-c{border:1px solid color-mix(in srgb,var(--tp-border) 70%,transparent)!important;border-radius:var(--tp-ui-radius)!important;background:var(--tp-surface)!important;box-shadow:0 1px 2px rgba(0,0,0,.04)}
body.tp-theme-dark .tp-c{box-shadow:0 1px 3px rgba(0,0,0,.22)}
.tp-c-head{min-height:38px!important;padding:8px 12px!important;gap:8px!important;border-bottom:1px solid color-mix(in srgb,var(--tp-border) 55%,transparent)}
.tp-c-title{margin:0;color:var(--tp-ui-heading)!important;font-size:13px!important;font-weight:700!important;line-height:1.25!important;letter-spacing:0!important;text-transform:uppercase}

/* Labels and muted text: higher contrast */
.tp-label,.tp-kpi-label,.tp-table th,.tp-scan-head,.tp-form-label,.tp-field-label{color:var(--tp-ui-label)!important}
.tp-status,.tp-empty,.tp-view-sub,small,.tp-muted{color:var(--tp-ui-muted)}

/* KPI strip: tighter density */
.tp-kpi-strip{gap:6px!important}
.tp-kpi{min-width:0!important;padding:8px 10px!important;border:1px solid color-mix(in srgb,var(--tp-border) 70%,transparent)!important;border-radius:6px!important;background:var(--tp-surface-raised)!important}
.tp-kpi-label{font-size:10px!important;font-weight:700!important;line-height:1.25!important;white-space:normal!important}
.tp-kpi-value{margin-top:3px!important;color:var(--tp-ui-heading)!important;font-size:16px!important;line-height:1.15!important;white-space:nowrap;font-variant-numeric:tabular-nums}

/* Financial data: tabular mono; controls: UI sans-serif */
.tp-kpi-value,.tp-performance-strip strong,.tp-t-num,.tp-scan-num,.tp-table .tp-t-num{font-family:var(--tp-font-numeric)!important}
.tp-btn,.tp-chip,.tp-seg-btn,.tp-in,.tp-sel,.tp-textarea{font-family:var(--tp-font-ui)!important}

/* Buttons: compact, consistent, no black rectangles */
.tp-btn{min-height:32px;border-radius:5px!important;font-size:12px!important;font-weight:600!important;padding:6px 12px!important}
.tp-btn-sm{min-height:28px!important;padding-inline:9px!important;font-size:11px!important}
.tp-btn-primary{background:var(--tp-info)!important;border-color:var(--tp-info)!important;color:#fff!important}
.tp-btn-primary:hover:not(:disabled){filter:brightness(1.1)}
body.tp-theme-light .tp-btn-primary{background:var(--tp-info)!important;border-color:var(--tp-info)!important;color:#fff!important}
body.tp-theme-light .tp-btn-danger{background:var(--tp-short-bg)!important;border-color:var(--tp-short)!important;color:var(--tp-short)!important}
body.tp-theme-light .tp-btn-long{background:var(--tp-long-bg)!important;border-color:var(--tp-long)!important;color:var(--tp-long)!important}
body.tp-theme-light .tp-btn-short{background:var(--tp-short-bg)!important;border-color:var(--tp-short)!important;color:var(--tp-short)!important}
body.tp-theme-light .tp-btn{background:var(--tp-surface)!important;border-color:var(--tp-border)!important;color:var(--tp-text-2)!important}
body.tp-theme-light .tp-btn:hover:not(:disabled){background:var(--tp-hover)!important;border-color:var(--tp-border-strong)!important;color:var(--tp-text)!important}
body.tp-theme-light .tp-btn-ghost{background:transparent!important;border-color:transparent!important;color:var(--tp-text-2)!important}

/* Segment controls */
.tp-seg{border-color:var(--tp-border)!important;border-radius:5px!important;background:var(--tp-surface-2)!important;overflow:hidden}
body.tp-theme-light .tp-seg{background:var(--tp-surface-2)!important}
.tp-seg-btn{min-height:30px!important;padding-inline:10px!important;color:var(--tp-ui-label)!important;font-size:11px!important}
.tp-seg-btn.is-active{color:var(--tp-info)!important;background:var(--tp-info-bg)!important}

/* Inputs / selects / textareas: theme-aware, readable */
.tp-in,.tp-sel,.tp-textarea{min-height:34px;border-radius:5px!important;border:1px solid var(--tp-border-strong)!important;background:var(--tp-surface-raised)!important;color:var(--tp-ui-heading)!important;padding:6px 10px!important;font-size:13px!important}
body.tp-theme-light .tp-in,body.tp-theme-light .tp-sel,body.tp-theme-light .tp-textarea{background:var(--tp-surface)!important;border-color:var(--tp-border-2)!important;color:var(--tp-text)!important}
body.tp-theme-light .tp-in:focus,body.tp-theme-light .tp-sel:focus,body.tp-theme-light .tp-textarea:focus{border-color:var(--tp-info)!important;box-shadow:0 0 0 2px var(--tp-info-bg)!important}
body.tp-theme-light select{background-color:var(--tp-surface)!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2358697D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 8px center!important;background-size:14px!important;padding-right:28px!important}
body.tp-theme-dark select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23A0B0C4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 8px center!important;background-size:14px!important;padding-right:28px!important}
.tp-in::placeholder,.tp-textarea::placeholder{color:var(--tp-ui-muted)!important;opacity:1}

/* Badges: tighter */
.tp-badge{min-height:20px;padding:2px 6px!important;border-radius:4px!important;font-size:10px!important;font-weight:700!important;line-height:1.2!important}
.tp-empty{min-height:72px!important;padding:14px!important;font-size:12px!important}

/* Tables and scanner */
.tp-table-wrap,.tp-scan{border-color:var(--tp-border)!important;border-radius:6px!important;background:var(--tp-surface)!important}
.tp-table{font-size:11px!important}
.tp-table th{background:var(--tp-surface-2)!important;font-size:10px!important;font-weight:700!important;letter-spacing:.03em}
.tp-table td{color:var(--tp-ui-heading)!important}
.tp-table tr:hover td{background:var(--tp-hover)!important}

/* Dashboard density */
.tp-summary-card{padding:0!important}
.tp-summary-card #tpDashboardAccountNotice{margin:0 10px 2px!important}
.tp-summary-card #tpDashboardAccountNotice .tp-alert{padding:4px 8px;border-inline-start-width:2px;font-size:10.5px;line-height:1.3}
.tp-summary-card .tp-kpi-strip{display:grid!important;overflow:visible;padding:8px 10px 6px!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;align-items:stretch}
.tp-summary-card .tp-kpi{height:100%;min-height:60px}
.tp-summary-card .tp-performance-strip{margin:0 10px 10px!important}
.tp-performance-strip{gap:1px!important;border-radius:6px!important}
.tp-performance-strip>div{min-width:0!important;padding:8px 10px!important}
.tp-performance-strip small{color:var(--tp-ui-label)!important;font-size:10px!important}
.tp-performance-strip strong{font-size:13px!important}
.tp-action-position{padding:8px 0!important}
.tp-dashboard-review-grid{gap:var(--tp-ui-gap)!important}
.tp-dashboard-review-grid>.tp-c,.tp-dashboard-lifecycle,.tp-dashboard-opportunities,.tp-market-overview{margin-bottom:0!important}
.tp-market-overview-grid{gap:6px!important;padding:0 10px 10px!important}
.tp-market-card{min-height:120px!important;padding:8px!important;border-radius:6px!important}
.tp-market-card-head strong,.tp-market-card-price>strong{font-size:12px!important}
.tp-mini-chart-host,.tp-mini-chart{height:50px!important}
.tp-dashboard-grid{gap:10px!important;margin-bottom:10px!important}
.tp-dashboard-secondary{gap:10px!important}

/* Markets */
.tp-market-explorer-bar{margin-bottom:8px!important;padding:7px 10px;border:1px solid var(--tp-border);border-radius:6px;background:var(--tp-surface)}
.tp-view[data-view="markets"] .tp-split-main{gap:10px!important}
.tp-view[data-view="markets"] #tpSignalPanelMarkets{border-inline-start:1px solid var(--tp-border);padding-inline-start:10px}

/* Mobile account summary: keep the three primary performance facts in one
   full-width row and move secondary metrics below as a compact disclosure. */
@media(max-width:600px){
  .tp-summary-card .tp-performance-strip{display:block!important;margin:0 10px 8px!important}
  .tp-performance-primary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1px;border:1px solid var(--tp-border);border-radius:6px;overflow:hidden;background:var(--tp-border)}
  .tp-performance-primary>div{display:grid;place-items:center;gap:3px;min-width:0;min-height:52px;padding:7px 4px;background:var(--tp-surface-raised);text-align:center}
  .tp-performance-primary small{font-size:10px!important;white-space:nowrap}
  .tp-performance-primary strong{font-size:13px!important;white-space:nowrap}
  .tp-more-statistics{width:100%;box-sizing:border-box}
  .tp-more-statistics summary{min-height:18px}
  .tp-trade-review-row{gap:7px;min-height:42px;padding:5px 2px}
  .tp-trade-review-row b,.tp-trade-review-row strong{line-height:1.2}
  .tp-trade-review-metrics{gap:5px!important}
}

/* Scanner / Reports */
.tp-view[data-view="scanner"] .tp-scan-bar,.tp-view[data-view="reports"] .tp-scan-bar{padding:7px 10px!important;border-radius:6px!important;background:var(--tp-surface)!important;border:1px solid var(--tp-border)!important}
.tp-view[data-view="scanner"] .tp-scan-row{min-height:34px!important;padding-block:3px!important}
.tp-view[data-view="scanner"] .tp-score-track{height:3px!important;border-radius:2px}
.tp-view[data-view="reports"] .tp-c{margin-bottom:10px}
.tp-view[data-view="reports"] .tp-table td,.tp-view[data-view="reports"] .tp-table th{padding:7px 8px!important}

/* Workspace: preserve chart, clean surrounding chrome */
.tp-workspace-top{border-bottom-color:var(--tp-border)!important;padding:6px 10px!important}
.tp-workspace-bottom{border-top-color:var(--tp-border)!important}
.tp-terminal-section-head{font-size:11px!important}
.tp-workspace-bottom #tpWorkspaceBottomBody{padding:10px 12px!important}
.tp-workspace-side .tp-c{margin-bottom:8px}
body.tp-theme-light .tp-workspace-top,body.tp-theme-light .tp-workspace-side,body.tp-theme-light .tp-workspace-bottom,body.tp-theme-light .tp-terminal-tabs,body.tp-theme-light .tp-settings-drawer{background:var(--tp-surface);color:var(--tp-text);border-color:var(--tp-border)}
body.tp-theme-light .tp-workspace-chart,body.tp-theme-light .tp-chart-frame{background:var(--tp-bg)!important}
/* Workspace controls inherit the shared primitive states; avoid a broad
   button reset that could flatten semantic Buy/Sell and submit actions. */
body.tp-theme-light .tp-terminal-tabs button,body.tp-theme-light .tp-terminal-subtabs button,body.tp-theme-light .tp-terminal-mode button{color:var(--tp-text-2);opacity:1}
body.tp-theme-light .tp-terminal-tabs button.is-active,body.tp-theme-light .tp-terminal-subtabs button.is-active,body.tp-theme-light .tp-terminal-mode button.is-active{color:var(--tp-info)}
body.tp-theme-light .tp-market-card{background:var(--tp-surface-2);color:var(--tp-text);border-color:var(--tp-border)}
body.tp-theme-light .tp-market-card-head small,body.tp-theme-light .tp-mini-chart-empty{color:var(--tp-text-2)!important}
body.tp-theme-light .tp-market-symbol{background:var(--tp-surface-3);color:var(--tp-text);border-color:var(--tp-border-2)}
body.tp-theme-light .tp-market-strip,body.tp-theme-light .tp-market-strip strong,body.tp-theme-light .tp-market-symbol{opacity:1;color:var(--tp-text-primary)}
body.tp-theme-light .tp-market-strip small{opacity:1;color:var(--tp-text-muted)}
body.tp-theme-light .tp-market-live,body.tp-theme-light .tp-market-live strong{opacity:1;color:var(--tp-positive)}
body.tp-theme-light #tpWorkspaceChange.tp-pnl-pos{color:var(--tp-positive)}

/* Phase B layout: collapsible navigation and full-width chart with the
   existing trade terminal flowing below it. */
.tp-sidebar-collapse{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;min-height:32px;padding:5px 8px;border:1px solid var(--tp-border);border-radius:var(--tp-r);background:var(--tp-surface-2);color:var(--tp-text-2);font:600 var(--tp-fs-xs)/1 inherit;cursor:pointer}
.tp-sidebar-collapse:hover{background:var(--tp-hover);color:var(--tp-text)}
.tp-sidebar-collapse>span:first-child{font-size:20px;line-height:.8}
.tp-sidebar-collapsed{--tp-sidebar-w:72px}
.tp-sidebar-collapsed .tp-side{padding-inline:8px}
.tp-sidebar-collapsed .tp-side-link{justify-content:center;padding-inline:6px;gap:0}
.tp-sidebar-collapsed .tp-side-link>span:last-child,.tp-sidebar-collapsed .tp-sidebar-collapse-label{display:none}
.tp-sidebar-collapsed .tp-sidebar-collapse>span:first-child{transform:rotate(180deg)}
.tp-sidebar-collapsed .tp-side-link{position:relative}
.tp-sidebar-collapsed .tp-side-link:hover::after{content:attr(data-tooltip);position:absolute;inset-inline-start:calc(100% + 8px);top:50%;transform:translateY(-50%);z-index:500;padding:5px 8px;border:1px solid var(--tp-border);border-radius:5px;background:var(--tp-surface);color:var(--tp-text);white-space:nowrap;box-shadow:var(--tp-shadow-2);pointer-events:none}
.tp-workspace-shell{display:flex!important;flex-direction:column!important;height:auto!important;min-height:0!important}
.tp-workspace-chart{width:100%;min-height:clamp(500px,68vh,760px)!important}
.tp-workspace-side{width:100%;order:2;border-inline-start:0!important;border-top:1px solid var(--tp-border);max-height:none!important;overflow:visible!important}
.tp-workspace-bottom{width:100%}
@media(max-width:600px){.tp-workspace-chart{min-height:430px!important}.tp-sidebar-collapse{min-height:38px}}
body.tp-theme-light #tpWorkspaceChange.tp-pnl-neg{color:var(--tp-negative)}
body.tp-theme-light .tp-workspace-bottom-tabs{box-shadow:0 1px 6px rgba(15,23,42,.05)}

/* Settings + Account: reduce whitespace */
.tp-view[data-view="settings"]{position:relative;padding-bottom:var(--tp-space-4);background:transparent}
.tp-view[data-view="settings"] .tp-set-layout{grid-template-columns:180px minmax(0,760px);gap:var(--tp-space-2);align-items:start}
.tp-view[data-view="settings"] .tp-set-nav{position:sticky;top:calc(var(--tp-topbar-h) + var(--tp-space-2));padding:var(--tp-space-2);border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface)}
.tp-view[data-view="settings"] .tp-set-nav button{min-height:34px;color:var(--tp-text-secondary);border:1px solid transparent}
.tp-view[data-view="settings"] .tp-set-nav button:hover{color:var(--tp-text);background:var(--tp-hover)}
.tp-view[data-view="settings"] .tp-set-nav button.is-active{color:var(--tp-text);background:var(--tp-selected);border-color:var(--tp-border)}
.tp-view[data-view="settings"] .tp-set-body>.tp-c{padding:var(--tp-space-2) var(--tp-space-3)}
.tp-account-layout{display:grid;grid-template-columns:200px minmax(0,1fr);gap:var(--tp-space-2);align-items:start}
.tp-account-nav{position:sticky;top:calc(var(--tp-topbar-h) + var(--tp-space-2));max-height:calc(100dvh - var(--tp-topbar-h) - 16px);overflow-y:auto;padding:var(--tp-space-2);border:1px solid var(--tp-border);border-radius:var(--tp-radius-md);background:var(--tp-surface)}
.tp-account-nav-group+.tp-account-nav-group{margin-top:var(--tp-space-2)}
.tp-account-nav button{min-height:34px;padding:var(--tp-space-1) var(--tp-space-2)}
.tp-account-nav button.is-active{box-shadow:inset 2px 0 0 var(--tp-accent)}
.tp-account-content>.tp-c{padding:var(--tp-space-2) var(--tp-space-3)}
.tp-account-summary{grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--tp-space-2);margin-bottom:var(--tp-space-2)}
.tp-account-summary>div{padding:var(--tp-space-2);border:1px solid var(--tp-border);border-radius:var(--radius-md);background:var(--tp-surface-raised)}

/* Light-mode popovers/menus/modals: no dark backgrounds */
body.tp-theme-light .tp-modal,body.tp-theme-light .tp-drawer,body.tp-theme-light .tp-menu,body.tp-theme-light .tp-popover,body.tp-theme-light .tp-account-menu{background:var(--tp-surface)!important;border-color:var(--tp-border)!important;color:var(--tp-text)!important}
body.tp-theme-light .tp-menu-item{color:var(--tp-text-2)!important}
body.tp-theme-light .tp-menu-item:hover{background:var(--tp-surface-2)!important;color:var(--tp-text)!important}
body.tp-theme-light .tp-drawer{border-left:1px solid var(--tp-border)!important}
body.tp-theme-light [dir="rtl"] .tp-drawer{border-left:0!important;border-right:1px solid var(--tp-border)!important}

/* Sidebar light-mode: clean white */
body.tp-theme-light .tp-side{background:var(--tp-surface)!important;border-inline-end-color:var(--tp-border)!important}
body.tp-theme-light .tp-side-link:hover{background:var(--tp-surface-2)!important;color:var(--tp-text)!important}
body.tp-theme-light .tp-side-link.is-active{background:var(--tp-selected)!important;color:var(--tp-text)!important}

/* Topbar light-mode: clean */
body.tp-theme-light .tp-topbar{background:var(--tp-surface)!important;border-bottom-color:var(--tp-border)!important}
body.tp-theme-light .tp-account-btn{background:var(--tp-surface-2)!important;border-color:var(--tp-border)!important;color:var(--tp-text-2)!important}
body.tp-theme-light .tp-hamburger{background:transparent!important;border-color:var(--tp-border)!important}
body.tp-theme-light .tp-hamburger span{background:var(--tp-text-2)!important}

/* Bottom nav light */
body.tp-theme-light .tp-bottomnav{background:var(--tp-surface)!important;border-top-color:var(--tp-border)!important}

/* Tab cards: tighter spacing */
.tp-tab{padding:var(--tp-space-2)!important;gap:var(--tp-space-2)!important}
.tp-chip{min-height:30px!important;padding:4px 10px!important;font-size:12px!important}

/* Reports / AI: reduce padding */
.tp-view[data-view="reports"] .tp-c,.tp-view[data-view="ai"] .tp-c,.tp-view[data-view="account"] .tp-c{margin-bottom:10px}

/* Responsive */
@media(max-width:900px){
  .tp-view:not(.tp-workspace-view){padding-inline:10px}
  .tp-view[data-view="markets"] #tpSignalPanelMarkets{border-inline-start:0;border-top:1px solid var(--tp-border);padding:10px 0 0}
  .tp-view[data-view="settings"] .tp-set-layout{grid-template-columns:1fr}
  .tp-account-layout{grid-template-columns:1fr}
}
@media(max-width:600px){
  .tp-view-title{font-size:18px!important}
  .tp-view-head{min-height:38px;margin-bottom:8px}
  .tp-c-head{padding:7px 10px!important}
  .tp-summary-card .tp-kpi-strip{padding:6px!important}
  .tp-summary-card .tp-performance-strip{margin:0 6px 6px!important}
  .tp-kpi-value{font-size:15px!important}
  .tp-market-explorer-bar{align-items:stretch}
  .tp-market-explorer-bar .tp-in{width:100%}
  .tp-view:not(.tp-workspace-view){padding:var(--tp-space-2) var(--tp-space-3)!important;overflow-x:hidden}
  .tp-position-numbers{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .tp-now{flex-direction:column;align-items:stretch;gap:10px;padding:10px 12px!important}
  .tp-now strong{font-size:18px!important}
  body.tp-theme-light .tp-btn{background:var(--tp-surface)!important;border-color:var(--tp-border)!important;color:var(--tp-text-2)!important}
}


/* ============================================================
   Stage 023 mobile visual repair
   Targeted responsive fixes only. Desktop rules above are
   unchanged; every rule here is gated behind a mobile media
   query or a Light-mode theme selector.
   ============================================================ */
/* ==== Stage 023 mobile visual repair ==== */

/* --- Light mode: remove remaining dark control surfaces --- */
/* AI Assistant quick-action chips + workspace lower tabs used
   var(--surface-1)=surface which was fine, but the shared control
   reset at .tp-chip bound them to surface-1 with no light contrast.
   Force clean light surfaces with readable text and clear states. */
body.tp-theme-light .tp-ai-quick .tp-chip,
body.tp-theme-light .tp-ai-chip,
body.tp-theme-light .tp-workspace-bottom-tabs .tp-chip,
body.tp-theme-light .tp-terminal-tabs button,
body.tp-theme-light .tp-terminal-subtabs button,
body.tp-theme-light .tp-terminal-mode button {
  background: var(--tp-surface);
  border-color: var(--tp-border);
  color: var(--tp-text-2);
}
body.tp-theme-light .tp-ai-quick .tp-chip:hover:not(:disabled),
body.tp-theme-light .tp-ai-chip:hover,
body.tp-theme-light .tp-workspace-bottom-tabs .tp-chip:hover:not(:disabled),
body.tp-theme-light .tp-terminal-tabs button:hover:not(:disabled),
body.tp-theme-light .tp-terminal-subtabs button:hover:not(:disabled),
body.tp-theme-light .tp-terminal-mode button:hover:not(:disabled) {
  background: var(--tp-hover);
  border-color: var(--tp-border-strong);
  color: var(--tp-text);
}
body.tp-theme-light .tp-ai-quick .tp-chip.is-active,
body.tp-theme-light .tp-workspace-bottom-tabs .tp-chip.is-active,
body.tp-theme-light .tp-terminal-tabs button.is-active,
body.tp-theme-light .tp-terminal-subtabs button.is-active,
body.tp-theme-light .tp-terminal-mode button.is-active {
  background: var(--tp-selected);
  border-color: var(--tp-info);
  color: var(--tp-info);
}
body.tp-theme-light .tp-workspace-bottom-tabs,
body.tp-theme-light .tp-terminal-tabs {
  background: var(--tp-surface-2);
}

/* Empty states must not reserve huge fixed height. */
.tp-empty { padding: var(--tp-s4) var(--tp-s3); }
.tp-empty strong { display: block; margin-bottom: 3px; }
.tp-empty span { display: block; color: var(--tp-text-3); font-size: var(--tp-fs-sm); }
.tp-workspace-bottom .tp-empty { min-height: 0; padding: 16px 14px; }

/* --- Mobile header (<=720px) prioritized layout --- */
@media (max-width: 720px) {
  .tp-topbar { gap: 6px; padding-inline: 8px; }
  /* Logo must never be clipped or collide with controls. */
  .tp-logo { flex: 0 1 auto; min-width: 0; overflow: hidden; }
  .tp-logo-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 96px;
  }
  /* Status pill collapses to just the dot. */
  .tp-status { padding: 4px; border: 0; background: transparent; }
  /* Refresh + account-context selector are non-essential on mobile. */
  .tp-topbar-refresh { display: none; }
  .tp-topbar-context { display: none; }
  /* Theme toggle stays usable but compact icon-only. */
  .tp-global-theme { flex: 0 0 auto; }
  .tp-global-theme button { width: 30px; height: 30px; padding: 0; }
  .tp-global-theme button span { display: none; }
  /* Quick-settings + account become icon/avatar only. */
  .tp-quick-settings-wrap { flex: 0 0 auto; }
  .tp-account { flex: 0 0 auto; }
  .tp-account-btn { padding: 2px; border-radius: 50%; }
  .tp-account-btn .tp-account-name { display: none; }
  .tp-avatar { width: 30px; height: 30px; }
  .tp-icon-btn { width: 34px; height: 34px; }
}

/* Ultra-narrow header (<=380px): give the logo the room it needs. */
@media (max-width: 380px) {
  .tp-topbar { gap: 4px; padding-inline: 6px; }
  .tp-logo-text { max-width: 74px; }
  .tp-global-theme button { width: 28px; height: 28px; }
  .tp-icon-btn { width: 32px; height: 32px; }
  .tp-avatar { width: 28px; height: 28px; }
}

/* --- Scanner mobile: escape the desktop scanner-scoped grid --- */
/* The desktop rules `.tp-view[data-view="scanner"] .tp-scan-row`
   carry higher specificity than a plain `.tp-scan-row` inside a
   media query, so the mobile two-line layout was defeated and rows
   overlapped. Re-scope the mobile layout to the scanner view with
   matching specificity so it actually wins. */
@media (max-width: 720px) {
  .tp-view[data-view="scanner"] .tp-scan { width: 100%; overflow-x: hidden; }
  .tp-view[data-view="scanner"] .tp-scan-head { display: none; }
  .tp-view[data-view="scanner"] .tp-scan-row,
  .tp-view[data-view="scanner"] .tp-scan.is-compact .tp-scan-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "sym  dir"
      "nums fav";
    align-items: center;
    gap: 4px var(--tp-s2);
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 10px var(--tp-s2);
    line-height: 1.35;
  }
  .tp-view[data-view="scanner"] .tp-scan-group,
  .tp-view[data-view="scanner"] .tp-scan-group-head,
  .tp-view[data-view="scanner"] .tp-scan-group-body { min-width: 0; }
  .tp-view[data-view="scanner"] .tp-scan-row > .tp-scan-sym {
    grid-area: sym; font-size: var(--tp-fs-lg); font-weight: 700;
  }
  .tp-view[data-view="scanner"] .tp-scan-row > .tp-scan-dir {
    grid-area: dir; justify-self: end; white-space: nowrap;
  }
  .tp-view[data-view="scanner"] .tp-scan-row > .tp-scan-fav {
    grid-area: fav; justify-self: end; align-self: center;
  }
  .tp-view[data-view="scanner"] .tp-scan-row > .tp-scan-mobile { grid-area: nums; }
  /* Hide the desktop table cells; the condensed line replaces them. */
  .tp-view[data-view="scanner"] .tp-scan-row > .tp-scan-cell { display: none; }
  .tp-view[data-view="scanner"] .tp-scan-mobile {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    font-size: var(--tp-fs-sm);
    color: var(--tp-text-3);
    line-height: 1.5;
  }
  .tp-view[data-view="scanner"] .tp-scan-mobile > span { white-space: nowrap; }
  .tp-view[data-view="scanner"] .tp-scan-mobile b {
    color: var(--tp-text); font-weight: 650; font-variant-numeric: tabular-nums;
  }
  .tp-view[data-view="scanner"] .tp-scan-status { display: none; }
}

/* --- Workspace mobile: toolbar scroll + no page overflow --- */
@media (max-width: 720px) {
  .tp-workspace-bottom-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .tp-workspace-bottom { min-height: 0; }
  .tp-workspace-bottom #tpWorkspaceBottomBody { min-height: 0; padding: 12px; }
  .tp-workspace-top {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Dashboard mobile density: emphasize primary KPIs --- */
@media (max-width: 600px) {
  /* Phone KPI strip: two readable, equal-height cards per row. */
  .tp-summary-card .tp-kpi-strip {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    gap: 6px !important;
  }
  .tp-summary-card .tp-kpi-strip > .tp-kpi:last-child { grid-column: 1 / -1; }
  /* Capital cells are promoted through display:contents; target the final
     secondary KPI itself so an unpaired metric spans the phone row. */
  .tp-summary-card .tp-capital-secondary > .tp-kpi:last-child { grid-column: 1 / -1; }
  .tp-summary-card .tp-kpi-value { font-size: 15px !important; }
  /* Manual/action position numbers wrap to 2 columns, buttons wrap. */
  .tp-position-numbers { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tp-position-actions { flex-wrap: wrap; }
  .tp-position-actions .tp-btn { flex: 1 1 calc(50% - 6px); min-height: 38px; }
  /* Manual position cards keep readable label/value pairs. */
  .tp-pos-row .tp-pos-cell small { display: block; color: var(--tp-text-3); font-size: var(--tp-fs-xs); }
}

/* --- Positions / Paper empty state: compact --- */
.tp-pos .tp-empty,
#tpPositionsBody .tp-empty,
#tpPositionsBodyPaper .tp-empty,
.tp-useful-empty { min-height: 0; }
.tp-useful-empty { padding: 14px 10px; }

/* --- Markets mobile carousel affordance --- */
@media (max-width: 600px) {
  .tp-market-overview-grid {
    scroll-padding-inline: 10px;
    scrollbar-width: none;
  }
  .tp-market-overview-grid::-webkit-scrollbar { height: 0; }
  .tp-market-card { scroll-snap-align: start; }
}

/* --- AI Assistant mobile: chips wrap, form stacks --- */
@media (max-width: 600px) {
  .tp-ai-quick { display: flex; flex-wrap: wrap; gap: 6px; }
  .tp-ai-quick .tp-chip { flex: 0 1 auto; min-height: 38px; }
  .tp-ai-form { flex-wrap: wrap; gap: 8px; }
  .tp-ai-form .tp-in { flex: 1 1 100%; }
  .tp-ai-form .tp-btn { flex: 1 1 100%; }
}

/* --- Global: prevent accidental horizontal page overflow --- */
@media (max-width: 720px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .tp-view:not(.tp-workspace-view) { overflow-x: hidden; }
}
/* Completed-trade rows remain structured on narrow screens. */
.tp-trade-side-badge{display:inline-flex;align-items:center;justify-content:center;margin-inline-start:6px;padding:2px 6px;border-radius:999px;font:600 10px/1 var(--tp-font);background:var(--tp-surface-raised);border:1px solid var(--tp-border)}
.tp-trade-side-badge.is-buy{color:var(--tp-success)}.tp-trade-side-badge.is-sell{color:var(--tp-danger)}
@media(max-width:600px){.tp-trade-review-row{grid-template-columns:minmax(0,1fr) minmax(88px,.8fr);gap:8px;padding:10px 2px}.tp-trade-review-symbol{min-width:0}.tp-trade-review-symbol strong{display:inline-block;margin-inline-end:4px}.tp-trade-review-symbol small{display:block;margin-top:4px;white-space:normal;overflow-wrap:anywhere}.tp-trade-review-price{display:block!important;min-width:0}.tp-trade-review-price b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tp-trade-review-pnl{grid-column:1/-1;text-align:start;display:grid;grid-template-columns:auto 1fr;column-gap:8px;align-items:baseline}.tp-trade-review-pnl small:last-child{grid-column:1/-1}.tp-trade-review-duration{display:none}.tp-trade-review-row time{grid-column:2;grid-row:1;align-self:end;text-align:end;white-space:nowrap;font-size:10px}}

/* Keep the canonical provider/account selector usable in mobile portrait. */
@media(max-width:600px){
  .tp-topbar-context{display:flex!important;order:4;flex:0 1 146px;min-width:112px;max-width:150px;}
  .tp-topbar-context .tp-sel{width:100%;min-width:0;max-width:150px;padding-inline:6px;font-size:11px;}
  .tp-topbar{flex-wrap:nowrap;overflow:visible;}
  .tp-topbar .tp-logo-text{max-width:72px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  .tp-trade-raw-list{display:grid;gap:8px;min-width:0;}
  .tp-trade-raw-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:5px 10px;min-width:0;padding:10px 2px;border-bottom:1px solid var(--tp-border);}
  .tp-trade-raw-row:last-child{border-bottom:0;}
  .tp-trade-raw-row>strong{min-width:0;color:var(--tp-text-primary);font:700 12px/1.3 var(--tp-font);overflow-wrap:anywhere;}
  .tp-trade-raw-row>span{grid-column:1/-1;min-width:0;color:var(--tp-text-secondary);font:600 11px/1.45 var(--tp-font);overflow-wrap:anywhere;}
  .tp-trade-raw-row>time{color:var(--tp-text-muted);font:600 10px/1.3 var(--tp-mono);white-space:nowrap;}
  .tp-trade-raw-head{display:flex;align-items:center;gap:6px;min-width:0}
  .tp-trade-raw-fields{grid-column:1/-1;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 12px;min-width:0}
  .tp-trade-raw-fields>div{display:grid;gap:2px;min-width:0}
  .tp-trade-raw-fields small{color:var(--tp-text-muted);font-size:10px}
  .tp-trade-raw-fields b{font:650 11px/1.3 var(--tp-mono);overflow-wrap:anywhere}
  .tp-trade-review-row{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;gap:8px;padding:10px 2px;}
  .tp-trade-review-price{display:grid!important;gap:2px;min-width:0;}
  .tp-trade-review-price b{white-space:normal;overflow-wrap:anywhere;}
  .tp-trade-review-pnl{grid-column:1/-1;display:grid;grid-template-columns:auto 1fr;gap:3px 8px;text-align:start;}
  .tp-trade-review-pnl small:last-child{grid-column:1/-1;}
  .tp-trade-review-duration{display:grid!important;gap:2px;}
.tp-trade-review-row>time{grid-column:2;grid-row:auto;text-align:end;align-self:end;}
  .tp-trade-review-metrics{grid-column:1/-1;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 12px;min-width:0}
  .tp-trade-review-metrics>div{display:grid;gap:2px;min-width:0}
  .tp-trade-review-metrics small{color:var(--tp-text-muted);font-size:10px}
  .tp-trade-review-metrics strong{font:650 11px/1.3 var(--tp-mono);overflow-wrap:anywhere}
}
@media(max-width:380px){
  .tp-topbar-context{flex-basis:122px;min-width:108px;max-width:124px;}
  .tp-topbar-context .tp-sel{max-width:124px;}
}
.tp-workspace-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.tp-chart-analysis-result{margin-top:12px;padding:10px;border:1px solid var(--tp-border);border-radius:10px;line-height:1.55;min-height:20px}.tp-chart-analysis-result strong{color:var(--tp-accent)}
@media (max-width:700px){.tp-workspace-actions{width:100%;justify-content:flex-end}.tp-workspace-actions .tp-btn{min-height:36px}.tp-chart-analysis-result{font-size:.88rem}}
@media(max-width:600px){
  .tp-analysis-grid,.tp-analysis-scores{grid-template-columns:repeat(2,minmax(0,1fr));min-width:0;}
  .tp-analysis-metric{min-width:0;overflow:hidden;}
  .tp-analysis-metric small{overflow-wrap:normal;word-break:normal;white-space:normal;}
  .tp-analysis-metric strong{overflow-wrap:normal;word-break:normal;white-space:nowrap;min-width:0;}
}

/* B1/B2 final cascade: preserve the clean chart while reflowing workspace. */
.tp-sidebar-collapse{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;min-height:32px;padding:5px 8px;border:1px solid var(--tp-border);border-radius:var(--tp-r);background:var(--tp-surface-2);color:var(--tp-text-2);font:600 var(--tp-fs-xs)/1 inherit;cursor:pointer}
.tp-sidebar-collapse:hover{background:var(--tp-hover);color:var(--tp-text)}
.tp-sidebar-collapse>span:first-child{font-size:20px;line-height:.8}.tp-sidebar-collapsed{--tp-sidebar-w:72px}.tp-sidebar-collapsed .tp-side{padding-inline:8px}.tp-sidebar-collapsed .tp-side-link{justify-content:center;padding-inline:6px;gap:0;position:relative}.tp-sidebar-collapsed .tp-side-link>span:last-child,.tp-sidebar-collapsed .tp-sidebar-collapse-label{display:none}.tp-sidebar-collapsed .tp-sidebar-collapse>span:first-child{transform:rotate(180deg)}.tp-sidebar-collapsed .tp-side-link:hover::after{content:attr(data-tooltip);position:absolute;inset-inline-start:calc(100% + 8px);top:50%;transform:translateY(-50%);z-index:500;padding:5px 8px;border:1px solid var(--tp-border);border-radius:5px;background:var(--tp-surface);color:var(--tp-text);white-space:nowrap;box-shadow:var(--tp-shadow-2);pointer-events:none}
.tp-workspace-shell{display:flex!important;flex-direction:column!important;height:auto!important;min-height:0!important}.tp-workspace-chart{width:100%;min-height:clamp(500px,68vh,760px)!important}.tp-workspace-side{width:100%;order:2;border-inline-start:0!important;border-top:1px solid var(--tp-border);max-height:none!important;overflow:visible!important}.tp-workspace-bottom{width:100%}
@media(max-width:600px){.tp-workspace-chart{min-height:430px!important}.tp-sidebar-collapse{min-height:38px}}

/* Recovery candidate 118: restore the intended desktop workspace split. */
@media (min-width:901px) {
  .tp-workspace-shell { display:grid !important; grid-template-columns:minmax(0,1fr) clamp(300px,22vw,340px) !important; height:clamp(560px,72vh,760px) !important; min-height:560px !important; }
  .tp-workspace-chart { min-height:0 !important; overflow:hidden !important; }
  .tp-workspace-chart .tp-chart-wrap { height:100% !important; min-height:0 !important; }
}
