:root {
  color-scheme: dark;
  --bg: #050806;
  --panel: #0b100d;
  --panel-2: #101812;
  --line: #22372a;
  --line-2: #33523e;
  --text: #d8f7dd;
  --muted: #86a58d;
  --green: #7cff8a;
  --cyan: #5eead4;
  --amber: #facc15;
  --red: #fb7185;
  --blue: #93c5fd;
  --shadow: 0 0 40px rgba(124, 255, 138, 0.08);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(124, 255, 138, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 255, 138, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 18% 0%, rgba(94, 234, 212, 0.09), transparent 28%),
    #050806;
  background-size: 28px 28px, 28px 28px, auto, auto;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.scanline {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035),
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: overlay;
  opacity: 0.26;
}

.shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.command-panel,
.auth-panel,
.metric-card,
.sidebar,
.terminal-window,
.footer {
  border: 1px solid var(--line);
  background: rgba(11, 16, 13, 0.88);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 14px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--green);
  color: var(--bg);
  background: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.eyebrow,
.metric-label,
.panel-title {
  margin: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3vw, 38px);
  line-height: 1;
  letter-spacing: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
}

.command-panel {
  margin-top: 14px;
  padding: 14px;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
}

.auth-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.auth-status[data-state="telegram"] {
  color: var(--green);
}

.auth-status[data-state="dev"] {
  color: var(--amber);
}

.auth-status[data-state="error"] {
  color: var(--red);
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.prompt-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line-2);
  background: #050806;
  padding: 0 12px;
}

.prompt {
  color: var(--cyan);
  white-space: nowrap;
}

#commandInput {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

button {
  min-height: 36px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background: #0d1711;
  color: var(--green);
  cursor: pointer;
  padding: 0 12px;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

button:hover {
  border-color: var(--green);
  background: rgba(124, 255, 138, 0.09);
  color: var(--text);
}

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

code {
  color: var(--cyan);
  font: inherit;
  word-break: break-word;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric-card {
  min-height: 110px;
  padding: 15px;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(20px, 3vw, 32px);
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.live-monitor {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
  margin-top: 14px;
}

.monitor-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.monitor-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.monitor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  border: 1px solid var(--line-2);
  background: #050806;
  color: var(--muted);
  padding: 0 10px;
  text-transform: none;
}

.check-control input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}

.account-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.account-summary div {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 14px;
}

.account-summary div:last-child {
  border-right: 0;
}

.account-summary div.is-bad strong {
  color: var(--red);
}

.account-summary span,
.kv-row small {
  color: var(--muted);
  font-size: 11px;
}

.account-summary strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.compact-table table {
  min-width: 680px;
}

.source-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line-2);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

.source-status.ok {
  color: var(--green);
}

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

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

.live-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.kv-list {
  display: grid;
  max-height: 360px;
  overflow: auto;
}

.kv-row,
.empty-state {
  display: grid;
  gap: 7px;
  min-height: 64px;
  border-bottom: 1px solid rgba(51, 82, 62, 0.58);
  padding: 12px;
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-row strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
}

.kv-row small {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.kv-row.is-bad strong,
.kv-row.is-bad small {
  color: var(--red);
}

.empty-state {
  color: var(--muted);
  font-size: 12px;
}

.json-preview {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  margin-top: 14px;
}

.sidebar {
  align-self: start;
  padding: 14px;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 38px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background: #050806;
  color: var(--text);
  padding: 0 10px;
}

input[type="range"] {
  accent-color: var(--green);
}

.range-value {
  color: var(--green);
}

.divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line);
}

.mini-log {
  display: grid;
  gap: 8px;
  min-height: 180px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mini-log div::before {
  color: var(--green);
  content: "> ";
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 14px;
  min-width: 0;
}

.terminal-window {
  min-width: 0;
  overflow: hidden;
}

.window-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--cyan);
  padding: 0 12px;
  font-size: 12px;
}

.window-controls {
  color: var(--muted);
  font-size: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid rgba(51, 82, 62, 0.58);
  padding: 14px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  color: var(--text);
  font-size: 13px;
}

.market-name {
  display: grid;
  gap: 4px;
}

.market-name small {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line-2);
  padding: 0 8px;
  color: var(--cyan);
}

.badge.arbitrage {
  color: var(--green);
}

.badge.copy {
  color: var(--blue);
}

.badge.referral {
  color: var(--amber);
}

.edge-positive {
  color: var(--green);
}

.edge-watch {
  color: var(--amber);
}

.right-stack {
  display: grid;
  gap: 14px;
}

.leader-list {
  display: grid;
}

.leader-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border-bottom: 1px solid rgba(51, 82, 62, 0.58);
  padding: 13px 12px;
}

.leader-row:last-child {
  border-bottom: 0;
}

.leader-row strong {
  display: block;
  font-size: 13px;
}

.leader-row small {
  color: var(--muted);
}

.leader-pnl {
  color: var(--green);
  font-weight: 700;
  text-align: right;
}

.routes {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  list-style: none;
}

.routes li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.routes span {
  color: var(--green);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-monitor,
  .live-detail-grid {
    grid-template-columns: 1fr;
  }

  .workspace,
  .main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-actions {
    justify-content: flex-start;
  }

  .monitor-toolbar {
    flex-direction: column;
  }

  .monitor-actions {
    justify-content: flex-start;
  }

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

  .account-summary div:nth-child(2) {
    border-right: 0;
  }

  .account-summary div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .status-strip {
    justify-content: flex-start;
  }

  .prompt-line {
    grid-template-columns: 1fr;
    padding: 10px;
  }

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