/* ===== Торговый терминал: тёмная тема ===== */

:root {
  --t-bg:     #0c0c0c;
  --t-panel:  #141414;
  --t-tile:   #1b1b1b;
  --t-tile-2: #242424;
  --t-line:   #1f1f1f;
  --t-text:   #e8e8e8;
  --t-mute:   #8a8a8a;
  --t-green:  #23c45f;
  --t-red:    #e5484d;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body.terminal {
  background: var(--t-bg);
  color: var(--t-text);
  font-size: 14px;
}

.app {
  display: flex;
  height: 100vh;
  min-height: 0;
}

/* --- Левая панель иконок --- */

.rail {
  flex: 0 0 78px;
  background: var(--t-panel);
  border-right: 1px solid var(--t-line);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top: 8px;
}

.rail__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  color: var(--t-text);
}

.rail__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  background: transparent;
  border: 0;
  color: var(--t-mute);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.rail__item:hover { color: var(--t-text); }

.rail__item.is-active {
  color: #fff;
  background: #1b1b1b;
}

.rail__item svg { width: 22px; height: 22px; }

/* Кнопка выхода: заметная и всегда первая, чтобы её не искали. */
.rail__exit {
  margin: 4px 8px 10px;
  border-radius: 10px;
  background: #242424;
  color: var(--t-text);
  text-decoration: none;
}

.rail__exit:hover { background: #0d63d1; color: #fff; }

.rail__spacer { flex: 1; }

.rail__back {
  padding: 14px 4px;
  font-size: 11px;
  color: var(--t-mute);
  text-align: center;
}

.rail__back:hover { color: var(--t-text); }

/* --- Верхняя панель --- */

.topbar {
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--t-panel);
  border-bottom: 1px solid var(--t-line);
}

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

.mode {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--t-mute);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.mode:hover { color: var(--t-text); }

.mode.is-active { background: var(--t-tile-2); color: #fff; }

.mode__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--t-green);
}

.topbar__spacer { flex: 1; }

.balance {
  text-align: right;
  line-height: 1.2;
  margin-right: 6px;
}

.balance__value { font-size: 17px; }

.balance__label {
  font-size: 11px;
  color: var(--t-mute);
}

.btn-pay {
  padding: 11px 24px;
  border: 0;
  border-radius: 8px;
  background: var(--t-green);
  color: #052915;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-pay:hover { background: #1fae54; }

.avatar {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--t-tile-2);
  color: #cfcfcf;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Рабочая область --- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.chartcol {
  flex: 1;
  position: relative;
  min-width: 0;
}

#chart {
  display: block;
  width: 100%;
  height: 100%;
}

