:root {
  color-scheme: dark;
  --bg: #080c0f;
  --panel: #10171c;
  --panel-2: #0c1216;
  --line: #243039;
  --text: #eff6f2;
  --muted: #91a19b;
  --green: #00d087;
  --green-soft: rgba(0, 208, 135, 0.14);
  --red: #ff5b64;
  --red-soft: rgba(255, 91, 100, 0.15);
  --amber: #eab84f;
  --blue: #4fb8ff;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand img {
  width: 42px;
  height: 42px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: 0;
}

.brand p,
.panel-head p,
small {
  color: var(--muted);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(98px, 1fr));
  gap: 10px;
}

.status-card,
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: var(--radius);
}

.status-card {
  min-height: 54px;
  padding: 9px 12px;
}

.status-card span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.status-card strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
}

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

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

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

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas:
    "metrics side"
    "ladder side";
  gap: 14px;
  margin-top: 16px;
}

.metrics {
  grid-area: metrics;
  display: grid;
  grid-template-columns: repeat(6, minmax(118px, 1fr));
  gap: 0;
  overflow: hidden;
}

.metric {
  min-height: 108px;
  padding: 17px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
}

.metric small {
  display: block;
  margin-top: 5px;
}

.ladder {
  grid-area: ladder;
  min-height: 600px;
}

.side {
  grid-area: side;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

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

.panel-head.compact {
  padding: 13px 15px;
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 730;
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.bid {
  background: var(--green);
}

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

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(36, 48, 57, 0.75);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.02);
}

tr.buy td:first-child,
tr.buy td:nth-child(3) {
  color: var(--green);
}

tr.sell td:first-child,
tr.sell td:nth-child(3) {
  color: var(--red);
}

.empty-state {
  height: 220px;
  color: var(--amber);
  text-align: center;
  vertical-align: middle;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
}

.risk-list,
.warnings {
  padding: 14px 18px;
  margin: 0;
  color: var(--muted);
}

.risk-list li {
  margin: 0 0 8px;
}

.warnings div {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(234, 184, 79, 0.4);
  background: rgba(234, 184, 79, 0.08);
  color: #f2cf81;
  border-radius: 6px;
}

.controls {
  padding-bottom: 14px;
}

.controls input {
  width: calc(100% - 30px);
  margin: 14px 15px 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #070b0e;
  color: var(--text);
  font: inherit;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 0 15px;
}

button {
  min-height: 38px;
  border: 1px solid rgba(0, 208, 135, 0.45);
  border-radius: 7px;
  background: var(--green-soft);
  color: var(--text);
  font: 700 12px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

button.danger {
  grid-column: 1 / -1;
  border-color: rgba(255, 91, 100, 0.45);
  background: var(--red-soft);
}

#controlResult {
  min-height: 18px;
  padding: 8px 15px 0;
  color: var(--muted);
  font-size: 12px;
}

.events {
  min-height: 300px;
  overflow: hidden;
}

#events {
  max-height: 520px;
  overflow: auto;
  padding: 8px 14px 14px;
}

.event {
  padding: 10px 0;
  border-bottom: 1px solid rgba(36, 48, 57, 0.75);
}

.event span {
  color: var(--muted);
  font-size: 11px;
}

.event strong {
  display: block;
  margin: 2px 0;
  color: var(--blue);
  font-size: 12px;
}

.event.warning strong {
  color: var(--amber);
}

.event.error strong,
.event.critical strong {
  color: var(--red);
}

.event p {
  color: #c8d4ce;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .topbar,
  .grid {
    display: block;
  }

  .status-strip {
    margin-top: 14px;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 14px;
  }

  .metric {
    border-bottom: 1px solid var(--line);
  }

  .side {
    margin-top: 14px;
  }
}

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

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

  .metric,
  .status-card {
    min-height: auto;
  }
}
