/* =============================================================================
   BTick — trade desk
   Styling for the multi-account MT5 workspace (trade.js / bridge/bls_server.py).
   Uses the same design tokens as styles.css so light and dark themes both work.
   ============================================================================= */

.trade-desk[hidden] { display: none !important; }

.trade-desk {
  position: relative;
  inset: auto;
  grid-column: 1;
  grid-row: 1;
  z-index: 12;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: var(--bg);
  border-right: 1px solid var(--border-strong);
  animation: desk-in 0.16s ease;
}
@keyframes desk-in { from { opacity: 0; } }

/* Docked column on the left: charts stay visible while the desk is open. */
body.desk-docked .workspace {
  grid-template-columns: var(--desk-w, 520px) minmax(0, 1fr) 270px 44px;
}
body.desk-docked .workspace:has(.watchlist.expanded) {
  grid-template-columns: var(--desk-w, 520px) minmax(0, 1fr) 360px 44px;
}
body.desk-docked .chart-area,
body.desk-docked .trade-quickbar,
body.desk-docked .bottombar { grid-column: 2; }
body.desk-docked .trade-desk { grid-row: 1 / -1; }
body.desk-docked .watchlist { grid-column: 3; }
body.desk-docked .utility-rail { grid-column: 4; }
/* Rail flyouts stay on the right, next to the rail. */
body.desk-docked .flyout { grid-column: 3; }

.desk-resize {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 7px;
  z-index: 30;
  cursor: col-resize;
  touch-action: none;
}
.desk-resize::after {
  content: '';
  position: absolute;
  right: 3px;
  top: 50%;
  width: 1px;
  height: 42px;
  margin-top: -21px;
  background: var(--border-strong);
  border-radius: 1px;
  transition: background 0.12s ease;
}
.desk-resize:hover::after { background: var(--accent); }
body.desk-resizing { cursor: col-resize; user-select: none; }

.desk-shell {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--bg);
  color: var(--text);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

