/* app.css — a dark, dense trading terminal.
 * No preprocessor, no framework: CSS custom properties plus grid layouts. */

:root {
  --bg: #070a11;
  --bg-1: #0b0f17;
  --bg-2: #0e131d;
  --bg-3: #131a26;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.26);
  --text: #cbd5e1;
  --text-dim: #64748b;
  --text-bright: #f1f5f9;
  --up: #089981;
  --down: #f23645;
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --warn: #f59e0b;
  --radius: 6px;
  --topbar-h: 44px;
  --status-h: 24px;
  --rail-w: 248px;
  --rail-r: 288px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button, .chip, .layout-btn, .tf, .icon-btn, .dtool, .mobile-tab {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.dim { color: var(--text-dim); }
.tiny { font-size: 11px; }
.is-up { color: var(--up); }
.is-down { color: var(--down); }

/* ================================================================== shell */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--rail-r);
  grid-template-rows: var(--topbar-h) 1fr var(--status-h);
  grid-template-areas:
    "top top top"
    "left stage right"
    "status status status";
  height: 100%;
}

/* ================================================================ topbar */

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding-right: 8px;
  border-right: 1px solid var(--line);
  height: 100%;
  align-items: center;
}

.logo { color: var(--accent); font-size: 15px; }
.brand-name { font-weight: 700; letter-spacing: 0.2px; color: var(--text-bright); }
.brand-sub { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }

.topbar__search { flex: 1; max-width: 380px; }

.topbar__search input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
.topbar__search input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18); }

.topbar__layouts { display: flex; gap: 3px; }

.layout-btn {
  width: 32px;
  height: 26px;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.layout-btn:hover { border-color: var(--line-strong); background: var(--bg-3); }
.layout-btn.is-active { border-color: var(--accent); background: rgba(59, 130, 246, 0.15); }

.layout-glyph {
  display: block;
  width: 15px;
  height: 12px;
  background-image: linear-gradient(var(--text-dim), var(--text-dim));
  background-repeat: no-repeat;
}
.layout-btn.is-active .layout-glyph { background-image: linear-gradient(var(--accent), var(--accent)); }

/* Each glyph is a hand-tuned set of background rectangles. */
.layout-glyph--1 { background: var(--text-dim); }
.layout-glyph--2h { background: linear-gradient(90deg, var(--text-dim) 0 46%, transparent 46% 54%, var(--text-dim) 54% 100%); }
.layout-glyph--2v { background: linear-gradient(180deg, var(--text-dim) 0 46%, transparent 46% 54%, var(--text-dim) 54% 100%); }
.layout-glyph--3 {
  background:
    linear-gradient(90deg, var(--text-dim) 0 46%, transparent 46% 54%, var(--text-dim) 54% 100%),
    linear-gradient(180deg, transparent 0 46%, var(--bg-1) 46% 54%, transparent 54% 100%);
}
.layout-glyph--4 {
  background:
    linear-gradient(90deg, var(--text-dim) 0 46%, transparent 46% 54%, var(--text-dim) 54% 100%),
    linear-gradient(180deg, var(--text-dim) 0 46%, transparent 46% 54%, var(--text-dim) 54% 100%);
  background-blend-mode: multiply;
}
.layout-btn.is-active .layout-glyph--1,
.layout-btn.is-active .layout-glyph--2h,
.layout-btn.is-active .layout-glyph--2v,
.layout-btn.is-active .layout-glyph--3,
.layout-btn.is-active .layout-glyph--4 { background-color: transparent; }

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text);
  text-decoration: none;
}
.chip:hover { border-color: var(--line-strong); }
.chip.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.14);
}

/* Studies drawer: the right rail collapses to zero width so the charts get the
   space; the inspector keeps its own width and slides out (grid track
   interpolation is supported in Chrome 107+, worst case it snaps). */
@media (min-width: 1001px) {
  .app { transition: grid-template-columns 0.18s ease; }
  .app.inspector-collapsed { grid-template-columns: var(--rail-w) 1fr 0px; }
  .app.inspector-collapsed .rail--right { border-left-color: transparent; overflow: hidden; }
  .app.inspector-collapsed .rail--right .inspector { min-width: var(--rail-r); }
  .app.inspector-collapsed #inspector-chip { color: var(--text-dim); border-color: var(--line); }

  .app.watchlist-collapsed { grid-template-columns: 0px 1fr var(--rail-r); }
  .app.watchlist-collapsed .rail--left { border-right-color: transparent; overflow: hidden; }
  .app.watchlist-collapsed .rail--left > * { min-width: var(--rail-w); }
  .app.watchlist-collapsed #watchlist-chip { color: var(--text-dim); border-color: var(--line); }
  .app.watchlist-collapsed.inspector-collapsed { grid-template-columns: 0px 1fr 0px; }
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.5);
}
.dot[data-state="live"] { background: var(--up); animation: pulse 2.4s infinite; }
.dot[data-state="connecting"] { background: var(--warn); }
.dot[data-state="down"] { background: var(--down); }
.dot[data-state="idle"] { background: var(--text-dim); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(8, 153, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(8, 153, 129, 0); }
}

/* ================================================================== rails */

.rail {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  overflow: hidden;
}
.rail--left { grid-area: left; border-right: 1px solid var(--line); }
.rail--right { grid-area: right; border-left: 1px solid var(--line); overflow-y: auto; }

.rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.rail__head h2 {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
}
.rail__head-actions,
.insp__head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.rail__close {
  display: none;
}
.rail__foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
.rail__foot a { color: var(--accent); text-decoration: none; font-size: 11px; }
.rail__foot a:hover { text-decoration: underline; }

/* ============================================================== watchlist */

.watchlist { overflow-y: auto; flex: 1; }

