:root {
  color-scheme: dark;
  --sidebar-w: clamp(214px, 14.2vw, 244px);
  --right-col: clamp(320px, 23vw, 380px);
  --gap: clamp(8px, 0.75vw, 12px);
  --bg: #02070d;
  --panel: rgba(6, 20, 32, 0.86);
  --panel-strong: rgba(8, 27, 43, 0.96);
  --line: rgba(76, 173, 255, 0.18);
  --line-strong: rgba(40, 137, 255, 0.78);
  --blue: #1268ff;
  --cyan: #04c8ff;
  --green: #33d66b;
  --orange: #ffb02e;
  --pink: #c874ff;
  --red: #ff4f69;
  --text: #f5f8ff;
  --muted: #93a4b9;
  --shadow: 0 0 28px rgba(20, 116, 255, 0.24);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(24, 120, 255, 0.12), transparent 28rem),
    linear-gradient(180deg, #02070d 0%, #04111d 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

h1,
h2,
h3,
h4,
button,
strong,
th {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 600;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--gap);
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  padding: var(--gap);
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: var(--gap);
  height: calc(100vh - (var(--gap) * 2));
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(4, 16, 27, 0.9);
  box-shadow: inset 0 0 26px rgba(20, 173, 255, 0.04);
}

.brand {
  text-align: center;
  padding: 2px 0 clamp(46px, 5.2vh, 66px);
}

.brand img {
  width: clamp(86px, 7.4vw, 116px);
  height: clamp(86px, 7.4vw, 116px);
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 1.55vw, 25px);
  line-height: 1.04;
}

.brand p {
  margin: 3px 0 0;
  color: var(--cyan);
  font-weight: 700;
}

.side-block,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.side-block {
  padding: 10px;
  margin-bottom: 9px;
}

.side-title {
  font-size: 13px;
  margin-bottom: 7px;
  color: #d9e5f5;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid rgba(136, 178, 215, 0.24);
  background: rgba(2, 11, 20, 0.72);
  color: var(--text);
  border-radius: 6px;
  outline: none;
}

.input,
.select {
  height: 36px;
  padding: 0 10px;
}

.textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  align-items: center;
}

.primary,
.ghost,
.danger {
  height: 38px;
  border-radius: 6px;
  border: 1px solid rgba(74, 158, 255, 0.45);
  color: var(--text);
  background: rgba(9, 33, 54, 0.9);
}

.primary {
  width: 100%;
  background: linear-gradient(180deg, #1268ff, #0850df);
  border-color: rgba(74, 174, 255, 0.85);
  box-shadow: 0 0 18px rgba(18, 104, 255, 0.28);
  font-weight: 700;
}

.danger {
  width: 100%;
  border-color: rgba(255, 79, 105, 0.55);
  background: rgba(84, 18, 32, 0.82);
}

.ghost {
  padding: 0 12px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  border: 1px solid rgba(33, 119, 255, 0.52);
  border-radius: 6px;
  background: rgba(6, 54, 115, 0.52);
  color: var(--text);
  text-decoration: none;
}

.status-pill {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(51, 214, 107, 0.18);
  background: rgba(14, 58, 41, 0.33);
}

.status-pill.bad {
  border-color: rgba(255, 79, 105, 0.28);
  background: rgba(58, 14, 24, 0.33);
}

.status-pill strong {
  color: var(--green);
  font-size: 17px;
}

.status-pill.bad strong {
  color: var(--red);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--green);
  display: inline-block;
}

.dot.bad {
  background: var(--red);
}

.main {
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: grid;
  height: calc(100vh - (var(--gap) * 2));
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.top {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(142px, 180px) minmax(142px, 180px) var(--right-col);
  gap: var(--gap);
  align-items: stretch;
  min-width: 0;
}

.top-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(4, 15, 27, 0.82);
}

.top-title h2 {
  margin: 0;
  font-size: 22px;
}

.top-title p,
.muted {
  margin: 0;
  color: var(--muted);
}

.stat {
  padding: 12px 14px;
  min-height: 82px;
}

.stat span {
  display: block;
  color: var(--muted);
}

.stat strong {
  display: block;
  color: var(--green);
  font-size: clamp(21px, 1.45vw, 25px);
  line-height: 1.1;
}

.stat.locked strong {
  color: var(--orange);
}

.stat.error strong {
  color: var(--red);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--right-col);
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.left-stack {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--gap);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.panel {
  padding: clamp(10px, 0.8vw, 14px);
  min-width: 0;
}

.panel h3 {
  margin: 0 0 9px;
  font-size: clamp(16px, 1.05vw, 18px);
}

.subtitle {
  color: var(--muted);
  margin: -4px 0 10px;
  font-size: 13px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
  min-width: 0;
}

