/* ============================================================
   $mallX — Phase 3.1 Design System
   Premium, mobile-first dark theme for the trade controller.
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* surfaces — deeper, closer to the logo's true black */
  --bg-0: #030307;
  --bg-1: #0a0a12;
  --bg-2: #11111c;
  --bg-3: #1a1a26;
  --bg-elev: #232333;

  /* borders / dividers */
  --border: #24242f;
  --border-strong: #38384a;

  /* text */
  --text: #f4f4f7;
  --text-dim: #b4b4c0;
  --text-mute: #74748a;
  --text-faint: #4a4a5e;

  /* brand — matched to the $mallX logo green + red */
  --green: #2dd05f;
  --green-bright: #5eea83;
  --green-deep: #16a34a;
  --green-glow: rgba(45, 208, 95, 0.42);

  --red: #ed3838;
  --red-bright: #f87171;
  --red-deep: #c91414;
  --red-glow: rgba(237, 56, 56, 0.42);

  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.35);

  /* shadows / glow */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
  --shadow-glow-g: 0 0 24px var(--green-glow);
  --shadow-glow-r: 0 0 24px var(--red-glow);

  /* shapes */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* spacing rhythm (8px grid) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
}

html,
body {
  background: var(--bg-0);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

body {
  /* layered ambient glow — vibrant green + red vignettes matching the logo */
  background:
    radial-gradient(ellipse 80% 60% at 8% 0%, rgba(45, 208, 95, 0.14), transparent 60%),
    radial-gradient(ellipse 80% 60% at 92% 100%, rgba(237, 56, 56, 0.14), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom, 0);
  position: relative;
}

/* $mallX logo watermark — bold ambient brand presence. The robotic face is
   now clearly visible behind the dashboard, not just hinted at. The vignette
   below softens edges so cards stay comfortably readable. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('/logo.png');
  background-position: center 38%;
  background-repeat: no-repeat;
  background-size: min(130vmin, 1000px) auto;
  opacity: 0.19;
  pointer-events: none;
  z-index: 0;
  filter: saturate(1.35) contrast(1.10);
}
body::after {
  /* Vignette softens watermark edges so cards remain comfortably readable. */
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 82% 72% at center 40%, transparent 0%, rgba(3, 3, 7, 0.32) 58%, var(--bg-0) 96%);
  pointer-events: none;
  z-index: 0;
}

/* Keep all real content above the watermark */
.appbar, .app-content, .modal, .toast-stack { position: relative; z-index: 1; }
.appbar { z-index: 50; }
.modal { z-index: 200; }
.toast-stack { z-index: 300; }

button {
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  border: none;
  color: inherit;
}

input,
select {
  font-family: inherit;
}

code {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 0.85em;
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--green-bright);
}

