:root {
  color-scheme: dark;
  --bg: #080a0d;
  --panel: #11181f;
  --panel-soft: #17212a;
  --surface: #0c1117;
  --surface-2: #141b23;
  --line: #2b3946;
  --line-soft: #1d2a35;
  --text: #f4f7f8;
  --muted: #91a0ad;
  --muted-2: #6f7f8e;
  --blue: #5ca8ff;
  --green: #18d28a;
  --red: #ff5368;
  --orange: #f5a524;
  --yellow: #e7d764;
  --violet: #b58cff;
  --shadow: 0 18px 52px rgba(0, 0, 0, .34);
}

* {
  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;
  font-size: 14px;
  line-height: 1.35;
}

body.auth-locked {
  overflow: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 10, 13, .88);
  backdrop-filter: blur(10px);
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card .brand-mark {
  margin-bottom: 18px;
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: 30px;
}

.auth-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 16px;
}

.auth-card button,
.logout-button {
  border: 1px solid #245d45;
  border-radius: 8px;
  background: #0f7a52;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.auth-card button {
  width: 100%;
  padding: 13px 16px;
}

.auth-card button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.auth-card small {
  display: block;
  margin-top: 14px;
  color: var(--muted-2);
}

.logout-button {
  padding: 10px 14px;
}

.logout-button.hidden {
  display: none;
}

body::-webkit-scrollbar,
.table-shell::-webkit-scrollbar,
.coin-modal__body::-webkit-scrollbar,
.anomaly-list::-webkit-scrollbar,
.sector-strip::-webkit-scrollbar,
.detail-content::-webkit-scrollbar,
.notifications-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body::-webkit-scrollbar-thumb,
.table-shell::-webkit-scrollbar-thumb,
.coin-modal__body::-webkit-scrollbar-thumb,
.anomaly-list::-webkit-scrollbar-thumb,
.sector-strip::-webkit-scrollbar-thumb,
.detail-content::-webkit-scrollbar-thumb,
.notifications-list::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: #334554;
}

body::-webkit-scrollbar-track,
.table-shell::-webkit-scrollbar-track,
.coin-modal__body::-webkit-scrollbar-track,
.anomaly-list::-webkit-scrollbar-track,
.sector-strip::-webkit-scrollbar-track,
.detail-content::-webkit-scrollbar-track,
.notifications-list::-webkit-scrollbar-track {
  background: transparent;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
  padding: 14px 18px 13px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 17, 23, .98);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .22);
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(24, 210, 138, .42);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  color: var(--text);
  background: #0f171d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .03);
  font-weight: 950;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.notification-widget {
  position: relative;
  flex: 0 0 auto;
}

.notifications-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 126px;
  border-color: #314251;
  background: var(--surface);
}

.notifications-button strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  color: #071018;
  background: var(--muted);
}

.notifications-button.has-signals {
  border-color: rgba(245, 165, 36, .75);
  color: #fff3d6;
  background: rgba(245, 165, 36, .10);
}

.notifications-button.has-signals strong {
  background: var(--orange);
}

.online-pill {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 112px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #314251;
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 800;
}

.online-pill strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  color: #071018;
  background: var(--green);
}

.notifications-feed {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: min(460px, calc(100vw - 24px));
  max-height: min(640px, calc(100vh - 108px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 17, 23, .98);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.notifications-feed header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}

.notifications-feed header strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.notifications-feed header button {
  height: 32px;
}

.notifications-list {
  display: grid;
  gap: 8px;
  max-height: calc(min(640px, calc(100vh - 108px)) - 64px);
  padding: 10px;
  overflow: auto;
}

.notification-card {
  display: grid;
  gap: 5px;
  height: auto;
  min-height: 104px;
  padding: 10px 11px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.notification-card.green {
  border-left-color: var(--green);
}

.notification-card.red {
  border-left-color: var(--red);
}

.notification-card:hover {
  border-color: var(--blue);
  background: #162431;
}

.notification-kind {
  width: max-content;
  padding: 3px 7px;
  border-radius: 6px;
  color: #071018;
  background: var(--orange);
  font-size: 11px;
  font-weight: 900;
}

.notification-card.green .notification-kind {
  background: var(--green);
}

.notification-card.red .notification-kind {
  color: #fff;
  background: var(--red);
}

.notification-card strong {
  font-size: 15px;
}

.notification-card p {
  margin: 0;
  color: #c8d2dc;
  line-height: 1.35;
}

.notification-card small {
  color: var(--muted);
  line-height: 1.35;
}

.controls {
  display: grid;
  grid-template-columns: 260px minmax(160px, 250px) 178px 86px 112px;
  gap: 8px;
  align-items: center;
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.view-switch button {
  height: 30px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.view-switch button.active {
  border-color: rgba(92, 168, 255, .55);
  color: var(--text);
  background: #172432;
}

input,
select,
button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(92, 168, 255, .12);
}

button {
  cursor: pointer;
  background: var(--panel-soft);
  font-weight: 800;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}

button:hover,
button.active {
  border-color: var(--blue);
  color: #dcecff;
}

button:active {
  transform: translateY(1px);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 82px);
}

.panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02);
}

.hidden {
  display: none !important;
}

.overview-panel {
  grid-column: 1 / -1;
  padding: 12px;
  background: var(--surface-2);
}

.status-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 8px;
}

.status-row > div {
  min-height: 58px;
  padding: 10px 12px 11px;
  border: 1px solid var(--line-soft);
  border-left: 3px solid #304354;
  border-radius: 6px;
  background: var(--surface);
}

.status-row > div:nth-child(3) {
  border-left-color: var(--green);
}

.status-row > div:nth-child(4) {
  border-left-color: var(--orange);
}

.status-row > div:nth-child(5) {
  border-left-color: var(--red);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.status-row strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.tabs.hidden,
.sector-strip.hidden,
.cvd-legend.hidden {
  display: none;
}

.tabs button {
  height: 32px;
  padding: 0 10px;
  border-color: #314251;
  background: #111a22;
  color: #d8e3ec;
}

.setup-tabs button {
  font-weight: 800;
}

.tabs button.active {
  border-color: var(--blue);
  background: #172a3b;
  color: #f5fbff;
}

.setup-tabs button.active {
  border-color: rgba(24, 210, 138, .72);
  color: #dfffee;
  background: rgba(24, 210, 138, .12);
}

.cvd-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

.cvd-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cvd-key {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--green);
}

.cvd-key.hidden {
  border: 1px dashed var(--orange);
  background: transparent;
}

.sector-strip {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.sector-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sector-pill.active {
  border-color: rgba(78, 161, 255, .9);
  background: rgba(78, 161, 255, .16);
  box-shadow: inset 0 0 0 1px rgba(78, 161, 255, .22);
}

.sector-pill b {
  color: var(--text);
}

.heatmap-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #080d12;
}

.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  background:
    linear-gradient(90deg, rgba(24, 210, 138, .08), transparent 34%),
    linear-gradient(270deg, rgba(255, 83, 104, .06), transparent 38%),
    var(--surface-2);
}

.heatmap-header h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.heatmap-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.heatmap-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heatmap-controls select {
  min-width: 130px;
}

.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 16px 0;
  color: var(--muted);
  font-weight: 800;
}

.heatmap-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

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

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

.legend-line {
  width: 22px;
  height: 2px;
  background: #f4f7f8;
}

.heatmap-canvas-shell {
  position: relative;
  flex: 1;
  min-height: 560px;
  margin: 12px 14px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #070c11;
  overflow: hidden;
}

#heatmapCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 560px;
}

.table-panel {
  min-width: 0;
}

.table-shell {
  height: 100%;
  overflow: auto;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 1880px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
  background: var(--panel);
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
}

th:first-child {
  z-index: 5;
}

tbody tr:nth-child(even) td {
  background: #10171e;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: transparent;
}