/* Watchlist Category Tabs */
.wl__tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-1, #0f172a);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}
.wl__tabs::-webkit-scrollbar {
  height: 4px;
}
.wl__tabs::-webkit-scrollbar-track {
  background: transparent;
}
.wl__tabs::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}
.wl__tabs::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}
.wl__tab {
  flex: 0 0 auto;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: var(--text-dim, #94a3b8);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}
.wl__tab:hover {
  background: rgba(51, 65, 85, 0.9);
  color: var(--text-bright, #f8fafc);
}
.wl__tab.is-active {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.wl__tab-count {
  opacity: 0.8;
  font-size: 9.5px;
  margin-left: 1px;
}
.wl__bucket-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.wl__bucket--new {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}
.wl__bucket--active {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}
.wl__bucket--macro {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
}
.wl__bucket--smc {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}
.wl__bucket--golden {
  background: rgba(234, 179, 8, 0.2);
  border: 1px solid rgba(234, 179, 8, 0.55);
  color: #fde047;
}
.wl__bucket--pdl {
  background: rgba(6, 182, 212, 0.18);
  border: 1px solid rgba(6, 182, 212, 0.5);
  color: #38bdf8;
}
.wl__row--smc-fib {
  border-left: 2px solid #fbbf24;
}
.wl__bucket--supertrend {
  background: rgba(14, 165, 233, 0.2);
  border: 1px solid rgba(14, 165, 233, 0.55);
  color: #38bdf8;
  font-weight: 600;
}
.wl__row--supertrend {
  border-left: 2px solid #0ea5e9;
}
.wl__bucket--prime {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.55);
  color: #34d399;
  font-weight: 600;
}
.wl__row--prime80 {
  border-left: 2px solid #10b981;
}
.wl__bucket--daily {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.55);
  color: #fbbf24;
  font-weight: 600;
}
.wl__bucket--green {
  background: rgba(0, 230, 118, 0.14);
  border: 1px solid rgba(0, 230, 118, 0.45);
  color: #4ade80;
  font-weight: 600;
}
.wl__bucket--red {
  background: rgba(255, 82, 82, 0.14);
  border: 1px solid rgba(255, 82, 82, 0.45);
  color: #f87171;
  font-weight: 600;
}
.wl__row--daily {
  border-left: 2px solid #f59e0b;
}

.wl { list-style: none; margin: 0; padding: 0; }

.wl__row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 9px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  transition: background 0.15s ease;
}
.wl__row.is-hidden { display: none !important; }
.wl__row:hover { background: var(--bg-2); }

.wl__row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}

.wl__sym {
  display: flex;
  align-items: baseline;
  gap: 5px;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.wl__ticker {
  font-weight: 700;
  color: var(--text-bright);
  font-size: 12px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.wl__base {
  font-size: 9.5px;
  white-space: nowrap;
  color: var(--text-dim);
  text-transform: uppercase;
}

.wl__values {
  display: flex;
  align-items: center;
  gap: 6px;
  shrink: 0;
}
.wl__price {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  transition: color 0.2s;
  white-space: nowrap;
  text-align: right;
}
.wl__chg {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  min-width: 44px;
  text-align: right;
  white-space: nowrap;
}
.wl__del {
  background: none;
  border: 0;
  color: var(--text-dim);
  opacity: 0;
  font-size: 10px;
  padding: 2px 3px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s, color 0.15s;
}
.wl__row:hover .wl__del { opacity: 0.8; }
.wl__del:hover { opacity: 1; color: var(--down); }

.wl__badges {
  display: flex;
  align-items: center;
  gap: 4.5px;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 1px;
}
.wl__tier {
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.15;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.wl__tier--daily {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}
.wl__tier--dual {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.wl__tier--sniper {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.wl__tier--apex {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.4);
}
.wl__tier--pf {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.55);
}
.wl__surge-badge {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.15;
  white-space: nowrap;
  color: #ff5722;
  background: rgba(255, 87, 34, 0.16);
  border: 1px solid rgba(255, 87, 34, 0.45);
  letter-spacing: 0.02em;
}
.wl__tag {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  padding: 1px 3.5px;
  border-radius: 3px;
  line-height: 1.15;
  white-space: nowrap;
}
.wl__tag.is-up {
  color: var(--up);
  background: rgba(34, 197, 94, 0.12);
}
.wl__tag.is-down {
  color: var(--down);
  background: rgba(239, 68, 68, 0.12);
}
.wl__entry-badge {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.12);
  padding: 1px 3.5px;
  border-radius: 3px;
  line-height: 1.15;
  white-space: nowrap;
}
.wl__score {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text-dim);
  line-height: 1.15;
  white-space: nowrap;
}
.wl__near-tag {
  display: none;
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(34, 197, 94, 0.22);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.55);
  animation: pulse-entry-tag 1.6s infinite ease-in-out;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.wl__row.is-near-entry .wl__near-tag {
  display: inline-block;
}
.wl__row.is-near-entry {
  background: rgba(34, 197, 94, 0.08);
  box-shadow: inset 2.5px 0 0 #22c55e;
}
@keyframes pulse-entry-tag {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}
#alerts-toggle-btn {
  font-size: 13px;
  transition: transform 0.15s, opacity 0.15s;
}
#alerts-toggle-btn:hover {
  transform: scale(1.15);
}

/* ================================================================== stage */

.stage { grid-area: stage; overflow: hidden; background: var(--bg); }

.workspace {
  display: grid;
  gap: 1px;
  background: var(--line);
  height: 100%;
  width: 100%;
}

