:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --line: #d9e2ec;
  --text: #16202a;
  --muted: #667789;
  --blue: #1769aa;
  --green: #0f7b52;
  --amber: #a86100;
  --red: #b42318;
  --violet: #5b42a5;
  --shadow: 0 10px 24px rgba(20, 36, 54, 0.08);
}

* {
  box-sizing: border-box;
}

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 {
  font: inherit;
}

.shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.18;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

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

.seg {
  min-width: 48px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

.seg.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 12px 14px;
  min-height: 82px;
}

.label,
.metric small,
.panel-head p,
.search span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 5px 0 4px;
  font-size: 22px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
}

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

.panel-head.compact {
  display: block;
}

.search {
  display: grid;
  gap: 4px;
  min-width: 220px;
}

.search input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  outline: none;
}

.search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.14);
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: #334455;
  font-size: 12px;
  font-weight: 700;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.symbol {
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.rating-a {
  background: #dff6ea;
  color: var(--green);
}

.rating-a- {
  background: #e5f7ff;
  color: #0b6b88;
}

.rating-b {
  background: #e8f1ff;
  color: var(--blue);
}

.rating-c {
  background: #fff3d9;
  color: var(--amber);
}

.rating-d {
  background: #ffe6e2;
  color: var(--red);
}

.reason {
  max-width: 340px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-panel {
  max-height: calc(100vh - 112px);
  overflow: auto;
}

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

.subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.subhead span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.order {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.order-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.order-main strong {
  font-size: 13px;
}

.side-long {
  color: var(--green);
}

.side-short {
  color: var(--red);
}

.order-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

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

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

  .paper-panel {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .shell {
    width: calc(100vw - 20px);
    padding-top: 14px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

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

  h1 {
    font-size: 23px;
  }

  .search {
    min-width: 0;
  }
}