.money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ============================================================
   APP BAR
   ============================================================ */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top, 14px));
  background: rgba(6, 6, 10, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.appbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* App-bar brand mark — THE anchor logo. Sized big enough that the robotic
   face is unmistakable at every glance. Surrounded by a layered neon halo
   that breathes — the brand should feel alive, not pasted. */
.brand-logo-wrap {
  position: relative;
  flex-shrink: 0;
}
.brand-logo {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 36px rgba(45, 208, 95, 0.50),
    0 0 36px rgba(237, 56, 56, 0.42),
    0 10px 22px rgba(0, 0, 0, 0.78),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  animation: brand-pulse 3.4s ease-in-out infinite;
  transform-origin: center;
  position: relative;
  z-index: 2;
}
/* Soft outer halo that pulses with the logo — adds visual mass without
   making the image itself larger. */
.brand-logo-wrap::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 28px;
  background: conic-gradient(
    from 0deg,
    rgba(45, 208, 95, 0.28) 0deg,
    rgba(237, 56, 56, 0.28) 180deg,
    rgba(45, 208, 95, 0.28) 360deg
  );
  filter: blur(14px);
  opacity: 0.55;
  z-index: 1;
  animation: brand-halo-rotate 14s linear infinite,
             brand-halo-pulse 3.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes brand-pulse {
  0%, 100% {
    box-shadow:
      0 0 36px rgba(45, 208, 95, 0.50),
      0 0 36px rgba(237, 56, 56, 0.42),
      0 10px 22px rgba(0, 0, 0, 0.78),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  50% {
    box-shadow:
      0 0 50px rgba(45, 208, 95, 0.72),
      0 0 50px rgba(237, 56, 56, 0.58),
      0 10px 22px rgba(0, 0, 0, 0.78),
      inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  }
}
@keyframes brand-halo-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes brand-halo-pulse {
  0%, 100% { opacity: 0.40; }
  50%      { opacity: 0.70; }
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.brand-name {
  font-weight: 900;
  font-size: 28px;
  letter-spacing: -0.025em;
  background: linear-gradient(95deg, var(--green-bright) 0%, var(--text) 38%, var(--text) 62%, var(--red-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--text);
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.06);
}
.brand-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--text-mute);
  text-transform: uppercase;
  margin-top: 4px;
}

.brand-logo-modal {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}
/* Hero brand splash — the welcome moment. Massive, ambient-lit, with an
   entrance + ambient float + outer halo so the face commands the screen.
   The first impression of $mallX should be unforgettable. */
.brand-logo-hero-wrap {
  position: relative;
  width: fit-content;
  margin: 8px auto 12px;
}
.brand-logo-hero {
  width: 220px;
  height: 220px;
  border-radius: 44px;
  box-shadow:
    0 0 64px rgba(45, 208, 95, 0.55),
    0 0 64px rgba(237, 56, 56, 0.46),
    0 22px 52px rgba(0, 0, 0, 0.80),
    inset 0 0 0 1px rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: block;
  position: relative;
  z-index: 2;
  animation: hero-logo-enter 0.7s cubic-bezier(0.34, 1.4, 0.64, 1) both,
             hero-logo-float 5s ease-in-out 0.7s infinite;
}
/* Big breathing halo behind the hero logo. */
.brand-logo-hero-wrap::before {
  content: '';
  position: absolute;
  inset: -32px;
  border-radius: 64px;
  background: conic-gradient(
    from 0deg,
    rgba(45, 208, 95, 0.35) 0deg,
    rgba(237, 56, 56, 0.35) 180deg,
    rgba(45, 208, 95, 0.35) 360deg
  );
  filter: blur(28px);
  z-index: 1;
  animation: hero-halo-rotate 22s linear infinite,
             hero-halo-pulse 3.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hero-halo-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes hero-halo-pulse {
  0%, 100% { opacity: 0.40; transform: rotate(0deg) scale(1); }
  50%      { opacity: 0.65; transform: rotate(0deg) scale(1.08); }
}
@keyframes hero-logo-enter {
  from { opacity: 0; transform: scale(0.65) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes hero-logo-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.modal-card-hero {
  text-align: center;
  align-items: center;
}
.modal-hero-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}
.modal-hero-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(95deg, var(--green-bright) 0%, var(--text) 38%, var(--text) 62%, var(--red-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.modal-hero-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--text-mute);
  text-transform: uppercase;
}
.modal-hero-sub {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 8px;
}

/* Small brand-mark next to a card header — gives the card a $mallX accent
   without competing with the card's main content. */
.card-head-with-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-head-brand {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 12px rgba(45, 208, 95, 0.22),
    0 0 12px rgba(237, 56, 56, 0.18);
  flex-shrink: 0;
}

/* Prominent ACCOUNT card — replaces the subtle top-bar pill. */
.account-card {
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.account-card[data-type='demo'] { border-color: rgba(45, 208, 95, 0.35); }
.account-card[data-type='real'] { border-color: rgba(237, 56, 56, 0.45); }

.account-pending-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--amber);
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--r-pill);
  background: rgba(245, 158, 11, 0.08);
}

.account-row {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}
.account-info { flex: 1; min-width: 0; }

.account-current {
  display: flex;
  align-items: center;
  gap: 10px;
}
.account-current-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green-glow);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
.account-card[data-type='real'] .account-current-dot {
  background: var(--red);
  box-shadow: 0 0 12px var(--red-glow);
}
.account-current-label {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--green);
}
.account-card[data-type='real'] .account-current-label { color: var(--red-bright); }
.account-hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 4px;
  letter-spacing: 0.02em;
}
.account-card[data-type='real'] .account-hint { color: var(--red-bright); }

