/* ==========================================================================
   DT Nexus Cloud — signed-in app + auth. Mobile-first; desktop ≥ 1024px gets
   a left rail instead of the bottom tab bar.
   ========================================================================== */

.ic { width: 20px; height: 20px; flex: none; }
.ic-inline { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; }
.rot90 { transform: rotate(90deg); }
.mark { width: 28px; height: auto; color: var(--text); flex: none; }

.muted { color: var(--text-3); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 32px 0; }
.pos { color: var(--win); }
.neg { color: var(--loss); }
.warn-t { color: var(--warn); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-sm { font-size: 13.5px; font-weight: 600; color: var(--text-2); text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
.link-sm .ic { width: 16px; height: 16px; }
.link-sm:hover { color: var(--brand); }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; text-decoration: underline; cursor: pointer; }
.static { margin: 0; padding: 11px 0; color: var(--text-2); font-size: 14px; }
@media (max-width: 599px) { .hide-sm { display: none !important; } }
@media (max-width: 419px) { .hide-xs { display: none !important; } }

.h1 { font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.01em; }
.h2 { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -0.005em; }
.h3 { font-size: 16px; font-weight: 600; }
.h4 { font-size: 14.5px; font-weight: 600; }
@media (min-width: 1024px) { .h1 { font-size: 28px; } .h2 { font-size: 22px; } }

.tag {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.22em;
  color: var(--text-3); border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px 2px 6px; line-height: 1;
}

/* ---------- boot + skip ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; }
.boot .mark { width: 44px; animation: bootPulse 1.2s ease-in-out infinite; }
@keyframes bootPulse { 50% { opacity: 0.45; transform: scale(0.94); } }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--brand); color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }

/* ==========================================================================
   Shell
   ========================================================================== */
.rail { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-brand, .rail-brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.top-brand .wordmark { font-size: 17px; }
.top-brand .mark { width: 24px; }
.top-right { display: flex; align-items: center; gap: 10px; }

/* Other DT Nexus products (BRS app): rail list on desktop, top-bar menu on phones. */
.rail-label { margin: 0 0 6px; padding: 0 12px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.rail-products a, .apps-menu a { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--text-2); }
.rail-products a:hover, .apps-menu a:hover { background: var(--surface-2); color: var(--text); }
.rail-products a > span, .apps-menu a > span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rail-products b, .apps-menu b { font-size: 13.5px; font-weight: 500; }
.rail-products small, .apps-menu small { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-products .prod-go, .apps-menu .prod-go { width: 14px; height: 14px; color: var(--text-3); }
.top-apps { position: relative; }
.top-apps summary { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--text-2); cursor: pointer; list-style: none; }
.top-apps summary::-webkit-details-marker { display: none; }
.top-apps summary .ic { width: 21px; height: 21px; }
.top-apps[open] summary { color: var(--brand); background: var(--brand-tint); }
/* The extra icon leaves no room for "New" as a word on a phone. */
.top-apps ~ .top-new span { display: none; }
.top-apps ~ .top-new { padding-inline: 10px; }
/* Fixed resolves against the top bar (its backdrop-filter makes it the containing block). */
.apps-menu { position: fixed; top: calc(56px + env(safe-area-inset-top) + 6px); right: 16px; width: min(280px, calc(100vw - 32px)); padding: 12px 6px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); z-index: 30; }
.win-name { display: block; margin-bottom: 6px; }
.top-new { --bh: 36px; padding: 0 12px 0 9px; }
.top-new .ic { width: 18px; height: 18px; }
/* Narrow phones: brand + bell + New don't fit in 360px (the New button was
   pushed 17px off-screen) — drop the CLOUD tag, then the New label. */
@media (max-width: 379px) { .top-brand .tag { display: none; } }
@media (max-width: 339px) { .top-new span { display: none; } .top-new { padding: 0 9px; } }

.main { display: block; min-height: 100vh; min-height: 100dvh; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); outline: none; }
#view { max-width: 1160px; margin: 0 auto; }

/* Phones: the tab bar must stay put while a long list (trades, alerts) is
   flung to its end. iOS Safari lets position:fixed ride along with the page
   during rubber-band overscroll, and a fixed element with backdrop-filter
   can lag behind the scroll until it settles — so no root overscroll, and
   the bars get their own compositing layer. */
html, body { overscroll-behavior-y: none; }
.tabbar, .ed-bar { transform: translateZ(0); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0 4px; border-radius: 12px; text-decoration: none;
  font-size: 11px; font-weight: 500; color: var(--text-3); -webkit-tap-highlight-color: transparent;
}
.tabbar a .ic { width: 23px; height: 23px; }
.tabbar a.active { color: var(--brand); }
.tabbar a.active span { color: var(--text); font-weight: 600; }
.nav-dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--win-strong); box-shadow: 0 0 0 2px var(--surface); }
.nav-dot[hidden] { display: none; }
body.editor-open .tabbar { display: none; }
body.editor-open .main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

.stopall-bar {
  position: sticky; top: calc(57px + env(safe-area-inset-top)); z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 13.5px; color: var(--text-2);
}
.stopall-bar[hidden] { display: none; }
.stopall-bar span { display: inline-flex; align-items: center; gap: 8px; }
.stopall-bar .pill-dot { background: var(--win-strong); animation: pulse 2s infinite; }
.stopall-bar .btn { --bh: 34px; }
body.editor-open .stopall-bar { display: none; }