.channel,
.strategy-card,
.trade-button,
.percent-card,
.badge {
  border: 1px solid rgba(92, 151, 205, 0.22);
  background: rgba(3, 17, 29, 0.78);
  border-radius: var(--radius);
}

.channel,
.strategy-card {
  position: relative;
  text-align: left;
  color: var(--text);
}

.channel {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  min-height: 86px;
  padding: 12px 10px;
  overflow: hidden;
}

.channel-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--cyan);
  font-weight: 800;
  font-size: 17px;
}

.channel h4,
.strategy-card h4 {
  margin: 0 0 5px;
  font-size: clamp(12px, 0.82vw, 14px);
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.channel p,
.strategy-card p,
.status-small {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.selected {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  background: rgba(5, 35, 70, 0.9);
}

.channel.selected::after,
.strategy-card.selected::after {
  content: "OK";
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 10px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  padding: 2px 4px;
  background: var(--blue);
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.strategy-card {
  min-height: 0;
  height: clamp(94px, 11.4vh, 108px);
  padding: 8px 9px;
  overflow: hidden;
}

.strategy-card h4 {
  padding-right: 20px;
}

.strategy-heading {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  margin-bottom: 4px;
}

.strategy-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--cyan);
  border: 1px solid rgba(4, 200, 255, 0.34);
  background: rgba(4, 200, 255, 0.08);
  font-size: 10px;
  font-weight: 700;
}

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 6px;
  font-size: clamp(9.6px, 0.66vw, 11.2px);
  line-height: 1.1;
}

.kv span:nth-child(odd) {
  color: var(--muted);
}

.risk-low {
  color: var(--green);
}

.risk-mid {
  color: var(--orange);
}

.risk-high {
  color: var(--red);
}

.gain {
  color: var(--cyan);
}

.gain-high {
  color: var(--pink);
}

.recommended {
  position: absolute;
  top: -10px;
  right: 10px;
  color: #bfe5ff;
  font-size: 10px;
  background: rgba(18, 104, 255, 0.9);
  border: 1px solid rgba(125, 197, 255, 0.7);
  border-radius: 4px;
  padding: 2px 6px;
}