.grid--cols-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid--cols-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.grid--rows-2 { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.grid--triple { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.grid--triple .panel:first-child { grid-row: span 2; }
.grid--quad { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.mobile-tabs { display: none; }

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  min-width: 0;
  min-height: 0;
  position: relative;
  border: 1px solid transparent;
}
.panel.is-active { border-color: rgba(59, 130, 246, 0.4); }

.panel.is-maximized {
  position: fixed;
  inset: var(--topbar-h) 0 var(--status-h) 0;
  z-index: 60;
}

.panel__body {
  flex: 1;
  display: grid;
  grid-template-columns: 30px 1fr;
  min-height: 0;
}

.panel.drawbar-collapsed .panel__body {
  grid-template-columns: 0px 1fr;
}
.panel.drawbar-collapsed .dtools {
  display: none;
}
.panel.drawbar-open .phead__actions [data-act="drawbar"] {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.18);
}

.panel__plot {
  position: relative;
  min-height: 0;
  min-width: 0;
  display: flex;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.panel__chart {
  flex: 1;
  min-width: 0;
  min-height: 0;
  touch-action: none;
}

/* --------------------------------------------------------------- header -- */

.phead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  min-height: 30px;
  overflow: hidden;
}

.phead__id { display: flex; align-items: center; gap: 6px; }
.phead__slot {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--text-dim);
  font-size: 9px;
  font-family: var(--mono);
}
.phead__symbol {
  background: none;
  border: 0;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-bright);
  letter-spacing: 0.2px;
}
.phead__symbol:hover { background: var(--bg-3); }
.phead__exch { font-size: 9px; color: var(--text-dim); }

.phead__tfs { display: flex; gap: 1px; }
.tf {
  background: none;
  border: 0;
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.tf:hover { background: var(--bg-3); color: var(--text); }
.tf.is-active { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }

.phead__ohlc {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.phead__spacer { flex: 1; }

.phead__badges { display: flex; gap: 3px; overflow: hidden; }
.badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-dim);
  white-space: nowrap;
}

.phead__actions { display: flex; gap: 2px; }

.icon-btn {
  background: none;
  border: 0;
  border-radius: 3px;
  padding: 2px 5px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.3;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text-bright); }

/* ------------------------------------------------------------ draw tools -- */

.dtools {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 2px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.dtools::-webkit-scrollbar { display: none; }

.dtool {
  background: none;
  border: 0;
  border-radius: 3px;
  width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 12px;
  flex: 0 0 auto;
}
.dtool:hover { background: var(--bg-3); color: var(--text-bright); }
.dtool.is-active { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.dtools__sep { height: 1px; background: var(--line); margin: 3px 2px; flex: 0 0 auto; }

/* --------------------------------------------------------------- legend -- */

.panel__legend {
  position: absolute;
  top: 4px;
  left: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
  font-size: 10.5px;
  font-family: var(--mono);
  z-index: 3;
  max-width: calc(100% - 70px);
}
.lg { white-space: nowrap; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }
.lg--sym { font-weight: 700; color: var(--text-bright); }
.lg--iv { color: var(--text-dim); }
.lg--bias { padding: 0 4px; border-radius: 3px; background: rgba(11, 15, 23, 0.6); }

.panel__smc {
  position: absolute;
  top: 4px;
  right: 74px;
  z-index: 3;
  pointer-events: none;
}

.smcdash {
  border-collapse: collapse;
  font-size: 9.5px;
  background: rgba(11, 15, 23, 0.78);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.smcdash td { padding: 2px 6px; }
.smcdash__k { color: var(--text-dim); }
.smcdash__v { font-family: var(--mono); color: var(--text); text-align: right; }

.panel__state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(7, 10, 17, 0.72);
  z-index: 5;
  font-size: 12px;
  color: var(--text-dim);
}

/* The display rule above overrides the UA's [hidden] { display: none }, so the
   busy overlay would never disappear once shown without this. */
.panel__state[hidden] { display: none; }

/* Non-blocking "catching up…" pill shown while a wake-triggered tail repair
   backfills candles the feed missed while the tab was idle. Deliberately not
   the full-chart dim overlay: the chart stays readable and interactive. */
.panel__resume {
  position: absolute;
  top: 8px;
  right: 66px;
  z-index: 6;
  padding: 3px 10px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 999px;
  background: rgba(9, 12, 18, 0.85);
  color: #93c5fd;
  font-size: 11px;
  font-family: var(--mono);
  pointer-events: none;
}
.panel__resume[hidden] { display: none; }

.skeleton { padding: 14px; color: var(--text-dim); font-size: 12px; }

/* ============================================================= inspector */

.insp { padding: 0 0 18px; }
.insp__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg-1);
  z-index: 2;
}
.insp__slot { color: var(--text-dim); font-size: 10px; font-family: var(--mono); }
.insp__sym { font-weight: 700; color: var(--text-bright); }
.insp__tf { color: var(--accent); font-size: 11px; font-family: var(--mono); }
.insp__head .icon-btn { margin-left: auto; }

.insp__section { padding: 10px; border-bottom: 1px solid var(--line); }
.insp__section h3 {
  margin: 0 0 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
}

.insp__group { border-bottom: 1px solid var(--line); }
.insp__group > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.insp__group > summary::-webkit-details-marker { display: none; }
.insp__group > summary::before {
  content: "▸";
  color: var(--text-dim);
  font-size: 9px;
  transition: transform 0.15s;
}
.insp__group[open] > summary::before { transform: rotate(90deg); }
.insp__group > summary:hover { background: var(--bg-2); }
.insp__count { margin-left: auto; font-size: 10px; }

.insp__items { padding: 0 6px 8px; }

.insp__item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.insp__item:hover { background: var(--bg-2); }
.insp__item input { accent-color: var(--accent); margin: 0; }

.insp__swatch {
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--swatch);
  flex: 0 0 auto;
}
.insp__text { display: flex; flex-direction: column; min-width: 0; }
.insp__label { font-size: 11.5px; color: var(--text); }
.insp__params { font-size: 9.5px; color: var(--text-dim); font-family: var(--mono); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 11px; }
.kv label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kv input[type="number"] {
  width: 64px;
  padding: 3px 5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
}
.kv--readonly span { color: var(--text-dim); }
.kv--readonly b { font-family: var(--mono); font-weight: 500; text-align: right; }

.btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 10px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 5px;
  font-size: 11px;
  color: #93c5fd;
  text-decoration: none;
}
.btn:hover { background: rgba(59, 130, 246, 0.26); }
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
  margin-left: 4px;
}
.btn--ghost:hover { border-color: var(--line-strong); color: var(--text); }

