:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --text: #17202a;
  --muted: #657181;
  --line: #d8e0e8;
  --blue: #1e68c8;
  --green: #16845f;
  --red: #c0392b;
  --amber: #a86900;
  --ink: #0f1720;
  --shadow: 0 10px 28px rgba(21, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.side {
  min-height: 100vh;
  padding: 20px;
  background: #111820;
  color: #f8fbff;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: #a9b7c6;
  font-size: 12px;
}

.pill {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 9px;
  color: #d8e6f5;
  font-size: 12px;
  white-space: nowrap;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  padding: 14px;
}

.panel h2,
.block h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: inherit;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.field label {
  color: inherit;
  font-size: 12px;
  font-weight: 650;
}

.field small {
  color: var(--muted);
  line-height: 1.4;
}

.side .field small {
  color: #a9b7c6;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

.side .field input,
.side .field textarea,
.side .field select {
  border-color: rgba(255, 255, 255, 0.16);
  background: #0c1218;
  color: #f8fbff;
}

.field textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.45;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 700;
  white-space: nowrap;
}

.btn.primary {
  background: var(--blue);
  color: #fff;
}

.btn.good {
  background: var(--green);
  color: #fff;
}

.btn.warn {
  background: #f3b544;
  color: #221500;
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.94);
  backdrop-filter: blur(10px);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 12px 18px 0;
  overflow-x: auto;
}

.tab {
  min-width: 104px;
  min-height: 40px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-color: var(--surface);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  min-height: 70px;
}

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

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
  line-height: 1;
}

.content {
  padding: 18px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

.block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.block-head h2 {
  margin: 0;
}

.block-body {
  padding: 14px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 9px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #f2f5f8;
}

tr:last-child td {
  border-bottom: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  color: var(--ink);
  background: #e8eef4;
  font-size: 12px;
  font-weight: 750;
}

.tag.good {
  background: #dff3eb;
  color: #0b6044;
}

.tag.warn {
  background: #fff1cc;
  color: #7b4c00;
}

.tag.bad {
  background: #ffe2dd;
  color: #9d2416;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.status-item.compact {
  min-height: 62px;
}

.status-item strong {
  font-size: 12px;
}

.status-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.notice {
  border-left: 4px solid var(--amber);
  background: #fff8e8;
  padding: 12px 14px;
  line-height: 1.5;
}

.notice strong {
  display: block;
  margin-bottom: 3px;
}

.jsonbox {
  min-height: 280px;
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  background: #0c1218;
  color: #d7e6f4;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.market-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.depth {
  display: grid;
  gap: 4px;
  min-width: 170px;
}

.depth-row {
  display: grid;
  grid-template-columns: 52px 1fr 64px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.depth-bar {
  height: 8px;
  border-radius: 999px;
  background: #dfe7ef;
  overflow: hidden;
}

.depth-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.depth-fill.ask {
  background: var(--amber);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

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

  .side {
    min-height: auto;
  }

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

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

  .content {
    padding: 12px;
  }

  .status-item {
    grid-template-columns: 1fr;
  }

  .market-toolbar {
    grid-template-columns: 1fr;
  }
}