.account-switch-btn {
  flex-shrink: 0;
  padding: 12px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: all 0.15s;
}
.account-switch-btn:hover { color: var(--text); border-color: var(--text-mute); background: var(--bg-elev); }
.account-switch-btn:active { transform: scale(0.97); }
.account-card[data-type='demo'] .account-switch-btn { border-color: rgba(237, 56, 56, 0.35); color: var(--red-bright); }
.account-card[data-type='demo'] .account-switch-btn:hover { background: rgba(237, 56, 56, 0.08); }
.account-card[data-type='real'] .account-switch-btn { border-color: rgba(45, 208, 95, 0.4); color: var(--green-bright); }
.account-card[data-type='real'] .account-switch-btn:hover { background: rgba(45, 208, 95, 0.08); }

/* Switching state — button locked, gentle pulse on the card while the bot
   drives PO's cabinet change. */
.account-card[data-switching] {
  border-color: var(--amber);
  animation: account-switching-pulse 1.2s ease-in-out infinite;
}
.account-card[data-switching] .account-switch-btn {
  cursor: progress;
  opacity: 0.6;
}
@keyframes account-switching-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50%      { box-shadow: 0 0 24px rgba(245, 158, 11, 0.25); }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  text-transform: uppercase;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}
.status-pill[data-state='online'] .status-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
.status-pill[data-state='online'] .status-label { color: var(--text-dim); }
.status-pill[data-state='halted'] .status-dot {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}
.status-pill[data-state='halted'] .status-label { color: var(--amber); }
.status-pill[data-state='paused'] .status-dot { background: var(--amber); }
.status-pill[data-state='paused'] .status-label { color: var(--amber); }
.status-pill[data-state='offline'] .status-label { color: var(--text-mute); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   APP CONTENT LAYOUT
   ============================================================ */
.app-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   HALT BANNER
   ============================================================ */
.halt-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  animation: slide-in 0.25s ease;
}
.halt-banner[hidden] { display: none; }
[hidden] { display: none !important; }
.halt-icon {
  font-size: 24px;
  color: var(--amber);
  flex-shrink: 0;
}
.halt-text {
  flex: 1;
  min-width: 0;
}
.halt-title {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--amber);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.halt-reason {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}
.halt-clear {
  padding: 7px 14px;
  background: var(--amber);
  color: var(--bg-0);
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.halt-clear:hover { filter: brightness(1.1); }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   HERO BALANCE
   ============================================================ */
.hero {
  position: relative;
  padding: 22px;
  background: linear-gradient(160deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -10% auto auto;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, var(--green-glow), transparent 70%);
  pointer-events: none;
  opacity: 0.6;
  z-index: 0;
}
/* In-card watermark: the robotic face shows through the hero card itself —
   the user's most-watched surface (balance). Subtle but always present. */
.hero {
  background-image:
    url('/logo.png'),
    linear-gradient(160deg, var(--bg-2) 0%, var(--bg-1) 100%);
  background-repeat: no-repeat, no-repeat;
  background-position: right -20px center, center;
  background-size: 320px auto, cover;
  background-blend-mode: soft-light, normal;
}
.hero::after {
  /* Dark overlay to keep the balance number high-contrast against the
     in-card logo watermark. */
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    rgba(10, 10, 18, 0.55) 0%,
    rgba(10, 10, 18, 0.20) 55%,
    rgba(10, 10, 18, 0.60) 100%
  );
  pointer-events: none;
  z-index: 0;
}
.hero-top, .hero-stats { position: relative; z-index: 1; }

/* (Hero brand seal removed — body watermark + larger app bar logo deliver
   brand presence without competing with the P&L value on mobile.) */
.hero::after {
  content: '';
  position: absolute;
  inset: auto auto -40% -10%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, var(--red-glow), transparent 70%);
  pointer-events: none;
  opacity: 0.4;
}

.hero-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.hero-balance-wrap { min-width: 0; }
.hero-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}
.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
.hero-balance {
  font-weight: 800;
  font-size: 36px;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
}
.hero-currency {
  font-size: 22px;
  color: var(--text-mute);
  margin-right: 2px;
  font-weight: 700;
}

.hero-pnl {
  text-align: right;
  flex-shrink: 0;
}
.hero-pnl-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.hero-pnl-value {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.hero-pnl-value.profit { color: var(--green-bright); }
.hero-pnl-value.loss { color: var(--red-bright); }

.hero-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.hero-stat {
  text-align: center;
}
.hs-value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hs-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 4px;
}
.win-num { color: var(--green-bright); }
.loss-num { color: var(--red-bright); }
.hs-sep {
  color: var(--text-faint);
  margin: 0 6px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.card-head h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text);
}
.card-sub {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}