/* The docked column is narrow, so stack cards and let the header wrap. */
.desk-shell > * { min-width: 0; }
body.desk-docked .desk-head { flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; }
body.desk-docked .desk-brand-text p { display: none; }
body.desk-docked .desk-kpis {
  order: 3; flex: 1 1 100%; width: 100%; max-width: 100%; min-width: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px; overflow: visible;
}
body.desk-docked .desk-kpi { min-width: 0; padding: 5px 8px; }
body.desk-docked .desk-head-actions { margin-left: auto; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
body.desk-docked .desk-head-actions .btn { height: 24px; padding: 0 7px; font-size: 10px; }
body.desk-docked .desk-tabs { overflow-x: auto; scrollbar-width: none; padding: 0 8px; }
body.desk-docked .desk-tabs::-webkit-scrollbar { display: none; }
body.desk-docked .desk-tabs button[data-pane] { padding: 0 6px; font-size: 10.5px; }
body.desk-docked .desk-grid.two,
body.desk-docked .desk-grid.side { grid-template-columns: minmax(0, 1fr); }
body.desk-docked .desk-body { padding: 12px 12px 18px; }

/* ------------------------------ bottom drawer ----------------------------
   The quickbar opens one section at a time as a panel over the chart instead
   of the docked column. The same shell/pane code is reused, so every action
   works identically; the tabs are trimmed to the four quick sections. */
/* The drawer sits above the bottom bars. The workspace keeps the same grid row
   but is shortened by the drawer height, so the chart and side panels crop to
   the space that is actually visible instead of being covered. */
body.desk-drawer .workspace {
  height: 100%;
  align-self: start;
}
body.desk-drawer .trade-desk {
  position: fixed;
  left: 0;
  /* Never over the watchlist / rail column: the width is cropped to the left of
     them by --drawer-right, which trade.js keeps in sync with the live widths. */
  right: var(--drawer-right, 0);
  bottom: 64px;
  top: auto;
  grid-column: auto;
  grid-row: auto;
  height: var(--drawer-h, 46vh);
  z-index: 42;
  border-top: 0;
  border-right: 0;
  box-shadow: none;
  transform-origin: bottom center;
  animation: drawer-in 280ms var(--ease, ease);
}
@keyframes drawer-in { from { transform: translateY(16px) scaleY(0.97); opacity: 0.5; } }
body.desk-drawer .trade-desk {
  transition: top 150ms var(--ease, ease), left 150ms var(--ease, ease), width 150ms var(--ease, ease);
}
/* Dragged above the drawing tools button: the panel turns into a full-height
   left column, the chart starts after it and the watchlist runs to the bottom
   of the workspace instead of stopping above a bottom strip. */
body.desk-drawer-full .workspace {
  height: 100%;
  padding-left: var(--desk-w, 520px);
  box-sizing: border-box;
}
body.desk-drawer-full .trade-desk {
  top: 46px;
  bottom: 64px;
  left: 0;
  right: auto;
  width: var(--desk-w, 520px);
  height: auto;
  border-top: 0;
  border-right: 1px solid var(--border-strong);
  box-shadow: 18px 0 46px rgba(15, 23, 42, 0.22);
  animation: none;
}
body.desk-drawer-full .desk-grid.two,
body.desk-drawer-full .desk-grid.side { grid-template-columns: minmax(0, 1fr); }
body.desk-drawer .desk-shell { grid-template-rows: auto auto minmax(0, 1fr); }
/* Focus desk keeps its stats: the KPI strip stays, the brand and action buttons
   that belong to the old docked column do not. */
body.desk-drawer .desk-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 2px; border-bottom: 0; min-height: 0;
}
body.desk-drawer .desk-brand,
body.desk-drawer .desk-head-actions,
body.desk-drawer .desk-foot { display: none; }
body.desk-drawer .desk-kpis { display: flex; width: 100%; gap: 6px; overflow-x: auto; scrollbar-width: none; }
body.desk-drawer .desk-kpis::-webkit-scrollbar { display: none; }
body.desk-drawer .desk-kpi { min-width: 86px; padding: 3px 7px; border-radius: 6px; }
body.desk-drawer .desk-kpi label { font-size: 8px; margin-bottom: 0; }
body.desk-drawer .desk-kpi b { font-size: 11.5px; }
body.desk-drawer .desk-tabs { height: 32px; padding: 0 8px; overflow: hidden; }
/* The quickbar below the panel already lists every section, so the drawer head
   only names the one that is open. */
body.desk-drawer .desk-tabs button[data-pane] { display: none; }
body.desk-drawer #deskConn { display: none; }
body.desk-drawer .desk-drawer-title {
  display: inline-flex; align-items: center;
  height: 32px; padding: 0 2px;
  font-size: 11px; font-weight: 700; color: var(--text); white-space: nowrap;
}
body.desk-drawer .desk-body { padding: 8px 12px 12px; overflow: auto; }
body.desk-drawer .desk-grid.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
body.desk-drawer .desk-grid.side { grid-template-columns: minmax(0, 1fr) 320px; }
/* One scrollbar for the whole panel: inner lists flow instead of scrolling. */
body.desk-drawer .desk-scroll,
body.desk-drawer .log-list { max-height: none; overflow: visible; }
body.desk-drawer .card-body { padding: 9px 10px; }
body.desk-drawer .desk-table th,
body.desk-drawer .desk-table td { padding: 5px 8px; }
body.desk-drawer .desk-empty { padding: 14px 10px; }

.desk-drawer-title { display: none; }

/* Expanded drawer: restore the complete tab strip and the desk's own controls
   so the full desk really is the full desk, not just a taller copy of the four
   quick sections. */