/* -------------------------------------------------------------- drawings */

.dlist { list-style: none; margin: 0 0 8px; padding: 0; }
.dlist__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.07);
  font-size: 11px;
}
.dlist__tool {
  font-family: var(--mono);
  color: var(--text);
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 3px;
}
.dlist__meta { margin-left: auto; font-size: 10px; }

/* ============================================================= status bar */

.statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 10px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-dim);
}
.statusbar__spacer { margin-left: auto; }
.statusbar__item { white-space: nowrap; }
.statusbar__item--btn {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 7px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  line-height: 1.4;
  transition: border-color 0.15s, color 0.15s;
}
.statusbar__item--btn:hover {
  border-color: var(--line-strong);
  color: var(--text-bright);
}

/* ================================================================ palette */

.palette { position: fixed; inset: 0; z-index: 100; display: grid; place-items: start center; padding-top: 70px; }
.palette[hidden] { display: none; }
.palette__scrim { position: absolute; inset: 0; background: rgba(3, 6, 12, 0.6); backdrop-filter: blur(2px); }
.palette__panel {
  position: relative;
  width: min(760px, 92vw);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.palette__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
}
.palette__body { overflow-y: auto; }

/* --------------------------------------------------------------- picker */

.picker__search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.picker__search input {
  flex: 1;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
}
.picker__search input:focus { border-color: var(--accent); }
kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text-dim);
}
.picker__hint { padding: 6px 12px; font-size: 10.5px; color: var(--text-dim); }
.picker__empty { padding: 18px 12px; color: var(--text-dim); font-size: 12px; }

.symlist { list-style: none; margin: 0; padding: 0; }
.symlist__btn {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  text-align: left;
}
.symlist__btn:hover { background: var(--bg-3); }
.symlist__sym { font-weight: 600; color: var(--text-bright); font-size: 12px; }
.symlist__base { font-size: 10.5px; }
.symlist__vol { font-family: var(--mono); font-size: 10.5px; }

/* ---------------------------------------------------------------- status */

.status__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1px;
  background: var(--line);
}
.stat { background: var(--bg-1); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.stat__k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.stat__v { font-size: 12px; font-family: var(--mono); display: flex; align-items: center; gap: 6px; }

.status__section { padding: 12px; border-top: 1px solid var(--line); }
.status__section h3 {
  margin: 0 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
}

.tbl { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--mono); }
.tbl th {
  text-align: left;
  padding: 4px 8px;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  text-transform: uppercase;
}
.tbl td { padding: 4px 8px; border-bottom: 1px solid rgba(148, 163, 184, 0.06); }
.tbl td:first-child { font-family: var(--sans); }

/* ================================================================= toast */

.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-width: 70vw;
}
.toast--error { border-color: rgba(242, 54, 69, 0.6); color: #fca5a5; }
.toast--ok { border-color: rgba(8, 153, 129, 0.6); color: #6ee7b7; }

/* ============================================================ scrollbars */

* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.25) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.4); background-clip: content-box; }

/* ============================================================ responsive */

@media (max-width: 1280px) {
  :root { --rail-w: 200px; --rail-r: 260px; }
}

@media (max-width: 1000px) {
  .app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  .topbar {
    flex: 0 0 var(--topbar-h);
    width: 100%;
  }

  .stage {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
  }

  .statusbar {
    flex: 0 0 var(--status-h);
    width: 100%;
  }

  .rail__close {
    display: inline-flex;
    font-size: 13px;
    padding: 3px 6px;
  }

  .rail {
    position: fixed;
    top: var(--topbar-h);
    bottom: var(--status-h);
    z-index: 70;
    width: min(320px, 86vw);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
    visibility: hidden;
    pointer-events: none;
  }

  .rail--left {
    left: 0;
    transform: translateX(-105%);
  }

  .rail--right {
    right: 0;
    transform: translateX(105%);
  }

  .app.mobile-watchlist-open .rail--left {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .app.mobile-inspector-open .rail--right {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .drawer-scrim {
    position: fixed;
    inset: var(--topbar-h) 0 var(--status-h) 0;
    background: rgba(4, 7, 13, 0.6);
    backdrop-filter: blur(2px);
    z-index: 65;
  }
  .drawer-scrim[hidden] {
    display: none;
  }

  .wl__del {
    opacity: 0.75;
    padding: 3px 6px;
    font-size: 11px;
  }
}

@media (max-width: 768px) {
  :root {
    --topbar-h: 46px;
    --status-h: 26px;
  }

  /* Safe area support for iOS and Android displays */
  .topbar {
    padding-top: env(safe-area-inset-top, 0);
    padding-left: max(6px, env(safe-area-inset-left, 0));
    padding-right: max(6px, env(safe-area-inset-right, 0));
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .topbar::-webkit-scrollbar {
    display: none;
  }

  .brand-sub {
    display: none;
  }

  .topbar__search {
    flex: 0 1 125px;
    min-width: 80px;
  }
  .topbar__search input {
    padding: 4px 8px;
    font-size: 11px;
  }

  .layout-btn {
    width: 26px;
    height: 24px;
    flex-shrink: 0;
  }

  #user-chip,
  #logout-chip {
    display: none;
  }

  .chip {
    padding: 3px 7px;
    font-size: 10.5px;
    flex-shrink: 0;
  }

  /* Workspace & Panels on mobile: Single Chart UX with tabs */
  .workspace {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    min-width: 0;
    width: 100%;
    overflow: hidden;
  }

  .mobile-tabs {
    display: flex;
    gap: 4px;
    padding: 4px 6px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .mobile-tabs::-webkit-scrollbar {
    display: none;
  }

  .mobile-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    cursor: pointer;
  }
  .mobile-tab.is-active {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent);
    color: var(--text-bright);
    font-weight: 600;
  }
  .mobile-tab__id {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--accent);
  }
  .mobile-tab__sym {
    font-weight: 600;
  }
  .mobile-tab__tf {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
  }

  /* Single panel layout always displays its panel */
  .workspace.grid--cols-1 .panel {
    display: flex !important;
  }

  /* Multi-panel layouts: hide inactive panels, display active panel */
  .workspace .panel {
    display: none;
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    height: 100%;
    width: 100%;
  }

  .workspace .panel.is-active {
    display: flex !important;
  }

  /* Robust fallback: if no panel has is-active yet, always show the first panel */
  .workspace:not(:has(.panel.is-active)) .panel:first-child {
    display: flex !important;
  }

  .panel__body {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    display: flex;
    position: relative;
    width: 100%;
    height: 100%;
  }

  .panel__plot {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    display: flex;
    position: relative;
    width: 100%;
    height: 100%;
  }

  .panel__chart {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    position: relative;
  }

  /* Drawing tools overlay drawer on mobile */
  .dtools {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    background: var(--bg-2);
    border-right: 1px solid var(--line-strong);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.55);
    width: 38px;
    padding: 4px 2px;
  }

  .panel.drawbar-open .dtools {
    display: flex;
  }

  .dtool {
    width: 32px;
    height: 30px;
    font-size: 14px;
  }

  /* Panel Header */
  .phead {
    padding: 3px 6px;
    gap: 5px;
    min-height: 32px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .phead::-webkit-scrollbar {
    display: none;
  }

  .phead__ohlc,
  .phead__badges {
    display: none;
  }

  .phead__tfs {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
  }
  .phead__tfs::-webkit-scrollbar {
    display: none;
  }
  .phead__tfs .tf {
    min-width: 25px;
    padding: 2px 5px;
    font-size: 10.5px;
  }

  /* Legend & overlays on mobile */
  .panel__legend {
    font-size: 9.5px;
    max-width: calc(100% - 40px);
  }

  /* Status Bar */
  .statusbar {
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: max(6px, env(safe-area-inset-left, 0));
    padding-right: max(6px, env(safe-area-inset-right, 0));
    gap: 8px;
    font-size: 10px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .statusbar::-webkit-scrollbar {
    display: none;
  }

  #stat-ohlc,
  #stat-keys,
  #stat-draw,
  #stat-bars {
    display: none;
  }

  /* Modals */
  .palette {
    padding: 12px 8px;
    place-items: center;
  }
  .palette__panel {
    width: 100%;
    max-height: 88vh;
  }
  .symlist__btn {
    grid-template-columns: 85px 1fr auto;
    padding: 8px 10px;
    gap: 6px;
  }
}