.link-btn {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
}
.link-btn:hover {
  color: var(--text);
  background: var(--bg-3);
}

/* ============================================================
   RUN / STOP CARD
   ============================================================ */
.run-card {
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
}
.run-card[data-state='paused'] {
  border-color: rgba(245, 158, 11, 0.4);
}

.run-top {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
.run-info { min-width: 0; flex: 1; }
.run-state-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.run-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green-glow);
  animation: pulse-dot 1.8s ease-in-out infinite;
}
.run-card[data-state='paused'] .run-pulse {
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber-glow);
  animation: none;
}
.run-state {
  font-size: 18px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.04em;
}
.run-card[data-state='paused'] .run-state {
  color: var(--amber);
}
.run-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.run-toggle {
  flex-shrink: 0;
  width: 96px;
  height: 44px;
  position: relative;
  padding: 0;
  background: transparent;
}
.run-slider {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  transition: background 0.2s, border-color 0.2s;
  overflow: hidden;
}
.run-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--green-bright) 0%, var(--green-deep) 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), 0 0 14px var(--green-glow);
  transition: transform 0.25s cubic-bezier(0.5, 0, 0.5, 1.4), background 0.2s;
}
.run-on,
.run-off {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: none;
  transition: opacity 0.2s;
}
.run-on {
  left: 12px;
  color: var(--green);
  opacity: 0;
}
.run-off {
  right: 12px;
  color: var(--amber);
  opacity: 1;
}
.run-card[data-state='running'] .run-slider {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
}
.run-card[data-state='running'] .run-on { opacity: 0; }
.run-card[data-state='running'] .run-off { opacity: 1; }
.run-card[data-state='running'] .run-knob { transform: translateX(0); }
.run-card[data-state='paused'] .run-slider {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
}
.run-card[data-state='paused'] .run-knob {
  transform: translateX(52px);
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), 0 0 14px var(--amber-glow);
}
.run-card[data-state='paused'] .run-on { opacity: 1; color: var(--amber); }
.run-card[data-state='paused'] .run-off { opacity: 0; }

/* ============================================================
   MARTINGALE
   ============================================================ */
.mg-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  margin-bottom: 14px;
}
.mg-stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
}
.mg-stat-stake { background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), var(--bg-2)); border-color: rgba(34, 197, 94, 0.2); }
.mg-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.mg-stat-stake .mg-value { color: var(--green-bright); }
.mg-label {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 6px;
}

.mg-progress { display: grid; gap: 6px; }
.mg-progress-track {
  height: 6px;
  background: var(--bg-3);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.mg-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--amber));
  transition: width 0.4s ease, background 0.3s;
  border-radius: var(--r-pill);
}
.mg-progress-fill.danger {
  background: linear-gradient(90deg, var(--amber), var(--red));
}
.mg-progress-label {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.05em;
}

/* ============================================================
   PAYOUT FILTER
   ============================================================ */
.payout-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}
.payout-stat {
  background: linear-gradient(135deg, rgba(34,197,94,0.08), var(--bg-2));
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: var(--r-md);
  padding: 14px 18px;
  text-align: center;
  min-width: 92px;
}
.payout-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--green-bright);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.payout-label {
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 4px;
}
.payout-slider-wrap {
  display: grid;
  gap: 6px;
}

input[type='range'].payout-slider,
#payout-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: linear-gradient(to right,
    var(--red) 0%,
    var(--amber) 50%,
    var(--green) 100%);
  border-radius: var(--r-pill);
  outline: none;
  cursor: pointer;
  margin: 8px 0;
}
#payout-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: linear-gradient(180deg, #fff 0%, #e5e7eb 100%);
  border-radius: 50%;
  border: 2px solid var(--green);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6), 0 0 12px var(--green-glow);
  cursor: grab;
  transition: transform 0.1s;
}
#payout-slider::-webkit-slider-thumb:active { transform: scale(1.1); cursor: grabbing; }
#payout-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--green);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6), 0 0 12px var(--green-glow);
  cursor: grab;
}
.payout-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-mute);
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 0 2px;
}
.payout-hint {
  font-size: 12px;
  color: var(--text-mute);
  line-height: 1.5;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   FORM
   ============================================================ */
.form-row { margin-bottom: 14px; }
.form-row-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 12px;
}
.form-row-2col > * { min-width: 0; }
@media (max-width: 460px) {
  .form-row-2col { grid-template-columns: 1fr; gap: 14px; }
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}
.field-hint {
  display: block;
  font-size: 10px;
  color: var(--text-mute);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.select-wrap { position: relative; }
.select {
  width: 100%;
  padding: 13px 36px 13px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--r-md);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.select:focus { border-color: var(--green); }
.select-caret {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--text-mute);
  pointer-events: none;
  font-size: 10px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--green); }