body.desk-drawer-full .desk-shell { grid-template-rows: auto auto minmax(0, 1fr) auto; }
body.desk-drawer-full .desk-head { flex-wrap: wrap; gap: 6px 8px; padding: 8px 10px; }
body.desk-drawer-full .desk-brand { display: flex; }
body.desk-drawer-full .desk-brand-text p { display: none; }
body.desk-drawer-full .desk-head-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
body.desk-drawer-full .desk-head-actions .btn { height: 24px; padding: 0 7px; font-size: 10px; }
body.desk-drawer-full .desk-kpis { order: 3; flex: 1 1 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 6px; overflow: visible; }
body.desk-drawer-full .desk-foot { display: flex; }
body.desk-drawer-full .desk-tabs { height: 36px; padding: 0 8px; overflow-x: auto; overflow-y: hidden; }
body.desk-drawer-full .desk-tabs button[data-pane] { display: inline-flex; align-items: center; }
body.desk-drawer-full .desk-drawer-title { display: none; }
body.desk-drawer-full #deskConn { display: inline-flex; }
body.desk-drawer-full .desk-tab-action { flex: 0 0 auto; }

.desk-tab-action {
  display: none;
  width: 25px; height: 25px; margin-left: 3px;
  place-items: center;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--panel); color: var(--muted);
  font-size: 11px; line-height: 1;
  cursor: pointer;
}
.desk-tab-action:hover { border-color: var(--accent); color: var(--accent-dark); }
body.desk-drawer .desk-tab-action { display: inline-grid; }
/* Drawer grip: the docked left-edge resizer becomes a top horizontal grip. */
body.desk-drawer .desk-resize {
  top: -6px; left: 0; right: 0; bottom: auto;
  width: auto; height: 12px;
  cursor: row-resize;
  background: transparent;
}
body.desk-drawer .desk-resize::after {
  right: auto; left: 50%; top: 4px;
  width: 64px; height: 3px; margin: 0 0 0 -32px;
  background: var(--accent);
  opacity: 0.6;
}
body.desk-drawer .desk-resize:hover::after { opacity: 1; }
body.desk-drawer.desk-resizing { cursor: row-resize; }
/* Dragged to the bottom: the panel fades, so letting go reads as a close. */
body.desk-drawer .trade-desk { transition: opacity 140ms ease; }
body.desk-drawer.drawer-close-armed .trade-desk { opacity: 0.45; }
body.desk-drawer.drawer-close-armed .desk-resize::after { opacity: 1; background: #f23645; }

/* ------------------------------- header ---------------------------------- */
.desk-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.desk-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.desk-logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
}
.desk-brand-text h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.desk-brand-text p { margin: 1px 0 0; font-size: 10.5px; color: var(--muted); }

.desk-kpis { display: flex; gap: 8px; flex: 1 1 auto; overflow: hidden; }
.desk-kpi {
  min-width: 108px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.desk-kpi label {
  display: block;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--faint); margin-bottom: 2px;
}
.desk-kpi b { font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 700; }
.desk-kpi b.pos { color: var(--positive); }
.desk-kpi b.neg { color: var(--negative); }