/* ========================================================== trade modal */

.trade-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none; /* Allow interaction with chart behind the modal */
}
.trade-modal[hidden] { display: none; }
.trade-modal__scrim {
  display: none; /* Removed blocking modal scrim so chart remains fully visible and interactive */
}
.trade-modal__dialog {
  position: absolute;
  width: min(440px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: rgba(14, 19, 29, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow-y: auto;
  color: var(--text);
  pointer-events: auto; /* Re-enable pointer events for the modal dialog itself */
  user-select: text;
  transition: opacity 0.15s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.trade-modal__dialog.is-peeking {
  opacity: 0.18 !important;
  pointer-events: none !important;
}
.trade-modal__dialog.is-minimized .trade-form {
  display: none;
}
.trade-modal__dialog.is-minimized {
  width: auto;
  min-width: 280px;
}
.trade-modal__mobile-handle {
  display: none;
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  margin: 6px auto 2px;
}
.trade-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(19, 23, 34, 0.96);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.trade-modal__head:active {
  cursor: grabbing;
}
.trade-modal__title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.trade-modal__title-group strong {
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--text-bright);
}
.trade-modal__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.trade-form {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tm-row--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tm-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tm-field label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tm-field input, .tm-field select {
  padding: 7px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
}
.tm-field input:focus, .tm-field select:focus {
  outline: none;
  border-color: var(--accent);
}
.tm-balance-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 2px;
}
.tm-balance-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tm-balance-item strong {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-bright);
}
.tm-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.tm-presets .chip {
  cursor: pointer;
  padding: 2px 7px;
  font-size: 10px;
}
.tm-presets .chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* Side Toggle: Long vs Short manual override */
.tm-side-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.28);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.tm-side-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tm-side-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-bright);
}
.tm-side-btn.is-long.is-active {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.6);
  color: #22c55e;
}
.tm-side-btn.is-short.is-active {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.6);
  color: #ef4444;
}
.btn-trade {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--up);
  color: #031409;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-trade.is-short {
  background: var(--down);
  color: #1a0202;
}
.btn-trade:hover {
  opacity: 0.92;
}
.btn-trade:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .trade-modal {
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: stretch !important;
    pointer-events: none !important;
  }
  .trade-modal[hidden] {
    display: none !important;
  }
  .trade-modal__dialog {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 60vh !important;
    margin: 0 !important;
    transform: translateY(0);
    border-radius: 16px 16px 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-top: 1px solid rgba(251, 191, 36, 0.35) !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.75) !important;
    background: rgba(14, 19, 29, 0.96) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.28s ease !important;
    overflow-y: auto !important;
    pointer-events: auto !important;
  }
  .trade-modal__mobile-handle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 8px 0 4px;
    cursor: pointer;
  }
  .trade-modal__mobile-handle::before {
    content: '';
    display: block;
    width: 44px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    transition: background 0.15s;
  }
  .trade-modal__mobile-handle:active::before {
    background: #fbbf24;
  }
  .trade-modal__head {
    padding: 6px 12px 10px !important;
    border-bottom: 1px solid var(--line) !important;
  }
  /* Collapsed drawer state: sits neatly as an active bar at the bottom */
  .trade-modal__dialog.is-minimized {
    max-height: 48px !important;
    height: 48px !important;
    overflow: hidden !important;
    transform: translateY(0) !important;
  }
  .trade-modal__dialog.is-minimized .trade-form {
    display: none !important;
  }
  .trade-form {
    padding: 10px 14px 24px !important;
    gap: 8px !important;
  }
  .tm-row--split {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .tm-balance-box {
    padding: 6px 10px !important;
  }
  .tm-presets {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .tm-presets .chip {
    flex: 1 1 calc(25% - 4px) !important;
    text-align: center !important;
    padding: 5px 6px !important;
  }
  .panel__float-trade {
    top: 10px !important;
    right: 52px !important;
  }
  .float-trade__btn {
    padding: 4px 9px !important;
    font-size: 10px !important;
  }
}

/* Panel header and watchlist trade triggers */
.is-trade-btn {
  color: #fbbf24 !important;
  font-weight: bold;
}
.is-trade-btn:hover {
  background: rgba(251, 191, 36, 0.15) !important;
  border-color: #fbbf24 !important;
}
.wl__trade-btn {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fbbf24;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: auto;
}
.wl__trade-btn:hover {
  background: #fbbf24;
  color: #090c12;
  border-color: #fbbf24;
}

/* Floating draggable chart order button */
.panel__float-trade {
  position: absolute;
  top: 14px;
  right: 78px;
  z-index: 25;
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.panel__float-trade:active {
  cursor: grabbing;
}
.float-trade__btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(19, 23, 34, 0.88);
  border: 1px solid rgba(251, 191, 36, 0.6);
  border-radius: 20px;
  color: #fbbf24;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: all 0.15s ease;
}
.float-trade__btn:hover {
  background: #fbbf24;
  color: #090c12;
  border-color: #fbbf24;
  box-shadow: 0 6px 18px rgba(251, 191, 36, 0.35);
  transform: translateY(-1px);
}
.float-trade__icon {
  font-size: 13px;
  line-height: 1;
}
.float-trade__label {
  font-family: var(--sans);
  line-height: 1;
}

/* ======================================================= Chart Draggable Plan Handles */

.panel__plan-handles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 12;
}