@media (min-width: 1024px) {
  .topbar { display: none; }
  .tabbar { display: none; }
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 25; width: 248px;
    display: flex; flex-direction: column; gap: 18px; padding: 22px 16px 18px;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .rail-brand { padding: 2px 8px 6px; }
  .rail-brand .wordmark { font-size: 18px; }
  .rail-nav { display: flex; flex-direction: column; gap: 2px; }
  .rail-nav a {
    display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 10px;
    text-decoration: none; color: var(--text-2); font-weight: 500; font-size: 14.5px;
  }
  .rail-nav a:hover { background: var(--surface-2); color: var(--text); }
  .rail-nav a.active { background: var(--brand-tint); color: var(--text); font-weight: 600; }
  .rail-nav a.active .ic { color: var(--brand); }
  .nav-count { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--text-3); font-family: var(--font-mono); }
  .nav-count.is-live { color: var(--win); }
  .rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
  .rail-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); min-width: 0; }
  .main { margin-left: 248px; padding: 0 40px 64px; }
  .stopall-bar { top: 0; margin-left: 248px; padding: 10px 40px; }
  .bot-grid > [data-status] { position: sticky; top: 72px; }
  body.editor-open .main { padding-bottom: 120px; }
}

.avatar {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--night); color: #fff; font-weight: 600; font-size: 13px;
}
.avatar.lg { width: 52px; height: 52px; font-size: 20px; font-family: var(--font-display); }