.input-prefix {
  padding-left: 14px;
  color: var(--text-mute);
  font-weight: 700;
}
.input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  padding: 13px 14px 13px 6px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.input-wrap input::placeholder { color: var(--text-mute); font-weight: 500; }

.seg-control {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  min-width: 0;
  width: 100%;
}
.seg-control-sm { padding: 3px; }
.seg-btn {
  padding: 9px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-mute);
  border-radius: 8px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  text-align: center;
  min-width: 0;
  white-space: nowrap;
}
.seg-control-sm .seg-btn { padding: 6px 4px; font-size: 11px; }
.seg-btn:hover { color: var(--text); }
.seg-btn:active { transform: scale(0.97); }
.seg-btn.active {
  background: var(--bg-elev);
  color: var(--green-bright);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.25);
}

/* ============================================================
   TRADE BUTTONS
   ============================================================ */
.trade-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}
.trade-btn {
  padding: 18px 12px;
  border-radius: var(--r-md);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.08s ease, filter 0.15s, box-shadow 0.15s;
  color: white;
}
.trade-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 50%);
  pointer-events: none;
}
.trade-btn.buy {
  background: linear-gradient(180deg, var(--green-bright) 0%, var(--green-deep) 100%);
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.4), inset 0 -2px 0 rgba(0,0,0,0.18);
}
.trade-btn.sell {
  background: linear-gradient(180deg, var(--red-bright) 0%, var(--red-deep) 100%);
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.4), inset 0 -2px 0 rgba(0,0,0,0.18);
}
.trade-btn:hover:not(:disabled) { filter: brightness(1.08); }
.trade-btn:active:not(:disabled) { transform: translateY(2px); filter: brightness(0.95); }
.trade-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.trade-arrow { font-size: 18px; }

/* ============================================================
   TRADE HISTORY
   ============================================================ */