.desk-head-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.live-pill {
  padding: 5px 9px; border-radius: 6px;
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.6px;
  border: 1px solid transparent;
}
.live-pill.on { background: #ffe9e6; color: #b3261e; border-color: #f5c1ba; }
.live-pill.off { background: var(--selected); color: var(--muted); }
body.dark .live-pill.on { background: #3a1e1c; color: #ff8d84; border-color: #5c2b27; }

.btn {
  height: 28px; padding: 0 11px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { background: #fdeae8; border-color: #f3c4bf; color: #b3261e; }
body.dark .btn.danger { background: #3a1e1c; border-color: #5c2b27; color: #ff8d84; }
.btn.ghost { background: transparent; }
.btn.sm { height: 24px; padding: 0 8px; font-size: 10px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); }

/* -------------------------------- tabs ----------------------------------- */
.desk-tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
}
.desk-tabs button {
  height: 36px; padding: 0 12px;
  border: none; border-bottom: 2px solid transparent;
  background: none; color: var(--muted);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.desk-tabs button:hover { color: var(--text); }
.desk-tabs button.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.desk-tab-spacer { flex: 1; }
.desk-conn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--muted); padding-right: 2px;
}
.desk-conn i { width: 7px; height: 7px; border-radius: 50%; background: #c0392b; }
.desk-conn.on i { background: var(--positive); }
.desk-conn.on { color: var(--positive); }

/* -------------------------------- body ----------------------------------- */
.desk-body { overflow: auto; padding: 14px 16px 22px; background: var(--bg); }
.desk-pane { display: none; }
.desk-pane.active { display: block; }

.desk-grid { display: grid; gap: 12px; }
.desk-grid.two { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.desk-grid.side { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1180px) {
  .desk-grid.two, .desk-grid.side { grid-template-columns: minmax(0, 1fr); }
}

.card {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: 0.2px; }
.card-head .spacer { flex: 1; }
.card-head .hint { font-size: 10px; color: var(--faint); }
.card-body { padding: 12px; }
.card-body.tight { padding: 0; }
.card-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; border-top: 1px solid var(--border);
  background: var(--bg);
}

/* -------------------------------- tables --------------------------------- */
.desk-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.desk-table th {
  text-align: left; padding: 7px 9px;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--faint); font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.desk-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.desk-table tr:last-child td { border-bottom: none; }
.desk-table tbody tr:hover { background: var(--panel-hover); }
.desk-table td.num, .desk-table th.num { text-align: right; }
.desk-table .pos { color: var(--positive); font-weight: 600; }
.desk-table .neg { color: var(--negative); font-weight: 600; }
.desk-table .muted { color: var(--muted); }
.desk-table .tiny { font-size: 10px; }
.desk-scroll { max-height: 420px; overflow: auto; }
.desk-empty { padding: 22px 12px; text-align: center; color: var(--faint); font-size: 11px; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #b0b6c0; margin-right: 5px; }
.dot.on { background: var(--positive); }
.dot.warn { background: #e0a800; }
.dot.off { background: #c0392b; }

.badge {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.4px;
  background: var(--selected); color: var(--accent-dark);
}
.badge.live { background: #fdeae8; color: #b3261e; }
body.dark .badge.live { background: #3a1e1c; color: #ff8d84; }
.badge.demo { background: #fff2d6; color: #8a5a00; }
body.dark .badge.demo { background: #3a2f16; color: #e8b64c; }
.badge.gray { background: var(--panel-hover); color: var(--muted); }

/* -------------------------------- forms ---------------------------------- */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 9px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field-row.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 9.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--faint); }
.field input, .field select, .field textarea, .desk-input {
  height: 30px; padding: 0 9px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--bg); color: var(--text);
  font-size: 11.5px; font-family: inherit;
  min-width: 0;
}
.field textarea { height: auto; padding: 7px 9px; resize: vertical; min-height: 62px; }
.field input:focus, .field select:focus, .field textarea:focus, .desk-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.field small { font-size: 9.5px; color: var(--faint); }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline.gap { gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; cursor: pointer; }
.check input { width: 13px; height: 13px; accent-color: var(--accent); cursor: pointer; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button {
  height: 28px; padding: 0 11px; border: none;
  background: var(--bg); color: var(--muted);
  font-size: 11px; font-weight: 600; border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--accent); color: #fff; }

/* ------------------------------ checklist -------------------------------- */
.checklist { display: flex; flex-direction: column; gap: 2px; }
.checklist .item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 7px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
}
.checklist .item:hover { background: var(--panel-hover); }
.checklist .item.done { background: var(--accent-soft); border-color: #d8c9ff; }
body.dark .checklist .item.done { border-color: #4b3a6b; }
.checklist input { width: 14px; height: 14px; margin-top: 1px; accent-color: var(--accent); }
.checklist .txt strong { display: block; font-size: 11px; font-weight: 600; }
.checklist .txt small { display: block; font-size: 9.5px; color: var(--muted); line-height: 1.35; }
.progress { height: 5px; border-radius: 3px; background: var(--panel-hover); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 0.18s ease; }
.progress-label { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  padding: 3px 8px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--bg);
  font-size: 10px; color: var(--muted); cursor: pointer;
}
.tag.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }

/* --------------------- magnet tag popover ------------------------------ */
.card:has(.ord-extra-tags) { overflow: visible; }
.card:has(.ord-extra-tags.open) { position: relative; z-index: 6; }
.ord-extra-tags { position: relative; }
.ord-extra-total {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: inline-grid; place-items: center; background: var(--accent-soft);
  color: var(--accent-dark); font-size: 9.5px; font-weight: 800;
}
.ord-extra-trigger {
  width: 100%; height: 33px; display: flex; align-items: center; gap: 7px;
  padding: 0 9px; border: 1px dashed var(--border-strong); border-radius: 8px;
  background: var(--bg); color: var(--text); font: 600 11px inherit;
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.ord-extra-trigger:hover { border-color: var(--accent); background: var(--panel-hover); }
.ord-extra-plus {
  width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-dark); flex: 0 0 auto;
}
.ord-extra-caret { display: flex; color: var(--faint); transition: transform 0.2s ease; }
.ord-extra-tags.open .ord-extra-caret { transform: rotate(180deg); }
.ord-extra-selected { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.ord-extra-none { font-size: 10px; color: var(--faint); }
.tag-x {
  border: 0; background: transparent; color: inherit; margin-left: 4px;
  padding: 0; cursor: pointer; font-size: 11px; line-height: 1;
}
.tag-pop {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 7px);
  display: flex; flex-direction: column; max-height: 320px; padding: 8px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--panel); box-shadow: 0 14px 34px rgba(16, 24, 40, 0.18);
  opacity: 0; transform: translateY(-7px) scale(0.97); transform-origin: top center;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ord-extra-tags.open .tag-pop { opacity: 1; transform: none; pointer-events: auto; }
.tag-pop-search {
  display: flex; align-items: center; gap: 7px; height: 31px; padding: 0 8px;
  margin-bottom: 7px; border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--bg); color: var(--faint);
}
.tag-pop-search svg { flex: 0 0 auto; }
.tag-pop-search input {
  flex: 1; height: 100%; min-width: 0; border: 0; outline: none;
  background: transparent; color: var(--text); font: inherit; font-size: 11px;
}
.tag-pop-list {
  display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start;
  min-height: 42px; max-height: 210px; overflow: auto; padding: 2px;
}
.tag-pop-empty { padding: 10px 4px; font-size: 10.5px; color: var(--faint); }
.tag-pop-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border);
  font-size: 10px; color: var(--muted);
}
@media (prefers-reduced-motion: reduce) {
  .tag-pop, .ord-extra-caret { transition: none; }
}

/* --------------------------- risk / order summary ------------------------ */
.summary-line {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 11px; padding: 3px 0;
}
.summary-line span { color: var(--muted); }
.summary-line b { font-variant-numeric: tabular-nums; }

.gate {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 7px;
  border: 1px solid var(--border-strong); background: var(--bg);
  font-size: 11px;
}
.gate.on { border-color: #f0b8b2; background: #fdf1ef; }
body.dark .gate.on { border-color: #5c2b27; background: #2a1a18; }
.gate .grow { flex: 1; }
.switch {
  position: relative; width: 34px; height: 19px; border-radius: 10px;
  background: var(--border-strong); border: none; flex: 0 0 auto;
  transition: background 0.15s ease;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%; background: #fff;
  transition: transform 0.15s ease;
}
.switch.on { background: #c0392b; }
.switch.on::after { transform: translateX(15px); }

/* ------------------------------- warnings -------------------------------- */
.note {
  padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--bg);
  font-size: 10.5px; color: var(--muted); line-height: 1.45;
}
.note.warn { border-color: #ecd39a; background: #fffaf0; color: #7a5b00; }
body.dark .note.warn { border-color: #4d3f1d; background: #2a2313; color: #d8b25c; }
.note.error { border-color: #f0b8b2; background: #fdf1ef; color: #a92b21; }
body.dark .note.error { border-color: #5c2b27; background: #2a1a18; color: #ff9d94; }
.note.ok { border-color: #d8c9ff; background: var(--accent-soft); color: var(--accent-dark); }

/* -------------------------------- log ------------------------------------ */
.log-list { max-height: 460px; overflow: auto; font-size: 10.5px; }
.log-row {
  display: grid; grid-template-columns: 128px 90px minmax(0, 1fr);
  gap: 8px; padding: 4px 10px; border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: none; }
.log-row time { color: var(--faint); font-variant-numeric: tabular-nums; }
.log-row .who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.log-row .what { color: var(--text); word-break: break-word; }
.log-row.error .what { color: #b3261e; }
body.dark .log-row.error .what { color: #ff8d84; }
.log-row.ok .what { color: var(--accent-dark); }

/* -------------------------------- footer --------------------------------- */
.desk-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 10px; color: var(--faint);
}
.desk-foot-right { display: flex; gap: 12px; }
#deskClock { font-variant-numeric: tabular-nums; }

/* -------------------------------- modal ---------------------------------- */
.desk-modal {
  position: fixed; inset: 0; z-index: 340;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 17, 24, 0.55);
  padding: 20px;
}
.desk-modal-card {
  width: min(460px, 100%);
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.desk-modal-card h3 { margin: 0; padding: 13px 15px; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.desk-modal-body { padding: 14px 15px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.desk-modal-body b { color: var(--text); }
.desk-modal-body .list { margin: 8px 0 0; padding-left: 16px; }
.desk-modal-body .list li { margin-bottom: 3px; }
.desk-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 11px 15px; border-top: 1px solid var(--border); background: var(--panel); }

/* ------------------------------- toasts ---------------------------------- */
#deskToasts {
  position: fixed; right: 22px; bottom: 60px; z-index: 360;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}

/* ----------------------------- misc helpers ------------------------------ */
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.right { text-align: right; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mb8 { margin-bottom: 8px; }
.flex1 { flex: 1; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

.demo-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; margin-bottom: 12px;
  border: 1px solid #ecd39a; border-radius: 8px;
  background: #fffaf0; color: #7a5b00; font-size: 11px;
}
body.dark .demo-banner { border-color: #4d3f1d; background: #2a2313; color: #e8c06a; }
.demo-banner b { color: inherit; }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------ demo replay ------------------------------ */
.demo-chart {
  display: block;
  width: 100%;
  height: 300px;
  background: var(--bg);
}
@media (max-width: 1180px) {
  .demo-chart { height: 240px; }
}

/* Backtest rows in Positions / Pending orders. */
.bt-row td { background: rgba(139, 92, 246, 0.05); }
/* The bottom strips belong to the chart column: the drawer crops the chart to
   the space above it, and the full-height panel reaches the window bottom so
   every column to its right keeps running down. */
body.desk-drawer .chart-area { margin-bottom: var(--drawer-h, 46vh); }
body.desk-drawer-full .chart-area { margin-bottom: 0; }
body.desk-drawer-full .trade-desk { bottom: 0; }

.bt-tag {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  background: rgba(139, 92, 246, 0.16); color: #6d28d9;
  font-size: 8.5px; font-weight: 800; letter-spacing: 0.05em; white-space: nowrap;
}

/* Phone (Android) card in Settings: QR beside the address and pairing code. */
.phone-pair {
  display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap;
}
.phone-qr {
  width: 116px; height: 116px; border-radius: 8px; padding: 5px;
  background: #fff; border: 1px solid var(--border, #2b3145);
}
.phone-pair-text { min-width: 0; flex: 1; }
.phone-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text, #e6e9f2); word-break: break-all;
}