/* connection indicator */
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.conn[data-state="live"] i { background: var(--win-strong); }
.conn[data-state="connecting"] i, .conn[data-state="offline"] i { background: var(--real-fill); animation: blink 1.2s infinite; }
.conn-compact { width: 28px; height: 28px; justify-content: center; }
.conn-dark { color: var(--night-muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ==========================================================================
   Page scaffolding
   ========================================================================== */
.page { padding: 20px 0 8px; }
.page-narrow { max-width: 620px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .eyebrow { margin-bottom: 6px; }
.page-sub { margin-top: 6px; color: var(--text-3); font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 1024px) { .page { padding-top: 32px; } .page-head { margin-bottom: 24px; } }

.back { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 10px -6px; padding: 6px 8px 6px 4px; border-radius: 8px; color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none; }
.back .ic { width: 18px; height: 18px; }
.back:hover { background: var(--surface-2); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px; box-shadow: var(--shadow);
}
@media (min-width: 600px) { .card { padding: 20px; } }
.card + .card { margin-top: 14px; }
.section + .section, .section + .card { margin-top: 18px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sec-head .eyebrow { margin-bottom: 4px; }
.sec-foot { margin-top: 10px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- segmented control (buttons with aria-pressed, or radios) ---------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px;
  background: var(--surface-3); border: 1px solid var(--line); max-width: 100%;
}
.seg > button, .seg-opt > span {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent;
  font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.seg > button[aria-pressed="true"], .seg-opt input:checked + span {
  background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--line);
}
:root[data-theme="dark"] .seg > button[aria-pressed="true"], :root[data-theme="dark"] .seg-opt input:checked + span { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-strong); }
.seg-opt { position: relative; display: flex; flex: 1 1 auto; min-width: 0; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt input:focus-visible + span { box-shadow: var(--focus); }
.seg-opt > span { width: 100%; padding: 0 10px; }
.seg-opt .ic { width: 16px; height: 16px; }
.seg-full { display: flex; width: 100%; }
.seg-full .seg-opt > span { white-space: normal; text-align: center; line-height: 1.2; padding: 6px 8px; }
.seg-sm > button { min-height: 30px; padding: 0 10px; font-size: 12.5px; }

/* ---------- pills / chips / tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; flex: none;
  background: var(--surface-3); color: var(--text-2);
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; display: inline-block; }
.pill-go { background: var(--win-tint); color: var(--win); }
.pill-go .pill-dot { background: var(--win-strong); animation: pulse 2s infinite; }
.pill-go-soft { background: var(--info-tint); color: var(--info); }
.pill-warn { background: var(--warn-tint); color: var(--warn); }
.pill-bad { background: var(--loss-tint); color: var(--loss); }
.pill-idle { background: var(--surface-3); color: var(--text-3); }
.pill-lg { height: 32px; padding: 0 13px; font-size: 14px; }

.acct { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; flex: none; }
.acct b { font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.08em; font-size: 10.5px; }
.acct span { font-family: var(--font-mono); font-size: 11.5px; }
.acct-demo { border: 1px solid var(--line-strong); color: var(--text-2); }
.acct-real { background: var(--real-fill); color: var(--real-ink); }
.acct-missing { border: 1px dashed var(--loss); color: var(--loss); font-weight: 600; }

.kind { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px; font-family: var(--font-mono); font-weight: 600; font-size: 10.5px; letter-spacing: 0.1em; background: var(--surface-3); color: var(--text-2); flex: none; }
.kind-brs { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.kind-hedging { background: var(--info-tint); color: var(--info); }

.pnl { font-weight: 700; white-space: nowrap; }
.pnl.pos { color: var(--win); }
.pnl.neg { color: var(--loss); }
.pnl.flat { color: var(--text-2); }
.pnl-md { font-size: 18px; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.pnl-xl { font-size: 32px; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }

/* ---------- buttons extra ---------- */
.btn-real { background: var(--real-fill); color: var(--real-ink); }
.btn-real:hover { background: #e08e06; }
.btn-light { background: #fff; color: #0e0e0e; }
.btn-light:hover { background: #eceef0; }
.btn .ic { width: 18px; height: 18px; }
.btn.danger, .btn-icon.danger { color: var(--loss); }

/* ---------- night (brand) surfaces ---------- */
.night { position: relative; overflow: hidden; background: var(--night); color: var(--night-text); isolation: isolate; }
.night-grid {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(228, 31, 40, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(228, 31, 40, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.2) 75%, transparent);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.2) 75%, transparent);
}
.night-glow {
  position: absolute; z-index: -1; width: 340px; height: 340px; top: -150px; left: -120px; pointer-events: none;
  background: radial-gradient(circle, rgba(228, 31, 40, 0.42), transparent 65%); filter: blur(8px);
}
.night .eyebrow { color: var(--night-muted); }
.skel.on-night { background: rgba(255, 255, 255, 0.08); }

/* ==========================================================================
   Home
   ========================================================================== */
.hero-card { border-radius: var(--r-xl); padding: 18px 18px 18px; box-shadow: var(--shadow-lg); }
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.hero-main { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.hero-state { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.hero-live { display: inline-flex; align-items: center; gap: 10px; }
.hero-live .pill-dot { width: 10px; height: 10px; background: #2bd97c; animation: pulse 2s infinite; }
.hero-idle { color: var(--night-muted); }
.hero-figs { display: flex; gap: 28px; flex-wrap: wrap; }
.hero-fig { display: flex; flex-direction: column; gap: 2px; }
.hero-k { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--night-muted); }
.hero-v { font-family: var(--font-display); font-size: 40px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }
.hero-v.sm { font-size: 26px; }
.hero-v.pos { color: #2bd97c; } .hero-v.neg { color: #ff5a60; } .hero-v.flat { color: #fff; }
.hero-s { font-size: 12.5px; color: var(--night-muted); }
.hero-actions { margin-top: 18px; display: flex; gap: 10px; }
.hero-actions .btn { flex: 1; }
@media (min-width: 600px) {
  .hero-card { padding: 24px 26px; }
  .hero-main { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .hero-actions .btn { flex: 0 0 auto; min-width: 200px; }
  .hero-v { font-size: 48px; }
}
@media (min-width: 1024px) {
  .hero-card { display: grid; column-gap: 40px; grid-template-columns: 1fr auto; grid-template-areas: "top top" "main actions"; align-items: end; }
  .hero-top { grid-area: top; } .hero-main { grid-area: main; } .hero-actions { grid-area: actions; margin: 0; }
}

.acct-strip { display: flex; gap: 10px; overflow-x: auto; margin: 14px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; scroll-snap-type: x mandatory; }
.acct-strip::-webkit-scrollbar { display: none; }
.acct-tile {
  flex: 0 0 auto; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; row-gap: 2px;
  align-items: center; min-width: 168px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; scroll-snap-align: start;
}
.acct-tile .acct { grid-row: 1; }
.acct-tile .acct-id { grid-row: 1; font-size: 12px; color: var(--text-3); }
.acct-tile .acct-bal { grid-column: 1 / -1; font-weight: 700; font-size: 16px; }
.acct-tile .cur { font-size: 12px; color: var(--text-3); font-weight: 500; }
.acct-tile.is-real { border-color: color-mix(in srgb, var(--real-fill) 55%, var(--line)); }
@media (min-width: 1024px) { .acct-strip { margin: 16px 0 0; padding: 2px 0 4px; } }

.home-grid { display: grid; gap: 18px; margin-top: 20px; }
.home-col { min-width: 0; display: flex; flex-direction: column; }
@media (min-width: 1024px) { .home-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; align-items: start; } }

.onboard .h2 { margin: 6px 0 14px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.steps li > div { flex: 1; min-width: 0; }
.steps li b { font-size: 14.5px; }
.steps li p { font-size: 13px; color: var(--text-3); }
.step-n { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none; font-family: var(--font-mono); font-weight: 600; font-size: 13px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); }
.steps li.now .step-n { background: var(--brand); color: #fff; border-color: transparent; }
.steps li.done .step-n { background: var(--win-strong); color: #fff; border-color: transparent; }
.steps li.done .step-n .ic { width: 16px; height: 16px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.kpi { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi-k { font-size: 12px; color: var(--text-3); }
.kpi-v { font-size: 17px; font-weight: 700; }
.kpi-v.pos { color: var(--win); } .kpi-v.neg { color: var(--loss); }
@media (min-width: 600px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .ch-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .ch-zero { stroke: var(--line-strong); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart .ch-axis { font-family: var(--font-mono); font-size: 10px; fill: var(--text-3); }
.chart .ch-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart.up .ch-line { stroke: var(--win-strong); } .chart.down .ch-line { stroke: var(--loss); }
.chart .ch-stop-a { stop-opacity: 0.22; } .chart .ch-stop-b { stop-opacity: 0; }
.chart.up .ch-stop-a, .chart.up .ch-stop-b { stop-color: var(--win-strong); }
.chart.down .ch-stop-a, .chart.down .ch-stop-b { stop-color: var(--loss); }
.chart .ch-area { fill: url(#chFill); }
.chart .ch-bar { opacity: 0.35; } .chart .ch-bar.pos { fill: var(--win-strong); } .chart .ch-bar.neg { fill: var(--loss); }
.chart .ch-dot { stroke: var(--surface); stroke-width: 2; }
.chart.up .ch-dot { fill: var(--win-strong); } .chart.down .ch-dot { fill: var(--loss); }
.chart .ch-hair { stroke: var(--text-3); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 10px; white-space: nowrap;
  background: var(--night); color: #fff; font-size: 12px; box-shadow: var(--shadow-lg);
}
.chart-tip[hidden] { display: none; }
.chart-tip b { font-weight: 600; }
.chart-tip .pos { color: #2bd97c; } .chart-tip .neg { color: #ff5a60; }
.chart-empty { height: 160px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--text-3); font-size: 13.5px; border: 1px dashed var(--line-strong); border-radius: 12px; text-align: center; padding: 16px; }
.chart-skel { height: 200px; border-radius: 12px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed-i { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.feed-i:first-child { border-top: 0; }
.feed-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); transform: translateY(-1px); }
.tone-pos .feed-dot { background: var(--win-strong); } .tone-neg .feed-dot { background: var(--loss); } .tone-warn .feed-dot { background: var(--real-fill); }
.feed-main { min-width: 0; display: flex; flex-wrap: wrap; column-gap: 8px; }
.feed-bot { font-weight: 600; text-decoration: none; color: var(--text); }
.feed-text { color: var(--text-2); }
.tone-pos .feed-text { color: var(--win); } .tone-neg .feed-text { color: var(--loss); }
.feed-t { font-size: 11.5px; color: var(--text-3); font-family: var(--font-mono); }
.feed-empty { padding: 6px 0 2px; }

/* ==========================================================================
   Bot cards
   ========================================================================== */
.grid-bots { display: grid; gap: 12px; }
@media (min-width: 760px) { .grid-bots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid-bots { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.bot-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0;
  padding: 14px 14px 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.bot-card:hover { border-color: var(--line-strong); }
.bot-card.is-real { border-left: 4px solid var(--real-fill); padding-left: 12px; }
.bot-card.is-live { border-color: color-mix(in srgb, var(--win-strong) 35%, var(--line)); }
.bot-card.is-real.is-live { border-left-color: var(--real-fill); }
.bot-card-link { position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
.bot-card-link:focus-visible { box-shadow: var(--focus); }
.bot-card > *:not(.bot-card-link) { position: relative; z-index: 1; pointer-events: none; }
.bot-card .bc-actions, .bot-card .bc-actions * { pointer-events: auto; }
.bc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.bc-id { min-width: 0; flex: 1; }
.bc-name { font-weight: 600; font-size: 15.5px; display: flex; min-width: 0; }
.bc-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.bc-pnl { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.bc-pnl-k { font-size: 11px; color: var(--text-3); }
.bc-status { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bc-line { font-size: 13px; color: var(--text-2); }
.bc-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 8px 0 0; border-top: 1px solid var(--line); }
.bc-strip div { min-width: 0; }
.bc-strip dt { font-size: 11px; color: var(--text-3); }
.bc-strip dd { margin: 0; font-weight: 600; font-size: 13.5px; }
.bc-actions { display: flex; gap: 8px; }
.bc-actions .btn:first-child { flex: 1; }
.skel-card { gap: 10px; min-height: 140px; }

/* ==========================================================================
   Bot detail
   ========================================================================== */
.bot-head { margin-bottom: 16px; }
.bot-head .h1 { overflow-wrap: anywhere; } /* one unbreakable 80-char name was clipped mid-word by the 2-line clamp */
.bot-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 13.5px; }
.bot-grid { display: grid; gap: 16px; }
@media (min-width: 1024px) { .bot-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; gap: 24px; } }

.status-card {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 18px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.status-card.is-real { border: 2px solid var(--real-fill); }
.real-band {
  display: flex; align-items: center; gap: 8px; margin: -18px -18px 14px; padding: 8px 18px;
  background: var(--real-fill); color: var(--real-ink); font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
}
.real-band .ic { width: 16px; height: 16px; }
.sc-row { display: flex; flex-direction: column; gap: 14px; }
.sc-state { min-width: 0; }
.sc-line { margin-top: 10px; font-size: 14.5px; color: var(--text-2); min-height: 1.5em; }
.sc-pnl { display: flex; flex-direction: column; gap: 2px; }
.sc-k { font-size: 12px; color: var(--text-3); }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 16px 0 0; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.metric { background: var(--surface); padding: 10px 12px; }
.metric dt { font-size: 11.5px; color: var(--text-3); }
.metric dd { margin: 2px 0 0; font-weight: 700; font-size: 16px; }
.metric dd.pos { color: var(--win); } .metric dd.neg { color: var(--loss); }
@media (min-width: 480px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
.sc-actions { display: flex; gap: 10px; margin-top: 16px; }
.sc-actions .sc-main { flex: 1; }
.sc-note { margin-top: 10px; }
.status-card .notice { margin-top: 14px; }
.window { margin-top: 16px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.window-head { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); margin-bottom: 8px; }
.window-head b.pos { color: var(--win); } .window-head b.neg { color: var(--loss); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--win-strong); border-radius: inherit; transition: width 0.4s var(--ease); }
.window-foot { margin-top: 8px; }

.bot-tabs { padding-top: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 -16px 14px; padding: 0 12px; overflow-x: auto; }
.tabs button { position: relative; padding: 12px 10px; border: 0; background: none; font-weight: 600; font-size: 14px; color: var(--text-3); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px; }
@media (min-width: 600px) { .tabs { margin: 0 -20px 16px; padding: 0 16px; } }
.tab-body .h4 { margin: 4px 0 8px; color: var(--text-2); font-size: 12px; font-family: var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; }
.tab-body .feed + .h4, .tab-body .h4 + .trades { margin-top: 0; }
.tab-body .feed { margin-bottom: 14px; }
.bot-more { display: flex; justify-content: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.trades, .runs { list-style: none; margin: 0; padding: 0; }
.trade { display: grid; grid-template-columns: 4px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.trades .trade:first-child { border-top: 0; }
.trade-mark { width: 4px; align-self: stretch; border-radius: 4px; background: var(--line-strong); }
.trade.is-won .trade-mark { background: var(--win-strong); } .trade.is-lost .trade-mark { background: var(--loss); } .trade.is-open .trade-mark { background: var(--info); }
.trade-main { min-width: 0; }
.trade-what { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade-what .muted { font-weight: 500; }
.trade-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade-res .pnl { font-size: 14.5px; }
.run { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "main res" "mid mid"; gap: 2px 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.runs .run:first-child { border-top: 0; }
.run-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.run-mid { grid-area: mid; }
.run-res { grid-area: res; align-self: center; }
@media (min-width: 760px) { .run { grid-template-columns: 1fr 200px auto; grid-template-areas: "main mid res"; align-items: center; } }

.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: minmax(110px, 42%) 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

.risk-box { padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.risk-box .eyebrow { margin-bottom: 2px; }
.risk-head { font-weight: 600; color: var(--text); font-size: 14.5px; line-height: 1.4; }
.risk-warn { display: flex; gap: 8px; align-items: flex-start; color: var(--warn); font-weight: 500; }
.risk-warn .ic { width: 17px; height: 17px; margin-top: 2px; }
.tab-body .risk-box { margin-bottom: 14px; }

/* ---------- notices ---------- */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; margin-bottom: 14px; }
.notice .ic { width: 18px; height: 18px; margin-top: 1px; }
.notice-warn { background: var(--warn-tint); color: var(--warn); }
.notice-err { background: var(--loss-tint); color: var(--loss); }
.notice-info { background: var(--info-tint); color: var(--info); }
.notice-real { background: var(--real-tint); color: var(--real); border: 1px solid color-mix(in srgb, var(--real-fill) 45%, transparent); }
.notice-real.big { font-size: 14.5px; }

/* ---------- empty / error / skeleton ---------- */
.empty { text-align: center; padding: 40px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface); }
.empty-ic { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px; background: var(--brand-tint); color: var(--brand); }
.empty-ic .ic { width: 26px; height: 26px; }
.empty h3 { font-size: 17px; font-weight: 600; }
.empty p { margin: 8px auto 0; max-width: 380px; color: var(--text-3); font-size: 14px; }
.empty-act { margin-top: 18px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.empty-err .empty-ic { background: var(--loss-tint); color: var(--loss); }

.skel { position: relative; overflow: hidden; display: block; background: var(--surface-3); border-radius: 8px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); animation: shimmer 1.4s infinite; }
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); }
.skel-line { height: 14px; margin: 4px 0; }
.w40 { width: 40%; } .w60 { width: 60%; } .w80 { width: 80%; }
.skel-block { height: 140px; border-radius: 12px; }
.skel-block.tall { height: 320px; }
.skel-title { height: 30px; width: 50%; margin: 24px 0 16px; }
span.skel.skel-line { display: inline-block; min-width: 60px; vertical-align: middle; }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field, .field + .row-2, .row-2 + .field, .row-2 + .row-2 { margin-top: 14px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.field-hint a { color: var(--text-2); }
.field-warn { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--warn); font-weight: 500; }
.field-warn .ic { width: 15px; height: 15px; margin-top: 2px; }
.row-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.row-2:empty { display: none; }
.row-2 > .field + .field { margin-top: 0; }
@media (min-width: 520px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.row-inline { display: flex; gap: 8px; }
.row-inline > * { flex: 1; min-width: 0; }

.input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
  font-size: 16px; /* no iOS zoom */ font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--text-3); font-weight: 400; }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input.mono { font-family: var(--font-mono); }
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.4; }
input[type="number"].input { -moz-appearance: textfield; }
input[type="number"].input::-webkit-inner-spin-button, input[type="number"].input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 64px; }
.input-suffix { position: absolute; right: 14px; font-size: 13px; color: var(--text-3); pointer-events: none; }
.input-btn { position: absolute; right: 6px; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.input-btn:hover { background: var(--surface-2); }
.select-wrap { position: relative; display: flex; }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; text-overflow: ellipsis; }
.select-ic { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.select-wrap.sm .input { min-height: 38px; padding-left: 12px; }
.select:disabled { opacity: 0.5; cursor: not-allowed; }

.form-msg { padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin: 4px 0 14px; }
.form-msg[hidden] { display: none; }
.form-msg-error { background: var(--loss-tint); color: var(--loss); }
.form-msg-ok { background: var(--win-tint); color: var(--win); }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { position: relative; display: inline-flex; }
.check input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.check span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 13px; font-weight: 600; color: var(--text-2); }
.check input:checked + span { background: var(--text); color: var(--bg); border-color: var(--text); }
.check input:focus-visible + span { box-shadow: var(--focus); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

.stakes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill-input { position: relative; display: inline-flex; align-items: center; }
.pill-input .input { width: 92px; min-height: 40px; padding: 0 28px 0 12px; border-radius: 999px; }
.pill-x { position: absolute; right: 4px; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; }
.pill-x:hover { background: var(--surface-3); color: var(--loss); }
.pill-x .ic { width: 14px; height: 14px; }

.fgroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.fgroup + .fgroup, [data-fields] > .fgroup:first-child { margin-top: 14px; }
.fgroup-head { padding: 14px 16px 0; }
.fgroup-head .eyebrow { margin-bottom: 4px; }
.fgroup-body { padding: 14px 16px 18px; }
@media (min-width: 600px) { .fgroup-head { padding: 18px 20px 0; } .fgroup-body { padding: 16px 20px 20px; } }

.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--brand-tint); color: var(--text); font-size: 13.5px; line-height: 1.45; margin-bottom: 14px; }
.callout .ic { color: var(--brand); width: 18px; height: 18px; margin-top: 1px; }

.ai-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.ai-card {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--night); color: var(--night-text); border: 1px solid transparent; position: relative; overflow: hidden;
}
.ai-card .ic { color: var(--brand); width: 20px; height: 20px; margin-top: 1px; }
.ai-card b { display: block; font-size: 13.5px; }
.ai-card small { display: block; font-size: 12px; color: var(--night-muted); margin-top: 2px; }
.ai-card.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.ai-card:hover { background: var(--night-2); }

.rung-solo { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.ladder { list-style: none; margin: 14px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rung { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.rung-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; }
.rung-n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none; background: var(--night); color: #fff; font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; }
.rung-desc { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rung-tools { display: flex; flex: none; }
.rung-tools .btn-icon { --bh: 34px; width: 34px; }
.rung-tools .ic { width: 17px; height: 17px; }
.rung-body { border-top: 1px solid var(--line); }
.rung-body > summary { padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; list-style: none; }
.rung-body > summary::-webkit-details-marker { display: none; }
.rung-body[open] > summary { color: var(--text-3); }
.rung-body > .field, .rung-body > .row-2, .rung-body > .and-cond, .rung-body > .callout { margin-left: 12px; margin-right: 12px; }
.rung-body > :last-child { margin-bottom: 14px; }
.and-cond { margin-top: 14px; padding: 12px; border-left: 3px solid var(--brand); background: var(--surface); border-radius: 0 10px 10px 0; }
.and-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13.5px; }
.and-head .btn { margin-left: auto; --bh: 30px; padding: 0 6px; }
.and-tag { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; color: #fff; background: var(--brand); padding: 3px 6px; border-radius: 5px; }

.legs { list-style: none; margin: 16px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.leg { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 14px; background: var(--surface-2); }
.leg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.leg-n { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2); }
.leg-tools { display: flex; gap: 2px; }
.leg-tools .btn { --bh: 34px; }
.leg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.leg-grid > .field + .field { margin-top: 0; }
.leg-grid > .field:first-child { grid-column: 1 / -1; }
.leg-risk { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.leg-risk > summary { font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; margin-bottom: 10px; }

/* ==========================================================================
   Editor (new bot flow)
   ========================================================================== */
.ed-head { align-items: center; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; width: 100%; }
.stepper li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; color: var(--text-3); }
.stepper li::before { content: ""; height: 3px; border-radius: 3px; background: var(--line); }
.stepper li.done::before { background: var(--text-2); }
.stepper li.now::before { background: var(--brand); }
.stepper li.now { color: var(--text); font-weight: 600; }
.st-n { display: none; }
.st-l { white-space: nowrap; }
@media (min-width: 760px) {
  .stepper { width: auto; gap: 18px; }
  .stepper li { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
  .stepper li::before { display: none; }
  .st-n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); font-family: var(--font-mono); font-size: 11.5px; }
  .st-n .ic { width: 15px; height: 15px; }
  .stepper li.now .st-n { background: var(--brand); color: #fff; border-color: transparent; }
  .stepper li.done .st-n { background: var(--text); color: var(--bg); border-color: transparent; }
}
.ed-narrow { max-width: 680px; }
.ed-narrow > .h2 { margin-bottom: 6px; }
.ed-narrow > .muted { margin-bottom: 18px; font-size: 14.5px; }

.kind-list { display: flex; flex-direction: column; gap: 10px; }
.kind-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px; cursor: pointer;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.1s;
}
.kind-card:hover { border-color: var(--brand); }
.kind-card:active { transform: scale(0.995); }
.kind-card.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.kind-ic { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; flex: none; background: var(--night); color: #fff; }
.kind-ic .ic { width: 24px; height: 24px; }
.kind-card:nth-child(1) .kind-ic .ic { color: #fff; }
.kind-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.kind-text b { font-size: 16px; }
.kind-text > span { font-size: 13.5px; color: var(--text-3); line-height: 1.45; }
.kind-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.kind-tags i { font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.kind-go { width: 20px; height: 20px; color: var(--text-3); flex: none; }

.import-box { margin-top: 14px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.import-toggle { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; background: none; border: 0; cursor: pointer; text-align: left; }
.import-toggle > .ic:first-child { width: 22px; height: 22px; color: var(--brand); }
.import-toggle span { flex: 1; display: flex; flex-direction: column; }
.import-toggle small { color: var(--text-3); font-size: 13px; }
.import-box.open .kind-go { transform: rotate(180deg); }
.import-body { padding: 0 16px 16px; }
.import-body .btn { margin-top: 12px; }

.acct-pick { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.acct-opt {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px;
  border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.acct-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.acct-opt.on { border-color: var(--text); box-shadow: 0 0 0 1px var(--text) inset; }
.acct-opt.is-real.on { border-color: var(--real-fill); box-shadow: 0 0 0 1px var(--real-fill) inset; background: var(--real-tint); }
.acct-opt:has(input:focus-visible) { box-shadow: var(--focus); }
.ao-main { display: flex; flex-direction: column; min-width: 0; }
.ao-main small { color: var(--text-3); font-size: 12.5px; }
.ao-bal { font-weight: 700; font-size: 14.5px; text-align: right; }
.ao-bal .cur { font-size: 12px; color: var(--text-3); font-weight: 500; }
.more-link { margin-top: 6px; }
.more-link > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); padding: 8px 0; }
.inline-link { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.inline-link .btn { align-self: flex-start; }

.ed-split { display: grid; gap: 16px; }
.ed-form { min-width: 0; }
.ed-form > .notice { margin-bottom: 14px; }
.ed-aside-in { display: flex; flex-direction: column; gap: 12px; }
.aside-id { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 1024px) {
  .ed-split { grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
  .ed-aside { position: sticky; top: 24px; }
}
@media (max-width: 1023px) { .ed-aside { order: 2; } }

.ed-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.ed-bar-risk { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-3); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-bar-risk b { font-size: 13.5px; }
.ed-bar-actions { display: flex; gap: 8px; }
@media (min-width: 1024px) { .ed-bar { left: 248px; padding: 12px 40px; } }

.review-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.review-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.review-name { font-size: 18px; font-family: var(--font-display); font-weight: 600; }
.review-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.review-rows > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); padding: 4px 0 8px; }

/* ==========================================================================
   History / Accounts / Profile
   ========================================================================== */
.sum-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 4px 14px 6px; box-shadow: var(--shadow); }
.day + .day { margin-top: 12px; }
.day-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
.day-head h3 { font-size: 12px; font-family: var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); font-weight: 500; }
.day .trades .trade:first-child, .day .runs .run:first-child { border-top: 0; }

.grid-accts { display: grid; gap: 12px; margin-bottom: 18px; }
@media (min-width: 760px) { .grid-accts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid-accts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.acct-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.acct-card.is-real { border: 2px solid var(--real-fill); }
.ac-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ac-type { font-size: 12px; color: var(--text-3); }
.ac-id { font-size: 14px; color: var(--text-2); }
.ac-bal { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.ac-bal .cur { font-family: var(--font-body); font-size: 13px; color: var(--text-3); font-weight: 500; }
.ac-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.ac-real-note { font-size: 12.5px; color: var(--real); font-weight: 500; }
.link-card { display: grid; gap: 18px; }
.link-card .h3 { margin: 4px 0 10px; }
@media (min-width: 900px) { .link-card { grid-template-columns: 1fr 1fr; gap: 32px; } }
.howto { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text-2); }
.howto a { color: var(--text); font-weight: 600; }
.link-side { display: flex; flex-direction: column; gap: 16px; }
.link-connect { display: flex; flex-direction: column; gap: 10px; }
.link-connect .btn { align-self: flex-start; }
.link-or { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; }
.link-or::before, .link-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.link-form { display: flex; flex-direction: column; gap: 12px; }
.link-form .field + .field { margin-top: 0; }
.link-form .btn { align-self: flex-start; }

.profile-id { display: flex; align-items: center; gap: 14px; }
.profile-id div { display: flex; flex-direction: column; min-width: 0; }
.profile-id b { font-size: 16px; }
.links-list { padding: 4px 6px; }
.links-list a { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 10px; text-decoration: none; font-weight: 500; font-size: 14.5px; }
.links-list a span { flex: 1; }
.links-list a .ic:last-child { color: var(--text-3); width: 18px; height: 18px; }
.links-list a:hover { background: var(--surface-2); }
.links-list a + a { border-top: 1px solid var(--line); }
.page-narrow > [data-body] > .btn { margin-top: 18px; }
.page-narrow > [data-body] > p { margin-top: 10px; }

/* ==========================================================================
   Auth
   ========================================================================== */
.auth-main { min-height: 100vh; min-height: 100dvh; }
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth-brand { position: relative; overflow: hidden; isolation: isolate; background: var(--night); color: var(--night-text); padding: 20px 20px 26px; display: flex; flex-direction: column; gap: 18px; }
.auth-logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.auth-logo .mark { color: #fff; width: 28px; }
.auth-logo .wordmark { color: #fff; font-size: 19px; }
.auth-logo .tag { color: var(--night-muted); border-color: var(--night-line); }
.auth-pitch h1 { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1.2; margin-top: 8px; letter-spacing: -0.01em; }
.auth-points { list-style: none; margin: 16px 0 0; padding: 0; display: none; flex-direction: column; gap: 10px; color: #cfd3da; font-size: 14.5px; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; }
.auth-points .ic { color: #2bd97c; width: 18px; height: 18px; margin-top: 2px; }
.auth-foot { display: none; font-size: 10.5px; letter-spacing: 0.2em; color: var(--night-muted); }
.auth-panel { flex: 1; padding: 24px 20px 40px; display: flex; flex-direction: column; align-items: center; }
.auth-panel > * { width: 100%; max-width: 420px; }
.auth-form { display: flex; flex-direction: column; }
.auth-form .field + .field, .auth-form .row-2 + .field { margin-top: 14px; }
.auth-title { font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.auth-sub { color: var(--text-3); margin: 6px 0 20px; font-size: 14.5px; }
.auth-row { display: flex; justify-content: flex-end; margin: 10px 0 14px; }
.auth-form > .btn { margin-top: 6px; }
.auth-form > .form-msg { margin: 0 0 12px; }
.auth-form > .field-hint { margin-top: 8px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 14px; color: var(--text-3); }
.auth-switch a { color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.auth-switch .ic { width: 16px; height: 16px; }
.auth-form .row-2 { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) {
  .auth { flex-direction: row; }
  .auth-brand { width: 46%; max-width: 620px; padding: 40px 48px; justify-content: space-between; }
  .auth-pitch h1 { font-size: 34px; max-width: 460px; }
  .auth-points { display: flex; }
  .auth-foot { display: block; }
  .auth-panel { justify-content: center; padding: 48px; }
}

/* ==========================================================================
   Toasts + dialogs
   ========================================================================== */
.toasts { position: fixed; z-index: 90; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; align-items: center; }
@media (min-width: 760px) { .toasts { left: auto; right: 20px; top: 20px; width: 380px; align-items: stretch; } }
.toast {
  pointer-events: auto; width: 100%; max-width: 440px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 10px 12px 14px;
  border-radius: 14px; background: var(--night); color: #fff; box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0; transform: translateY(-8px); transition: opacity 0.2s, transform 0.2s var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast-ic { width: 20px; height: 20px; margin-top: 1px; }
.toast-ok .toast-ic { color: #2bd97c; } .toast-error .toast-ic { color: #ff5a60; } .toast-warn .toast-ic { color: #fbbf24; } .toast-info .toast-ic { color: #9fb4ff; }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.toast-body span { color: #b6bcc6; }
.toast-x { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border: 0; background: transparent; color: #8a919c; border-radius: 8px; cursor: pointer; }
.toast-x:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.toast-x .ic { width: 16px; height: 16px; }

body.modal-open { overflow: hidden; }
.dlg-scrim { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; padding: 12px; background: rgba(7, 10, 19, 0.55); opacity: 0; transition: opacity 0.18s; }
.dlg-scrim.in { opacity: 1; }
.dlg {
  width: 100%; max-width: 460px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: auto; padding: 22px 20px calc(16px + env(safe-area-inset-bottom));
  border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  transform: translateY(16px); transition: transform 0.22s var(--ease);
}
.dlg-scrim.in .dlg { transform: none; }
@media (min-width: 600px) { .dlg-scrim { align-items: center; } .dlg { padding-bottom: 18px; } }
.dlg-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.25; }
.dlg-body { margin-top: 10px; color: var(--text-2); font-size: 14.5px; line-height: 1.5; }
.dlg-body p + p { margin-top: 8px; }
.dlg-details { margin-top: 14px; padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; }
.dlg-risk { font-weight: 600; }
.dlg-warn { color: var(--warn); margin-top: 6px; }
.dlg-require { margin-top: 14px; }
.dlg-wide { max-width: 620px; }
.dlg-text { display: block; width: 100%; margin-top: 14px; min-height: 220px; font-size: 12.5px; white-space: pre; overflow: auto; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.dlg-actions .btn { flex: 1; }
@media (min-width: 600px) { .dlg-actions .btn { flex: 0 0 auto; } }
.dlg-real { border: 2px solid var(--real-fill); padding-top: 0; }
.dlg-flag { display: flex; align-items: center; gap: 8px; margin: 0 -20px 16px; padding: 9px 20px; background: var(--real-fill); color: var(--real-ink); font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; }
.dlg-flag .ic { width: 16px; height: 16px; }
.more-trades { margin-top: 12px; }
.auth-main #view { max-width: none; }
:root[data-theme="dark"] .auth-brand { border-right: 1px solid var(--line); }
body.editor-open .top-new { display: none; }
.show-xs { display: none; margin-top: 10px; }
@media (max-width: 419px) { .show-xs { display: flex; } }
.fgroup-body > p.small { margin-top: 8px; } .fgroup-body > p.small + .field { margin-top: 18px; }
.more-btn { margin-top: 14px; }
@media (max-width: 599px) {
  .toolbar .filters { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar .filters .select-wrap { min-width: 0; }
}
/* History's date range: each day picker carries its label inside. */
.date-wrap { position: relative; display: flex; min-width: 0; }
.date-wrap .input { min-height: 38px; padding-left: 52px; padding-right: 10px; min-width: 0; }
.date-k { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 12.5px; font-weight: 600; color: var(--text-3); pointer-events: none; }
.date-clear { align-self: center; gap: 4px; padding: 0 4px; border: 0; background: none; cursor: pointer; font-family: inherit; }
@media (max-width: 599px) {
  .toolbar .filters .select-wrap:only-of-type, .toolbar .filters .date-clear { grid-column: 1 / -1; }
  .toolbar .filters .date-clear { justify-self: start; }
  /* Half a phone's width: keep the whole date readable beside its label. */
  .date-wrap .input { padding-left: 42px; padding-right: 4px; }
  .date-wrap .input::-webkit-calendar-picker-indicator { margin: 0; padding: 0; width: 14px; }
  .date-k { left: 9px; font-size: 11.5px; }
}
.bot-grid > * { min-width: 0; } .sc-line, .notice span { overflow-wrap: anywhere; }
.sc-actions .sc-main { min-width: 0; white-space: normal; line-height: 1.2; text-align: center; } .sc-actions > a.btn { flex: none; padding: 0 16px; }
.metrics { background: var(--surface); gap: 0; }
.metric { box-shadow: 0 0 0 0.5px var(--line); }

/* Deriv links still holding a retired API token (relink needed). */
.acct-card.needs-relink { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.acct-card .notice .btn { margin-left: 6px; vertical-align: middle; }
.acct-opt.is-disabled { opacity: .7; cursor: not-allowed; }
.acct-opt.is-disabled input { cursor: not-allowed; }
.acct-opt.is-disabled a { pointer-events: auto; position: relative; z-index: 1; }

/* ==========================================================================
   Alerts — top-bar bell, inbox, Profile → Alerts switches
   ========================================================================== */
.top-bell { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--text-2); text-decoration: none; }
.top-bell .ic { width: 21px; height: 21px; }
.top-bell.active { color: var(--brand); background: var(--brand-tint); }
.bell-n { position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.bell-n[hidden] { display: none; }
@media (min-width: 1024px) { .nav-count.is-alert { color: #fff; background: var(--brand); border-radius: 999px; padding: 1px 7px; } }

.notes { list-style: none; margin: 0; padding: 4px 16px; }
.note { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.note:first-child { border-top: 0; }
.note-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); color: var(--text-3); }
.note-ic .ic { width: 17px; height: 17px; }
.note-error .note-ic { background: var(--loss-tint); color: var(--loss); }
.note-warning .note-ic { background: var(--warn-tint); color: var(--warn); }
.note-success .note-ic { background: var(--win-tint); color: var(--win); }
.note-main { min-width: 0; }
.note-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.note-head b { font-size: 14.5px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.note-head time { flex: none; font-size: 11.5px; color: var(--text-3); font-family: var(--font-mono); }
.note p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); overflow-wrap: anywhere; }
.note-link { display: inline-flex; align-items: center; gap: 2px; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--brand-ink); text-decoration: none; }
.note-link .ic { width: 15px; height: 15px; }
.note.is-unread .note-head b::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--brand); vertical-align: 2px; }

.alerts-lede { margin: 0 0 6px; line-height: 1.5; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
div.switch-row { cursor: default; }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.switch-row + .btn { margin-top: 10px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 26px; margin: 0; border-radius: 999px; background: var(--line-strong); cursor: pointer; transition: background .2s var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { box-shadow: var(--focus); }
.switch:disabled { opacity: .5; cursor: default; }
.note.is-focus { margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 12px; background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); animation: noteFocus 2.4s var(--ease) 1; }
@keyframes noteFocus { 0%, 40% { background: color-mix(in srgb, var(--brand) 18%, transparent); } }