.plan-handle {
  position: absolute;
  right: 74px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  min-height: 26px;
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
  z-index: 10;
  white-space: nowrap;
}

.plan-handle:hover {
  transform: translateY(-50%) scale(1.04);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.75);
  z-index: 20;
}

.plan-handle.is-dragging {
  transform: translateY(-50%) scale(1.06);
  cursor: grabbing !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.9);
  z-index: 30;
}

.plan-handle--sl {
  background: rgba(220, 38, 38, 0.92);
  border: 1px solid #ef4444;
}
.plan-handle--sl:hover,
.plan-handle--sl.is-dragging {
  background: #dc2626;
  border-color: #f87171;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.45);
}

.plan-handle--tp {
  background: rgba(16, 185, 129, 0.92);
  border: 1px solid #10b981;
}
.plan-handle--tp:hover,
.plan-handle--tp.is-dragging {
  background: #059669;
  border-color: #34d399;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
}

.plan-handle--entry,
.plan-handle--rung {
  background: rgba(14, 116, 144, 0.92);
  border: 1px solid #38bdf8;
  color: #ffffff;
}
.plan-handle--entry:hover,
.plan-handle--entry.is-dragging,
.plan-handle--rung:hover,
.plan-handle--rung.is-dragging {
  background: #0284c7;
  border-color: #7dd3fc;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.45);
}

.plan-handle--filled {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #cbd5e1;
  cursor: default;
}
.plan-handle--filled:hover {
  transform: translateY(-50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.expos-ex {
  display: inline-block;
  font-weight: 800;
  font-size: 11px;
  color: #f59e0b;
  margin-right: 2px;
}

.expos-side {
  display: inline-block;
  font-weight: 800;
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1;
}

.expos-side--long {
  color: #10b981;
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.expos-side--short {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.expos-qty {
  font-weight: 700;
  color: #f8fafc;
}

.expos-pnl {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 2px;
}

.expos-pnl--pos {
  color: #34d399;
}

.expos-pnl--neg {
  color: #f87171;
}

.plan-handle--ex-entry {
  background: rgba(15, 23, 42, 0.94) !important;
  border: 1px solid rgba(245, 158, 11, 0.6) !important;
  color: #ffffff !important;
  cursor: pointer !important;
  padding: 2px 6px !important;
  min-height: 24px !important;
  gap: 4px !important;
}
.plan-handle--ex-entry:hover {
  background: rgba(30, 41, 59, 0.98) !important;
  border-color: #f59e0b !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45) !important;
  transform: translateY(-50%) scale(1.03);
}

.plan-handle__cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  margin-left: 2px;
  opacity: 0.85;
  transition: all 0.15s ease;
}
.plan-handle__cancel:hover {
  background: #ef4444;
  color: #fff;
  opacity: 1;
  transform: scale(1.15);
}

.plan-handle__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.plan-handle__btn:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
  transform: scale(1.1);
}
.plan-handle__btn--manage:hover {
  background: #2563eb;
  color: #fff;
}
.plan-handle__btn--close:hover {
  background: #dc2626;
  color: #fff;
}

.plan-handle__grip {
  display: inline-flex;
  font-size: 11px;
  line-height: 1;
  opacity: 0.75;
  letter-spacing: -1px;
}

.plan-handle__tag {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  opacity: 0.95;
}

.plan-handle__price {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.plan-handle__dist {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  opacity: 0.9;
}

/* Mobile adjustments: compact handle & touch-friendly icon buttons */
@media (max-width: 768px) {
  .plan-handle {
    right: 56px;
    padding: 2px 5px;
    min-height: 24px;
    font-size: 11px;
    gap: 4px;
  }
  .plan-handle__tag {
    font-size: 10px;
  }
  .plan-handle__dist {
    font-size: 9px;
    padding: 1px 3px;
  }
  .plan-handle--ex-entry {
    padding: 2px 4px !important;
    gap: 3px !important;
    min-height: 22px !important;
  }
  .plan-handle__btn {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }
}

/* ======================================================= Execution Plans */

.chip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  line-height: 1;
  margin-left: 2px;
}

.wl__plan-btn {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #38bdf8;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: auto;
}
.wl__plan-btn:hover {
  background: #38bdf8;
  color: #090c12;
  border-color: #38bdf8;
}
.wl__trade-btn {
  margin-left: 4px;
}

/* Slide-out Plans Drawer (Non-blocking, chart remains fully interactive) */
.plans-drawer {
  position: fixed;
  top: var(--topbar-h, 44px);
  right: 0;
  bottom: 0;
  width: min(480px, 94vw);
  z-index: 130;
  display: flex;
  pointer-events: none;
}
.plans-drawer[hidden] { display: none; }
.plans-drawer__scrim {
  display: none; /* Background remains interactive and unblurred like studies drawer */
}
.plans-drawer__panel {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(14, 19, 29, 0.96);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  box-shadow: -10px 0 32px rgba(0, 0, 0, 0.7);
  z-index: 1;
}
.plans-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.plans-drawer__title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.plans-drawer__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.plans-drawer__tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}
.plans-tab {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.plans-tab:hover {
  color: var(--text);
}
.plans-tab.is-active {
  color: var(--text-bright);
  border-bottom-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.plans-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.plans-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plans-empty {
  text-align: center;
  padding: 40px 16px;
  font-size: 13px;
}

/* ------------------------------------------------ Agent tab (enhanced modern UI) */
.agent-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.85) 100%);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 10px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.agent-hero__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.agent-hero__status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.agent-hero__status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.agent-hero__badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}
.agent-hero__badge.is-up {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
}
.agent-hero__badge.is-down {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}
.agent-hero__badge.dim {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: none;
}
.agent-hero__note {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.agent-hero__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.agent-refresh-btn,
.agent-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.agent-refresh-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.agent-refresh-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}
.agent-refresh-btn svg {
  transition: transform 0.3s ease;
}
.agent-refresh-btn:hover svg {
  transform: rotate(180deg);
}

