/* ==========================================================================
   OPTION ALGO — "EDITORIAL BOLD"

   Revolut / Robinhood lineage. Warm off-white page, white 16px-radius cards
   with a 1px warm border and no shadow, one indigo accent, and a loud
   typographic hierarchy: the open-position P&L is the biggest thing on the
   page. Light by default; dark follows the OS or html[data-theme="dark"].

   Mobile-first. Breakpoints: 640 (tables -> list), 900 (desktop tabs + menu
   dropdown), 1024 (two columns).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */
:root {
  --bg:            #FAFAF8;
  --card:          #FFFFFF;
  --surface-alt:   #F4F3EF;
  --border:        #ECEBE6;
  --border-strong: #DBD9D2;
  --text:          #16161A;
  --muted:         #6F6E6A;
  --faint:         #A8A7A2;

  --accent:        #4F46E5;
  --accent-hover:  #4338CA;
  --accent-soft:   #EEF0FF;
  --accent-ring:   rgba(79, 70, 229, .22);

  --pos:           #0B7A52;
  --neg:           #C4261C;
  --pos-bg:        rgba(15, 138, 95, .12);
  --neg-bg:        rgba(217, 48, 37, .12);
  --pos-tint:      #EAF7F1;

  --warn-bg:       #FFF4E0;
  --warn-text:     #8A4B00;
  --warn-bar:      #E8900C;
  --band-real:     #C3261B;          /* 6.1:1 with white */

  --brand-fill:    #4F46E5;
  --brand-fill-2:  #3730A3;
  --brand-text:    #FFFFFF;
  --brand-muted:   rgba(255, 255, 255, .72);
  --brand-line:    rgba(255, 255, 255, .18);

  --mesh-1:        rgba(79, 70, 229, .16);
  --mesh-2:        rgba(52, 211, 153, .18);
  --mesh-3:        rgba(251, 146, 60, .16);

  --scrim:         rgba(22, 22, 26, .4);
  --menu-shadow:   0 16px 40px rgba(22, 22, 26, .12), 0 1px 2px rgba(22, 22, 26, .06);
  --card-shadow:   0 24px 60px rgba(22, 22, 26, .10), 0 2px 6px rgba(22, 22, 26, .05);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --gutter: 16px;
  --gap: 16px;
  --card-pad: 20px;
  --radius: 16px;
  --radius-sm: 12px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #111114;
    --card:          #1A1A1F;
    --surface-alt:   #222228;
    --border:        #2A2A31;
    --border-strong: #3A3A43;
    --text:          #F0EFEB;
    --muted:         #A09F9A;
    --faint:         #6C6B68;
    --accent:        #7C76F2;
    --accent-fill:   #4F46E5;
    --tick-on-pos:   #111114;
    --accent-hover:  #968FF7;
    --accent-soft:   #23244A;
    --accent-ring:   rgba(124, 118, 242, .32);
    --pos:           #34C48F;
    --neg:           #F26A5E;
    --pos-bg:        rgba(52, 196, 143, .16);
    --neg-bg:        rgba(242, 106, 94, .16);
    --pos-tint:      #15261F;
    --warn-bg:       #2B2010;
    --warn-text:     #F7B955;
    --warn-bar:      #F7B955;
    --band-real:     #C3261B;
    --brand-fill:    #3F38C9;
    --brand-fill-2:  #2A2480;
    --mesh-1:        rgba(124, 118, 242, .18);
    --mesh-2:        rgba(52, 196, 143, .12);
    --mesh-3:        rgba(251, 146, 60, .10);
    --scrim:         rgba(0, 0, 0, .6);
    --menu-shadow:   0 16px 40px rgba(0, 0, 0, .5);
    --card-shadow:   0 24px 60px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg:            #111114;
  --card:          #1A1A1F;
  --surface-alt:   #222228;
  --border:        #2A2A31;
  --border-strong: #3A3A43;
  --text:          #F0EFEB;
  --muted:         #A09F9A;
  --faint:         #6C6B68;
  --accent:        #7C76F2;
  --accent-fill:   #4F46E5;
  --tick-on-pos:   #111114;
  --accent-hover:  #968FF7;
  --accent-soft:   #23244A;
  --accent-ring:   rgba(124, 118, 242, .32);
  --pos:           #34C48F;
  --neg:           #F26A5E;
  --pos-bg:        rgba(52, 196, 143, .16);
  --neg-bg:        rgba(242, 106, 94, .16);
  --pos-tint:      #15261F;
  --warn-bg:       #2B2010;
  --warn-text:     #F7B955;
  --warn-bar:      #F7B955;
  --band-real:     #C3261B;
  --brand-fill:    #3F38C9;
  --brand-fill-2:  #2A2480;
  --mesh-1:        rgba(124, 118, 242, .18);
  --mesh-2:        rgba(52, 196, 143, .12);
  --mesh-3:        rgba(251, 146, 60, .10);
  --scrim:         rgba(0, 0, 0, .6);
  --menu-shadow:   0 16px 40px rgba(0, 0, 0, .5);
  --card-shadow:   0 24px 60px rgba(0, 0, 0, .5);
}