.history-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.hs-cell { text-align: center; }
.hs-cell-val {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.hs-cell-val.profit { color: var(--green-bright); }
.hs-cell-val.loss { color: var(--red-bright); }
.hs-cell-lbl {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 3px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}
.history-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  align-items: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.history-row:hover { border-color: var(--border-strong); background: var(--bg-3); }
.history-row.win { border-left: 3px solid var(--green); }
.history-row.loss { border-left: 3px solid var(--red); }
.history-row.tie { border-left: 3px solid var(--amber); }
.history-row.skip { border-left: 3px solid var(--text-faint); opacity: 0.7; }
.history-row.unknown { border-left: 3px solid var(--amber); }

.outcome-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.outcome-tag.win { background: rgba(34,197,94,0.15); color: var(--green-bright); }
.outcome-tag.loss { background: rgba(239,68,68,0.15); color: var(--red-bright); }
.outcome-tag.tie { background: rgba(245,158,11,0.15); color: var(--amber); }
.outcome-tag.skip { background: rgba(116,116,138,0.15); color: var(--text-dim); }
.outcome-tag.unknown { background: rgba(245,158,11,0.15); color: var(--amber); }

.history-mid { min-width: 0; }
.history-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.history-asset { color: var(--text); }
.history-dir-up { color: var(--green-bright); }
.history-dir-down { color: var(--red-bright); }
.history-line2 {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.history-right {
  text-align: right;
  flex-shrink: 0;
}
.history-profit {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.history-profit.profit { color: var(--green-bright); }
.history-profit.loss { color: var(--red-bright); }
.history-profit.zero { color: var(--text-mute); }
.history-time {
  font-size: 10px;
  color: var(--text-mute);
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  padding: 32px 12px 28px;
  color: var(--text-mute);
  font-size: 13px;
  font-style: italic;
  position: relative;
}
/* Empty states get a sizable robotic-face brand mark above the message —
   turns dead negative space into a real brand moment. */
.empty-state::before {
  content: '';
  display: block;
  width: 104px;
  height: 104px;
  margin: 0 auto 16px;
  background-image: url('/logo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow:
    0 0 30px rgba(45, 208, 95, 0.32),
    0 0 30px rgba(237, 56, 56, 0.26),
    0 10px 22px rgba(0, 0, 0, 0.60);
  opacity: 0.94;
  animation: empty-brand-breathe 4s ease-in-out infinite;
}
@keyframes empty-brand-breathe {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50%      { opacity: 1.0; transform: scale(1.03); }
}

/* ============================================================
   ACTIVITY LOG (live session)
   ============================================================ */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.activity-item {
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border-left: 3px solid var(--text-faint);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.activity-item.win { border-left-color: var(--green); }
.activity-item.loss { border-left-color: var(--red); }
.activity-item.tie { border-left-color: var(--amber); }
.activity-item.skip { border-left-color: var(--text-faint); opacity: 0.75; }
.activity-item.pending {
  border-left-color: var(--green);
  animation: pulse-pending 1.6s ease-in-out infinite;
}
@keyframes pulse-pending {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.activity-detail {
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.activity-time {
  color: var(--text-mute);
  font-size: 10px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   ADMIN CARD
   ============================================================ */
.admin-grid {
  display: grid;
  gap: 8px;
}
.admin-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}
.admin-btn:hover { border-color: var(--border-strong); background: var(--bg-3); }
.admin-btn-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.admin-btn-sub {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
}
.admin-btn-ghost { background: transparent; }
.admin-btn-ghost:hover { background: var(--bg-2); }

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 4px;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow:
    0 0 14px rgba(45, 208, 95, 0.28),
    0 0 14px rgba(237, 56, 56, 0.22);
  flex-shrink: 0;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 16px;
  animation: fade-in 0.18s ease;
}
.modal[hidden] { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: pop-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.modal-head-warn {
  color: var(--amber);
}
.modal-warn-icon {
  font-size: 28px;
  color: var(--amber);
}
.modal-head h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.logo-modal { font-size: 24px; }

.modal-body {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
}
.modal-body p + p { margin-top: 8px; }
.modal-note {
  font-size: 12px !important;
  color: var(--text-mute) !important;
  font-style: italic;
}

.modal-card input[type='text'] {
  padding: 13px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.15s;
}
.modal-card input[type='text']:focus { border-color: var(--green); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-primary,
.btn-danger,
.btn-ghost {
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: filter 0.15s, transform 0.08s;
}
.btn-primary {
  background: linear-gradient(180deg, var(--green-bright) 0%, var(--green-deep) 100%);
  color: var(--bg-0);
  box-shadow: 0 6px 18px rgba(34,197,94,0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-danger {
  background: linear-gradient(180deg, var(--red-bright) 0%, var(--red-deep) 100%);
  color: white;
  box-shadow: 0 6px 18px rgba(239,68,68,0.35);
}
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-2); }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-stack {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 360px;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toast-in 0.25s ease, toast-out 0.25s ease 3s forwards;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.warn { border-left: 3px solid var(--amber); }
.toast.info { border-left: 3px solid var(--text-mute); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(20px); }
}

/* ============================================================
   LIVE CONFIG CONTROLS (Martingale, Safety)
   ============================================================ */
.config-section {
  margin-top: 18px;
  padding-top: 4px;
}
.config-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--text-mute);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.config-divider::before, .config-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.config-row { margin-bottom: 16px; }
.config-row:last-child { margin-bottom: 0; }

.config-label-wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.config-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.config-label.safety-loss { color: var(--red-bright); }
.config-label.safety-win  { color: var(--green-bright); }
.config-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.config-hint {
  display: block;
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 6px;
  line-height: 1.5;
}

/* Range slider styling — used for max-steps + future tunables. */
#mg-max-steps {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: linear-gradient(to right, var(--green) 0%, var(--amber) 60%, var(--red) 100%);
  border-radius: var(--r-pill);
  outline: none;
  cursor: pointer;
  margin: 6px 0;
}
#mg-max-steps::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: linear-gradient(180deg, #fff 0%, #e5e7eb 100%);
  border-radius: 50%;
  border: 2px solid var(--green);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6), 0 0 12px var(--green-glow);
  cursor: grab;
  transition: transform 0.1s;
}
#mg-max-steps::-webkit-slider-thumb:active { transform: scale(1.12); cursor: grabbing; }
#mg-max-steps::-moz-range-thumb {
  width: 24px; height: 24px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--green);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6), 0 0 12px var(--green-glow);
  cursor: grab;
}
.config-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-mute);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0 2px;
}

