/* DTC Web — геометрия как desktop (65% MC | 25% DTC | 200px settings) */
:root {
  --bg: #191919;
  --panel: #191919;
  --chart-bg: #191919;
  --border: #333;
  --text: #eee;
  --muted: #888;
  --accent: #5b9bd5;
  --buy: #2ecc71;
  --sell: #e74c3c;
  --edge-w: 12px;
  --edge-hit-h: 60px;
  --settings-w: 200px;
  --win-topbar-h: 30px;
  /* общий горизонтальный сплит (desktop + жёлтые стрелки) */
  --col-mc-fr: 65;
  --col-dtc-fr: 25;
  /* общий вертикальный сплит M1 | M5+M30 = Oси+ID */
  --row-top-fr: 55;
  --row-bot-fr: 45;
  --stats-collapsed-h: 42px;
  --stats-expanded-pct: 50%;
  --stat-row-h: 22px;
  --slot-head-bg: #111;
  --slot-head-fg: #777;
  --slot-head-border: #333;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.35 system-ui, Segoe UI, sans-serif; overflow: hidden;
}
button, input, select { font: inherit; }
button {
  cursor: pointer; background: #333; color: #fff; border: 1px solid #555;
  padding: 6px 10px; border-radius: 2px;
}
button:hover { background: #444; }
button.primary { background: #2a5a8a; border-color: var(--accent); }
input, select {
  background: #222; color: #fff; border: 1px solid #555;
  padding: 5px 8px; border-radius: 2px; width: 100%;
}

#app { display: flex; flex-direction: column; height: 100vh; }

.ca-topbar {
  flex-shrink: 0;
  z-index: 35;
}

/* Общая шапка МК и ЦА — одна высота и стиль */
.win-topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--win-topbar-h);
  padding: 0 8px;
  background: #111;
  border-bottom: 1px solid var(--border);
  position: relative;
  box-sizing: border-box;
}
.win-topbar-title {
  font-size: 13px;
  font-weight: 600;
  color: #ccc;
  white-space: nowrap;
  text-align: center;
}
.settings-api-status {
  text-align: center;
  font-weight: bold;
  font-size: 11px;
  margin: 4px 0 8px;
  color: #888;
}
.settings-api-status.online { color: #0f0; }
.settings-api-status.offline { color: #888; }
.settings-api-status.reset { color: #0f0; }

/* ── workspace grid: MC | ЦА | settings — ширина колонок по видимым панелям ── */
.workspace {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: 65fr 25fr var(--settings-w);
  grid-template-rows: 1fr;
  grid-template-areas: "mc center settings";
}

.grid-mc { grid-area: mc; min-width: 0; overflow: hidden; }
.grid-center { grid-area: center; min-width: 0; }
.grid-settings { grid-area: settings; min-width: 0; overflow: hidden; }

/* все три: 65% MC | 25% ЦА | 200px settings (default) */

/* только ЦА + settings */
.workspace.mc-closed:not(.settings-closed) {
  grid-template-columns: 1fr var(--settings-w);
  grid-template-areas: "center settings";
}

/* только MC + ЦА */
.workspace.settings-closed:not(.mc-closed) {
  grid-template-columns: 65fr 25fr;
  grid-template-areas: "mc center";
}

/* только ЦА */
.workspace.mc-closed.settings-closed {
  grid-template-columns: 1fr;
  grid-template-areas: "center";
}

.workspace.mc-closed .grid-mc {
  display: none;
}
.workspace.settings-closed .grid-settings {
  display: none;
}

/* Шторки MC / настроек — на краях окна ЦА (как desktop terminal) */
.edge-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  width: var(--edge-w);
  height: var(--edge-hit-h);
  padding: 0;
  background: transparent;
  border: none;
  color: #888;
  font-weight: bold;
  font-size: 10px;
  cursor: pointer;
}
.edge-toggle:hover { color: #fff; background: rgba(61, 61, 61, 0.7); }
.edge-toggle-left { left: 0; }
.edge-toggle-right { right: 0; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; height: 100%;
}
.panel-head {
  flex-shrink: 0;
}
.panel-head.win-topbar {
  padding: 0 8px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  color: inherit;
  background: #111;
}

/* ── MC: M1 60% / M5+M30 40% ── */
.mc-head {
  justify-content: center;
}
.panel-body { flex: 1; overflow: hidden; padding: 0; min-height: 0; }

.mc-head-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1;
  background: #353545;
  border-color: #555;
  color: #c8d4ff;
}
.mc-head-btn:hover { background: #454560; }
.mc-head-btn.active { background: #2a4a7a; border-color: var(--accent); color: #fff; }
.mc-charts-body { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.mc-mosaic-host {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--chart-bg); min-width: 0;
}
.mc-mosaic-top {
  flex: var(--row-top-fr) 1 0; min-height: 0;
  display: flex; flex-direction: column; border-bottom: 1px solid #222;
}
.mc-mosaic-bottom {
  flex: var(--row-bot-fr) 1 0; min-height: 0;
  display: flex; flex-direction: row; gap: 2px; padding: 0 1px 1px;
}
.mc-pane { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.mc-mosaic-top .mc-pane { height: 100%; }
.mc-mosaic-bottom .mc-pane { border-left: 1px solid #222; }
.mc-mosaic-bottom .mc-pane:first-child { border-left: none; }

/* Режимы окон мозаики (web). 1 = только M1, 2 = M1 + M5, 3 = M1 + M5 + M30. */
.mc-mosaic-host.mc-layout-1 .mc-mosaic-bottom { display: none; }
.mc-mosaic-host.mc-layout-1 .mc-mosaic-top { border-bottom: none; }
.mc-mosaic-host.mc-layout-2 .mc-pane[data-tf="M30"] { display: none; }
.mc-pane-head {
  font: 600 10px/1.2 system-ui, sans-serif; color: #888;
  padding: 2px 6px; background: #191919; flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  cursor: pointer;
}
.mc-pane-tf { color: #b4b4be; font-weight: 600; }
.mc-pane-status { color: #647896; font-size: 10px; margin-left: auto; }
.mc-pane-tools-btn {
  margin-left: 4px;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.2;
  background: #191919;
  border: 1px solid #3a3a3a;
  color: #9ab0d0;
  cursor: pointer;
  border-radius: 2px;
}
.mc-pane-tools-btn.has-active { color: #8ab4f8; border-color: #5b7ab0; }
.mc-pane-tools-menu {
  position: absolute;
  z-index: 40;
  left: 0;
  right: auto;
  top: 100%;
  min-width: 210px;
  background: #191919;
  border: 1px solid #444;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  padding: 4px 0;
}
.mc-pane-tools-menu.hidden { display: none; }
.mc-pane-head { position: relative; }
.mc-pane-tools-hdr,
.mc-pane-tools-row {
  display: grid;
  grid-template-columns: 1fr 36px 44px;
  gap: 4px;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
}
.mc-pane-tools-hdr { color: #888; border-bottom: 1px solid #333; margin-bottom: 2px; }
.mc-pane-tools-name { color: #ddd; }
.mc-pane-tools-row input { margin: 0 auto; }
.mc-tb-btn.mc-tb-tool.active { background: #252525; border-color: #777; color: #fff; }
.mc-pane-status.downloading {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #8ab4f8;
}
.mc-download-spin {
  width: 10px;
  height: 10px;
  border: 2px solid #3a4a60;
  border-top-color: #8ab4f8;
  border-radius: 50%;
  animation: mc-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes mc-spin {
  to { transform: rotate(360deg); }
}
.mc-pane.active .mc-pane-head {
  background: #191919;
  box-shadow: inset 0 0 0 1px #5b9bd5;
}
.mc-pane.active .mc-pane-tf { color: #eef4ff; }
.mc-pane-canvas { flex: 1; width: 100%; display: block; min-height: 0; }
.mc-mosaic-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 2px 4px;
  background: #191919; border-bottom: 1px solid #2a2a2a; flex-shrink: 0;
}
.mc-tb-btn {
  padding: 1px 7px; font-size: 11px; line-height: 1.4;
  background: #191919; border: 1px solid #3a3a3a; color: #a0b0d0;
  cursor: pointer; border-radius: 3px; white-space: nowrap;
}
.mc-tb-btn:hover { background: #252525; color: #d0e0ff; }
.mc-tb-btn.active { background: #252525; border-color: #777; color: #fff; }
.mc-tb-btn.mc-tb-tf { font-weight: 700; min-width: 30px; text-align: center; }
.mc-tb-btn.mc-tb-tile { font-weight: 700; min-width: 26px; text-align: center; font-size: 13px; }
.mc-tb-sep { width: 1px; height: 14px; background: #3a3a3a; margin: 0 2px; }
.mc-tb-btn.mc-tb-tool-icon {
  min-width: 28px;
  min-height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.mc-tb-hline {
  display: block;
  width: 12px;
  height: 0;
  border-top: 2px solid currentColor;
  flex-shrink: 0;
}
.mc-tb-btn.mc-tb-tool .mc-tb-hline { pointer-events: none; }
.mc-tb-vprof {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  width: 12px;
  height: 12px;
  pointer-events: none;
}
.mc-tb-vprof-line {
  display: block;
  height: 0;
  border-top: 2px solid currentColor;
  flex-shrink: 0;
}
.mc-tb-vprof-line.short { width: 6px; }
.mc-tb-vprof-line.long { width: 12px; }

/* ── DTC центр: тот же сплит 60/40 ── */
.dtc-stack {
  display: flex; flex-direction: column; min-height: 0; height: 100%;
  background: var(--chart-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.dtc-stack > .ca-topbar { flex: 0 0 auto; }
.dtc-stack > .stack-view { flex: 1 1 0; min-height: 0; }
.stack-view {
  flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  position: relative;
}
.stack-view.hidden { display: none; }

.dtc-view { height: 100%; position: relative; }

.dtc-row-top {
  flex: var(--row-top-fr) 1 0; min-height: 0;
  display: flex; flex-direction: column;
}

.dtc-trade-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 5px 5px 0;
}
.dtc-trade-btn {
  width: 145px;
  height: 40px;
  padding: 0 6px;
  border: 2px solid #555;
  border-radius: 0;
  background: #333;
  color: #fff;
  font: bold 11px/1 system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dtc-trade-btn:active { border-color: #fff; }
.dtc-trade-btn.dtc-balance {
  cursor: default;
  pointer-events: none;
  text-align: center;
}
.dtc-trade-btn.dtc-martin.on { border-color: lime; }
.dtc-trade-btn.dtc-auto.on { border-color: lime; }
.dtc-trade-btn.dtc-auto.wait { border-color: #555; font-weight: normal; }
.dtc-trade-btn.dtc-auto .auto-face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  font-size: 10px;
  font-weight: bold;
}
.dtc-trade-btn.dtc-auto .auto-face .dim { color: #666; }
.dtc-trade-btn.dtc-auto .auto-face .dn { color: #e44; }
.dtc-trade-btn.dtc-auto .auto-face .up { color: #6f6; }
.dtc-trade-btn.dtc-auto .auto-face .lbl { color: #fff; }
.dtc-row-bottom {
  flex: var(--row-bot-fr) 1 0; min-height: 0;
  display: flex; flex-direction: column;
  border-top: 1px solid #2a2a2a;
}

.dtc-trade-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid #444;
}
.dtc-view.stats-expanded .dtc-trade-footer {
  flex: 1 1 0;
  min-height: 0;
}
.dtc-view.stats-expanded .dtc-analysis {
  flex: 0 0 0;
  overflow: hidden;
  visibility: hidden;
}

/* Статстрока — под таблицей сделок */
.dtc-stat-row {
  flex: 0 0 var(--stat-row-h);
  height: var(--stat-row-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chart-bg);
  border-top: 1px solid #2a2a2a;
}
.dtc-stat-row-inner {
  display: flex;
  align-items: center;
  max-width: 100%;
  padding: 0 6px;
}
.dtc-stat-reset {
  flex-shrink: 0;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  font: normal 8pt/1 system-ui, sans-serif;
  padding: 1px 3px;
  height: 18px;
  cursor: pointer;
}
.dtc-stat-reset:active { border-color: #888; }
.dtc-stat-blocks {
  margin-left: 0.45em;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dtc-stat-gap { display: inline-block; width: 0.45em; }
.dtc-stat-blocks .stat-n,
.dtc-stat-blocks .stat-wr { color: #888; }
.dtc-stat-blocks .stat-pl-pos { color: #0f0; }
.dtc-stat-blocks .stat-pl-neg { color: #f00; }

.chart-area { flex: 1; min-height: 0; position: relative; overflow: hidden; background: var(--chart-bg); }
#wormCanvas { display: block; width: 100%; height: 100%; }

/* debug-тиков: не ломает пропорции (лента уже в canvas) */
.tick-stream {
  flex: 0 0 0; height: 0; overflow: hidden; opacity: 0; pointer-events: none;
}

/* Оси + Идентификатор — вертикально 50/50 */
.dtc-analysis {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 2px 2px 0;
}
.bot-slot {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  border: 1px solid #333; background: var(--chart-bg);
}
.bot-slot-head {
  font: 600 9px/1.2 system-ui, sans-serif; color: var(--slot-head-fg);
  padding: 3px 6px; background: var(--slot-head-bg); flex-shrink: 0;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.bot-osi .bot-slot-head,
.bot-id .bot-slot-head {
  text-align: center;
}
.bot-slot-body { flex: 1; min-height: 0; overflow: hidden; padding: 0; position: relative; }
.bot-canvas { display: block; width: 100%; height: 100%; }

.trade-table {
  width: 100%; border-collapse: collapse; font-size: 10px;
}
.trade-table th, .trade-table td {
  padding: 2px 4px; border-bottom: 1px solid #222; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 72px;
}
.trade-table th { color: #666; font-weight: 600; background: var(--chart-bg); position: sticky; top: 0; }
.trade-table .pl-pos { color: #6f6; }
.trade-table .pl-neg { color: #f66; }

/* Таблица сделок — только нижняя панель (не перекрывает червя) */
.trade-stats-drawer {
  position: relative;
  display: flex; flex-direction: column;
  flex: 0 0 auto;
  height: var(--stats-collapsed-h);
  background: var(--chart-bg);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.45);
  transition: flex 0.22s ease, height 0.22s ease;
  overflow: hidden;
  min-height: 0;
}
.trade-stats-drawer:not(.expanded) {
  box-shadow: none;
}
.trade-stats-drawer.expanded {
  flex: 1 1 0;
  height: auto;
}

.stats-shutter {
  flex-shrink: 0;
  width: 100%;
  height: auto;
  min-height: 14px;
  padding: 3px 6px;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--slot-head-border);
  border-radius: 0;
  font: 600 9px/1.2 system-ui, sans-serif;
  font-size: 11px;
  line-height: 1;
  font-weight: bold;
  text-transform: none;
  letter-spacing: normal;
  text-align: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: var(--slot-head-bg);
  color: var(--slot-head-fg);
}
.stats-shutter:hover {
  background: var(--slot-head-bg);
  color: #999;
}
.trade-stats-drawer.expanded .stats-shutter,
.trade-stats-drawer:not(.expanded) .stats-shutter {
  background: var(--slot-head-bg);
  color: var(--slot-head-fg);
}

.trade-stats-body {
  flex: 1; min-height: 0; overflow: auto;
  font-size: 11px; padding: 4px 8px; color: var(--muted);
}

/* MC settings — стиль как у Панели настроек DTC (#panel-settings) */
#view-mc-settings,
#view-hotkeys {
  background: #252525;
}
.hotkeys-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px;
  font-size: 12px;
  color: #ddd;
}
.hotkeys-table th,
.hotkeys-table td {
  border: 1px solid #444;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.hotkeys-table th {
  background: #333;
  color: #fff;
  font-weight: 600;
}
.hotkeys-table kbd {
  display: inline-block;
  min-width: 1.2em;
  padding: 1px 6px;
  border: 1px solid #666;
  border-radius: 3px;
  background: #1a1a1a;
  color: #9cf;
  font-family: Consolas, monospace;
  font-size: 11px;
}
.mc-settings-scroll {
  flex: 1; overflow: auto; padding: 6px 10px 16px; min-height: 0;
  background: #252525;
}
.mc-settings-title {
  margin: 4px 0 8px; font-size: 11px; font-weight: bold; color: #fff;
  text-align: center;
}
.mc-sec, .mc-subsec {
  margin-bottom: 4px; border: none; background: transparent;
}
.mc-sec > summary, .mc-subsec > summary {
  cursor: pointer; list-style: none; padding: 5px 8px;
  background: #444; color: #fff; font-weight: normal; font-size: 11px;
  border: 1px solid #555; user-select: none;
}
.mc-sec > summary:hover, .mc-subsec > summary:hover { background: #505050; }
.mc-sec > summary::-webkit-details-marker,
.mc-subsec > summary::-webkit-details-marker { display: none; }
.mc-sec-body { padding: 4px 0 6px; background: transparent; }
.mc-subsec { margin: 6px 0 0; }
.mc-subsec > summary { background: #444; font-size: 11px; }
.mc-hint { margin: 4px 0 0; font-size: 10px; color: #888; line-height: 1.35; }
.mc-cz-vars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
  margin-top: 4px;
}
.mc-info { font-size: 11px; color: #888; margin-bottom: 6px; }
.mc-reload { width: 100%; margin-top: 4px; font-size: 11px; }
.mc-settings-close {
  width: 100%; margin-top: 12px; padding: 8px;
  background: #333; border: 1px solid #555; color: #fff;
}
#view-mc-settings .field label { color: #fff; font-size: 11px; }
#view-mc-settings .field input,
#view-mc-settings .field select {
  width: 100%; height: 24px; padding: 2px 6px; box-sizing: border-box;
  background: #333; color: #fff; border: 1px solid #555; border-radius: 0; font-size: 11px;
}

.field { margin-bottom: 8px; }
.field label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.trade-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 10px; }
.trade-btns .buy { background: #1a4d2e; border-color: var(--buy); font-weight: 600; }
.trade-btns .sell { background: #4d1a1a; border-color: var(--sell); font-weight: 600; }

.settings-trade-block {
  margin: 6px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #444;
}

.expiry-block {
  margin: 8px 0 4px;
  padding: 8px;
  background: #1e1e28;
  border: 1px solid #444;
  border-radius: 4px;
}
.expiry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.expiry-title { font-size: 11px; color: #fff; font-weight: 600; }
.expiry-summary { font-size: 10px; color: #9ab; }
.expiry-units {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 6px;
}
.expiry-unit {
  padding: 4px 2px;
  font-size: 10px;
  background: #333;
  border: 2px solid #555;
  color: #ccc;
  cursor: pointer;
}
.expiry-unit.active {
  color: #fff;
  border-color: #777;
  background: #3a3a42;
}
.expiry-unit.ind-ok {
  border-color: var(--buy);
  color: #dfe;
  box-shadow: 0 0 0 1px rgba(46, 204, 113, 0.25);
}
.expiry-unit.ind-err {
  border-color: var(--sell);
  color: #fdd;
  box-shadow: 0 0 0 1px rgba(231, 76, 60, 0.25);
}
.expiry-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 6px;
}
.expiry-mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  font-size: 12px;
  background: #333;
  border: 1px solid #555;
  color: #aaa;
  cursor: pointer;
}
.expiry-mode-btn:hover { background: #3a3a3a; color: #ccc; }
.expiry-mode-btn.active {
  background: #333;
  color: #ddd;
  border-color: #555;
}
.expiry-mode-icon {
  display: block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  font-size: 12px;
  color: inherit;
}
.expiry-mode-btn svg.expiry-mode-icon { width: 13px; height: 13px; }
.expiry-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.expiry-preset {
  padding: 5px 2px;
  font-size: 10px;
  background: #333;
  border: 1px solid #555;
  color: #ddd;
  cursor: pointer;
}
.expiry-preset.active { background: #eee; color: #111; font-weight: 600; }
.expiry-preset.disabled { opacity: 0.35; pointer-events: none; }
.expiry-presets.hidden { display: none; }
.expiry-manual.hidden { display: none; }
.expiry-range { font-size: 10px; color: #888; margin-top: 4px; }

/* ── DTC Settings panel (desktop parity) ── */
.panel-settings {
  background: #252525;
  border-left: 1px solid #444;
  overflow-y: auto;
  overflow-x: hidden;
}
.panel-settings .panel-head { display: none; }
.settings-titlebar {
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0 8px;
}
.settings-mode-cap {
  flex-shrink: 0;
}
.settings-mode-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 5.5rem;
  height: 22px;
  padding: 0 2px;
  background: #333;
  color: #fff;
  border: 1px solid #555;
  font-size: 11px;
  border-radius: 0;
  text-align: center;
}
.settings-body {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  padding: 6px 10px 0;
  gap: 0;
}
.settings-bot-name {
  text-align: center; font-weight: bold; font-size: 11px;
  color: #fff; margin: 4px 0 8px;
}
.settings-lbl {
  display: block; font-size: 11px; color: #fff;
  margin: 6px 0 2px; font-weight: normal;
}
.settings-section-h {
  font-size: 11px; color: #fff; font-weight: bold;
  margin: 8px 0 2px;
}
.settings-row {
  width: 100%; height: 24px; padding: 2px 6px;
  background: #333; color: #fff; border: 1px solid #555;
  font-size: 11px; border-radius: 0;
}
.settings-dd {
  margin: 0 0 4px; border: none;
}
.settings-dd > summary {
  cursor: pointer; list-style: none;
  background: #444; color: #fff; font-size: 11px;
  padding: 5px 8px; border: 1px solid #555;
  user-select: none;
}
.settings-dd > summary:hover { background: #505050; }
.settings-dd > summary::-webkit-details-marker { display: none; }
.settings-dd-body {
  padding: 4px 0 6px; background: transparent;
}
.settings-dd-body .check-row {
  font-size: 11px; color: #ddd; margin: 3px 0;
  display: flex; align-items: center; justify-content: flex-start;
  gap: 6px; padding: 0; width: 100%; box-sizing: border-box;
}
.api-keys-body { display: flex; flex-direction: column; gap: 8px; }
.api-key-row { display: flex; flex-direction: column; gap: 3px; }
.api-key-row > label { font-size: 11px; color: #fff; display: flex; justify-content: space-between; align-items: center; }
.api-key-row input {
  width: 100%; box-sizing: border-box; font-size: 11px; padding: 3px 5px;
  background: #1b1f27; border: 1px solid #3a4150; color: #eee; border-radius: 3px;
}
.api-key-btns { display: flex; gap: 4px; }
.api-key-btns button {
  flex: 1; font-size: 10px; padding: 3px 4px; cursor: pointer;
  background: #2a3140; border: 1px solid #3a4150; color: #ddd; border-radius: 3px;
}
.api-key-btns button:hover { background: #353d4e; }
.api-key-state { font-size: 10px; color: #888; }
.api-key-state.on { color: #5bd58a; }
.api-key-hint { font-size: 10px; color: #888; line-height: 1.3; }
.settings-payout {
  font-size: 11px; color: #ccc; margin: 6px 0 2px;
}
.panel-settings .check-row,
#view-mc-settings .check-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin: 4px 0;
  padding: 0;
  padding-left: 0;
  font-size: 11px;
  color: #fff;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}
#view-mc-settings .mc-sec-body {
  padding: 4px 0 6px;
}
#view-mc-settings .check-row {
  color: #ddd;
}
#view-mc-settings .mc-cz-vars .check-row {
  margin: 2px 0;
}
.panel-settings .check-row input[type="checkbox"],
#view-mc-settings .check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  accent-color: #fff;
  width: 14px;
  height: 14px;
  margin: 0;
  margin-left: 0;
  flex-shrink: 0;
  box-sizing: border-box;
  border: 1px solid #888;
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  position: relative;
}
.panel-settings .check-row input[type="checkbox"]:checked,
#view-mc-settings .check-row input[type="checkbox"]:checked {
  background: #fff;
  border-color: #888;
}
.panel-settings .check-row input[type="checkbox"]:checked::after,
#view-mc-settings .check-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #222;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.panel-settings .check-row input[type="checkbox"]:disabled,
#view-mc-settings .check-row input[type="checkbox"]:disabled {
  opacity: 0.45;
  cursor: default;
}
.settings-import-ta {
  width: 100%; font: 10px monospace;
  background: #1a1a1a; color: #aaa; border: 1px solid #444;
  padding: 4px; margin-bottom: 6px; resize: vertical;
}
.settings-more { margin-top: 4px; }
.settings-spacer { flex: 1; min-height: 8px; }
.media-ctrl-row {
  display: flex;
  gap: 4px;
  align-items: stretch;
  margin-bottom: 4px;
}
.media-ctrl-row .settings-row {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}
.media-btn {
  flex-shrink: 0;
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid #555;
  border-radius: 3px;
  background: #333;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}
.media-btn-add { color: lime; }
.media-btn-del { color: #f66; }

#overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
#overlay.hidden { display: none; }
.login-box {
  background: #222; border: 1px solid #444; padding: 20px;
  width: 420px; max-width: 94vw; border-radius: 4px;
}
.login-box h2 { margin: 0 0 12px; font-size: 16px; }
.login-box p { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.check-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin: 4px 0;
  font-size: 12px;
  text-align: left;
}

/* ── Паспорт сделки ── */
.trade-row-closed { cursor: pointer; }
.trade-row-closed:hover { background: #1a2430; }
.passport-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.passport-overlay.hidden { display: none; }
.passport-dialog {
  display: flex; gap: 12px;
  width: min(980px, 96vw); height: min(720px, 92vh);
  background: #151515; color: #ddd;
  border: 1px solid #333; border-radius: 4px;
  padding: 12px; box-sizing: border-box;
}
.passport-left {
  width: 280px; flex-shrink: 0;
  background: #1e1e1e; border: 1px solid #333; border-radius: 4px;
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
  overflow: auto;
}
.passport-asset { font-size: 13px; word-break: break-word; }
.passport-grid {
  display: grid; grid-template-columns: 88px 1fr; gap: 4px 8px;
  font-size: 12px; margin-top: 4px;
}
.passport-grid .pp-k { color: #888; }
.passport-grid .pp-v { color: #ccc; word-break: break-word; }
.passport-close {
  margin-top: auto; background: #333; color: #fff; border: 0;
  padding: 8px; font-weight: bold; cursor: pointer;
}
.passport-close:hover { background: #444; }
.passport-right {
  flex: 1; min-width: 0; overflow: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.passport-sec-title { font-size: 12px; font-weight: bold; color: #ccc; }
.passport-chart-wrap { height: 220px; background: #000; border: 1px solid #222; }
.passport-tape-wrap { height: 36px; background: #111; border: 1px solid #222; }
.passport-axes-wrap { height: 120px; background: #000; border: 1px solid #222; }
.passport-bw-wrap { height: 140px; background: #161616; border: 1px solid #222; }
.passport-chart-wrap canvas,
.passport-tape-wrap canvas,
.passport-axes-wrap canvas,
.passport-bw-wrap canvas { display: block; width: 100%; height: 100%; }