.assetbar {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-add,
.tool {
  border: 0;
  border-radius: 10px;
  background: var(--t-tile);
  color: var(--t-text);
  font: inherit;
  cursor: pointer;
}

.asset-add {
  width: 38px;
  height: 38px;
  font-size: 22px;
  line-height: 1;
}

.asset-add:hover,
.tool:hover { background: var(--t-tile-2); }

.asset-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--t-tile);
  color: var(--t-text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.asset-chip:hover { background: var(--t-tile-2); }

.asset-menu {
  position: absolute;
  top: 48px;
  left: 0;
  z-index: 6;
  width: 266px;
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  background: #1b1b1b;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

.asset-menu[hidden] { display: none; }

.asset-menu__head {
  padding: 8px 10px 4px;
  font-size: 11px;
  color: var(--t-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.asset-menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--t-text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.asset-menu__item:hover { background: var(--t-tile-2); }
.asset-menu__item.is-active { background: #2c2c2c; }

.asset-menu__name { flex: 1; }

.asset-menu__payout { color: var(--t-green); font-size: 13px; }

.asset-chip__icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f3ba2f;
  color: #1c1300;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset-chip__payout { color: var(--t-green); }

/* Панель рисования у левого края — как в торговых терминалах. */
.draw-tools {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px;
  border-radius: 12px;
  background: rgba(24, 24, 24, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.tool--draw {
  width: 34px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: #9a9a9a;
}

.tool--draw:hover { background: var(--t-tile-2); color: var(--t-text); }

.tool--draw.is-on {
  background: #0d63d1;
  color: #fff;
}

.tool--draw svg { width: 17px; height: 17px; }

.draw-tools__sep {
  height: 1px;
  margin: 3px 4px;
  background: #333;
}

.chart-tools {
  position: absolute;
  left: 56px;
  bottom: 58px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool {
  width: 44px;
  height: 40px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool svg { width: 18px; height: 18px; }

.tool.is-on {
  background: var(--t-blue, #0d63d1);
  color: #fff;
}

/* --- Выпадающие меню панели: тип графика и индикаторы --- */

.tool-wrap { position: relative; }

.tool-menu {
  position: absolute;
  left: 52px;
  bottom: 0;
  z-index: 6;
  min-width: 210px;
  padding: 6px;
  border-radius: 12px;
  background: #1b1b1b;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

.tool-menu[hidden] { display: none; }

.tool-menu__head {
  padding: 8px 10px 4px;
  font-size: 11px;
  color: var(--t-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tool-menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--t-text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.tool-menu__item:hover { background: var(--t-tile-2); }

/* Кружок с цветом линии индикатора. */
.tool-menu__item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

/* Включённый пункт помечается галочкой справа. */
.tool-menu__item.is-on { background: #2c2c2c; }
.tool-menu__item.is-on::after {
  content: "✓";
  margin-left: auto;
  color: var(--t-green);
  font-size: 13px;
}

@media (max-width: 900px) {
  .tool-menu { left: auto; right: 0; bottom: 48px; }
}

.zoom {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 20px;
  background: var(--t-tile);
}

.zoom button {
  width: 34px;
  height: 30px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--t-text);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.zoom button:hover { background: var(--t-tile-2); }

.ticks {
  position: absolute;
  left: 56px;
  bottom: 14px;
  z-index: 3;
  font-size: 12px;
  color: #4d4d4d;
}

/* --- Правая панель сделки --- */

.panel {
  flex: 0 0 300px;
  background: var(--t-bg);
  border-left: 1px solid var(--t-line);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: var(--t-tile);
}

.field__body {
  flex: 1;
  text-align: center;
  line-height: 1.25;
}

.field__label {
  font-size: 11px;
  color: var(--t-mute);
}

.field__value { font-size: 18px; }

.step {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 0;
  border-radius: 50%;
  background: var(--t-tile-2);
  color: var(--t-text);
  font: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.step:hover { background: #303030; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px;
  border-radius: 12px;
  background: var(--t-tile);
  color: var(--t-mute);
  font-size: 14px;
}

.toggle-row.is-on { color: var(--t-text); }

.hint {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--t-tile-2);
  color: var(--t-mute);
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
}

.switch {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: #3a3a3a;
  transition: background 0.18s;
  pointer-events: none;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #cfcfcf;
  transition: transform 0.18s, background 0.18s;
}

.switch input:checked + .switch__track { background: #1f6f3c; }
.switch input:checked + .switch__track::after {
  transform: translateX(20px);
  background: var(--t-green);
}

.btn-trade {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-trade:hover { filter: brightness(1.1); }
.btn-trade:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.btn-up   { background: var(--t-green); }
.btn-down { background: var(--t-red); }

.profit {
  text-align: center;
  font-size: 12px;
  color: var(--t-mute);
  margin: 2px 0 0;
}

.profit strong {
  display: block;
  font-size: 14px;
  color: var(--t-green);
  font-weight: 600;
}

.panel__note {
  margin-top: auto;
  font-size: 11px;
  color: #5a5a5a;
  text-align: center;
  line-height: 1.4;
}

/* --- Выдвижная панель сделок --- */

.drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 290px;
  z-index: 10;
  padding: 16px;
  background: var(--t-panel);
  border-right: 1px solid var(--t-line);
  overflow-y: auto;
  transform: translateX(-102%);
  transition: transform 0.22s ease;
}

.drawer.is-open {
  transform: none;
  box-shadow: 14px 0 28px rgba(0, 0, 0, 0.45);
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.drawer__title { font-size: 15px; }

.drawer__close {
  border: 0;
  background: transparent;
  color: var(--t-mute);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.trade {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--t-tile);
  border-left: 3px solid var(--t-mute);
  font-size: 13px;
}

.trade--up   { border-left-color: var(--t-green); }
.trade--down { border-left-color: var(--t-red); }

.trade__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--t-mute);
  font-size: 12px;
}

.trade__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  color: var(--t-text);
}

.trade__result--win  { color: var(--t-green); }
.trade__result--lose { color: var(--t-red); }
.trade__result--open { color: #d7b64a; }

.drawer__empty {
  color: var(--t-mute);
  font-size: 13px;
}

.drawer__reset {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--t-line);
  border-radius: 10px;
  background: transparent;
  color: var(--t-mute);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.drawer__reset:hover { color: var(--t-text); border-color: #333; }

/* --- Всплывающие уведомления --- */

.toasts {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 9px 18px;
  border-radius: 10px;
  background: #1f1f1f;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.2s ease;
}

.toast--win  { color: var(--t-green); }
.toast--lose { color: var(--t-red); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* --- Адаптив --- */

@media (max-width: 900px) {
  html, body { overflow: auto; }

  .app { height: auto; min-height: 100vh; }

  .rail {
    flex-basis: 60px;
  }

  .rail__item { font-size: 10px; padding: 10px 2px; }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    flex-basis: auto;
    padding: 10px;
    gap: 8px;
  }

  .modes { order: 3; width: 100%; overflow-x: auto; }

  .workspace { flex-direction: column; }

  .chartcol { height: 60vh; flex: none; }

  /* На телефоне панель рисования ложится горизонтально под шапкой графика. */
  .draw-tools {
    top: auto;
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    flex-direction: row;
    overflow-x: auto;
  }

  .draw-tools__sep { width: 1px; height: auto; margin: 4px 3px; }

  .chart-tools { left: 10px; bottom: 56px; flex-direction: row; }
  .ticks { display: none; }
  .zoom { bottom: 56px; }

  .panel {
    flex: none;
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--t-line);
  }

  .drawer { width: 82%; }
}