/* Inline input + quick presets row (used for Multiplier). */
.config-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 10px;
  align-items: center;
}
.config-input-row input[type='number'] {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.15s;
}
.config-input-row input[type='number']:focus { border-color: var(--green); }

.quick-preset {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  min-width: 0;
}
.quick-preset button {
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-mute);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  min-width: 0;
  white-space: nowrap;
}
.quick-preset button:hover { color: var(--text); }
.quick-preset button.active {
  background: var(--bg-elev);
  color: var(--green-bright);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.3);
}

.config-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 460px) {
  .config-grid-2 { grid-template-columns: 1fr; gap: 16px; }
  .config-input-row { grid-template-columns: 1fr; }
}

/* Rate limit row spans full width of Safety Limits card (sits below the 2-col grid). */
.config-row-fullwidth {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
#rate-limit {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: linear-gradient(to right, var(--green) 0%, var(--amber) 60%, var(--red) 100%);
  border-radius: var(--r-pill);
  outline: none;
  cursor: pointer;
  margin: 6px 0;
}
#rate-limit::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  background: linear-gradient(180deg, #fff 0%, #e5e7eb 100%);
  border-radius: 50%;
  border: 2px solid var(--green);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6), 0 0 12px var(--green-glow);
  cursor: grab;
}
#rate-limit::-webkit-slider-thumb:active { transform: scale(1.12); cursor: grabbing; }
#rate-limit::-moz-range-thumb {
  width: 24px; height: 24px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--green);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6), 0 0 12px var(--green-glow);
  cursor: grab;
}
#rate-limit-usage {
  display: block;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
}

/* ============================================================
   SIGNAL UPLOAD CARD
   ============================================================ */
.upload-format-hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-bottom: 12px;
  line-height: 1.5;
}
.upload-format-hint code {
  background: var(--bg-3);
  color: var(--green-bright);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 11px;
}

.signal-paste {
  width: 100%;
  min-height: 140px;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.signal-paste:focus { border-color: var(--green); }
.signal-paste::placeholder {
  color: var(--text-faint);
  font-style: italic;
}

.upload-feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 6px;
}
.upload-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.upload-stat strong {
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.upload-stat-valid {
  background: rgba(45, 208, 95, 0.12);
  color: var(--green-bright);
  border: 1px solid rgba(45, 208, 95, 0.30);
}
.upload-stat-invalid {
  background: rgba(237, 56, 56, 0.12);
  color: var(--red-bright);
  border: 1px solid rgba(237, 56, 56, 0.30);
}
.upload-stat-total {
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.upload-errors {
  max-height: 140px;
  overflow-y: auto;
  margin: 8px 0 12px;
  padding: 10px 12px;
  background: rgba(237, 56, 56, 0.06);
  border: 1px solid rgba(237, 56, 56, 0.20);
  border-radius: var(--r-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--red-bright);
}
.upload-error-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 2px 0;
}
.upload-error-line {
  color: var(--amber);
  font-weight: 700;
  flex-shrink: 0;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.upload-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.upload-file-btn:hover { color: var(--text); border-color: var(--text-mute); background: var(--bg-elev); }
.upload-actions .btn-ghost { padding: 11px 16px; }
.upload-actions .btn-primary { margin-left: auto; padding: 12px 22px; }
.upload-actions .btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

/* ============================================================
   SIGNAL QUEUE CARD
   ============================================================ */
.queue-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.qs-cell { text-align: center; }
.qs-cell-val {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.qs-cell-lbl {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 3px;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
}

.queue-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  align-items: center;
  transition: border-color 0.15s, background 0.15s;
}
.queue-row.pending { border-left: 3px solid var(--amber); }
.queue-row.executing {
  border-left: 3px solid var(--green);
  background: linear-gradient(135deg, rgba(45, 208, 95, 0.10), var(--bg-2));
  animation: queue-executing-pulse 1.4s ease-in-out infinite;
}
@keyframes queue-executing-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 208, 95, 0); }
  50% { box-shadow: 0 0 20px rgba(45, 208, 95, 0.20); }
}
.queue-row.completed { border-left: 3px solid var(--green); }
.queue-row.completed.loss-row { border-left-color: var(--red); }
.queue-row.completed.tie-row { border-left-color: var(--amber); }
.queue-row.skipped { border-left: 3px solid var(--text-faint); opacity: 0.7; }
.queue-row.cancelled { border-left: 3px solid var(--text-faint); opacity: 0.55; }
.queue-row.unknown { border-left: 3px solid var(--amber); }

