:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --line: #dbe3ee;
  --line-strong: #c2d0e0;
  --text: #152033;
  --muted: #68778d;
  --green: #138a52;
  --green-soft: #e5f7ee;
  --red: #d63b3b;
  --red-soft: #fff0f0;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --amber: #b7791f;
  --shadow: 0 18px 40px rgba(31, 44, 64, 0.08);
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1440px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 10px 0 22px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 800;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(183, 121, 31, 0.12);
}

.dot.live {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(19, 138, 82, 0.14);
}

.dot.warn {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(214, 59, 59, 0.12);
}

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

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.page-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  padding: 8px 12px;
}

.page-tab.active {
  border-color: rgba(37, 99, 235, 0.42);
  background: var(--blue-soft);
  color: var(--blue);
}

.metric {
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric.primary {
  background: var(--surface);
  border-color: rgba(37, 99, 235, 0.32);
}

.group-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.compact-metric {
  min-height: 92px;
}

.compact-metric strong {
  font-size: 22px;
}

.compact-metric em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric span,
.section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric strong {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  min-height: 1.1em;
  font-size: 26px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  vertical-align: bottom;
}

#marketSlug {
  font-size: 14px;
  overflow-wrap: anywhere;
}

#btcTarget {
  font-size: 23px;
}

.section {
  margin-top: 22px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.strategy-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

tbody tr:hover {
  background: #fbfdff;
}

tbody tr.selected-row {
  background: var(--blue-soft);
}

.group-summary td {
  background: #fbfdff;
  font-weight: 800;
}

.group-summary {
  cursor: pointer;
}

.subtle {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}

.strategy-group-row td {
  background: #eef4fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

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

.strategy-tabs {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.tab-group {
  display: grid;
  gap: 6px;
}

.tab-group-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tab-group-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.strategy-tab {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 800;
}

.strategy-tab.active {
  border-color: rgba(37, 99, 235, 0.4);
  background: var(--blue-soft);
}

.strategy-tab strong {
  font-variant-numeric: tabular-nums;
}

.orders-panel {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.orders-table {
  min-width: 1100px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.down {
  background: #fff7df;
  color: var(--amber);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

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

.muted {
  color: var(--muted);
}

.number-roll {
  animation: rollIn 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes rollIn {
  from {
    opacity: 0;
    transform: translateY(0.45em);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .number-roll {
    animation: none;
  }
}

@media (max-width: 900px) {
  .market-grid,
  .group-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 24px, 1440px);
  }

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

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