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

.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: 1580px;
  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);
}

.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);
}

.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);
}

.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;
  }
}