tbody tr:hover td,
tbody tr.selected td {
  background: #182632;
}

tbody tr.selected td:first-child {
  box-shadow: inset 3px 0 0 var(--blue);
}

tbody tr.has-cvd-divergence:not(.selected) td:first-child {
  box-shadow: inset 2px 0 0 var(--violet);
}

.cvd-cell {
  min-width: 76px;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
}

.cvd-none {
  color: #41505d;
}

.cvd-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 62px;
  height: 25px;
  padding: 0 7px;
  border: 1px solid currentColor;
  border-radius: 7px;
  font-size: 10px;
  line-height: 1;
  letter-spacing: .04em;
  background: rgba(255, 255, 255, .03);
}

.cvd-badge b {
  font-size: 10px;
}

.cvd-badge em {
  font-size: 12px;
  font-style: normal;
}

.cvd-active.bullish .cvd-badge {
  color: #42e6a5;
  background: rgba(24, 210, 138, .12);
  box-shadow: 0 0 14px rgba(24, 210, 138, .10);
}

.cvd-active.bearish .cvd-badge {
  color: #ff7181;
  background: rgba(255, 83, 104, .12);
  box-shadow: 0 0 14px rgba(255, 83, 104, .10);
}

.cvd-active.hidden-div .cvd-badge {
  border-style: dashed;
  border-color: var(--orange);
}

.coin-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.coin-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(145, 160, 173, .12);
}

.coin-dot.hot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(24, 210, 138, .16);
}

.coin-dot.risk {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 83, 104, .16);
}

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

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

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

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

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  font-weight: 800;
  background: #1b2934;
}

.score.good {
  color: #001b0f;
  background: var(--green);
}

.score.mid {
  color: #201400;
  background: var(--orange);
}

.score.bad {
  color: #27060d;
  background: var(--red);
}

.tags {
  display: flex;
  gap: 5px;
  max-width: 380px;
  overflow: hidden;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  color: #071018;
  background: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag.squeeze,
.tag.oispike {
  background: var(--green);
}

.tag.pump,
.tag.oi15,
.tag.near {
  background: var(--orange);
}

.tag.crowded,
.tag.trap,
.tag.dump {
  background: var(--red);
  color: #fff;
}

.tag.funding {
  background: var(--violet);
}

.tag.vwap {
  background: #2f80ed;
  color: #eaf3ff;
}

.vwap-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  background: var(--surface);
}

.vwap-pill.near {
  color: #071018;
  border-color: var(--orange);
  background: var(--orange);
}

.vwap-pill.above {
  color: #071018;
  border-color: var(--green);
  background: var(--green);
}

.vwap-pill.below {
  color: #fff;
  border-color: var(--red);
  background: var(--red);
}

.setup-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  color: #071018;
  font-size: 12px;
  font-weight: 900;
  background: var(--muted);
}

.setup-pill.long {
  background: var(--green);
}

.setup-pill.short {
  color: #fff;
  background: var(--red);
}

.setup-pill.watch {
  background: var(--orange);
}

.edge-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin-left: 4px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: var(--surface);
}

.edge-pill.good {
  color: #001b0f;
  border-color: var(--green);
  background: var(--green);
}

.edge-pill.mid {
  color: #201400;
  border-color: var(--orange);
  background: var(--orange);
}

.edge-pill.bad {
  color: #fff;
  border-color: var(--red);
  background: var(--red);
}

.quality-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin-left: 4px;
  padding: 0 8px;
  border-radius: 6px;
  color: #071018;
  font-size: 12px;
  font-weight: 900;
  background: var(--muted);
}

.quality-pill.grade-a {
  background: var(--green);
}

.quality-pill.grade-b {
  background: var(--orange);
}

.quality-pill.grade-c {
  background: var(--yellow);
}

.quality-pill.grade-d {
  color: #fff;
  background: var(--red);
}

.detail-panel {
  min-width: 0;
  background: var(--surface-2);
}

.detail-content {
  height: 100%;
  padding: 16px;
  overflow: auto;
}

.detail-content h2 {
  margin: 0 0 5px;
  font-size: 24px;
}

.detail-content p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.45;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.metric {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface);
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

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

.level-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface);
}

.learning-card {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  background: var(--surface);
}

.learning-card.good {
  border-left-color: var(--green);
}

.learning-card.mid {
  border-left-color: var(--orange);
}

.learning-card.bad {
  border-left-color: var(--red);
}

.learning-card strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.learning-card p {
  margin: 8px 0 10px;
}

.warning-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
}

.warning-row span {
  padding: 5px 8px;
  border: 1px solid rgba(255, 173, 50, .45);
  border-radius: 6px;
  color: var(--orange);
  background: rgba(255, 173, 50, .08);
  font-size: 12px;
  font-weight: 800;
}

.crime-memory {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
  padding: 10px;
  border: 1px solid rgba(245, 165, 36, .34);
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  background: rgba(245, 165, 36, .08);
}

.crime-memory > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.crime-memory strong {
  color: #ffd98f;
  font-size: 15px;
}

.crime-memory p {
  margin: 0;
  color: #d7e0e9;
  line-height: 1.45;
}

.crime-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crime-matches span {
  padding: 5px 7px;
  border: 1px solid rgba(245, 165, 36, .35);
  border-radius: 6px;
  color: #ffcf78;
  background: rgba(8, 13, 18, .55);
  font-size: 12px;
  font-weight: 900;
}

.learning-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.coin-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  padding: 18px;
  background: rgba(4, 7, 10, .82);
  overflow: hidden;
}

.coin-modal.open {
  display: block;
}

.coin-modal__dialog {
  display: flex;
  flex-direction: column;
  width: min(1680px, 100%);
  height: calc(100dvh - 36px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.coin-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}

.coin-modal__header h2 {
  margin: 0;
  font-size: 24px;
}

.coin-modal__header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.modal-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.coin-modal__body {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 380px;
  align-items: start;
  gap: 12px;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chart-panel,
.modal-anomaly-side section,
.modal-depth-side section,
.setup-brief {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
}

.chart-panel {
  position: relative;
  height: min(70dvh, 760px);
  min-height: 560px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .015);
}

#coinChart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 560px;
  cursor: grab;
  touch-action: none;
}

#coinChart.dragging {
  cursor: grabbing;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  display: none;
  max-width: 320px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(10, 15, 21, .97);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .32);
  pointer-events: none;
}

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

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

.modal-anomaly-side,
.modal-depth-side {
  display: grid;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
}

.modal-anomaly-side section,
.modal-depth-side section {
  min-height: 0;
  overflow: hidden;
}

.modal-anomaly-side h3,
.modal-depth-side h3 {
  margin: 0;
  padding: 12px 12px 0;
  font-size: 16px;
}

.depth-grid {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.depth-row {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.depth-row__top,
.depth-row__values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
}

.depth-row__bar {
  display: grid;
  grid-template-columns: var(--bid, 50%) var(--ask, 50%);
  height: 7px;
}

.depth-row__bar span:first-child {
  background: var(--green);
}

.depth-row__bar span:last-child {
  background: var(--red);
}

.imbalance-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  color: #071018;
  font-weight: 800;
  background: var(--muted);
}

.imbalance-chip.orange {
  background: var(--orange);
}

.imbalance-chip.green {
  background: var(--green);
}

.imbalance-chip.red {
  color: #fff;
  background: var(--red);
}

.anomaly-list {
  display: grid;
  gap: 8px;
  max-height: 100%;
  overflow: auto;
  padding: 12px;
}

.anomaly-card {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--muted);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.anomaly-card:hover,
.anomaly-card.active {
  border-color: var(--blue);
  background: #162431;
}

.anomaly-card.green {
  border-left-color: var(--green);
}

.anomaly-card.red {
  border-left-color: var(--red);
}