.agent-reset-btn {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #f87171;
}
.agent-reset-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}
.agent-reset-btn svg {
  transition: transform 0.2s ease;
}
.agent-reset-btn:hover svg {
  transform: scale(1.1);
}

@keyframes agentSpin {
  100% { transform: rotate(360deg); }
}
.is-spinning {
  animation: agentSpin 0.7s linear infinite !important;
}

@media (max-width: 480px) {
  .agent-hero__top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .agent-hero__actions {
    width: 100%;
    justify-content: flex-start;
  }
  .agent-refresh-btn,
  .agent-reset-btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

.agent-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}
.agent-dot--on { background: #22c55e; box-shadow: 0 0 8px #22c55e; animation: pulse 2s infinite; }
.agent-dot--off { background: #64748b; }
.agent-dot--bad { background: #ef4444; box-shadow: 0 0 8px #ef4444; animation: pulse 1s infinite; }

.agent-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.agent-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s;
}
.agent-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}
.agent-card__header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.agent-card__icon {
  font-size: 16px;
  line-height: 1;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}
.agent-card__title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-bright);
}
.agent-card__desc {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

/* Switch Cards Grid */
.agent-switches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.agent-switch-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.agent-switch-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(56, 189, 248, 0.25);
}
.agent-switch-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.agent-switch-card__slider {
  width: 32px;
  height: 18px;
  background: #334155;
  border-radius: 18px;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.agent-switch-card__slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  left: 2px;
  top: 2px;
  background: #cbd5e1;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.agent-switch-card input:checked + .agent-switch-card__slider {
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}
.agent-switch-card input:checked + .agent-switch-card__slider::before {
  transform: translateX(14px);
  background: #0f172a;
}
.agent-switch-card__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.agent-switch-card__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.agent-switch-card__sub {
  font-size: 9.5px;
  color: var(--text-dim);
  line-height: 1.2;
}

/* Execution Mode Select Card */
.agent-field-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}
.agent-field-card__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.agent-select-wrapper {
  position: relative;
}
.agent-select {
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #38bdf8;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.agent-select:focus, .agent-select:hover {
  border-color: #38bdf8;
}

/* Parameters Grid */
.agent-params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.agent-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.agent-input-group label {
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.02em;
}
.agent-input-box {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  padding: 0 8px;
  transition: all 0.15s ease;
}
.agent-input-box:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}
.agent-input-prefix, .agent-input-suffix {
  font-size: 11px;
  color: #64748b;
  font-family: var(--mono);
  user-select: none;
}
.agent-input-box input {
  flex: 1;
  min-width: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 4px;
  outline: none;
}

/* Filters & Multi-Select Chips */
.agent-card__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.agent-filter-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  transition: all 0.25s ease;
  user-select: none;
}
.agent-filter-mode-badge.is-watchlist {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}
.agent-filter-mode-badge.is-radar {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #c084fc;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.agent-selectors-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 10px;
}
.agent-selector-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-selector-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.agent-selector-label {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  letter-spacing: 0.03em;
}
.agent-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.agent-chip {
  appearance: none;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  color: #94a3b8;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  transition: all 0.15s ease;
  line-height: 1;
}
.agent-chip:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(56, 189, 248, 0.35);
  color: #f1f5f9;
}
.agent-chip .chip-check {
  font-size: 10px;
  display: none;
}
.agent-chip.is-selected .chip-check {
  display: inline;
}
.agent-chip.is-selected {
  background: rgba(56, 189, 248, 0.16);
  border-color: #38bdf8;
  color: #38bdf8;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.22);
}
.agent-chip--tier.is-selected {
  background: rgba(16, 185, 129, 0.18);
  border-color: #10b981;
  color: #34d399;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.25);
}
.agent-chip--radar.is-selected {
  background: rgba(168, 85, 247, 0.18);
  border-color: #a855f7;
  color: #c084fc;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.25);
}
.agent-chip--deny {
  border-color: rgba(239, 68, 68, 0.2);
}
.agent-chip--deny:hover {
  border-color: rgba(239, 68, 68, 0.5);
}
.agent-chip--deny.is-selected {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
  color: #f87171;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.25);
}
.agent-chip--all {
  font-weight: 600;
}
.agent-chip--all.is-selected {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.15);
}
.agent-chip .chip-hint {
  font-size: 8.5px;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: #64748b;
  margin-left: 2px;
}
.agent-chip.is-dimmed {
  opacity: 0.45;
  border-style: dashed;
}
.agent-chip__remove {
  font-size: 13px;
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.agent-chip__remove:hover {
  opacity: 1;
  color: #ef4444;
}

.agent-custom-tag-row {
  margin-top: 3px;
}
.agent-custom-input {
  background: rgba(15, 23, 42, 0.45);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 10px;
  width: 100%;
  max-width: 320px;
  outline: none;
  transition: all 0.15s ease;
  box-sizing: border-box;
}
.agent-custom-input:focus {
  background: rgba(15, 23, 42, 0.85);
  border-color: #38bdf8;
  border-style: solid;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}
.agent-custom-input--deny:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}
.agent-custom-input::placeholder {
  color: #475569;
}