/* --------------------------------------------------------------------------
   2. BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
small { font-size: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sign colour only on signed values. */
.text-green, .green, .pos-text { color: var(--pos) !important; }
.text-red,   .red,   .neg-text { color: var(--neg) !important; }
.num { text-align: right; }

.mono, .mono-text, .ltp-tick, .pnl-tick { font-family: inherit; }

/* 200ms tick flash. */
.flash-green { background: var(--pos-bg); border-radius: 6px; }
.flash-red   { background: var(--neg-bg); border-radius: 6px; }
.tick-price, .kv-value, .pos-hero-value { transition: background .2s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* --------------------------------------------------------------------------
   3. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--surface-alt); }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent-fill, var(--accent)); border-color: var(--accent-fill, var(--accent)); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { border-color: var(--neg); color: var(--neg); background: transparent; }
.btn-danger:hover { background: var(--neg-bg); }

.btn-block { width: 100%; height: 48px; font-size: 15px; }


/* --------------------------------------------------------------------------
   4. LOGIN — single wide card on a soft mesh, brand half inside
   -------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px var(--gutter);
  background-color: var(--bg);
  background-image:
    radial-gradient(60% 50% at 10% 0%,   var(--mesh-1) 0%, transparent 70%),
    radial-gradient(50% 45% at 95% 15%,  var(--mesh-2) 0%, transparent 70%),
    radial-gradient(55% 50% at 50% 105%, var(--mesh-3) 0%, transparent 70%);
  background-attachment: fixed;
}

.auth-shell {
  width: 100%;
  max-width: 960px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

/* Brand half */
.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 20px 24px;
  color: var(--brand-text);
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(255, 255, 255, .14) 0%, transparent 60%),
    linear-gradient(160deg, var(--brand-fill) 0%, var(--brand-fill-2) 100%);
}
.auth-brand-top { display: flex; align-items: center; gap: 12px; }
.auth-mark { display: inline-flex; flex-shrink: 0; }
.auth-mark svg { width: 36px; height: 36px; display: block; }
.mark-bg   { fill: rgba(255, 255, 255, .16); stroke: rgba(255, 255, 255, .35); stroke-width: 1.5; }
.mark-line { stroke: #fff; fill: none; }
.mark-dot  { fill: #A7F3D0; }
.auth-brand-name { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }

.auth-brand-body { display: none; }
.auth-brand-title {
  font-size: 28px;
  line-height: 34px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin-bottom: 14px;
}
.auth-brand-text { font-size: 14px; line-height: 22px; color: var(--brand-muted); margin-bottom: 28px; max-width: 34ch; }

.auth-brand-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.auth-brand-list li { display: flex; align-items: baseline; gap: 12px; font-size: 13px; color: var(--brand-muted); }
.auth-brand-k {
  flex-shrink: 0;
  min-width: 112px;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid var(--brand-line);
  text-align: center;
  white-space: nowrap;
}

.auth-brand-foot { display: none; gap: 24px; margin-top: auto; padding-top: 20px; border-top: 1px solid var(--brand-line); }
.auth-tick { display: flex; flex-direction: column; gap: 2px; }
.auth-tick-name { font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-muted); }
.auth-tick-val { font-size: 16px; font-weight: 600; color: #fff; }

/* Form half */
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 28px 24px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-title { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -.02em; }
.auth-subtitle { color: var(--muted); font-size: 14px; margin: 6px 0 28px; }

.auth-form { display: block; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder { color: var(--muted); }
.field input:hover { border-color: var(--faint); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.field-pw { position: relative; }
.field-pw input { padding-right: 72px; }
.field-pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.field-pw-toggle:hover { background: var(--accent-soft); }

.field-error { font-size: 13px; font-weight: 500; color: var(--neg); min-height: 20px; margin: -4px 0 12px; }
.field-error:empty { min-height: 0; margin: 0; }

.auth-form .btn-block { margin-top: 8px; }
.auth-footer { margin-top: 24px; font-size: 12px; color: var(--muted); text-align: center; }

@media (min-width: 640px) {
  .auth-page { padding: 40px var(--gutter); }
  .auth-brand { padding: 32px; }
  .auth-brand-body { display: block; }
  .auth-brand-foot { display: flex; }
  .auth-panel { padding: 48px 40px; }
}

@media (min-width: 900px) {
  .auth-shell { grid-template-columns: 45fr 55fr; min-height: 580px; }
  .auth-brand { padding: 40px; gap: 40px; }
  .auth-brand-top { margin-bottom: 8px; }
  .auth-mark svg { width: 40px; height: 40px; }
  .auth-brand-title { font-size: 32px; line-height: 38px; }
  .auth-panel { padding: 56px 64px; }
  .auth-title { font-size: 32px; line-height: 38px; }
}


/* --------------------------------------------------------------------------
   5. TOP BAR — header + mobile tabs + live band, one sticky block
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 var(--gutter);
}

.brand { display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.brand-meta { display: none; font-size: 12px; color: var(--muted); }

/* Mode tabs: text with indigo underline */
.mode-switch { display: none; align-self: stretch; }
.mode-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  min-height: var(--tap);
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { color: var(--text); }
.mode-tab.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}
.tab-note { font-weight: 400; color: var(--muted); margin-left: 2px; }

.mode-switch-mobile {
  display: flex;
  height: 44px;
  border-top: 1px solid var(--border);
}
.mode-switch-mobile .mode-tab { flex: 1; justify-content: center; padding: 0; }

.header-end {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  min-width: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.is-danger { color: var(--neg); background: var(--neg-bg); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.dot.green { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-bg); }
.dot.red   { background: var(--neg); box-shadow: 0 0 0 3px var(--neg-bg); }
.dot.grey  { background: var(--faint); }

.btn-menu { height: 40px; min-width: 72px; border-radius: 999px; }
@media (max-width: 639px) { .btn-menu { height: 44px; } }

.status-short { display: none; }
@media (max-width: 639px) {
  #marketStatusChip { display: none; }
  #brokerStatusText { display: none; }
  .status-short { display: inline; }
}

/* Live-mode band: the loudest thing on the page when real money is armed. */
.live-band {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px var(--gutter);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  border-top: 1px solid var(--border);
}
.live-band.banner-dry {
  background: var(--warn-bg);
  color: var(--warn-text);
  box-shadow: inset 4px 0 0 var(--warn-bar);
}
.live-band.banner-real,
.live-band.banner-alert {
  background: var(--band-real);
  color: #fff;
  border-top-color: var(--band-real);
  font-weight: 700;
  letter-spacing: .01em;
}


/* --------------------------------------------------------------------------
   6. MENU — bottom sheet on mobile, dropdown on desktop
   -------------------------------------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); }

.menu {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  max-height: 85vh;
  overflow-y: auto;
  padding: 8px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--menu-shadow);
}
.menu-grabber { width: 36px; height: 4px; margin: 6px auto 14px; border-radius: 2px; background: var(--border-strong); }

.menu-section { padding: 8px 0; }
.menu-section + .menu-section { border-top: 1px solid var(--border); }
.menu-title { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 6px; }

.menu-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: var(--tap);
  padding: 10px 12px;
  margin: 0 -12px;
  width: calc(100% + 24px);
  border-radius: var(--radius-sm);
  text-align: left;
}
.menu-row:hover { background: var(--surface-alt); }
.menu-label { font-size: 14px; font-weight: 600; }
.menu-hint { font-size: 12px; color: var(--muted); line-height: 18px; }
.menu-row.danger .menu-label { color: var(--neg); }
.menu-row.is-off .menu-label { color: var(--muted); }
.menu-row.armed-dry .menu-label { color: var(--warn-text); }
.menu-row.armed-real .menu-label { color: var(--neg); }
.menu-row.armed-real { background: var(--neg-bg); }
.menu-footer { padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }


/* --------------------------------------------------------------------------
   7. PAGE + PANELS (cards)
   -------------------------------------------------------------------------- */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--gap) var(--gutter) 56px;
}

.panel {
  padding: var(--card-pad);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel + .panel { margin-top: var(--gap); }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-title { font-size: 16px; font-weight: 600; line-height: 22px; letter-spacing: -.01em; }
.panel-caption { font-size: 12px; color: var(--muted); margin-top: 2px; }
.panel-status {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.panel-status.pos { color: var(--pos); background: var(--pos-bg); font-weight: 600; }
.panel-status.neg { color: var(--neg); background: var(--neg-bg); font-weight: 600; }
.sep { margin: 0 5px; opacity: .6; }


/* --------------------------------------------------------------------------
   8. TICKER STRIP — three pill chips
   -------------------------------------------------------------------------- */
.ticker-strip {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter)) var(--gap);
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.ticker-strip::-webkit-scrollbar { display: none; }
.tick {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  /* Pro-terminal tick pulse: the flash class paints instantly (transition
     off), removing it eases the wash back out over ~450ms. */
  transition: background .45s ease-out, border-color .45s ease-out, box-shadow .45s ease-out;
}
.tick.tick-up {
  background: rgba(16, 185, 129, .16);
  border-color: rgba(16, 185, 129, .55);
  box-shadow: 0 0 14px rgba(16, 185, 129, .22);
  transition: none;
}
.tick.tick-down {
  background: rgba(239, 68, 68, .16);
  border-color: rgba(239, 68, 68, .55);
  box-shadow: 0 0 14px rgba(239, 68, 68, .22);
  transition: none;
}
.tick.tick-up .tick-price { color: #34D399; transition: none; }
.tick.tick-down .tick-price { color: #F87171; transition: none; }
.tick-name { font-size: 11px; font-weight: 500; color: var(--muted); }
.tick-price { font-size: 14px; font-weight: 600; line-height: 20px; transition: color .45s ease-out; }
.tick-change { font-size: 11px; font-weight: 500; }
.tick-change:not(.text-green):not(.text-red) { color: var(--muted); font-weight: 400; }

@media (min-width: 640px) {
  .ticker-strip { flex-wrap: wrap; gap: 12px; margin-left: 0; margin-right: 0; padding: 0; overflow: visible; }
  .tick { flex-direction: row; align-items: baseline; gap: 10px; padding: 10px 18px; border-radius: 999px; }
  .tick-name { font-size: 12px; }
  .tick-price { font-size: 15px; }
  .tick-change { font-size: 12px; }
}


/* --------------------------------------------------------------------------
   9. BODY GRID + SUMMARY
   -------------------------------------------------------------------------- */
.body-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.col-main, .col-side { min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.col-main .panel + .panel, .col-side .panel + .panel { margin-top: 0; }

@media (max-width: 1023px) {
  .col-main, .col-side { display: contents; }
  .p-position   { order: 1; }
  .p-summary    { order: 2; }
  .p-conditions { order: 3; }
  .p-chart      { order: 4; }
  .p-history    { order: 5; }
}

/* One white card divided by rules */
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; }
#sellingDashboardView .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sum-cell { min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 18px 16px; }
.sum-cell + .sum-cell { border-left: 1px solid var(--border); }
.sum-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.sum-value { font-size: 20px; font-weight: 700; line-height: 26px; letter-spacing: -.02em; white-space: nowrap; }
.sum-value.text-green { color: #34C48F !important; }
.sum-value.text-red   { color: #F26A5E !important; }
.sum-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 639px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-cell:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
  .sum-cell { padding: 14px 16px; }
  .sum-value { font-size: 18px; }
}


/* --------------------------------------------------------------------------
   10. POSITION — the hero card
   -------------------------------------------------------------------------- */
.pos-empty {
  padding: 20px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 14px;
  line-height: 21px;
}

/* Tinted full-bleed body when a position is open */
.pos-open {
  margin: 0 calc(-1 * var(--card-pad)) calc(-1 * var(--card-pad));
  padding: var(--card-pad);
  background: var(--accent-soft);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

.pos-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
}
.pos-head > div:first-child { min-width: 0; }
.pos-hero { flex-basis: 100%; text-align: left; }
.pos-hero-value { white-space: nowrap; }
@media (min-width: 640px) {
  .pos-hero { flex-basis: auto; text-align: right; }
}
.pos-contract { font-size: 18px; font-weight: 700; line-height: 24px; letter-spacing: -.01em; }
.pos-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.pos-hero-value { font-size: 40px; font-weight: 700; line-height: 46px; letter-spacing: -.02em; }
.pos-hero-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.pos-hero-sub span { font-weight: 600; }

.kv-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(79, 70, 229, .14);
  align-items: end;
}
.kv-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 2px; }
.kv-value { font-size: 15px; font-weight: 600; }

.kv-action { grid-column: 1 / -1; margin-top: 4px; }
.kv-action .btn { width: 100%; height: 44px; background: var(--card); }
@media (min-width: 640px) {
  .kv-row { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
  .kv-action { grid-column: auto; margin-top: 0; justify-self: end; }
  .kv-action .btn { width: auto; height: 40px; }
}


/* --------------------------------------------------------------------------
   11. CONDITIONS — clean list with a large tick
   -------------------------------------------------------------------------- */
.cond-table th {
  padding: 0 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cond-table td { padding: 14px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cond-table tr:last-child td { border-bottom: 0; padding-bottom: 4px; }
.cond-table td + td, .cond-table th + th { padding-left: 12px; }
.rule { font-weight: 600; font-size: 14px; }
.req-inline { display: block; color: var(--muted); line-height: 17px; margin-top: 2px; }
.cond-table .req { color: var(--muted); font-size: 12px; }
.cond-table td:nth-child(2) { white-space: nowrap; font-weight: 500; }
.cond-table .met { width: 44px; text-align: right; }
.cond-table .met span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.cond-table .met .passed { color: var(--tick-on-pos, #fff); background: var(--pos); }
.cond-table .met .not-passed { color: var(--muted); background: var(--surface-alt); }
.cond-table .met .dir { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); }

@media (max-width: 639px) {
  .cond-table .req { display: none; }
  .cond-table td:first-child { width: 44%; padding-right: 8px; }
  .cond-table td:nth-child(2) { font-size: 13px; }
  .rule { font-size: 13px; }
  .req-inline { font-size: 11px; line-height: 15px; }
  .cond-table .met { width: 36px; }
  .cond-table .met span { width: 28px; height: 28px; font-size: 14px; }
  .cond-table .met .dir { font-size: 11px; }
}
@media (min-width: 640px) {
  .req-inline { display: none; }
}


/* --------------------------------------------------------------------------
   12. TRADE HISTORY — table >=640px, two-line list below
   -------------------------------------------------------------------------- */
.table-scroll { display: none; overflow-x: auto; margin: 0 calc(-1 * var(--card-pad)); padding: 0 var(--card-pad); }
.data-table { width: 100%; min-width: 640px; }
.data-table td:last-child { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.data-table th {
  padding: 0 10px 10px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table th.num { text-align: right; }
.data-table td {
  height: 44px;
  padding: 0 10px 0 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 500;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-alt); }
.data-table .muted { color: var(--muted); font-size: 12px; font-weight: 400; }
.data-table .empty { color: var(--muted); text-align: center; height: 64px; font-weight: 400; }

.trade-list { list-style: none; }
.trade-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.trade-list li:last-child { border-bottom: 0; padding-bottom: 4px; }
.trade-list li.empty {
  padding: 20px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--muted);
  border-bottom: 0;
}
.tl-line { display: flex; justify-content: space-between; gap: 12px; }
.tl-line > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-line > span:last-child { flex-shrink: 0; white-space: nowrap; }
.tl-contract { font-weight: 600; font-size: 14px; }
.tl-pnl { font-weight: 700; font-size: 15px; }
.tl-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

@media (min-width: 640px) {
  .table-scroll { display: block; }
  .trade-list { display: none; }
}


/* --------------------------------------------------------------------------
   13. CHART
   -------------------------------------------------------------------------- */
.chart-box { position: relative; height: 200px; }


/* --------------------------------------------------------------------------
   14. BREAKPOINTS
   -------------------------------------------------------------------------- */
@media (min-width: 640px) {
  :root { --gutter: 24px; --gap: 20px; --card-pad: 24px; }
  .brand-meta { display: inline; }
  .chart-box { height: 240px; }
  .menu-grabber { display: none; }
  .page { padding-top: 20px; }
}

@media (min-width: 900px) {
  .mode-switch { display: flex; }
  .mode-switch-mobile { display: none; }

  .menu {
    position: fixed;
    top: 64px; right: var(--gutter); left: auto; bottom: auto;
    width: 340px;
    max-height: calc(100vh - 80px);
    padding: 10px 20px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--menu-shadow);
  }
  .scrim { background: transparent; }
}

@media (min-width: 1024px) {
  :root { --gap: 24px; }
  .page { padding-top: 24px; }
  .body-grid { grid-template-columns: 7fr 5fr; gap: 24px; align-items: start; }
  .pos-hero-value { font-size: 44px; line-height: 50px; }
  .sum-cell { padding: 22px 20px; }
  .sum-value { font-size: 22px; }
}

/* --------------------------------------------------------------------------
   15. TOP PERFORMING STRATEGIES LEADERBOARD
   -------------------------------------------------------------------------- */
.p-leaderboard {
  margin-bottom: var(--gap);
}
.leaderboard-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-subtle {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 120ms ease;
}
.btn-subtle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.leaderboard-table {
  width: 100%;
}
.leaderboard-table th {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 14px;
}
.leaderboard-table td {
  padding: 11px 14px;
  vertical-align: middle;
}
.rank-col {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rank-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 11.5px;
  font-weight: 800;
}
.rank-1 { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }
.rank-2 { background: #F3F4F6; color: #374151; border: 1px solid #D1D5DB; }
.rank-3 { background: #FFEDD5; color: #9A3412; border: 1px solid #FDBA74; }
.rank-num { font-size: 12px; color: var(--faint); }

.lb-strat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lb-strat-code {
  font-size: 11px;
  font-weight: 750;
  color: var(--accent);
  letter-spacing: .02em;
}
.lb-strat-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.badge-bucket {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 650;
  padding: 2.5px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-bucket-supertrend {
  background: rgba(14, 165, 233, .12);
  color: #0284C7;
  border: 1px solid rgba(14, 165, 233, .25);
}
.badge-bucket-vwap {
  background: rgba(168, 85, 247, .12);
  color: #9333EA;
  border: 1px solid rgba(168, 85, 247, .25);
}
.badge-bucket-engine {
  background: rgba(16, 185, 129, .12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, .25);
}
.badge-bucket-mispricing {
  background: rgba(245, 158, 11, .12);
  color: #D97706;
  border: 1px solid rgba(245, 158, 11, .25);
}
.badge-bucket-condor {
  background: rgba(244, 63, 94, .12);
  color: #E11D48;
  border: 1px solid rgba(244, 63, 94, .25);
}
.badge-bucket-default {
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-lb-switch {
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 120ms ease;
}
.btn-lb-switch:hover {
  background: var(--accent);
  color: #fff;
}
.btn-lb-link {
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  text-decoration: none;
  display: inline-block;
  transition: all 120ms ease;
}
.btn-lb-link:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.row-in-trade {
  background: color-mix(in srgb, var(--accent-soft) 40%, transparent);
}