.anomaly-card.orange {
  border-left-color: var(--orange);
}

.anomaly-card strong {
  display: block;
  margin-bottom: 4px;
}

.anomaly-card span {
  color: var(--muted);
}

.anomaly-card small {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font: 800 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.setup-brief {
  display: none;
  grid-column: 1 / -1;
  min-width: 0;
  padding: 14px;
  border-left: 4px solid var(--muted);
  background: var(--surface-2);
}

.setup-brief.visible {
  display: block;
}

.setup-brief.long {
  border-left-color: var(--green);
}

.setup-brief.short {
  border-left-color: var(--red);
}

.setup-brief.watch {
  border-left-color: var(--orange);
}

.brief-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.brief-head strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

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

.brief-grid > div {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface);
}

.brief-grid b {
  display: block;
  margin-bottom: 6px;
}

.brief-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.brief-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.brief-flow span {
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
}

@media (max-width: 1500px), (max-height: 860px) {
  .coin-modal {
    padding: 8px;
  }

  .coin-modal__dialog {
    width: 100%;
    height: calc(100dvh - 16px);
  }

  .coin-modal__header {
    padding: 9px 10px;
  }

  .coin-modal__header h2 {
    font-size: 21px;
  }

  .coin-modal__header p {
    margin-top: 2px;
    font-size: 13px;
  }

  .coin-modal__body {
    grid-template-columns: 250px minmax(0, 1fr) 320px;
    gap: 8px;
    padding: 8px;
    overflow-x: hidden;
  }

  .chart-panel {
    height: clamp(420px, 58dvh, 620px);
    min-height: 420px;
  }

  #coinChart {
    min-height: 420px;
  }

  .modal-anomaly-side,
  .modal-depth-side {
    gap: 8px;
  }

  .modal-anomaly-side h3,
  .modal-depth-side h3 {
    padding: 9px 10px 0;
    font-size: 15px;
  }

  .depth-grid {
    gap: 6px;
    padding: 9px;
  }

  .depth-row__top,
  .depth-row__values {
    padding: 6px 8px;
  }

  .depth-row__bar {
    height: 6px;
  }

  .anomaly-list {
    gap: 6px;
    padding: 9px;
    max-height: 300px;
  }

  .anomaly-card {
    padding: 8px;
  }

  .setup-brief {
    padding: 10px;
  }

  .brief-head {
    margin-bottom: 8px;
  }

  .brief-head strong {
    font-size: 16px;
  }

  .brief-grid {
    gap: 8px;
  }

  .brief-grid > div {
    padding: 8px;
  }
}

@media (max-width: 1100px) {
  .coin-modal__body {
    grid-template-columns: 1fr;
  }

  .modal-anomaly-side,
  .modal-depth-side {
    align-self: auto;
  }

  .anomaly-list {
    max-height: 320px;
  }

  .chart-panel {
    height: clamp(440px, 62dvh, 620px);
    min-height: 440px;
  }

  #coinChart {
    min-height: 440px;
  }

  .imbalance-chip {
    height: 22px;
    padding: 0 7px;
  }
}

@media (max-height: 760px) {
  .coin-modal__header {
    gap: 10px;
  }

  .modal-controls {
    gap: 6px;
  }

  .modal-controls select,
  .modal-controls button {
    height: 34px;
  }

  .chart-panel {
    height: clamp(360px, 52dvh, 500px);
    min-height: 360px;
  }

  #coinChart {
    min-height: 360px;
  }

  .anomaly-list {
    max-height: 220px;
  }

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

@media (max-width: 1180px), (max-height: 760px) {
  .setup-brief {
    position: static;
    max-height: none;
  }

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

@media (max-width: 1100px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .notification-widget {
    width: 100%;
  }

  .online-pill {
    width: 100%;
  }

  .notifications-button {
    width: 100%;
  }

  .notifications-feed {
    left: 0;
    right: auto;
    width: 100%;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 76px 96px;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 76px);
  }

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

  .detail-panel {
    min-height: 360px;
  }

  .detail-content {
    max-height: 520px;
  }

  .coin-modal__body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .heatmap-header {
    align-items: stretch;
    flex-direction: column;
  }

  .anomaly-list {
    max-height: 360px;
  }

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

@media (max-width: 640px) {
  .controls,
  .status-row,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    padding: 12px;
  }

  h1 {
    font-size: 20px;
  }

  .layout {
    padding: 8px;
    min-height: auto;
  }

  .coin-modal {
    padding: 6px;
  }

  .coin-modal__header,
  .modal-controls,
  .heatmap-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .heatmap-canvas-shell,
  #heatmapCanvas {
    min-height: 520px;
  }

  #coinChart {
    min-height: 420px;
  }

  .chart-panel {
    height: 520px;
    min-height: 420px;
  }

  .brief-head {
    flex-direction: column;
  }

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

/* 2026 Market Radar redesign */
:root {
  --bg: #05070c;
  --panel: #090e15;
  --panel-soft: #0d1520;
  --surface: #070c12;
  --surface-2: #0b121b;
  --line: #243042;
  --line-soft: #172233;
  --text: #f0f2f8;
  --muted: #8a92a8;
  --muted-2: #59647b;
  --blue: #38dcf5;
  --green: #28e9a2;
  --red: #ff5d76;
  --orange: #f4bd54;
  --yellow: #ddcf56;
  --violet: #9b8cff;
  --shadow: 0 22px 64px rgba(0, 0, 0, .46);
}

html,
body { min-height: 100%; background: #05070c; }

body {
  background:
    radial-gradient(900px 520px at 72% -8%, rgba(23, 64, 88, .28), transparent 70%),
    radial-gradient(700px 500px at 15% 110%, rgba(11, 53, 64, .12), transparent 68%),
    var(--bg);
  font-size: 13px;
}

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

.workspace { min-width: 0; }

.side-rail {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line-soft);
  background: rgba(5, 8, 13, .96);
}

.rail-brand {
  display: grid;
  place-items: center;
  gap: 8px;
  height: 92px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line-soft);
  color: #a9b9d4;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.side-rail .brand-mark {
  width: 52px;
  height: 32px;
  border: 0;
  border-radius: 0;
  color: #f4f7ff;
  background: transparent;
  box-shadow: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  letter-spacing: -.05em;
}