/* Actions Footer */
.agent-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  flex-wrap: wrap;
}
.agent-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 7px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}
.agent-save-btn:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}
.agent-save-btn:active {
  transform: translateY(0);
}
.agent-actions__hint {
  font-size: 10.5px;
  color: var(--text-dim);
  font-style: italic;
}

/* Section Wrappers for Lists */
.agent-section {
  margin-top: 16px;
}
.agent-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
}
.agent-section__title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}
.agent-badge {
  font-size: 9.5px;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-radius: 10px;
  padding: 1px 6px;
  font-family: var(--mono);
}
.agent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#agent-activity-list {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Modernized Activity Row */
.activity-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid #64748b;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(6px);
  transition: all 0.15s ease;
}
.activity-row:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.9);
}
.activity-row__icon {
  font-size: 13px;
  line-height: 20px;
  flex-shrink: 0;
}
.activity-row__body {
  flex: 1;
  min-width: 0;
}
.activity-row__top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.activity-row__top strong {
  font-family: var(--mono);
  color: var(--text-bright);
}
.activity-row__note {
  margin-top: 3px;
  font-size: 11px;
  color: #94a3b8;
  word-break: break-word;
  line-height: 1.35;
}
.activity-row__time {
  font-size: 10px;
  color: #64748b;
  font-family: var(--mono);
  white-space: nowrap;
  line-height: 20px;
}

/* Activity Tints */
.act-kind--ok { border-left-color: #22c55e; }
.act-kind--ok .activity-row__top .tiny { color: #4ade80; font-weight: 600; }
.act-kind--queue { border-left-color: #f59e0b; }
.act-kind--queue .activity-row__top .tiny { color: #fbbf24; }
.act-kind--bad { border-left-color: #ef4444; }
.act-kind--bad .activity-row__top .tiny { color: #f87171; }
.act-kind--warn { border-left-color: #f97316; }
.act-kind--warn .activity-row__top .tiny { color: #fb923c; }

/* Plan Card */
.plan-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}
.plan-card:hover {
  border-color: var(--line-strong);
}
.plan-card.is-armed {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.1);
}
.plan-card.is-partial {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.1);
}
.plan-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.plan-card__symbol {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-bright);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.plan-card__badges {
  display: flex;
  align-items: center;
  gap: 6px;
}
.plan-status-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.plan-status--planned { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.plan-status--armed { background: rgba(245, 158, 11, 0.18); color: #f59e0b; }
.plan-status--partial { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.plan-status--complete { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.plan-status--stopped { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.plan-status--expired { background: rgba(100, 116, 139, 0.2); color: #64748b; }
.plan-status--cancelled { background: rgba(100, 116, 139, 0.15); color: #64748b; }

.plan-card__metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 11px;
}
.plan-card__metric-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-card__metric-val {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text-bright);
}

/* Ladder visualization inside card */
.plan-card__ladder {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 6px;
}
.plan-card__rung-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
}
.plan-card__rung-row.is-filled {
  background: rgba(16, 185, 129, 0.12);
  border-left: 2px solid #10b981;
}
.plan-card__rung-price {
  font-family: var(--mono);
}

.plan-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.plan-card__autoarm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  cursor: pointer;
}
.plan-card__btns {
  display: flex;
  gap: 6px;
}

/* Plan Preview in modal */
.plan-preview-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin: 10px 0;
}
.plan-preview-head {
  display: flex;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.plan-rungs-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plan-rung-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  font-size: 11px;
}
.plan-rung-item .rung-alloc {
  color: var(--accent);
  font-weight: 600;
}
.plan-rung-item .rung-price {
  font-family: var(--mono);
  font-weight: 600;
}

/* Plan Modal Execution Mode Toggle */
.pm-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.pm-mode-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.pm-mode-btn .icon {
  font-size: 16px;
}
.pm-mode-btn .label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.pm-mode-btn .label strong {
  font-size: 12px;
  color: var(--text);
}
.pm-mode-btn .label small {
  font-size: 10px;
}
.pm-mode-btn.is-active {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.5);
  color: #fbbf24;
}
.pm-mode-btn.is-active .label strong {
  color: #fbbf24;
}

/* Plan Modal Execution Method Radio Box */
.pm-exec-type {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
}
.pm-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  user-select: none;
}
.pm-radio-label input[type="radio"] {
  accent-color: #fbbf24;
  cursor: pointer;
}
.pm-radio-label:hover {
  color: var(--text-bright);
}

/* ------------------------------------------- Alerts & Notifications Modal -- */
.alerts-dialog-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 600;
}

.alert-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--bg-1, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.alert-card:hover {
  border-color: var(--line-strong);
}

.alert-card--master {
  background: rgba(30, 58, 95, 0.25);
  border-color: rgba(56, 189, 248, 0.35);
}

.alert-card__info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.alert-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}

.alert-card__desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
}

.alert-card__sub {
  font-size: 10px;
  color: var(--accent);
  margin-top: 2px;
  font-family: var(--mono);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.12);
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #0284c7;
  border-color: #38bdf8;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.alert-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}





