:root {
  color-scheme: dark;
  --bg: #10110f;
  --panel: #181a17;
  --panel-2: #20231f;
  --line: #34392f;
  --text: #edf2ea;
  --muted: #9da795;
  --good: #24b47e;
  --bad: #ef5350;
  --warn: #f4b942;
  --accent: #62c6a5;
  --accent-2: #d7b85a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1080px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  display: grid;
  grid-template-columns: 1.15fr 1.35fr 0.72fr 0.95fr 1.65fr 0.75fr 0.9fr 0.9fr 1.1fr 1fr 1.35fr auto auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #141611;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand strong {
  font-size: 17px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  background: #0f120f;
  color: var(--text);
  padding: 6px 8px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
}

button,
.button-link {
  text-decoration: none;
}

button:hover {
  border-color: var(--accent);
}

.button-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 10px;
}

.button-link:hover {
  border-color: var(--accent);
}

button.primary {
  border-color: #2d8d6f;
  background: #1d6f58;
  color: white;
  font-weight: 700;
}

.ghost-button {
  width: fit-content;
  min-height: 26px;
  padding: 3px 8px;
  font-size: 12px;
  background: transparent;
}

button:disabled {
  cursor: progress;
  opacity: 0.55;
}

.toggles {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-self: center;
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.check input {
  width: auto;
  min-height: auto;
}

.server-key {
  min-height: 34px;
  display: flex;
  align-items: center;
  align-self: end;
  border: 1px solid var(--line);
  background: #11130f;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 12px;
}

.server-key.configured {
  color: var(--good);
  border-color: #23684f;
}

.server-key.missing {
  color: var(--warn);
}

.hidden {
  display: none;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(700px, 1fr) 440px;
  gap: 12px;
  padding: 12px;
}

.chart-pane,
.side {
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.chart-pane {
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.symbol {
  font-size: 19px;
  font-weight: 800;
}

.signal {
  min-width: 86px;
  text-align: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: #24251d;
  color: var(--warn);
  font-weight: 800;
}

.signal.long {
  color: var(--good);
}

.signal.short {
  color: var(--bad);
}

.signal.watch {
  color: var(--warn);
}

.signal.blocked {
  color: var(--bad);
}

#chart {
  position: absolute;
  inset: 0;
}

#chartWrap {
  position: relative;
  min-height: 620px;
  overflow: hidden;
}

#drawingLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

#drawingLayer.active {
  cursor: crosshair;
  pointer-events: auto;
}

#drawingLayer.selecting {
  cursor: default;
  pointer-events: auto;
}

.chart-tools {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #12150f;
  overflow-x: auto;
}

.chart-tool {
  min-width: 34px;
  min-height: 28px;
  padding: 4px 7px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.chart-tool.active {
  border-color: var(--accent);
  background: #1d6f58;
  color: #fff;
}

.tool-color {
  width: 34px;
  min-height: 28px;
  padding: 2px;
}

.tool-select {
  width: 62px;
  min-height: 28px;
  padding: 3px 6px;
  font-size: 11px;
}

.tool-toggle {
  min-height: 28px;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #11130f;
  padding: 4px 7px;
  white-space: nowrap;
}

.tool-toggle input {
  width: auto;
  min-height: auto;
}

.drawing-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.side {
  display: grid;
  grid-template-rows: auto 1fr;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: #151713;
  color: var(--muted);
}

.tab.active {
  color: var(--text);
  background: var(--panel-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.panel {
  min-height: 0;
  display: none;
  padding: 10px;
  overflow: auto;
}

.panel.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.metrics div {
  border: 1px solid var(--line);
  background: #11130f;
  padding: 8px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  color: #e8eee3;
}

.log-controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 10px;
}

.scan-controls {
  grid-template-columns: 1fr auto auto;
  align-items: end;
}

.live-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px auto auto auto auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}

.live-controls textarea {
  resize: vertical;
  min-height: 58px;
  font-family: Consolas, "Cascadia Mono", monospace;
}

.live-table {
  max-height: 190px;
}

#liveEventsText {
  margin-top: 10px;
  color: #dce5d5;
}

.section-title,
.live-group h3 {
  margin: 12px 0 7px;
  font-size: 13px;
  color: var(--text);
}

.live-groups {
  display: grid;
  gap: 10px;
}

.live-group {
  border: 1px solid var(--line);
  background: #11130f;
  padding: 8px;
}

.live-group h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0;
}

.live-group h3 span {
  color: var(--accent);
}

.ai-decisions {
  max-height: 220px;
}

.compact-table {
  max-height: 420px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  min-width: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  padding: 3px 6px;
  font-weight: 800;
}

.badge.long,
.badge.a,
.badge.b,
.badge.confirmed,
.badge.used,
.badge.pro,
.badge.trade,
.badge.ok {
  color: var(--good);
}

.badge.short,
.badge.wait,
.badge.error,
.badge.blocked,
.badge.blocked,
.badge.rejected,
.badge.toxic {
  color: var(--bad);
}

.badge.c,
.badge.running,
.badge.queued,
.badge.watch,
.badge.weak,
.badge.skipped,
.badge.cooldown {
  color: var(--warn);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  z-index: 1;
}

td {
  color: #dce5d5;
}

.status-success {
  color: var(--good);
}

.status-error {
  color: var(--bad);
}

.status-rate_limited {
  color: var(--warn);
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.settings-box {
  border: 1px solid var(--line);
  background: #11130f;
  padding: 10px;
}

.settings-box h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.login-body {
  min-width: 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(36, 180, 126, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(215, 184, 90, 0.12), transparent 36%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 22px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.login-brand strong {
  font-size: 24px;
}

.login-brand span {
  color: var(--muted);
  font-size: 12px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.account-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.account-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #141611;
}

.account-topbar > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-topbar strong {
  font-size: 20px;
}

.account-topbar span {
  color: var(--muted);
  font-size: 12px;
}

.account-actions,
.account-grid {
  display: flex;
  gap: 10px;
}

.account-grid {
  align-items: start;
  padding: 14px;
}

.account-grid > .settings-box {
  flex: 1 1 0;
  min-width: 360px;
}

@media (max-width: 1220px) {
  body {
    min-width: 0;
  }

  .toolbar,
  .workspace,
  .live-controls,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .account-grid {
    flex-direction: column;
  }

  .wide {
    grid-column: auto;
  }

  .workspace {
    min-height: auto;
  }

  #chartWrap {
    min-height: 480px;
  }
}