.right-stack {
  display: grid;
  gap: var(--gap);
  align-content: start;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.trade-button,
.percent-card {
  height: 40px;
  color: var(--text);
}

.percent-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.percent-card {
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 13px;
  padding: 5px;
}

.percent-card strong {
  display: block;
  font-size: 14px;
}

.percent-card:disabled {
  opacity: 0.38;
  box-shadow: none;
}

.cap-line {
  margin-top: 8px;
  font-size: 12px;
}

.api-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ready-badges {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.badge {
  height: 34px;
  min-width: 0;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(8.6px, 0.62vw, 10.2px);
  padding: 3px;
  overflow-wrap: normal;
  word-break: normal;
  white-space: normal;
  line-height: 1.05;
  overflow: hidden;
}

.trades-badge {
  white-space: nowrap;
  font-size: clamp(8.4px, 0.58vw, 9.8px);
}

.badge.ok {
  color: #dcffe8;
  border-color: rgba(51, 214, 107, 0.7);
  background: rgba(17, 93, 48, 0.76);
}

.start {
  height: 50px;
  font-size: clamp(16px, 1.05vw, 19px);
  background: linear-gradient(180deg, #31d66d, #149447);
  border-color: rgba(111, 255, 161, 0.85);
  box-shadow: 0 0 22px rgba(51, 214, 107, 0.28);
}

.info-box {
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #d9e5f5;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(3, 17, 29, 0.7);
  padding: 10px;
  font-size: 13px;
}

.start-infos {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: var(--gap);
}

.left-stack,
.dashboard-panel,
.strategy-table-panel,
.how-card {
  min-height: 0;
  overflow: hidden;
}

.strategy-table-panel {
  height: 100%;
  align-self: stretch;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.how-card {
  height: 100%;
  align-self: stretch;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.table-wrap {
  overflow-x: hidden;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(11.2px, 0.78vw, 13px);
  table-layout: fixed;
  height: 100%;
}

th,
td {
  border: 1px solid rgba(92, 151, 205, 0.18);
  padding: 5px 7px;
  text-align: center;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

th {
  color: #d9e5f5;
  font-weight: 600;
  background: rgba(3, 17, 29, 0.6);
}

td:nth-child(2),
th:nth-child(2) {
  text-align: left;
}

tr.active-row {
  background: rgba(18, 104, 255, 0.28);
  outline: 1px solid rgba(18, 104, 255, 0.62);
}

.steps {
  display: grid;
  gap: 5px;
  margin-top: 5px;
  align-content: start;
  min-height: 0;
}

.step {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.12;
}

.step span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 0 10px rgba(18, 104, 255, 0.42);
  font-size: 9.5px;
}

.step p {
  margin: 0;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 9px;
}

.small-link {
  border: 0;
  background: transparent;
  color: var(--cyan);
  padding: 0;
  font-size: 12px;
}

.warning {
  color: #d9e5f5;
  font-size: 12px;
  line-height: 1.45;
  border-left: 2px solid var(--orange);
  padding-left: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  padding: 20px;
}

.modal {
  width: min(560px, 100%);
  border: 1px solid rgba(51, 214, 107, 0.45);
  border-radius: var(--radius);
  background: #061422;
  padding: 20px;
  box-shadow: 0 0 44px rgba(51, 214, 107, 0.18);
}

.modal h3 {
  margin: 0 0 10px;
}

.log-list {
  display: grid;
  gap: 7px;
  max-height: 170px;
  overflow: auto;
}

.log-item {
  border: 1px solid rgba(92, 151, 205, 0.16);
  border-radius: 6px;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

.log-item strong {
  color: var(--text);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  border: 1px solid var(--line-strong);
  background: #061b2e;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .top {
    grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(130px, 1fr));
  }

  .content {
    grid-template-columns: 1fr;
  }

  .right-stack {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .right-stack > .panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .shell,
  .top {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .channel-grid,
  .strategy-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1500px) {
  .button-grid,
  .percent-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .ready-badges {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-height: 940px) and (min-width: 1181px) {
  :root {
    --gap: 8px;
    --sidebar-w: 214px;
    --right-col: 320px;
  }

  .sidebar {
    padding: 8px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .brand img {
    width: 68px;
    height: 68px;
    margin-bottom: 4px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .brand p,
  .muted,
  .warning {
    font-size: 11px;
  }

  .side-block {
    padding: 7px;
    margin-bottom: 6px;
  }

  .input,
  .select,
  .primary,
  .ghost,
  .danger,
  .link-button {
    height: 31px;
  }

  .field {
    gap: 3px;
    margin-bottom: 4px;
  }

  #auth-form + .row {
    margin-top: 5px !important;
  }

  .check-row,
  .small-link {
    font-size: 10px;
  }

  .side-block > div[style*="height:8px"] {
    height: 5px !important;
  }

  .status-pill {
    padding: 6px;
    gap: 2px;
    font-size: 11px;
  }

  .status-pill strong {
    font-size: 14px;
  }

  .side-block h2 {
    margin: 3px 0 !important;
    font-size: 19px;
  }

  .side-block p {
    margin-top: 2px;
    margin-bottom: 5px;
  }

  .top-title,
  .stat {
    min-height: 66px;
    padding: 9px 12px;
  }

  .stat strong {
    font-size: 19px;
  }

  .panel {
    padding: 8px;
  }

  .panel h3 {
    margin-bottom: 6px;
    font-size: 15px;
  }

  .subtitle {
    margin-bottom: 7px;
    font-size: 11px;
  }

  .channel-grid {
    gap: 6px;
    margin-bottom: 9px;
  }

  .channel {
    min-height: 66px;
    padding: 8px 7px;
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .channel-icon,
  .strategy-icon {
    width: 23px;
    height: 23px;
    font-size: 9px;
  }

  .channel h4,
  .strategy-card h4 {
    font-size: 11px;
    margin-bottom: 2px;
  }

  .channel p,
  .strategy-card p,
  .status-small {
    font-size: 10px;
  }

  .strategy-grid {
    gap: 6px;
  }

  .strategy-card {
    height: 90px;
    padding: 6px 7px;
  }

  .strategy-heading {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 5px;
    margin-bottom: 3px;
  }

  .kv {
    font-size: 9.5px;
    gap: 2px 5px;
  }

  .recommended {
    top: -7px;
    right: 7px;
    font-size: 9px;
    padding: 1px 4px;
  }

  .button-grid,
  .percent-grid,
  .ready-badges {
    gap: 5px;
  }

  .trade-button,
  .percent-card {
    height: 31px;
  }

  .badge {
    height: 30px;
    font-size: 8.4px;
  }

  .start {
    height: 41px;
  }

  .start-infos {
    margin-top: 8px;
    gap: 6px;
  }

  .info-box {
    min-height: 38px;
    padding: 7px;
    font-size: 11px;
  }

  .steps {
    gap: 5px;
  }

  .step {
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 6px;
    font-size: 10.5px;
  }

  .step span {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }

  table {
    font-size: 9.4px;
  }

  th,
  td {
    padding: 3px 4px;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 0;
  }

  .right-stack {
    grid-template-columns: 1fr;
  }

  .button-grid,
  .percent-grid,
  .ready-badges,
  .api-grid {
    grid-template-columns: 1fr 1fr;
  }

  .channel-grid,
  .strategy-grid {
    grid-template-columns: 1fr;
  }
}