.queue-status {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.10em;
  flex-shrink: 0;
}
.queue-status.pending { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.queue-status.executing {
  background: rgba(45, 208, 95, 0.18);
  color: var(--green-bright);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.queue-status.completed.win-row { background: rgba(45, 208, 95, 0.15); color: var(--green-bright); }
.queue-status.completed.loss-row { background: rgba(237, 56, 56, 0.15); color: var(--red-bright); }
.queue-status.completed.tie-row { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.queue-status.skipped, .queue-status.cancelled, .queue-status.unknown {
  background: rgba(116, 116, 138, 0.15);
  color: var(--text-dim);
}

.queue-mid { min-width: 0; }
.queue-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  flex-wrap: wrap;
}
.queue-asset { color: var(--text); }
.queue-dir-up { color: var(--green-bright); }
.queue-dir-down { color: var(--red-bright); }
.queue-tf {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.queue-line2 {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.queue-countdown {
  font-weight: 700;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.queue-row.executing .queue-countdown { color: var(--green-bright); }

.queue-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.queue-profit {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.queue-profit.profit { color: var(--green-bright); }
.queue-profit.loss { color: var(--red-bright); }
.queue-profit.zero { color: var(--text-mute); }
.queue-cancel-btn {
  font-size: 11px;
  font-weight: 700;
  color: var(--red-bright);
  background: rgba(237, 56, 56, 0.10);
  border: 1px solid rgba(237, 56, 56, 0.30);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  transition: background 0.15s;
  letter-spacing: 0.04em;
}
.queue-cancel-btn:hover { background: rgba(237, 56, 56, 0.20); }

.queue-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}
.btn-small { padding: 9px 14px; font-size: 11px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 640px) {
  .appbar { padding: 18px 28px; }
  .brand-logo { width: 108px; height: 108px; border-radius: 26px; }
  .brand-name { font-size: 36px; }
  .brand-tag { font-size: 13px; }
  .app-content { padding: 20px 24px; gap: 16px; }
  .hero { padding: 26px; }
  .hero-balance { font-size: 44px; }
  .hero-pnl-value { font-size: 22px; }
  .card { padding: 22px; }
  .brand-logo-hero { width: 260px; height: 260px; border-radius: 52px; }
  .brand-logo-hero-wrap::before { inset: -40px; border-radius: 76px; }
  .empty-state::before { width: 124px; height: 124px; border-radius: 30px; }
  .footer-logo { width: 44px; height: 44px; border-radius: 11px; }
  .card-head-brand { width: 36px; height: 36px; border-radius: 9px; }
}

@media (max-width: 380px) {
  .brand-logo { width: 68px; height: 68px; border-radius: 17px; }
  .brand-name { font-size: 22px; }
  .brand-tag { font-size: 10px; }
  .brand-logo-hero { width: 170px; height: 170px; border-radius: 34px; }
  .brand-logo-hero-wrap::before { inset: -22px; border-radius: 50px; }
  .modal-hero-title { font-size: 26px; }
  .empty-state::before { width: 88px; height: 88px; border-radius: 22px; }
  .card-head-brand { width: 28px; height: 28px; border-radius: 7px; }
  .hero-balance { font-size: 30px; }
  .hero-pnl-value { font-size: 18px; }
  .run-toggle { width: 84px; height: 40px; }
  .run-knob { width: 32px; height: 32px; }
  .run-card[data-state='paused'] .run-knob { transform: translateX(44px); }
  .trade-btn { font-size: 15px; padding: 16px 10px; }
  .seg-btn { font-size: 11px; padding: 8px 4px; }
}

/* Scrollbar polish */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-elev); }