.side-rail .view-switch {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 0;
  height: auto;
  padding: 18px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.side-rail .view-switch button {
  position: relative;
  display: grid;
  place-content: center;
  gap: 4px;
  width: 100%;
  height: 72px;
  padding: 0 8px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  text-transform: uppercase;
}

.side-rail .view-switch button span { font-size: 11px; letter-spacing: .06em; }
.side-rail .view-switch button small { color: var(--muted-2); font-size: 9px; font-weight: 600; text-transform: none; }
.side-rail .view-switch button:hover,
.side-rail .view-switch button.active { border-left-color: var(--blue); color: var(--blue); background: rgba(56, 220, 245, .08); }

.rail-status {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 18px 8px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  text-align: center;
}
.rail-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(40, 233, 162, .75); }
.rail-status strong,
.rail-status span { display: block; font-size: 9px; line-height: 1.45; }
.rail-status strong { color: #cce9df; text-transform: uppercase; }

.topbar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(500px, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  min-height: 74px;
  padding: 10px 14px;
  border-bottom-color: var(--line-soft);
  background: rgba(5, 8, 13, .94);
  box-shadow: none;
  backdrop-filter: blur(16px);
}

.brand { min-width: 0; }
.brand h1 { margin: 1px 0 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; text-transform: uppercase; }
.eyebrow { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.topbar p { max-width: 370px; margin-top: 3px; color: var(--muted-2); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 132px 170px 64px 84px;
  gap: 7px;
  min-width: 0;
}

input,
select,
button { height: 36px; border-color: var(--line); border-radius: 5px; background: #080d14; }
input::placeholder { color: #536078; }
input:focus,
select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(56, 220, 245, .12); }
button:hover,
button.active { border-color: var(--blue); color: var(--blue); }

.notifications-button,
.online-pill { min-width: auto; height: 36px; border-color: var(--line); border-radius: 5px; background: #080d14; }
.notifications-button strong,
.online-pill strong { height: 20px; min-width: 22px; border-radius: 4px; font-size: 11px; }

.layout {
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: calc(100vh - 74px);
  padding: 10px;
}

.panel { border-color: var(--line-soft); border-radius: 6px; background: rgba(8, 13, 20, .94); box-shadow: none; }
.overview-panel { padding: 0; background: rgba(8, 13, 20, .88); }
.status-row { grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: 0; }
.status-row > div { min-height: 55px; padding: 9px 13px; border: 0; border-right: 1px solid var(--line-soft); border-left: 0; border-radius: 0; background: transparent; }
.status-row > div:last-child { border-right: 0; }

.label,
th { color: #72809a; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.status-row strong { margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; font-weight: 700; }

.tabs,
.sector-strip { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line-soft); flex-wrap: nowrap; overflow-x: auto; }
.tabs { gap: 3px; }
.tabs button,
.sector-pill { flex: 0 0 auto; height: 28px; border-color: transparent; border-radius: 4px; color: #8995aa; background: transparent; font-size: 10px; font-weight: 700; }
.tabs button:hover,
.tabs button.active,
.setup-tabs button.active,
.sector-pill.active { border-color: rgba(56, 220, 245, .38); color: var(--blue); background: rgba(56, 220, 245, .08); box-shadow: none; }

.table-panel,
.table-shell { background: var(--surface); }
table { min-width: 1760px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
th,
td { padding: 7px 8px; border-bottom-color: #131e2c; background: #080d14; }
th { height: 38px; background: #0b121b; }
tbody tr:nth-child(even) td { background: #090f17; }
tbody tr:hover td,
tbody tr.selected td { background: #0d1c29; }
tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--blue); }
.coin-cell { gap: 6px; }
.coin-cell strong { color: #e9edf6; }
.rank-number { width: 17px; color: #56647b; font-size: 9px; text-align: right; }
.coin-dot { width: 6px; height: 6px; box-shadow: none; }

.score,
.tag,
.vwap-pill,
.setup-pill,
.quality-pill,
.edge-pill { border-radius: 4px; font-size: 10px; }
.score { min-width: 34px; height: 22px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.score.good { color: #02130d; background: var(--green); box-shadow: 0 0 18px rgba(40, 233, 162, .12); }
.tags { max-width: 300px; }
.tag { height: 20px; padding: 0 6px; }

.detail-panel { border-color: #223147; background: #080e16; }
.detail-content { padding: 14px; }
.detail-content h2 { display: flex; align-items: baseline; gap: 7px; margin-bottom: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 21px; }

.decision-hero { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 0; margin: 14px 0 10px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.decision-hero > div { min-width: 0; padding: 9px; border-right: 1px solid var(--line-soft); }
.decision-hero > div:last-child { border-right: 0; }
.decision-hero strong { display: block; margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.decision-score { color: var(--green); font-size: 24px !important; }
.signal-reasons { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0; }
.signal-reasons span { padding: 4px 6px; border: 1px solid rgba(56, 220, 245, .26); border-radius: 4px; color: #9be9f5; background: rgba(56, 220, 245, .07); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.market-read { padding: 10px 0 11px; border-bottom: 1px solid var(--line-soft); color: #c2ccdb !important; }

.detail-grid { grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line-soft); border-radius: 5px; overflow: hidden; }
.metric { padding: 8px 9px; border: 0; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); border-radius: 0; background: transparent; }
.metric strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.levels { gap: 0; border: 1px solid var(--line-soft); border-radius: 5px; overflow: hidden; }
.level-row { padding: 7px 9px; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; background: transparent; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; }

.heatmap-panel,
.heatmap-header,
.heatmap-canvas-shell,
.coin-modal__dialog,
.coin-modal__header,
.chart-panel,
.modal-anomaly-side section,
.modal-depth-side section,
.setup-brief { border-radius: 6px; background: #080d14; }
.heatmap-header { background: #0b121b; }
.notifications-feed,
.notification-card,
.auth-card { border-radius: 6px; background: #090f17; }
.auth-gate { background: rgba(3, 5, 9, .84); }
.auth-card { border-color: #2a394d; box-shadow: 0 30px 90px rgba(0, 0, 0, .62); }
.auth-card .brand-mark { color: var(--blue); border-color: rgba(56, 220, 245, .35); border-left-color: var(--blue); }
.auth-card button { border-color: var(--blue); color: #021117; background: var(--blue); }

@media (max-width: 1280px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .topbar { grid-template-columns: 190px minmax(430px, 1fr) auto auto; }
  .topbar p,
  .logout-button { display: none; }
  .controls { grid-template-columns: minmax(150px, 1fr) 120px 150px 58px 74px; }
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 980px) {
  .app-shell { display: block; }
  .side-rail { position: sticky; z-index: 40; display: grid; grid-template-columns: 104px 1fr auto; align-items: center; width: 100%; height: 54px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .rail-brand { height: 54px; padding: 5px; border-bottom: 0; }
  .rail-brand > span:last-child,
  .rail-status { display: none; }
  .side-rail .view-switch { display: flex; justify-content: center; height: 54px; padding: 0; }
  .side-rail .view-switch button { width: auto; height: 54px; padding: 0 16px; border-left: 0; border-bottom: 2px solid transparent; }
  .side-rail .view-switch button small { display: none; }
  .side-rail .view-switch button.active { border-bottom-color: var(--blue); }
  .topbar { position: static; grid-template-columns: 1fr auto auto; min-height: auto; }
  .brand { display: none; }
  .controls { grid-column: 1 / -1; grid-row: 2; }
  .layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(520px, 1fr) auto; height: auto; min-height: calc(100vh - 108px); }
  .overview-panel,
  .heatmap-panel { grid-column: 1; }
  .detail-panel { min-height: 520px; }
}

@media (max-width: 680px) {
  .side-rail { grid-template-columns: 72px 1fr; }
  .side-rail .view-switch button { padding: 0 10px; }
  .controls { grid-template-columns: 1fr 1fr; }
  #searchInput,
  #qualitySelect { grid-column: 1 / -1; }
  .status-row { grid-template-columns: repeat(2, 1fr); }
  .status-row > div:nth-child(5) { display: none; }
}

/* Readability and token-workspace refinement */
body {
  background: var(--bg);
  font-size: 14px;
}

.topbar {
  grid-template-columns: minmax(210px, 1fr) auto auto auto auto;
}

.controls {
  grid-template-columns: 220px 142px 190px 64px 90px;
  justify-content: end;
}

.layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.overview-panel {
  grid-column: 1 / -1;
}

.table-panel {
  grid-column: 1;
  grid-row: 2;
}

.detail-panel {
  grid-column: 2;
  grid-row: 2;
}

.label,
th {
  font-size: 10px;
}

.status-row > div {
  min-height: 62px;
  padding: 11px 15px;
}

.status-row strong {
  font-size: 17px;
}

.tabs,
.sector-strip {
  padding: 10px 12px;
}

.tabs button,
.sector-pill {
  height: 32px;
  padding-inline: 10px;
  font-size: 11px;
}

table {
  min-width: 2120px;
  font-size: 13px;
}

th,
td {
  height: 42px;
  padding: 9px 10px;
}

th {
  height: 44px;
  font-size: 11px;
}

.coin-cell {
  gap: 8px;
  font-size: 13px;
}

.coin-link {
  color: inherit;
  text-decoration: none;
}

.coin-link:hover strong,
.coin-link:focus-visible strong {
  color: var(--blue);
}

.coin-link:focus-visible {
  outline: 2px solid rgba(56, 220, 245, .45);
  outline-offset: 3px;
}

.rank-number {
  width: 21px;
  font-size: 11px;
}

.coin-dot {
  width: 8px;
  height: 8px;
}

.score,
.tag,
.vwap-pill,
.setup-pill,
.quality-pill,
.edge-pill {
  font-size: 11px;
}

.score {
  min-width: 38px;
  height: 25px;
}

.tags {
  max-width: 390px;
}

.tag {
  height: 23px;
  padding-inline: 7px;
}

.detail-content {
  padding: 18px;
}

.detail-content h2 {
  font-size: 24px;
}

.detail-content p {
  font-size: 13px;
}

.signal-reasons span {
  font-size: 10px;
}

.metric {
  padding: 10px 11px;
}

.metric span {
  font-size: 11px;
}

.metric strong {
  font-size: 14px;
}

.level-row {
  padding: 9px 11px;
  font-size: 11px;
}

/* Full token intelligence view */
.coin-modal {
  z-index: 80;
  padding: 10px;
  background: rgba(2, 5, 9, .94);
}

.coin-modal__dialog {
  width: min(1800px, 100%);
  height: calc(100dvh - 20px);
  border-color: #26364b;
  border-radius: 10px;
  background: #060a10;
}

.coin-modal__header {
  flex: 0 0 auto;
  min-height: 78px;
  padding: 14px 18px;
  border-bottom-color: #1c293a;
  background: #080d14;
}

.coin-modal__header h2 {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
  letter-spacing: -.03em;
}

.coin-modal__header p {
  margin-top: 6px;
  font-size: 13px;
}

.modal-controls select,
.modal-controls button {
  height: 40px;
  padding-inline: 13px;
  font-size: 12px;
}

.modal-controls #modalClose {
  border-color: #3c4b61;
  color: #dce5f2;
}

.coin-modal__body {
  display: block;
  padding: 14px;
  overflow-y: auto;
  background: #060a10;
}

.modal-snapshot {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(5, minmax(135px, 1fr));
  margin-bottom: 12px;
  border: 1px solid #1b2939;
  border-radius: 8px;
  background: #080d14;
  overflow: hidden;
}

.snapshot-identity,
.snapshot-stat {
  min-width: 0;
  min-height: 96px;
  padding: 15px 16px;
  border-right: 1px solid #1b2939;
}

.snapshot-stat:last-child {
  border-right: 0;
}

.snapshot-identity {
  display: flex;
  align-items: center;
  gap: 18px;
}

.snapshot-symbol {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -.06em;
}

.snapshot-identity div {
  display: grid;
  gap: 4px;
}

.snapshot-identity strong {
  font: 800 22px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.snapshot-stat > span,
.snapshot-stat small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.snapshot-stat > span {
  text-transform: uppercase;
  letter-spacing: .07em;
}

.snapshot-stat strong {
  display: block;
  margin: 8px 0 5px;
  color: #f2f5fb;
  font: 800 18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.snapshot-stat strong.good {
  color: var(--green);
}

.snapshot-stat strong.mid {
  color: var(--orange);
}

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

.modal-main-grid {
  display: grid;
  grid-template-columns: 270px minmax(580px, 1fr) 330px;
  align-items: stretch;
  gap: 12px;
}

.chart-panel,
.modal-anomaly-side section,
.modal-depth-side section,
.modal-market-data,
.setup-brief {
  border-color: #1b2939;
  background: #080d14;
}

.modal-anomaly-side,
.modal-depth-side {
  min-height: 640px;
}

.modal-anomaly-side section {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.modal-section-heading {
  padding: 14px 14px 10px;
}

.modal-section-heading h3 {
  margin: 3px 0 0;
  padding: 0;
  color: #eff4fb;
  font-size: 17px;
}

.anomaly-list {
  flex: 1;
  max-height: 590px;
  padding: 0 10px 10px;
}

.anomaly-card {
  padding: 12px;
  border-radius: 6px;
  background: #090f18;
}

.anomaly-card strong {
  font-size: 12px;
}

.anomaly-card p {
  color: #b6c0cf;
  font-size: 12px;
  line-height: 1.45;
}

.chart-panel {
  display: flex;
  flex-direction: column;
  height: 640px;
  min-height: 640px;
}

.chart-panel__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 11px 14px;
  border-bottom: 1px solid #1b2939;
}

.chart-panel__heading strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chart-legend span {
  padding: 4px 7px;
  border: 1px solid #25354a;
  border-radius: 4px;
  color: #a9b6c8;
  font-size: 10px;
  font-weight: 800;
}

.chart-legend .legend-flow {
  color: var(--green);
}

.chart-legend .legend-oi {
  color: #9d86ff;
}

.chart-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

#coinChart {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.modal-depth-side {
  grid-template-rows: auto minmax(0, 1fr);
}

.modal-bias-card {
  display: block;
  min-height: 206px;
  padding: 16px;
  border-color: #b28935 !important;
}

.modal-bias-card.long {
  border-color: rgba(40, 233, 162, .58) !important;
}

.modal-bias-card.short {
  border-color: rgba(255, 93, 118, .62) !important;
}

.bias-word {
  display: block;
  margin: 10px 0 12px;
  color: var(--orange);
  font: 900 30px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: -.05em;
}

.modal-bias-card.long .bias-word {
  color: var(--green);
}

.modal-bias-card.short .bias-word {
  color: var(--red);
}

.bias-meta,
.bias-ends {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bias-meta {
  color: #b5c0d0;
  font-size: 11px;
}

.bias-scale {
  position: relative;
  height: 7px;
  margin: 10px 0 5px;
  border-radius: 999px;
  background: #202b3b;
}

.modal-bias-card.long .bias-scale {
  background: rgba(40, 233, 162, .24);
}

.modal-bias-card.short .bias-scale {
  background: rgba(255, 93, 118, .24);
}

.bias-scale i {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 2px solid #080d14;
  border-radius: 50%;
  background: #f4f6fb;
  box-shadow: 0 0 0 2px rgba(244, 246, 251, .22);
  transform: translate(-50%, -50%);
}

.bias-ends {
  color: #606d82;
  font-size: 9px;
  font-weight: 900;
}

.modal-bias-card p {
  margin: 12px 0 0;
  color: #aab5c5;
  font-size: 12px;
  line-height: 1.45;
}

.modal-depth-section {
  min-height: 0;
}

.depth-grid {
  padding: 0 10px 10px;
}

.depth-row {
  background: #090f18;
}

.depth-row__top,
.depth-row__values {
  padding: 8px 10px;
  font-size: 11px;
}

.modal-market-data {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(420px, .9fr);
  gap: 12px;
  margin-top: 12px;
  border: 0;
  background: transparent;
}

.market-data-card {
  min-width: 0;
  border: 1px solid #1b2939;
  border-radius: 7px;
  background: #080d14;
}

.market-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid #1b2939;
}

.modal-metric {
  min-width: 0;
  padding: 13px 14px;
  border-right: 1px solid #1b2939;
  border-bottom: 1px solid #1b2939;
}

.modal-metric:nth-child(3n) {
  border-right: 0;
}

.modal-metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.modal-metric strong {
  display: block;
  margin-top: 6px;
  color: #f0f4fb;
  font: 800 15px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: capitalize;
}

.modal-patterns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
}

.positioning-card {
  padding-bottom: 10px;
}

.position-row {
  padding: 8px 14px;
}

.position-row__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #9eabbd;
  font-size: 11px;
}

.position-row__head strong {
  color: #e9eef7;
}

.position-bar {
  display: grid;
  grid-template-columns: var(--long, 50%) var(--short, 50%);
  height: 23px;
  border-radius: 4px;
  overflow: hidden;
}

.position-bar span {
  display: flex;
  align-items: center;
  padding-inline: 8px;
  color: #04100d;
  background: #2ed392;
  font-size: 9px;
  font-weight: 900;
  white-space: nowrap;
}

.position-bar span:last-child {
  justify-content: flex-end;
  color: #21080d;
  background: #e65b70;
}

.setup-brief {
  margin-top: 12px;
  padding: 16px;
}

.brief-head strong {
  font-size: 18px;
}

.brief-grid > div {
  min-height: 92px;
  padding: 12px;
}

.brief-grid p {
  font-size: 12px;
}

@media (max-width: 1500px) {
  .topbar {
    grid-template-columns: 200px minmax(520px, 1fr) auto auto;
  }

  .controls {
    grid-template-columns: minmax(180px, 1fr) 130px 170px 60px 84px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr) 330px;
  }

  .modal-snapshot {
    grid-template-columns: minmax(190px, 1.25fr) repeat(5, minmax(118px, 1fr));
  }

  .snapshot-identity,
  .snapshot-stat {
    padding: 13px;
  }

  .modal-main-grid {
    grid-template-columns: 235px minmax(520px, 1fr) 290px;
  }
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) minmax(125px, .65fr) minmax(165px, .8fr) 66px 88px;
  }

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

  .table-panel,
  .detail-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .modal-snapshot {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .snapshot-identity,
  .snapshot-stat {
    border-bottom: 1px solid #1b2939;
  }

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

  .chart-panel {
    order: -1;
    height: 620px;
  }

  .modal-anomaly-side,
  .modal-depth-side {
    min-height: auto;
  }

  .anomaly-list {
    max-height: 360px;
  }

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

@media (max-width: 680px) {
  .modal-snapshot,
  .market-metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .snapshot-identity {
    grid-column: 1 / -1;
  }

  .modal-metric:nth-child(3n) {
    border-right: 1px solid #1b2939;
  }

  .modal-metric:nth-child(2n) {
    border-right: 0;
  }

  .chart-panel {
    height: 520px;
    min-height: 520px;
  }

  .chart-panel__heading,
  .brief-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Margin loans radar */
.margin-panel {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-color: #24364b;
  background: #070c13;
}

.margin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line-soft);
  background: #0a111a;
}

.margin-header h2 {
  margin: 3px 0 0;
  font: 800 22px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: -.04em;
}

.margin-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.margin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.margin-controls select {
  min-width: 138px;
}

.margin-status {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(56, 220, 245, .24);
  color: #b8eaf1;
  background: rgba(56, 220, 245, .07);
  font-size: 12px;
  font-weight: 700;
}

.margin-status.setup {
  border-bottom-color: rgba(245, 165, 36, .38);
  color: #f8d79e;
  background: rgba(245, 165, 36, .08);
}

.margin-status.warn,
.margin-status.error {
  border-bottom-color: rgba(255, 96, 119, .36);
  color: #ffc4cd;
  background: rgba(255, 96, 119, .08);
}

.margin-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-soft);
  background: #080e16;
}

.margin-kpis > div {
  min-width: 0;
  padding: 12px 15px;
  border-right: 1px solid var(--line-soft);
}

.margin-kpis > div:last-child {
  border-right: 0;
}

.margin-kpis strong {
  display: block;
  margin-top: 6px;
  color: #f1f5fb;
  font: 800 19px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.margin-kpis > div:nth-child(2) strong,
.margin-borrow {
  color: #ff7186;
}

.margin-kpis > div:nth-child(3) strong,
.margin-repay {
  color: #38dda1;
}

.margin-kpis small {
  display: block;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 10px;
}

.margin-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  flex: 1;
  min-height: 0;
}

.margin-table-shell {
  min-width: 0;
  overflow: auto;
  background: #070c13;
}

.margin-table {
  min-width: 1320px;
  font-size: 12px;
}

.margin-table th,
.margin-table td {
  height: 43px;
  padding: 8px 10px;
}

.margin-table td small {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 9px;
}

.margin-asset-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.margin-asset-cell strong {
  color: #f0f5fc;
  font-size: 13px;
}

.ratio-value {
  color: #dfe8f5;
  font-size: 13px;
}

.margin-pressure {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 24px;
  border: 1px solid #304158;
  border-radius: 4px;
  color: #c4d0e2;
  background: #111a26;
  font-weight: 900;
}

.margin-pressure.good {
  border-color: rgba(255, 96, 119, .45);
  color: #26080d;
  background: #ff6077;
}

.margin-pressure.mid {
  border-color: rgba(245, 165, 36, .45);
  color: #201507;
  background: #f5a524;
}

.margin-pressure.bad {
  color: #8594a9;
  background: #101722;
}

.margin-signal {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border: 1px solid #34445a;
  border-radius: 4px;
  color: #aebbd0;
  background: #111927;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .04em;
  white-space: nowrap;
}

.margin-signal.surge {
  border-color: rgba(255, 96, 119, .55);
  color: #ffc1ca;
  background: rgba(255, 96, 119, .12);
}

.margin-signal.borrow {
  border-color: rgba(245, 165, 36, .5);
  color: #f6d394;
  background: rgba(245, 165, 36, .1);
}

.margin-signal.repay {
  border-color: rgba(40, 233, 162, .45);
  color: #a7f4d4;
  background: rgba(40, 233, 162, .09);
}

.margin-detail {
  min-width: 0;
  padding: 16px;
  border-left: 1px solid #243248;
  background: #080e16;
  overflow-y: auto;
}

.margin-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.margin-detail h3 {
  margin: 4px 0 0;
  font: 900 27px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: -.05em;
}

.margin-detail > div > p,
.margin-read {
  color: #b7c2d2;
  font-size: 12px;
  line-height: 1.5;
}

.margin-score-block {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  margin-top: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}

.margin-score-block > div {
  min-width: 0;
  padding: 10px;
  border-right: 1px solid var(--line-soft);
}

.margin-score-block > div:last-child {
  border-right: 0;
}

.margin-score-block span,
.margin-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.margin-score-block strong {
  display: block;
  margin-top: 5px;
  color: #edf3fb;
  font: 800 18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.margin-score-block > div:first-child strong {
  color: var(--orange);
  font-size: 24px;
}

.margin-read {
  margin: 13px 0;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line-soft);
}

.margin-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}

.margin-detail-grid > div {
  min-width: 0;
  min-height: 84px;
  padding: 10px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.margin-detail-grid > div:nth-child(2n) {
  border-right: 0;
}

.margin-detail-grid strong {
  display: block;
  margin-top: 7px;
  font: 800 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.margin-detail-grid small {
  display: block;
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 10px;
}

.margin-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.margin-detail-meta span {
  padding: 4px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--muted);
  font-size: 9px;
}

.margin-chart-shell {
  height: 230px;
  margin-top: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}

#marginHistoryChart {
  display: block;
  width: 100%;
  height: 100%;
}

.margin-method {
  padding: 9px 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  background: #080d14;
  font-size: 10px;
}

.margin-method strong {
  color: #c7d4e6;
}

.margin-open-chart {
  width: 100%;
  height: 42px;
  margin-top: 14px;
  border-color: rgba(56, 220, 245, .48);
  color: #dffbff;
  background: rgba(56, 220, 245, .09);
  font-weight: 900;
}

.margin-open-chart:hover:not(:disabled) {
  border-color: #38dcf5;
  background: rgba(56, 220, 245, .15);
}

.margin-open-chart:disabled {
  opacity: .42;
  cursor: not-allowed;
}

body.modal-open {
  overflow: hidden;
}

.margin-analytics-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  padding: 10px;
  background: rgba(2, 5, 9, .95);
  overflow: hidden;
}

.margin-analytics-modal.open {
  display: block;
}

.margin-analytics-dialog {
  display: flex;
  flex-direction: column;
  width: min(1880px, 100%);
  height: calc(100dvh - 20px);
  margin: 0 auto;
  border: 1px solid #29364a;
  border-radius: 9px;
  background: #06090f;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .58);
  overflow: hidden;
}

.margin-analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  padding: 13px 18px;
  border-bottom: 1px solid #202b3b;
  background: #090d14;
}

.margin-modal-identity > div {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.margin-modal-identity h2 {
  margin: 0;
  color: #f4f7fc;
  font: 900 28px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: -.04em;
}

.margin-modal-identity p {
  margin: 5px 0 0;
  color: #8593a8;
  font-size: 11px;
}

.margin-modal-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.margin-modal-controls label {
  display: grid;
  gap: 5px;
}

.margin-modal-controls label > span {
  color: #738199;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.margin-modal-controls select,
.margin-modal-controls button {
  min-width: 118px;
  height: 40px;
  font-size: 12px;
}

.margin-modal-controls button {
  min-width: auto;
}

.margin-analytics-body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding: 12px;
  overflow-y: auto;
}

.margin-modal-stats {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 10px;
  border: 1px solid #202b3b;
  border-radius: 6px;
  background: #090e16;
  overflow: hidden;
}

.margin-modal-stats > div {
  min-width: 0;
  min-height: 78px;
  padding: 11px 13px;
  border-right: 1px solid #202b3b;
}

.margin-modal-stats > div:last-child {
  border-right: 0;
}

.margin-modal-stats span,
.margin-modal-stats small {
  display: block;
  color: #78869c;
  font-size: 9px;
}

.margin-modal-stats span {
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.margin-modal-stats strong {
  display: block;
  margin: 8px 0 4px;
  color: #eef3fb;
  font: 900 17px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.margin-big-chart-panel {
  display: flex;
  flex: 1;
  min-height: 500px;
  flex-direction: column;
  border: 1px solid #202b3b;
  border-radius: 6px;
  background: #090c12;
  overflow: hidden;
}

.margin-big-chart-heading {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 10px 14px;
  border-bottom: 1px solid #1d2736;
}

.margin-big-chart-heading h3 {
  margin: 4px 0 0;
  color: #dfe6f1;
  font: 800 15px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.margin-series-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.margin-series-toggles button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 0 9px;
  border-color: #263448;
  color: #738096;
  background: #0c121c;
  font-size: 10px;
}

.margin-series-toggles button.active {
  color: #dbe4f1;
  border-color: #445268;
  background: #121925;
}

.margin-series-toggles button:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.margin-series-toggles i,
.margin-big-legend i,
.margin-big-tooltip i {
  display: inline-block;
  width: 10px;
  height: 3px;
  border-radius: 2px;
  background: var(--series-color);
}

.margin-big-chart-wrap {
  position: relative;
  flex: 1;
  min-height: 440px;
}

#marginBigChart {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.margin-big-tooltip {
  position: absolute;
  z-index: 3;
  display: none;
  width: 230px;
  padding: 11px 12px;
  border: 1px solid #354258;
  border-radius: 5px;
  color: #aeb9ca;
  background: rgba(17, 22, 31, .97);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .34);
  pointer-events: none;
}

.margin-big-tooltip.show {
  display: grid;
  gap: 8px;
}

.margin-big-tooltip > strong {
  padding-bottom: 7px;
  border-bottom: 1px solid #2a3445;
  color: #dfe6f1;
  font-size: 11px;
}

.margin-big-tooltip span {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 6px;
  font-size: 10px;
}

.margin-big-tooltip b {
  color: #eff4fb;
}

.margin-big-legend {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 10px 22px;
  min-height: 42px;
  padding: 10px 14px;
  border-top: 1px solid #1d2736;
}

.margin-big-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #8996aa;
  font-size: 10px;
}

.margin-big-legend strong {
  color: #d9e1ed;
}

.margin-modal-source {
  padding: 10px 4px 0;
  color: #748198;
  font-size: 9px;
  line-height: 1.5;
}

.margin-modal-source strong {
  color: #aeb9ca;
}

body.margin-mode #sectorSelect,
body.margin-mode #qualitySelect,
body.margin-mode #limitInput {
  display: none;
}

body.margin-mode .controls {
  grid-template-columns: minmax(220px, 360px) 90px;
}

body::-webkit-scrollbar,
.margin-table-shell::-webkit-scrollbar,
.margin-detail::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.margin-table-shell::-webkit-scrollbar-thumb,
.margin-detail::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: #334554;
}

@media (max-width: 1220px) {
  .margin-workspace {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .margin-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 980px) {
  .side-rail {
    grid-template-columns: 82px 1fr auto;
  }

  .side-rail .view-switch button {
    padding-inline: 11px;
  }

  .margin-panel {
    min-height: 900px;
  }

  .margin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .margin-controls {
    justify-content: flex-start;
  }

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

  .margin-kpis > div {
    border-bottom: 1px solid var(--line-soft);
  }

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

  .margin-table-shell {
    min-height: 560px;
  }

  .margin-detail {
    border-top: 1px solid #243248;
    border-left: 0;
  }

  .margin-analytics-header {
    align-items: stretch;
    flex-direction: column;
  }

  .margin-modal-controls {
    flex-wrap: wrap;
  }

  .margin-modal-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .margin-modal-stats > div:nth-child(3) {
    border-right: 0;
  }

  .margin-modal-stats > div:nth-child(-n+3) {
    border-bottom: 1px solid #202b3b;
  }

  .margin-big-chart-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .margin-series-toggles {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .margin-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .margin-controls select:first-child,
  .margin-controls button {
    grid-column: 1 / -1;
  }

  .margin-kpis,
  .margin-detail-grid {
    grid-template-columns: 1fr;
  }

  .margin-detail-grid > div {
    border-right: 0;
  }

  .margin-analytics-modal {
    padding: 0;
  }

  .margin-analytics-dialog {
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .margin-modal-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .margin-modal-controls label,
  .margin-modal-controls select {
    width: 100%;
  }

  .margin-modal-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .margin-modal-stats > div:nth-child(2n) {
    border-right: 0;
  }

  .margin-modal-stats > div {
    border-bottom: 1px solid #202b3b;
  }

  .margin-big-chart-panel {
    min-height: 600px;
  }
}

/* Signal desk */
body:not([data-view="screener"]) #marketDesk,
body:not([data-view="screener"]) #signalHead,
body[data-view="screener"] :is(#setupHead, #searchInput, #sectorSelect, #qualitySelect, #limitInput, #patternTabs, #cvdLegend, #sectorStrip, #setupTabs) {
  display: none;
}
body[data-view="screener"] .topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
body[data-view="screener"] .brand { flex: 1 1 180px; }
body[data-view="screener"] .controls { display: flex; }
.desk-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: clamp(18px, 3vw, 38px);
  background: linear-gradient(110deg, #1c1a16, #101720 65%);
  border-top: 2px solid #eeb668;
  border-bottom: 1px solid #38342e;
}
.desk-head .label { color: #edbc74; font-size: 12px; }
.desk-head h2 { margin: 8px 0; font-size: clamp(28px, 3.4vw, 44px); line-height: 1.1; letter-spacing: -.035em; }
.desk-head p, #depthCaption { margin: 4px 0; color: #b7c2ce; line-height: 1.5; font-size: 14px; }
#marketForm { flex: 0 1 390px; min-width: 0; }
#marketForm label { display: block; font-size: 14px; font-weight: 650; margin-bottom: 7px; }
#marketForm > div { display: flex; gap: 6px; }
#marketInput { flex: 1; width: 0; min-width: 0; height: 44px; font-size: 16px; }
#marketForm button { background: #efbd78; color: #21170b; border-color: #efbd78; height: 44px; padding: 0 16px; font-weight: 750; }
#marketHint { display: block; min-height: 16px; margin-top: 6px; color: #b4c0cd; }
body[data-view="screener"] #tablePanel table { width: 100%; min-width: 540px; font-size: 15px; }
body[data-view="screener"] #tablePanel :is(td,th) { padding: 12px; height: 48px; font-variant-numeric: tabular-nums; }
body[data-view="screener"] #tablePanel th { color: #b8c3cf; font-size: 12px; }
body[data-view="screener"] #tablePanel td small { display: block; margin-top: 3px; color: #9eacbc; }
body[data-view="screener"] #tablePanel td.empty { height: 140px; text-align: center; white-space: normal; color: #b5c3d4; }
.desk-score { color: #f0bd74; }
.depth-history-panel { padding: 18px; border: 1px solid var(--line-soft); border-radius: 7px; background: #101620; }
.depth-history-panel h3 { margin: 0; font-size: 18px; }
#depthRibbon { width: 100%; height: 116px; margin-top: 12px; }
.margin-header { border-top: 2px solid #eeb668; }
.margin-table { font-size: 14px; font-variant-numeric: tabular-nums; }
.margin-table th { font-size: 12px; color: #bfc9d5; }
.margin-borrow { color: #83bcff; }
.margin-repay { color: #80d8ae; }
.margin-controls { flex-wrap: wrap; }
@media (max-width: 720px) {
  .desk-head { flex-direction: column; align-items: stretch; gap: 18px; }
  #marketForm { flex: auto; }
  body[data-view="screener"] .topbar { padding: 10px; }
  body[data-view="screener"] .status-row { display: flex; overflow-x: auto; }
  body[data-view="screener"] .status-row > div { flex: 1 0 auto; }
}
#savedMarkets:not(:empty) { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
#savedMarkets button { height: 30px; border: 1px solid #445262; color: #e2e8ef; background: #18212a; padding-inline: 9px; font-size: 12px; }
#saveMarket[aria-pressed="true"] { color: #efbd78; border-color: #927341; }
@media (max-width: 620px) {
  .coin-modal__header { flex-wrap: wrap; }
  .modal-controls { flex-wrap: wrap; }
}

.coin-menu { display:flex; flex:0 0 auto; gap:6px; padding:0 16px; border-bottom:1px solid #263445; background:#0c121b; }
.coin-menu button { height:42px; border:0; border-bottom:2px solid transparent; border-radius:0; background:transparent; color:#aab6c6; padding:0 12px; }
.coin-menu button[aria-pressed="true"] { color:#f1c283; border-bottom-color:#f1c283; }
#coinEventCount { color:#acb9c9; font-size:11px; }
.coin-modal__header { min-height:60px; padding:8px 16px; }
.coin-modal__header h2 { font-size:22px; }
#coinModal [data-coin-panel][hidden], #levelsPanel[hidden] { display:none; }
#coinModal .chart-panel { height:clamp(400px,calc(100dvh - 172px),850px); min-height:0; }
.book-chart-tools,.levels-tools { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.book-chart-tools :is(button,select) { height:34px; padding-inline:10px; }
[data-book-side="bid"][aria-pressed="true"] { border-color:#36836a; color:#77deb4; background:#102a25; }
[data-book-side="ask"][aria-pressed="true"] { border-color:#995160; color:#ffa8b2; background:#301d26; }
#eventPins[aria-pressed="true"] { color:#e8bd73; border-color:#987a4b; }
.book-readout { color:#b9c6d6; border-top:1px solid #223142; padding:8px 12px; font:12px/1.5 ui-monospace,monospace; }
.coin-book-pane { display:grid; grid-template-columns:minmax(250px,1fr) minmax(0,2fr); align-items:start; gap:12px; }
.coin-book-pane .modal-depth-section { background:#0b121b; border:1px solid #253346; border-radius:7px; }
#coinModal .anomaly-list { display:grid; gap:8px; max-height:none; padding:0; }
.event-group { background:#0d141e; border:1px solid #223142; border-radius:6px; }
.event-group summary { cursor:pointer; padding:12px; }
.event-group summary span { margin-inline-start:12px; color:#adbbcc; }
.event-group .anomaly-card { display:block; width:calc(100% - 16px); margin:4px 8px; height:auto; text-align:left; white-space:normal; }
#coinModal [data-coin-panel="metrics"] > * { margin-bottom:10px; }
#coinModal .modal-bias-card { min-height:0; }
#coinModal .chart-tooltip { max-width:calc(100% - 8px); }
body[data-view="levels"] .overview-panel, body[data-view="levels"] .controls { display:none; }
body[data-view="levels"] .topbar { display:flex; gap:12px; flex-wrap:wrap; }
body[data-view="levels"] .brand { margin-right:auto; }
#levelsPanel { grid-column:1/-1; grid-row:1/-1; padding:clamp(12px,2vw,26px); overflow:auto; }
.levels-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; }
.levels-head h2 { margin:5px 0; font-size:28px; }
#levelsStatus, .levels-method { color:#b0bdce; font-size:13px; }
.levels-method { padding:12px 0; line-height:1.5; }
.levels-method summary { cursor:pointer; }
.levels-table-wrap { overflow:auto; max-height:65vh; border:1px solid #293445; border-radius:6px; }
#levelsPanel table { min-width:480px; width:100%; font-size:15px; }
#levelsPanel th { color:#bac5d3; font-size:12px; }
#levelsPanel :is(td,th) { height:42px; padding-inline:14px; }
#levelsPanel tr.below td { background:#41272d; }
#levelsPanel tr.above td { background:#173b32; }
#levelsPanel tr:is(:hover,:focus-visible) td { filter:brightness(1.3); }
@media (max-width:720px) {
  .coin-book-pane { grid-template-columns:1fr; }
  .coin-menu { padding:0 3px; gap:0; overflow-x:auto; }
  .coin-menu button { flex:1 0 auto; }
  #coinModal .chart-panel__heading { gap:8px; align-items:flex-start; }
  .book-chart-title .label { display:none; }
  .side-rail .view-switch { justify-content:flex-start; overflow-x:auto; }
  .side-rail .view-switch button { flex:0 0 auto; }
  .levels-tools input { width:140px; }
}
.book-key { flex: 0 0 auto; background:#10161c; border-bottom:1px solid #28323d; font-size:12px; }
.book-key summary { padding:6px 12px; color:#e2eaf1; cursor:pointer; }
.book-key summary strong { margin-right:14px; }
#bookKeyLegend { display:inline-flex; flex-wrap:wrap; column-gap:14px; row-gap:4px; }
#bookKeyLegend span { display:inline-flex; align-items:center; gap:5px; color:#bfccd4; }
#bookKeyLegend i { width:10px; height:10px; border-radius:2px; }
.book-key .book-readout { border:0; padding:0 12px 6px; color:#c8d2dc; }
.book-key:not([open]) #bookKeyLegend { display:none; }
#coinModal .book-toolbar { flex-direction:row; align-items:flex-start; gap:8px; padding:6px 9px; min-height:0; background:#10161c; }
.book-toolbar .book-key { flex:1 1 auto; min-width:0; border:0; }
.book-toolbar .book-key summary strong { display:inline; font-size:13px; }
.book-actions { display:flex; gap:5px; align-items:center; }
.book-actions > button,.book-settings > summary { height:30px; padding:5px 8px; font:600 12px/18px system-ui; white-space:nowrap; }
.book-settings { position:relative; }
.book-settings > summary { cursor:pointer; border:1px solid #344150; border-radius:4px; }
.book-settings .book-chart-tools { position:absolute; z-index:6; right:0; top:34px; width:min(270px,75vw); padding:10px; background:#101820; border:1px solid #344150; border-radius:5px; box-shadow:0 6px 16px #0007; }
@media(max-width:680px) {
  #coinModal .book-toolbar { flex-wrap:wrap; }
  .book-actions { margin-left:auto; }
}
