/* ═══════════════════════════════════════════════════════════════════════
   App loading overlay — shown until init() has real data, so the first
   ~seconds of a cold load don't read as "the app is broken." A branded
   splash (glossy icon tile + wordmark) rather than a bare spinner, so the
   very first thing anyone sees already looks like this app, not a
   generic loading state.
   ═══════════════════════════════════════════════════════════════════════ */
.app-loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
  background: #070912;
  transition: opacity .25s ease;
}
.app-loading-overlay[hidden] { display: none; }
.app-loading-overlay.fading { opacity: 0; pointer-events: none; }

.splash-mark {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 19px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  background: var(--accent-grad);
  box-shadow: inset 0 1px 0 #ffffff59, 0 14px 34px -10px #7c5cffb3;
  overflow: hidden;
  animation: splashBreathe 1.8s ease-in-out infinite;
}
.splash-mark::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(140deg, #ffffff59 0%, #ffffff00 48%);
  pointer-events: none;
}
.splash-mark svg {
  position: relative; z-index: 1;
  width: 40px; height: 40px;
  filter: drop-shadow(0 2px 4px #00000040);
  animation: splashAim 1.8s var(--ease-out) infinite;
}
@keyframes splashBreathe {
  50% { transform: scale(.94); box-shadow: inset 0 1px 0 #ffffff59, 0 0 0 10px #8b5cf61f, 0 18px 40px -10px #7c5cffcc; }
}
@keyframes splashAim {
  0% { transform: rotate(-45deg) scale(.8); opacity: .4; }
  60%, 100% { transform: none; opacity: 1; }
}

.splash-wordmark {
  display: block;
  text-align: center;
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  animation: splashRise .7s var(--ease-out) .1s backwards;
}
.splash-wordmark small {
  display: block;
  margin-top: 9px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .5em; text-indent: .5em;
  text-transform: uppercase;
  color: var(--text-faint);
}
@keyframes splashRise { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) {
  .splash-mark, .splash-mark svg, .splash-wordmark { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Design tokens
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: dark;

  --bg: #070912;
  --bg-soft: #0f1120;
  --surface: #12152a;
  --surface-2: #1a1e38;
  --surface-3: #232848;
  --border: #ffffff17;
  --border-strong: #ffffff26;
  --fill: #ffffff0d;
  --fill-strong: #ffffff17;

  --text: #f1f3ff;
  --text-dim: #b3b8d6;
  --text-faint: #767c9e;

  --accent: #8b7bff;
  --accent-2: #06b6d4;
  --accent-grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 48%, #06b6d4 100%);
  --accent-soft: #8b7bff2e;
  --glow: 0 10px 28px -8px #7c5cffb3;

  --green: #2ee6a6;
  --green-soft: #2ee6a629;
  --red: #ff5d7d;
  --red-soft: #ff5d7d29;
  --amber: #fbbf24;
  --amber-soft: #fbbf2429;

  --radius-lg: 24px;
  --radius-md: 17px;
  --radius-sm: 12px;

  /* An inset top highlight plus a drop shadow — not just a shadow alone —
     is what makes a translucent panel read as a pane of glass with a lit
     edge, rather than a flat dark card. */
  --shadow-hi: inset 0 1px 0 #ffffff24;
  --shadow-card: inset 0 1px 0 #ffffff24, 0 14px 34px -14px #000000a6;
  --shadow-float: inset 0 1px 0 #ffffff24, 0 20px 50px -12px #000000c0;

  --spring: cubic-bezier(.3, 1.45, .5, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --blur: var(--blur);

  /* System font first — on iOS/macOS this resolves to real San Francisco,
     matching Telegram's own UI instead of forcing a web font on top of it. */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;

  /* Glass surfaces: translucent so the ambient aurora behind bleeds through
     and backdrop-filter can actually blur something — but opaque enough
     that text sitting on top stays readable. */
  --glass: #ffffff0f; --glass-strong: #161a2ec7; --glass-border: #ffffff1f;

  /* Aurora blobs drifting behind the glass. */
  --blob-1: #6d28d9a6; --blob-2: #0891b28c; --blob-3: #db27775c; --blob-4: #4338ca8c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Deliberately NOT deferring to --tg-theme-bg-color/--tg-theme-text-color:
     Telegram's client auto-injects those to match the user's Telegram theme,
     which silently overrides our own palette (this is why background edits
     were invisible before — Telegram's dark theme color was winning). We
     want our own designed look regardless of the user's Telegram theme. */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  letter-spacing: -0.01em;
}

body {
  background: var(--bg);
}
/* Aurora backdrop: two soft colour fields drifting at different speeds
   behind the glass, instead of a static set of radial glows — this is
   what actually sells "frosted glass floating over something alive"
   rather than "dark card on a slightly lighter dark background". */
body::before, body::after {
  content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none; will-change: transform;
}
body::before {
  background:
    radial-gradient(38% 32% at 18% 14%, var(--blob-1), transparent 72%),
    radial-gradient(34% 30% at 88% 36%, var(--blob-2), transparent 72%),
    radial-gradient(40% 34% at 40% 92%, var(--blob-3), transparent 72%);
  animation: auroraDriftA 38s ease-in-out infinite alternate;
}
body::after {
  background:
    radial-gradient(30% 26% at 70% 70%, var(--blob-4), transparent 72%),
    radial-gradient(26% 22% at 22% 58%, var(--blob-2), transparent 72%);
  opacity: .8;
  animation: auroraDriftB 52s ease-in-out infinite alternate;
}
@keyframes auroraDriftA {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50% { transform: translate3d(5%, -4%, 0) rotate(10deg) scale(1.08); }
  100% { transform: translate3d(-4%, 5%, 0) rotate(-8deg) scale(1.03); }
}
@keyframes auroraDriftB {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(-7%, -6%, 0) rotate(-14deg) scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 96px;
}

svg { display: block; }

/* Shared tactile press feel: every button in the app settles with the
   same spring and shrinks the same amount on press, instead of each
   component inventing its own — small, but it's what makes the whole UI
   feel like one coherent material rather than a pile of components. */
button {
  transition: transform .35s var(--spring), background-color .2s, box-shadow .2s, opacity .2s, color .2s, border-color .2s;
}
button:active:not(:disabled) { transform: scale(.95); transition-duration: .08s; }

/* ═══════════════════════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  background: linear-gradient(180deg, #070912cc 45%, #07091200);
  border-bottom: 1px solid var(--glass-border);
}

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

.brand-mark {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad);
  box-shadow: inset 0 1px 0 #ffffff59, 0 6px 16px -4px #8b7bff66;
  color: white;
  flex-shrink: 0;
  overflow: visible;
  transition: box-shadow .3s;
}
/* A diagonal glass highlight across the top-left — the thing that makes a
   flat gradient circle read as a glossy tile instead of a plain dot. */
.brand-mark::after {
  content: "";
  position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(140deg, #ffffff59 0%, #ffffff00 48%);
  pointer-events: none;
}
.brand-mark svg { position: relative; z-index: 1; width: 20px; height: 20px; filter: drop-shadow(0 2px 4px #00000040); }
.brand-avatar {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.brand-initials {
  position: relative; z-index: 1;
  font-size: 15px;
  font-weight: 800;
  color: white;
  letter-spacing: 0.02em;
}

/* Real Telegram Premium users get a gold ring + star badge — tied to the
   actual `is_premium` flag from Telegram, not a made-up tier. */
.brand-mark.premium {
  box-shadow: 0 0 0 2px #ffd76a, 0 6px 18px -4px #ffb30099;
}
.premium-badge {
  position: absolute; z-index: 1;
  bottom: -2px; right: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffe9a8, #ffb300);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  color: #5c3d00;
  border: 2px solid var(--bg);
  box-shadow: 0 2px 5px #00000050;
}

.brand-title { font-size: 13.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; color: var(--text-dim); }
/* Styled as a glass pill ("data badge") rather than plain inline text —
   the live-dot + mode read as one status chip instead of a caption line. */
.brand-sub {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--text-dim);
  margin-top: 5px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--fill);
  border: 1px solid var(--border);
  width: fit-content;
}

.connects-left-badge {
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
  background: var(--surface-2, rgba(128,128,128,.15));
  color: var(--text-dim);
}
.connects-left-badge.low {
  background: var(--amber-soft); color: var(--amber);
}
.connects-left-badge.exhausted {
  background: var(--red-soft); color: var(--red);
}

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}
.live-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  animation: pulseDotGreen 2s ease-in-out infinite;
}
.live-dot.connecting {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
  animation: pulseDotAmber 0.9s ease-in-out infinite;
}
.live-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}
@keyframes pulseDotGreen {
  0%, 100% { box-shadow: 0 0 0 3px var(--green-soft); }
  50% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes pulseDotAmber {
  0%, 100% { box-shadow: 0 0 0 3px var(--amber-soft); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

/* The one number people open this app to check — given the same visual
   weight a forex ticker gives its price, not a small corner readout. */
.balance-box { text-align: right; }
.balance-label { font-size: 10.5px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; }
.balance-value {
  font-family: var(--mono);
  font-size: 26px; font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  color: var(--text);
  line-height: 1.05;
}
.balance-value.pending { color: var(--text-faint); font-weight: 500; font-size: 13px; font-family: var(--font); }
.balance-value.connecting {
  color: var(--amber);
  font-weight: 600; font-size: 13px; font-family: var(--font);
  animation: connectingPulse 1.1s ease-in-out infinite;
}
/* The animated "..." itself is driven from JS (app.js setDotsAnimation) —
   animating the CSS `content` property isn't reliably supported across
   the WebViews Telegram embeds, so we just update textContent on a timer. */
@keyframes connectingPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.balance-value.failed { color: var(--red); font-weight: 600; font-size: 13px; font-family: var(--font); }

/* ═══════════════════════════════════════════════════════════════════════
   Content / tabs
   ═══════════════════════════════════════════════════════════════════════ */
.content { flex: 1; padding: 6px 16px 12px; }
.tab { display: none; }
.tab.active { display: block; animation: tabIn .32s cubic-bezier(.2,.8,.2,1); }

@keyframes tabIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Each tab's direct sections cascade in one after another instead of the
   whole page appearing at once — this is most of what makes a static page
   of stacked cards read as a considered, modern layout rather than a form. */
.tab.active > * { animation: sectionRise .5s var(--ease-out) backwards; }
.tab.active > *:nth-child(1) { animation-delay: 0s; }
.tab.active > *:nth-child(2) { animation-delay: .04s; }
.tab.active > *:nth-child(3) { animation-delay: .08s; }
.tab.active > *:nth-child(4) { animation-delay: .12s; }
.tab.active > *:nth-child(5) { animation-delay: .16s; }
.tab.active > *:nth-child(6) { animation-delay: .2s; }
.tab.active > *:nth-child(n+7) { animation-delay: .24s; }
@keyframes sectionRise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
}
@media (prefers-reduced-motion: reduce) {
  .tab.active > * { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Panels / cards
   ═══════════════════════════════════════════════════════════════════════ */
.panel {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  transition: transform .15s;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head.bare { margin: 6px 4px 12px; }
.panel-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.icon-title { display: inline-flex; align-items: center; gap: 7px; }
.icon-title svg { width: 15px; height: 15px; color: var(--text-faint); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ═══════════════════════════════════════════════════════════════════════
   Hero card
   ═══════════════════════════════════════════════════════════════════════ */
.hero-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 24px 20px 22px;
  margin-bottom: 14px;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-float);
}
.hero-glow {
  position: absolute; inset: -45% -25% auto auto;
  width: 280px; height: 280px;
  background: radial-gradient(circle, #8b7bff3d, transparent 70%);
  pointer-events: none;
}
.hero-glow::after {
  content: "";
  position: absolute; inset: auto auto -120% -10%;
  width: 220px; height: 220px;
  background: radial-gradient(circle, #06b6d42e, transparent 70%);
}
.hero-top {
  position: relative;
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px;
}
.hero-eyebrow { font-size: 12px; font-weight: 600; color: var(--text-faint); margin-bottom: 6px; }
.hero-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }

.asset-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700;
  background: #ffffff0d;
  border: 1px solid var(--border-strong);
  padding: 7px 12px 7px 9px;
  border-radius: 999px;
  color: var(--text-dim);
}
.asset-pill svg { width: 14px; height: 14px; color: var(--accent); }

.toggle-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15.5px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: transform .15s cubic-bezier(.2,.8,.2,1), box-shadow .2s, filter .2s;
  color: #06110a;
}
/* A diagonal light sweep drifting across the button every few seconds —
   the one bit of ambient motion that signals "this is a live control",
   not just a static colored rectangle. */
.toggle-btn::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%;
  background: linear-gradient(100deg, transparent, #ffffff59, transparent);
  transform: skewX(-18deg);
  animation: toggleSheen 4.2s ease-in-out 1.2s infinite;
  pointer-events: none;
}
.toggle-btn:disabled::after { animation: none; display: none; }
@keyframes toggleSheen { 0% { left: -60%; } 38%, 100% { left: 130%; } }
.toggle-btn svg { position: relative; width: 18px; height: 18px; }
.toggle-btn .toggle-label { position: relative; }
.toggle-btn:active { transform: scale(0.965); }
.toggle-btn.stopped {
  background: linear-gradient(135deg, #3fe895, #1fb56b);
  box-shadow: 0 10px 24px -8px #2ee6a666;
}
.toggle-btn.running {
  background: linear-gradient(135deg, #ff7e8f, #e63552);
  box-shadow: 0 10px 24px -8px #ff5d7d66;
  color: #2a030c;
}
.toggle-btn:disabled { opacity: 0.55; cursor: default; filter: saturate(0.6); }
.toggle-btn .icon-stop { display: none; }
.toggle-btn.running .icon-play { display: none; }
.toggle-btn.running .icon-stop { display: block; }

.server-load {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
}
.server-load svg { width: 13px; height: 13px; opacity: 0.8; }

/* ═══════════════════════════════════════════════════════════════════════
   Session equity sparkline
   ═══════════════════════════════════════════════════════════════════════ */
.equity-spark { width: 100%; height: 64px; display: block; }
.equity-spark .spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.equity-spark .spark-fill { fill: url(#sparkGradient); opacity: 0.5; }
.equity-spark .spark-zero { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }

/* ═══════════════════════════════════════════════════════════════════════
   TP/SL risk progress bars
   ═══════════════════════════════════════════════════════════════════════ */
.risk-row { margin-bottom: 14px; }
.risk-row:last-child { margin-bottom: 0; }
.risk-row-head {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-dim); margin-bottom: 7px;
}
.risk-row-head span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.risk-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.risk-bar-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}
.risk-bar-fill.tp { background: linear-gradient(90deg, #2ee6a699, var(--green)); }
.risk-bar-fill.sl { background: linear-gradient(90deg, #ff5d7d99, var(--red)); }
.risk-bar-fill.trades { background: linear-gradient(90deg, #8b7bff99, var(--accent)); }

/* ═══════════════════════════════════════════════════════════════════════
   Stat grid
   ═══════════════════════════════════════════════════════════════════════ */
/* Bento: Session P&L (the number people actually open this tab to check)
   runs as a wider, taller featured tile; the rest fill in around it,
   rather than four identically-sized boxes in a flat 2x2. */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(0, auto);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card:nth-child(1) {
  grid-column: span 2;
  display: flex; align-items: center; justify-content: space-between;
  flex-direction: row;
}
.stat-card:nth-child(1) .stat-icon { margin-bottom: 0; width: 34px; height: 34px; }
.stat-card:nth-child(1) .stat-icon svg { width: 18px; height: 18px; }
.stat-card:nth-child(1) .stat-value { font-size: 25px; }
.stat-card {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 15px;
  box-shadow: var(--shadow-card);
  transition: transform .15s;
}
.stat-icon {
  width: 26px; height: 26px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.stat-icon svg { width: 14px; height: 14px; }
.stat-icon.pnl { background: var(--accent-soft); color: var(--accent); }
.stat-icon.wr { background: var(--amber-soft); color: var(--amber); }
.stat-icon.trades { background: #ffffff10; color: var(--text-dim); }
.stat-icon.time { background: #ffffff10; color: var(--text-dim); }
.stat-label { font-size: 11.5px; color: var(--text-faint); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-family: var(--mono); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

.row-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: 13.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.row-line:last-child { border-bottom: none; padding-bottom: 0; }
.row-line b { color: var(--text); font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.row-line b.win { color: var(--green); }
.row-line b.loss { color: var(--red); }

.err-banner {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  border: 1px solid #ff5d7d40;
  color: #ff8b9a;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════════
   Form controls
   ═══════════════════════════════════════════════════════════════════════ */
.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 13px;
  font-size: 15px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
/* Kill the native OS spinner buttons on number inputs — they render as a
   completely different, low-fidelity control style stapled onto the field. */
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input:focus {
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input.textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
}
.input.textarea.swap { animation: fieldSwap .3s cubic-bezier(.2,.8,.2,1); }
@keyframes fieldSwap {
  0% { opacity: 0.3; transform: translateY(3px); border-color: var(--accent); }
  100% { opacity: 1; transform: translateY(0); }
}
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; }
.select-wrap { position: relative; }
.select-chevron {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-faint); pointer-events: none;
}

/* ── Custom asset picker (replaces the native <select> — a plain select
   can't show flag icons or a search box, and looked too "raw" next to the
   rest of the UI) ── */
.asset-picker { position: relative; }
.asset-picker-btn {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.asset-picker-btn:active { transform: scale(0.995); }
.asset-picker.open .asset-picker-btn {
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.asset-picker-flag { display: inline-flex; flex-shrink: 0; }
.asset-picker-flag .flag-icon { margin-right: 0; }
.asset-picker-name { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.asset-picker.open .select-chevron { transform: translateY(-50%) rotate(180deg); }
.select-chevron { transition: transform .15s; position: static; width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }

.asset-picker-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--surface-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px #00000055;
  overflow: hidden;
  animation: pickerOpen .12s ease-out;
}
.asset-picker-panel[hidden] { display: none; }
@keyframes pickerOpen {
  0% { opacity: 0; transform: translateY(-4px); }
  100% { opacity: 1; transform: translateY(0); }
}
.asset-picker-search {
  border-radius: 0; border: none; border-bottom: 1px solid var(--glass-border);
  background: var(--surface-3);
}
.asset-picker-search:focus { box-shadow: none; }
.asset-picker-list { max-height: 260px; overflow-y: auto; padding: 4px; }
.asset-picker-group-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px 4px;
}
.asset-picker-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.asset-picker-row:hover { background: var(--surface-3); }
.asset-picker-row.selected { background: var(--accent-soft); color: var(--accent); }
/* `display: flex` above is author-origin and beats the UA `[hidden]{display:none}`
   rule regardless of specificity (same trap hit earlier with .real-warning) —
   without this, filtering the search box would never actually hide a row. */
.asset-picker-row[hidden] { display: none; }
.asset-picker-empty { padding: 16px 10px; text-align: center; color: var(--text-faint); font-size: 13px; }

.field-label { font-size: 12px; font-weight: 500; color: var(--text-faint); margin-bottom: 7px; }
.hint { font-size: 11.5px; color: var(--text-faint); margin-top: 12px; line-height: 1.5; }
.signal-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid #8b7bff30;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.signal-note svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--accent); margin-top: 1px; }

/* ── Risk profile presets ── */
.risk-profiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.risk-profile-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
}
.risk-profile-card:active { transform: scale(0.97); }
.risk-profile-card.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.rp-name { font-size: 12.5px; font-weight: 700; color: var(--text); }
.rp-desc { font-size: 10px; color: var(--text-faint); line-height: 1.35; }
.risk-profile-card.active .rp-name { color: var(--accent); }

/* ── Trading Plan summary ticket ── */
.plan-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  background: linear-gradient(160deg, #2a2f6b40, #070912 70%), var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid #8b7bff35;
  box-shadow: var(--shadow-card);
}
.plan-head { margin-bottom: 12px; }
.plan-head .panel-title { color: var(--accent); }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 8px; }
.plan-label { font-size: 10px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.plan-value { font-size: 13.5px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.input-row {
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  transition: border-color .15s, box-shadow .15s;
}
.input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-row .input { border: none; background: transparent; padding-left: 6px; box-shadow: none !important; }
.prefix { color: var(--text-faint); font-weight: 700; font-family: var(--mono); }

/* Quick-select chips (direction / amount / expiry presets) */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}
.chip {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.chip:active { transform: scale(0.95); }
.chip.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: white;
}

/* Martingale live preview */
.mg-preview { border-top: 1px solid var(--border); padding-top: 4px; }
.mg-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mg-step-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.mg-step-chip .mg-step-num { color: var(--text-faint); font-weight: 500; }
.mg-step-arrow { color: var(--text-faint); font-size: 13px; }
.mg-total {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}
.mg-total b { font-family: var(--mono); font-size: 15px; color: var(--amber); font-variant-numeric: tabular-nums; }

/* Segmented control with sliding thumb */
.segmented {
  position: relative;
  display: flex;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 5px;
}
.segmented-thumb {
  position: absolute;
  top: 5px; left: 5px;
  width: calc(50% - 5px); height: calc(100% - 10px);
  border-radius: 10px;
  background: var(--accent-grad);
  box-shadow: 0 4px 14px -2px #8b7bff66;
  transition: transform .5s var(--spring), background .2s, box-shadow .2s;
  z-index: 0;
}
.segmented-thumb.real { background: linear-gradient(135deg, #ff7e8f, #e63552); box-shadow: 0 4px 14px -2px #ff5d7d66; }
.seg-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-weight: 700;
  font-size: 13.5px;
  font-family: var(--font);
  border-radius: 10px;
  cursor: pointer;
  transition: color .2s;
}
.seg-btn svg { width: 15px; height: 15px; opacity: 0.7; transition: opacity .2s; }
.seg-btn.active { color: white; }
.seg-btn.active svg { opacity: 1; }

.real-warning {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--red-soft);
  border: 1px solid #ff5d7d40;
  border-radius: var(--radius-sm);
  color: #ff8b9a;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
}
/* `display: flex` above is an author-origin rule, which always beats the
   browser's built-in `[hidden] { display: none }` (a user-agent-origin
   rule) regardless of selector specificity — so without this override,
   setting the `hidden` property in JS had no visual effect at all and the
   banner showed unconditionally, in every account mode. */
.real-warning[hidden] { display: none; }
.real-warning.demo-mode {
  background: var(--accent-soft);
  border-color: #4f9dff40;
  color: var(--accent);
}
.real-warning svg { width: 17px; height: 17px; flex-shrink: 0; }

.request-access-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 10px; padding: 11px 13px;
  background: var(--accent-grad); color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 650; cursor: pointer; box-shadow: var(--glow);
}
.request-access-btn[hidden] { display: none; }
.request-access-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.request-access-btn:disabled { opacity: .6; cursor: default; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; transition: background .2s, border-color .2s;
}
.slider::before {
  content: ""; position: absolute; height: 19px; width: 19px;
  left: 3px; top: 3px; background: white; border-radius: 50%;
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 2px 6px #00000040;
}
input:checked + .slider { background: var(--accent-grad); border-color: transparent; }
input:checked + .slider::before { transform: translateX(19px); }

.save-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 15px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-grad);
  color: white;
  font-weight: 700;
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 10px 24px -8px #8b7bff66;
  transition: transform .15s cubic-bezier(.2,.8,.2,1);
}
.save-btn svg { width: 17px; height: 17px; }
.save-btn:active { transform: scale(0.98); }
.save-btn:disabled { opacity: 0.6; }
.save-btn.save-btn-sm {
  padding: 10px;
  font-size: 13px;
  margin-top: 10px;
  box-shadow: none;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.save-btn.save-btn-sm svg { width: 14px; height: 14px; }

.ssid-status {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  letter-spacing: 0.01em;
}
.ssid-status.set { background: var(--green-soft); color: var(--green); }
.ssid-status.unset { background: var(--red-soft); color: var(--red); }

/* Collapsed "saved" state — avoids showing a full textarea + save button
   for a field that's already set and doesn't need touching most visits. */
.ssid-saved-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ssid-saved-row[hidden] { display: none; }
.ssid-saved-left { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); font-family: var(--mono); letter-spacing: 0.04em; }
.ssid-saved-left svg { width: 16px; height: 16px; color: var(--green); flex-shrink: 0; }
.ssid-edit-btn {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
}
.ssid-edit-btn:active { transform: scale(0.95); }

/* ── Trading accounts (Settings) ──────────────────────────────────────
   One operator, several PocketOption accounts: each row is one account
   that Start will run, with its own enable toggle and proxy. */
.account-row {
  padding: 11px 13px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
/* Disabled accounts stay listed rather than hidden — "why didn't that one
   start" should be answerable by looking, not by remembering. */
.account-row.disabled { opacity: 0.55; }
.account-main { display: flex; align-items: center; gap: 10px; }
.account-name { flex: 1; min-width: 0; }
.account-label {
  font-size: 13px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-sub {
  font-size: 11px; color: var(--text-faint, var(--text-dim));
  font-family: var(--mono); display: flex; gap: 8px; align-items: center;
}
.account-toggle { position: relative; flex-shrink: 0; width: 34px; height: 20px; }
.account-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.account-toggle span {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  transition: background .15s ease;
  pointer-events: none;
}
.account-toggle span::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-dim); transition: transform .15s ease, background .15s ease;
}
.account-toggle input:checked + span { background: var(--green-soft); border-color: var(--green); }
.account-toggle input:checked + span::after { transform: translateX(14px); background: var(--green); }
.account-edit-btn {
  flex-shrink: 0; padding: 5px 10px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-dim); font-size: 11px; font-weight: 600; cursor: pointer;
}
.account-edit-btn:active { transform: scale(0.96); }
.account-del {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--red); font-size: 17px; line-height: 1; cursor: pointer;
}
.account-del:active { transform: scale(0.92); }
.account-edit-group { margin-top: 9px; }
.account-edit-group[hidden] { display: none; }
.account-add-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.account-add-row .proxy-select { margin-top: 0; flex: 1; }

/* Custom proxy picker — replaces a native <select>, whose browser-drawn
   popup ignores the app's theme entirely and (being alphabetical) lists
   "Server 10" before "Server 2". */
.proxy-select { position: relative; margin-top: 9px; }
.proxy-select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 12px; padding: 7px 9px; cursor: pointer;
  text-align: left;
}
.proxy-select-trigger span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proxy-select-chevron {
  width: 14px; height: 14px; flex-shrink: 0; color: var(--text-faint);
  transition: transform .15s;
}
.proxy-select-trigger[aria-expanded="true"] .proxy-select-chevron { transform: rotate(180deg); }
/* Positioned by JS (top/left/width) each time it opens — a single
   shared, body-level element rather than one per row (see the portal
   comment on #proxyMenuOverlay in index.html). */
.proxy-select-menu {
  position: fixed; z-index: 9999;
  max-height: 216px; overflow-y: auto;
  background: var(--glass-strong); backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-float);
  padding: 5px;
}
.proxy-select-option {
  padding: 9px 10px; border-radius: 9px; font-size: 13px;
  color: var(--text-dim); cursor: pointer;
}
.proxy-select-option:active { background: var(--surface-3); }
.proxy-select-option.selected { color: var(--text); font-weight: 600; background: var(--accent-soft); }
@media (hover: hover) {
  .proxy-select-option:hover { background: var(--surface-2); }
}
.account-empty {
  padding: 13px; text-align: center; font-size: 12px;
  color: var(--text-dim); background: var(--surface-2);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.account-state {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-dim);
}
.account-state.live { background: var(--green-soft); color: var(--green); }
.account-state.error { background: var(--red-soft); color: var(--red); }
.account-state.connecting { background: var(--surface-3); color: var(--text-dim); }

/* ── Live account rows (Dashboard) ──────────────────────────────────── */
.acct-live {
  padding: 10px 12px; margin-bottom: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.acct-live-main { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.acct-live-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-live-meta {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin-top: 5px; font-size: 11px; font-family: var(--mono); color: var(--text-dim);
}
.acct-live-proxy { opacity: 0.75; }
.acct-live-meta .pos { color: var(--green); }
.acct-live-meta .neg { color: var(--red); }

.csv-export-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
}
.csv-export-btn svg { width: 14px; height: 14px; }
.csv-export-btn:active { transform: scale(0.95); }
.csv-export-btn:disabled { opacity: 0.6; cursor: default; }

/* ═══════════════════════════════════════════════════════════════════════
   Insights tab
   ═══════════════════════════════════════════════════════════════════════ */
.insights-refresh-btn {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
}
.insights-refresh-btn svg { width: 15px; height: 15px; }
.insights-refresh-btn:active { transform: scale(0.9); }
.insights-refresh-btn.spinning svg { animation: insightsSpin .6s linear infinite; }
@keyframes insightsSpin { to { transform: rotate(360deg); } }

.insights-disclaimer {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 0 4px 16px;
}
.insights-disclaimer b { color: var(--text-dim); }

.insight-bars { display: flex; flex-direction: column; gap: 10px; }
.insight-bar-row { display: flex; flex-direction: column; gap: 4px; }
.insight-bar-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; }
.insight-bar-label { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.insight-bar-count { color: var(--text-faint); font-weight: 500; font-size: 11px; }
.insight-bar-pct { font-weight: 800; color: var(--green); }
.insight-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.insight-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
}
.insight-bar-row.insufficient .insight-bar-pct,
.insight-bar-row.insufficient .insight-bar-label { color: var(--text-faint); }
.insight-bar-row.insufficient .insight-bar-fill { background: var(--border-strong); }
.insight-bar-row.insufficient .insight-bar-count::after { content: " · limited data"; }

/* Rank-ordered lists (pairs) get a leading badge; fixed-category lists
   (days, martingale steps) skip it since order is chronological, not a
   ranking — a "#1" badge on Monday would misleadingly imply Monday won. */
.insight-bars:not(.insight-bars-row) .insight-bar-row:nth-child(1):not(.insufficient) .insight-bar-label::before { content: "🥇 "; }
.insight-bars:not(.insight-bars-row) .insight-bar-row:nth-child(2):not(.insufficient) .insight-bar-label::before { content: "🥈 "; }
.insight-bars:not(.insight-bars-row) .insight-bar-row:nth-child(3):not(.insufficient) .insight-bar-label::before { content: "🥉 "; }

.insight-hour-strip {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 90px;
  padding: 0 2px;
}
.insight-hour-col {
  flex: 1;
  display: flex;
  align-items: flex-end;
  height: 100%;
  border-radius: 3px 3px 1px 1px;
  cursor: pointer;
}
.insight-hour-bar {
  width: 100%;
  border-radius: 3px 3px 1px 1px;
  background: var(--accent-grad);
  min-height: 3px;
}
.insight-hour-col.insufficient .insight-hour-bar { background: var(--border-strong); }
.insight-hour-col.empty .insight-hour-bar { background: var(--border); min-height: 2px; }
.insight-hour-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 2px;
  font-size: 10px;
  color: var(--text-faint);
}

/* Row layout (days / martingale steps): a handful of fixed categories
   shown as small columns side by side, rather than the stacked
   horizontal-bar list used for the open-ended pairs ranking. */
.insight-bars-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
}
.insight-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.insight-col-pct { font-size: 11px; font-weight: 800; color: var(--green); margin-bottom: 4px; }
/* Fixed pixel height (not flex:1) so the inline height:X% on
   .insight-col-fill always resolves against a definite size — same
   approach as .insight-hour-strip below, deliberately not relying on
   percentage-height-inside-a-flex-item, which needs care to render
   consistently everywhere. */
.insight-col-track {
  height: 90px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--surface-3);
  border-radius: 6px;
  overflow: hidden;
}
.insight-col-fill { width: 100%; background: var(--accent-grad); min-height: 3px; border-radius: 6px 6px 0 0; }
.insight-col-label { font-size: 11px; font-weight: 700; color: var(--text-dim); margin-top: 6px; }
.insight-col-count { font-size: 10px; color: var(--text-faint); }
.insight-col.insufficient .insight-col-pct,
.insight-col.insufficient .insight-col-label { color: var(--text-faint); }
.insight-col.insufficient .insight-col-fill { background: var(--border-strong); }

.flag-icon {
  display: inline-block;
  width: 18px;
  height: 14px;
  border-radius: 2px;
  vertical-align: -2px;
  margin-right: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px #ffffff1a;
  background: #ffffff08; /* avoids a flash of empty space while it loads */
}
span.flag-icon { box-shadow: none; background: none; font-size: 13px; line-height: 1; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; color: var(--text-faint); padding: 56px 0; font-size: 13.5px;
}
.empty-state[hidden] { display: none; }
.empty-state svg { width: 40px; height: 40px; opacity: 0.5; }

/* ═══════════════════════════════════════════════════════════════════════
   Bottom-sheet modal base — shared by the real-money risk disclosure and
   the connect-popup below
   ═══════════════════════════════════════════════════════════════════════ */
.admin-overlay {
  position: fixed; inset: 0;
  z-index: 100;
  background: #06070ae0;
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
}
.admin-overlay[hidden] { display: none; }
.admin-sheet {
  width: 100%; max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  animation: sheetUp .3s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.risk-ack-sheet { max-width: 460px; }

/* Admin panel sheet: unlike the compact dialogs above, this needs to be
   near-fullscreen to actually fit a dashboard (sidebar, tables, charts) —
   it's an iframe onto admin.html, kept on this same page/URL rather than
   navigated to, matching the in-app-overlay pattern. */
.admin-panel-sheet {
  max-width: 100%; width: 100%; height: 100dvh; max-height: 100dvh;
  border-radius: 0; padding: calc(10px + env(safe-area-inset-top)) 0 0;
  display: flex; flex-direction: column;
}
.admin-panel-sheet .admin-sheet-head { padding: 0 14px 10px; margin-bottom: 0; flex-shrink: 0; }
.admin-panel-frame { flex: 1; width: 100%; border: 0; background: transparent; }
.risk-ack-body {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
}
.risk-ack-body p { margin: 0 0 10px; }
.risk-ack-body ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.risk-ack-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 14px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  cursor: pointer;
}
.risk-ack-checkbox-row input { margin-top: 2px; width: 16px; height: 16px; flex-shrink: 0; }
.risk-ack-actions { display: flex; gap: 10px; }
.risk-ack-actions .save-btn { flex: 1; }
.risk-ack-actions .save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.connect-popup-sheet { max-width: 380px; text-align: center; padding-top: 28px; }
.connect-popup-ring-wrap {
  position: relative;
  width: 120px; height: 120px;
  margin: 0 auto 18px;
}
.connect-ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.connect-ring-track { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.connect-ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 314.159; stroke-dashoffset: 314.159;
  transition: stroke-dashoffset .4s linear;
  transform-origin: 60px 60px;
}
.connect-popup-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--text-dim);
}
.connect-popup-center svg { width: 22px; height: 22px; }
.connect-popup-center span { font-size: 12px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.connect-popup-title { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.connect-popup-sub { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-bottom: 10px; }
.connect-popup-attempt {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  color: var(--amber);
  background: var(--amber-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.connect-popup-attempt[hidden] { display: none; }
#connectPopupHideBtn { width: 100%; margin-top: 16px; }

.risk-ack-cancel {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
}
.admin-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
/* ═══════════════════════════════════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  left: 50%; bottom: 100px;
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 40px);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2,.8,.2,1);
  z-index: 50;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: #2ee6a655; }
.toast.err { border-color: #ff5d7d55; }

/* ═══════════════════════════════════════════════════════════════════════
   Bottom nav
   ═══════════════════════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 14px; left: 0; right: 0;
  display: flex;
  max-width: 500px;
  width: calc(100% - 32px);
  margin: 0 auto;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 6px;
  box-shadow: var(--shadow-float);
  z-index: 40;
}
.nav-thumb {
  position: absolute;
  top: 6px; bottom: 6px; left: 6px;
  width: calc(25% - 3px);
  background: #ffffff1a;
  border: 1px solid #ffffff26;
  border-radius: 16px;
  transition: transform .55s var(--spring);
  z-index: 0;
}
.nav-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font);
  padding: 9px 0 7px;
  cursor: pointer;
  border-radius: 14px;
  transition: color .2s;
}
.nav-btn svg { width: 20px; height: 20px; transition: transform .2s; }
.nav-btn.active { color: var(--text); }
.nav-btn.active svg { transform: translateY(-1px); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════════
   Terminal
   ═══════════════════════════════════════════════════════════════════════ */
.countdown-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px 13px;
  background: var(--accent-soft);
  border: 1px solid #8b7bff40;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
}
.countdown-bar[hidden] { display: none; }
.countdown-bar svg { width: 15px; height: 15px; flex-shrink: 0; }
.countdown-bar b { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); }
.terminal {
  background: #0b0d12;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 14px 14px 16px;
  height: calc(100vh - 260px);
  min-height: 320px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  box-shadow: 0 1px 0 0 #ffffff08 inset, 0 8px 28px -12px #00000090;
}
.terminal-line {
  display: flex;
  gap: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  animation: termIn .2s ease;
}
@keyframes termIn { from { opacity: 0; } to { opacity: 1; } }
.terminal-line .t-time { color: var(--text-faint); flex-shrink: 0; }
.terminal-line .t-msg { color: #d6d9e2; }
.terminal-line.dim .t-msg { color: var(--text-faint); }
.terminal-line.success .t-msg { color: var(--green); }
.terminal-line.error .t-msg { color: var(--red); }
.terminal-line.warn .t-msg { color: var(--amber); }

.terminal-cursor {
  display: inline-block;
  width: 7px; height: 13px;
  background: var(--green);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 1s step-end infinite;
}
@keyframes cursorBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* Market picker: badges for markets without a flag image, and payouts. */
.asset-chip{display:inline-flex;align-items:center;justify-content:center;width:42px;height:16px;padding:0 2px;margin-right:6px;overflow:hidden;border-radius:5px;font-size:8.5px;font-weight:700;letter-spacing:.02em;line-height:1;background:#e7ecf5;color:#56658a;flex-shrink:0}
.asset-chip.ccy{width:19px;margin-right:4px;font-size:7px;padding:0}
.asset-chip.crypto{background:#fbefdc;color:#9a6a1c}
.asset-chip.stock{background:#e3f1ea;color:#2f7a55}
.asset-chip.index{background:#ece8f8;color:#6a5aa8}
.asset-chip.commodity{background:#f6ecdf;color:#8a6a3c}
.asset-picker-row .asset-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.asset-payout{font-style:normal;font-size:11px;font-weight:650;color:var(--green,#2f8f5b);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:8px}
.asset-payout.low{color:var(--text-faint,#97a1b3);font-weight:500}
.asset-picker-group-label small{font-weight:500;opacity:.6;margin-left:3px}

/* SSID Finder card (add / edit account) and account route lines. */
.finder-card{border:1px solid #e3e8f3;background:linear-gradient(135deg,#f7f9ff,#f4f7fb);border-radius:16px;padding:14px 14px 12px;margin:0 0 12px}
.finder-head{display:flex;gap:11px;align-items:flex-start}
.finder-head b{display:block;font-size:13px;font-weight:650;color:var(--text,#2d3a52)}
.finder-head small{display:block;font-size:11px;line-height:1.5;color:var(--text-dim,#6b7891);margin-top:3px}
.finder-icon{flex-shrink:0;display:grid;place-items:center;width:34px;height:34px;border-radius:11px;background:#e7edfb;color:#6680c4}
.finder-icon svg{width:18px;height:18px}
.finder-steps{margin:12px 0 0;padding:0;list-style:none;counter-reset:fs;display:grid;gap:9px}
.finder-steps li{counter-increment:fs;display:grid;grid-template-columns:20px 1fr;column-gap:8px;font-size:12px;line-height:1.5;color:var(--text,#3a4762)}
.finder-steps li::before{content:counter(fs);display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:#fff;border:1px solid #dfe5f1;font-size:10px;font-weight:650;color:#6b7fb8}
.finder-steps li>span{align-self:center}
.finder-dl{grid-column:2;display:flex;flex-wrap:wrap;gap:6px;margin-top:7px}
.finder-dl-btn{border:1px solid #cfd9ee;background:#fff;color:#4f68b0;border-radius:10px;min-height:34px;padding:0 13px;font-size:12px;font-weight:600;cursor:pointer}
.finder-dl-btn:disabled{opacity:.6}
.finder-server{color:#4f68b0;background:#e9eefb;border-radius:6px;padding:1px 6px}
.finder-muted{font-size:11px;color:var(--text-faint,#97a1b3)}
.account-route{font-size:11px;color:var(--text-dim,#6b7891);background:#f2f5fa;border-radius:10px;padding:8px 10px;margin-top:8px}
.account-alert{font-size:11px;line-height:1.55;color:#8a5a14;background:#fff5e2;border:1px solid #f0dcb2;border-radius:10px;padding:9px 10px;margin-top:8px}
.account-edit-group .finder-card{margin-top:10px}
