:root {
  --paper: #f7f7f4;
  --ink: #111111;
  --muted: #70706b;
  --line: #deded8;
  --soft: #ffffff;
  --soft-2: #eeeeea;
  --accent: #10a37f;
  --accent-soft: #dff4ec;
  /* multi-layer shadow: ring → float → ambient */
  --shadow:
    0 0 0 1px rgba(17,17,17,0.04),
    0 2px 6px rgba(17,17,17,0.05),
    0 12px 32px rgba(17,17,17,0.07);
  --shadow-lifted:
    0 0 0 1px rgba(17,17,17,0.06),
    0 4px 12px rgba(17,17,17,0.08),
    0 20px 48px rgba(17,17,17,0.10);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* subtle radial warm-to-cool gradient instead of a flat fill */
  background: radial-gradient(ellipse 120% 80% at 30% 20%, #f9f9f6 0%, #f4f4f0 60%, #efeff0 100%);
  min-height: 100vh;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  /* minmax(0,1fr): a 1fr track refuses to shrink below its items'
     min-content, which lets wide tables blow the page out sideways */
  grid-template-columns: 220px minmax(0, 1fr);
}

.rail {
  padding: 24px 18px;
  background: rgba(255,255,255,0.72);
  /* right edge casts a shadow into the workspace */
  box-shadow: 1px 0 0 var(--line), 4px 0 24px rgba(17,17,17,0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 34px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.nav-item.active {
  background: var(--ink);
  color: var(--paper);
}

.workspace {
  padding: 26px;
}

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

.eyebrow,
.label,
.panel-head span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 4px 0 0;
  font-size: 34px;
  letter-spacing: -0.045em;
}

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip,
.search,
.form-panel input {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 13px;
}

.chip {
  cursor: pointer;
}

.chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.search {
  width: 240px;
}

.view {
  display: none;
}

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

.hero-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(330px, 0.9fr);
  gap: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(330px, 0.72fr) minmax(460px, 1fr);
  gap: 18px;
}

.grid-3,
.fee-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.panel,
.fee-card {
  background: var(--soft);
  border: 1px solid rgba(17,17,17,0.07);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.panel-head strong {
  font-size: 13px;
}

#walletMarketLabel {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.funnel {
  display: grid;
  gap: 10px;
}

.stage {
  display: grid;
  grid-template-columns: 124px 1fr 72px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  cursor: pointer;
}

.stage:hover,
.stage.active {
  background: var(--soft-2);
}

.stage-name {
  font-weight: 700;
  font-size: 13px;
}

.track {
  height: 34px;
  background: var(--soft-2);
  border-radius: 999px;
  overflow: hidden;
}

.fill {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
}

.stage-value {
  text-align: right;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.metric-row div {
  background: var(--paper);
  border-radius: 14px;
  padding: 14px;
}

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

b {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.mini-list,
.bars,
.report-list,
.wallet-table {
  display: grid;
  gap: 10px;
}

.fee-market-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#feeBars {
  display: grid;
  /* rows keep natural height and stack at the top — without this, grid's
     default align-content: stretch expands a short result set (e.g. 2
     markets after a search) to fill the fixed scroll height */
  align-content: start;
  flex: none;
  height: 560px;
  max-height: calc(100vh - 300px);
  min-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.fee-market-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid transparent;
  font-size: 13px;
}

.fee-market-row:hover,
.fee-market-row.selected {
  background: #fff;
  border-color: var(--ink);
}

.fee-market-row span {
  min-width: 0;
  font-weight: 700;
}

.fee-market-row small {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fee-market-row strong {
  margin: 0;
  font-size: 14px;
}

.list-row,
.bar-row,
.report-row,
.wallet-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: var(--paper);
  font-size: 13px;
}

.bar-row {
  grid-template-columns: 120px 1fr 64px;
}

.bar-line {
  height: 8px;
  background: var(--soft-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-line i {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
}

.axis-card {
  height: 204px;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: 1fr 22px;
  gap: 8px 10px;
  padding-top: 8px;
}

.y-axis,
.x-axis {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.y-axis {
  writing-mode: vertical-rl;
  rotate: 180deg;
  align-self: center;
  justify-self: center;
}

.x-axis {
  grid-column: 2;
  text-align: center;
}

.histogram {
  height: 100%;
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 24px 0 22px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: relative;
}

.histogram i {
  flex: 1;
  background: var(--ink);
  border-radius: 999px 999px 8px 8px;
  min-height: 12px;
  position: relative;
}

.histogram em {
  position: absolute;
  left: 50%;
  bottom: -22px;
  translate: -50% 0;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  white-space: nowrap;
}

.freshness {
  height: 178px;
  display: grid;
  place-content: center;
  text-align: center;
  position: relative;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  right: 24px;
  top: 24px;
}

.form-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.form-panel input {
  width: 100%;
  border-radius: 12px;
}

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

.primary {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  padding: 13px 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary.ghost {
  width: 100%;
  margin-top: 14px;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--ink);
}
.primary.ghost:hover {
  background: var(--ink);
  color: var(--paper);
}

.fee-card {
  padding: 18px;
  cursor: pointer;
}

.fee-card.selected {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.fee-card.selected small {
  color: #c9c9c2;
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail { min-width: 0; }

  .rail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mark {
    margin: 0;
  }

  .nav {
    grid-auto-flow: column;
  }

  .hero-grid,
  .split,
  .grid-3,
  .fee-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .filters {
    justify-content: start;
  }

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

  .stage-value {
    text-align: left;
  }
}

/* ─── Ask module ────────────────────────────────── */

.ask-view {
  flex-direction: column;
  /* fallback only — sizeAskView() measures the real offset at runtime
     (the fixed 110px guess left the composer below the fold) */
  height: calc(100vh - 150px);
  gap: 0;
}

.ask-view.active {
  display: flex;
}

.ask-context-bar {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-row {
  display: flex;
}

.chat-row-user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-bubble-user {
  background: var(--ink);
  color: var(--paper);
  border-radius: 16px 16px 4px 16px;
  max-width: 60%;
}

.chat-bubble-agent {
  background: var(--soft);
  border: 1px solid rgba(17,17,17,0.07);
  border-radius: 16px 16px 16px 4px;
  box-shadow:
    0 0 0 1px rgba(17,17,17,0.03),
    0 2px 8px rgba(17,17,17,0.06),
    0 8px 24px rgba(17,17,17,0.05);
}

.chat-intro {
  margin: 0 0 2px;
  color: var(--ink);
}

.chat-intro em { color: var(--muted); font-style: normal; }

.chat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.chat-table th {
  text-align: left;
  padding: 5px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.chat-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}

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

.chat-meta {
  margin-top: 10px;
}

.chat-meta details > summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  list-style: none;
  user-select: none;
}

.chat-meta details > summary::marker,
.chat-meta details > summary::-webkit-details-marker { display: none; }

.chat-meta details > summary::before { content: "▶  "; font-size: 9px; }
.chat-meta details[open] > summary::before { content: "▼  "; font-size: 9px; }

.chat-sql {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin-top: 8px;
  white-space: pre;
  color: var(--ink);
  line-height: 1.6;
}

@keyframes think {
  0%, 80%, 100% { opacity: 0.15; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.thinking-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 3px;
  animation: think 1.1s ease-in-out infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.18s; }
.thinking-dot:nth-child(3) { animation-delay: 0.36s; }

.chat-footer {
  flex-shrink: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.ask-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.ask-example-chip {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

.ask-example-chip:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.ask-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.ask-input {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
  outline: none;
}

.ask-input:focus {
  border-color: rgba(17,17,17,0.4);
  box-shadow: 0 0 0 3px rgba(17,17,17,0.06), 0 2px 8px rgba(17,17,17,0.08);
  outline: none;
}

.ask-send {
  border: 0;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  padding: 11px 20px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}

.ask-send:hover { opacity: 0.85; }

/* ─── Compare module ─────────────────────────────── */

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.mkt-card {
  background: var(--soft);
  border: 1px solid rgba(17,17,17,0.07);
  border-radius: 18px;
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  text-align: left;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.mkt-card:hover {
  border-color: rgba(17,17,17,0.18);
  box-shadow: var(--shadow-lifted);
  transform: translateY(-2px);
}

.mkt-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.mkt-slug {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  margin-top: 2px;
}

.price-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.price-col small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 3px;
}

.price-col .yes-num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.price-col .no-num {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.delta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.delta {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
}

.delta.above { color: #16a34a; border-color: #16a34a; }
.delta.below { color: #dc2626; border-color: #dc2626; }
.delta.par   { color: var(--muted); border-color: var(--line); }

.spark-wrap {
  height: 44px;
}

.spark-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

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

.vol-pair small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.vol-pair b {
  font-size: 13px;
  letter-spacing: -0.02em;
}

/* Detail */
.detail-back {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.detail-back:hover { color: var(--ink); }

.detail-price-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-end;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.detail-price small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}

.detail-price .big {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
}

.detail-price .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.detail-section {
  background: var(--soft);
  border: 1px solid rgba(17,17,17,0.07);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

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

.section-head strong { font-size: 13px; }
.section-head small  { color: var(--muted); font-size: 12px; }

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.price-chart-wrap {
  width: 100%;
  height: 160px;
  overflow: visible;
}

.price-chart-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Order book */
.book-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.book-col-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.book-asks, .book-bids { display: grid; gap: 5px; }
.book-asks { margin-bottom: 4px; }
.book-bids { margin-top: 4px; }

.book-mid {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 5px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.depth-row {
  display: grid;
  grid-template-columns: 46px 1fr 58px;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.depth-row .price { font-weight: 700; }

.depth-bar {
  height: 6px;
  background: var(--soft-2);
  border-radius: 999px;
  overflow: hidden;
}

.depth-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.depth-row.ask .depth-bar i { background: var(--muted); opacity: 0.55; }
.depth-row.bid .depth-bar i { background: var(--ink); opacity: 0.55; }

.depth-row .size { text-align: right; color: var(--muted); }

/* Volume chart */
.vol-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 110px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 0 0;
  position: relative;
}

.vol-day {
  flex: 1;
  height: 100%; /* required: bar heights are percentages of the day cell */
  display: flex;
  gap: 2px;
  align-items: flex-end;
  position: relative;
}

.vol-bar-ps { flex: 1; background: var(--ink); border-radius: 3px 3px 0 0; min-height: 3px; }
.vol-bar-pm { flex: 1; background: var(--soft-2); border-radius: 3px 3px 0 0; min-height: 3px; border: 1px solid var(--line); }

.vol-day-label {
  position: absolute;
  bottom: -17px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.vol-legend {
  display: flex;
  gap: 16px;
  margin-top: 26px;
  font-size: 12px;
  color: var(--muted);
}

.vol-legend-ps::before { content: "■ "; color: var(--ink); }
.vol-legend-pm::before { content: "■ "; color: var(--line); }

/* Compare tabs */
.compare-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.compare-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
}

.compare-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* Card stat row (spread + depth) */
.card-stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.card-stat small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.card-stat span {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Spread & depth detail section */
.sd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 16px;
}

.sd-col-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}

.sd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.sd-row:last-child { border-bottom: 0; }
.sd-row span { color: var(--muted); font-size: 12px; }
.sd-row strong { font-variant-numeric: tabular-nums; }

.depth-ratio-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.depth-ratio-track {
  height: 8px;
  background: var(--soft-2);
  border-radius: 999px;
  overflow: hidden;
}

.depth-ratio-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  opacity: 0.7;
}

/* MM Activity */
.mm-activity-wrap { display: none; }

.mm-wallet-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.mm-chip {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left;
}

.mm-chip small {
  display: block;
  font-weight: 400;
  font-size: 10px;
  font-family: ui-monospace, monospace;
  margin-top: 1px;
  opacity: 0.6;
}

.mm-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.mm-chip.active small { opacity: 0.5; }

.mm-panel {
  background: var(--soft);
  border: 1px solid rgba(17,17,17,0.07);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.mm-panel-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.mm-legend {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  gap: 12px;
}

.mm-legend-m::before { content: "■ "; color: var(--ink); }
.mm-legend-t::before { content: "■ "; color: #b0afaa; }

/* Fill bars */
.fill-bar-item { margin-bottom: 12px; }
.fill-bar-item:last-child { margin-bottom: 0; }

.fill-bar-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 11px;
}

.fill-bar-meta span { color: var(--muted); }
.fill-bar-meta strong { font-variant-numeric: tabular-nums; }

.fill-bar-outer {
  height: 8px;
  background: var(--soft-2);
  border-radius: 999px;
  overflow: hidden;
}

.fill-bar-inner {
  height: 100%;
  display: flex;
  border-radius: 999px;
  overflow: hidden;
}

.fill-bar-m { background: var(--ink); height: 100%; }
.fill-bar-t { background: #b0afaa; height: 100%; }

/* MM bottom grid */
.mm-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 18px;
}

.mm-stat-list { display: grid; gap: 0; }

.mm-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.mm-stat-row:last-child { border-bottom: 0; }
.mm-stat-row span { color: var(--muted); }

.mm-note {
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}

.mm-contracts {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.mm-contracts th {
  text-align: left;
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.mm-contracts td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
}

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

@media (max-width: 640px) {
  .compare-grid { grid-template-columns: 1fr; }
  .book-compare { grid-template-columns: 1fr; }
  .sd-grid { grid-template-columns: 1fr; }
  .mm-bottom-grid { grid-template-columns: 1fr; }
}

/* ── Compare live-data states ── */
.compare-empty-note {
  grid-column: 1 / -1;
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface, #fff);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.compare-empty-note code {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: rgba(17,17,17,0.05);
  padding: 1px 5px;
  border-radius: 4px;
}
.compare-feed-note {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  padding: 0 2px 2px;
}

/* ── Topbar back link + subtitle (compare detail) ── */
.topbar-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.topbar-back:hover { color: var(--ink); }
.view-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}
.view-subtitle:empty { display: none; }

/* ── Midpoint-delta filter controls + critical flagging ── */
.delta-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.delta-threshold-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.delta-threshold-label input {
  width: 44px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 12px;
  text-align: center;
  color: var(--ink);
}
.chip-toggle {
  font: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.chip-toggle.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.critical-count {
  font-size: 12px;
  color: var(--muted);
}
.critical-count:empty { display: none; }
.critical-count::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dc2626;
  margin-right: 5px;
}
.mkt-card { position: relative; }
/* Critical = subtle red dot only; the card itself stays in the dual-tone system. */
.crit-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dc2626;
}

/* ── Mappings view ── */
.mappings-wrap { display: none; }
.mappings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.mappings-summary {
  font-size: 12px;
  color: var(--muted);
}
.mappings-sync-btn {
  font: inherit;
  font-size: 12px;
  padding: 7px 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.mappings-sync-btn:disabled {
  background: var(--soft, #eee);
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
}
.map-source {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.mappings-wrap .mono {
  font-family: ui-monospace, monospace;
  font-size: 11px;
}

/* ── Compare table layout ── */
.cmp-table-panel {
  grid-column: 1 / -1;
  background: var(--soft);
  border: 1px solid rgba(17,17,17,0.07);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cmp-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.cmp-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--soft-2);
  vertical-align: middle;
}
.cmp-row { cursor: pointer; }
.cmp-row:hover td { background: var(--soft-2); }
.cmp-row:last-child td { border-bottom: 0; }
.cmp-market { max-width: 320px; }
.cmp-title {
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-slug {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.cmp-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
}
.cmp-muted { color: var(--muted); font-weight: 400; font-size: 12px; }
.cmp-sub {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
}
.cmp-spark svg { width: 120px; height: 30px; display: block; }
.delta-sm { font-size: 11px; padding: 2px 8px; }
.crit-dot-inline {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dc2626;
  margin-right: 7px;
  vertical-align: 1px;
}

/* ── Hoverable volume bars ── */
.vol-day::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 5;
}
.vol-day:hover::after { opacity: 1; }
.vol-day:hover .vol-bar-ps { background: #000; }
.vol-day:hover .vol-bar-pm { border-color: var(--muted); }

/* ── Fees UX: modal, breakdown, notice, icons ── */
.custom-dates { display: none; gap: 6px; align-items: center; }
.custom-dates input {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--ink);
}
.top-report-btn { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,17,17,0.32);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  width: min(420px, calc(100vw - 40px));
  background: var(--soft);
  border-radius: 18px;
  box-shadow: var(--shadow-lifted);
  padding: 22px 24px 24px;
  display: grid;
  gap: 12px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head strong { font-size: 16px; letter-spacing: -0.02em; }
.modal-close {
  border: 0; background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { background: var(--soft-2); color: var(--ink); }
.modal-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.modal-box label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 700; }
.modal-box input {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 13.5px; background: #fff; color: var(--ink);
}
.modal-box .primary { margin-top: 4px; }

.market-totals {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.market-totals div { background: var(--paper); border-radius: 12px; padding: 10px 12px; }
.market-totals b { font-size: 15px; }

.wallet-cols { display: grid; grid-template-columns: repeat(3, 64px); gap: 4px; text-align: right; }
.wallet-cols i { font-style: normal; font-variant-numeric: tabular-nums; }
.wallet-head { background: transparent !important; padding-top: 0; padding-bottom: 4px; }
.wallet-head span, .wallet-head i { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }

.report-notice {
  display: none;
  background: var(--paper);
  color: var(--ink);
  border-left: 2px solid var(--ink);
  border-radius: 0 12px 12px 0;
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}
.report-actions { display: inline-flex; gap: 6px; align-items: center; }
.report-status { font-style: normal; font-size: 12px; color: var(--muted); }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--soft-2); }
.icon-del { color: var(--muted); }
.icon-del:hover { color: #dc2626; border-color: rgba(220,38,38,0.4); }

/* ── Fee summary 5-card row, info cards, collapsible recipients ── */
.fee-summary { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.fee-card.info { cursor: default; }
.fee-card.info:hover { transform: none; box-shadow: var(--shadow); }
.collapse-head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.collapse-chevron {
  color: var(--muted);
  font-size: 13px;
  transition: transform 0.15s;
}
.receivers-body { margin-top: 16px; }
.wallet-cols-4 { grid-template-columns: repeat(4, 70px); }

/* ── Freshness page (support-facing status) ── */
#freshness.active { display: block; }
.fresh-headline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  margin-bottom: 18px;
}
.fresh-headline small { color: var(--muted); font-size: 12px; margin-left: auto; }
.fresh-card { margin-bottom: 14px; }
.fresh-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.fresh-card-head strong { font-size: 14px; }
.fresh-card-head span { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.fresh-rows { display: grid; gap: 8px; }
.fresh-rows > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 12px;
  background: var(--paper);
  border-radius: 12px;
  font-size: 13px;
}
.fresh-rows span { color: var(--muted); }
.fresh-rows b { display: flex; align-items: center; gap: 7px; font-size: 13px; margin: 0; letter-spacing: 0; text-align: right; }
.fresh-rows b small { display: inline; color: var(--muted); font-weight: 400; }
.fresh-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.fresh-ok   { background: #10a37f; }
.fresh-warn { background: #d97706; }
.fresh-bad  { background: #dc2626; }
.fresh-note { font-size: 12px; color: var(--muted); margin-top: 12px; max-width: 640px; }
.fresh-note-warn { color: var(--ink); font-weight: 600; }
.fresh-stale > div { background: rgba(220, 38, 38, 0.04); }
.nav-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dc2626;
  margin-left: 8px;
  vertical-align: 1px;
}

/* ── Funnel lower row: top markets + a roomier order-size histogram ── */
.funnel-lower {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 18px;
}
.axis-card-tall { height: 320px; }

/* ── Funnel lower row v2: equal-height panels, scrollable markets,
      interactive histogram ── */
.funnel-lower-panel {
  height: 460px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.market-bars-scroll {
  align-content: start;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}
.hist {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 14px;
  padding: 8px 4px 0;
}
.hist-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 0;
  position: relative;
  cursor: default;
}
.hist-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: color 0.15s ease;
}
.hist-bar-track {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  background: var(--soft-2);
  border-radius: 10px;
  overflow: hidden;
}
.hist-bar-track i {
  display: block;
  width: 100%;
  background: var(--ink);
  border-radius: 10px 10px 0 0;
  transition: opacity 0.15s ease;
}
.hist-col:hover .hist-bar-track i { opacity: 0.75; }
.hist-col:hover .hist-count { color: var(--ink); }
.hist-col:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}
.hist-bucket {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.hist-x {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
}

/* ── Overview dashboard: minimal, dual-tone ── */
.ov-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.ov-kpis .fee-card { padding: 18px; cursor: default; }
.ov-delta {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.ov-trends {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.ov-trend { display: flex; flex-direction: column; }
.ov-chart {
  height: 120px;
  margin-top: 14px;
  display: flex;
  /* children stretch to the full 120px so the inner percentage heights
     resolve; the bars themselves bottom-anchor via .ov-day */
  align-items: stretch;
  gap: 6px;
}
.ov-day {
  flex: 1;
  display: flex;
  align-items: flex-end;
  position: relative;
  border-radius: 6px;
  background: var(--soft-2);
  overflow: visible;
  min-width: 0;
}
.ov-day i {
  display: block;
  width: 100%;
  background: var(--ink);
  border-radius: 6px;
  transition: opacity 0.15s ease;
}
.ov-day:hover i { opacity: 0.75; }
.ov-day:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}
.ov-mid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 18px;
}
.ov-leaders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.ov-link {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}
.ov-link:hover { color: var(--ink); }
.ov-sub { margin-left: 16px; opacity: 0.85; }
.ov-sub span { font-size: 12px; }

/* ── Mobile ── */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail { min-width: 0; }
  .rail {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    margin-bottom: 0;
    flex: none;
    font-size: 13px;
  }
  .nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
    min-width: 0; /* flex items refuse to shrink below content otherwise */
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item {
    padding: 8px 11px;
    white-space: nowrap;
    font-size: 13px;
  }
  .workspace { padding: 14px; }
  .topbar { flex-direction: column; gap: 10px; margin-bottom: 16px; }
  h1 { font-size: 24px; }
  .filters { justify-content: flex-start; width: 100%; }
  .search { flex: 1; min-width: 150px; width: auto; }

  /* stacked layouts */
  .hero-grid, .split, .grid-3, .ov-trends, .ov-mid, .ov-leaders, .funnel-lower {
    grid-template-columns: 1fr;
  }
  .fee-summary, .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ov-kpis .fee-card, .fee-card { padding: 14px; }
  .market-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel-lower-panel { height: auto; }
  .market-bars-scroll { max-height: 420px; }
  #feeBars { height: 420px; min-height: 0; }

  /* wide tables scroll horizontally instead of crushing */
  .compare-grid, .mm-activity-wrap, .mappings-wrap { overflow-x: auto; }
  .cmp-row, .cmp-head { min-width: 760px; }
  .compare-tabs { flex-wrap: wrap; gap: 8px; }
  .delta-controls { margin-left: 0; width: 100%; }
}

@media (max-width: 480px) {
  .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { grid-template-columns: 90px 1fr 60px; }
  b { font-size: 17px; }
  .hist { gap: 8px; }
  .hist-bucket { font-size: 9px; }
}

/* grid blowout guards: wide children must scroll inside their panel,
   never widen the page (grid items default to min-width:auto) */
.workspace, .view, .compare-grid, .mm-activity-wrap, .mappings-wrap {
  min-width: 0;
}
@media (max-width: 900px) {
  .compare-grid, .mm-activity-wrap, .mappings-wrap { max-width: 100%; }
  body { overflow-x: hidden; }
}

@media (max-width: 900px) {
  /* the table PANEL is the wide element — it scrolls internally */
  .cmp-table-panel { overflow-x: auto; max-width: 100%; min-width: 0; }
  .compare-grid { display: block; }
  .compare-feed-note { max-width: 100%; }
}

/* ── Ask: markdown + tool chips + session bar ── */
.md-table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
  width: 100%;
}
.md-table th, .md-table td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
}
.md-table th {
  background: var(--soft-2);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.md-table tr:nth-child(even) td { background: var(--paper); }
.md-code {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 12px;
  overflow-x: auto;
  margin: 10px 0;
}
.md-list { margin: 8px 0; padding-left: 20px; }
.md-list li { margin: 3px 0; }
.md-h { margin: 14px 0 6px; font-size: 14px; }
.ask-answer p { margin: 8px 0; line-height: 1.55; }
.ask-answer code {
  background: var(--soft-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12px;
}
.ask-cursor { animation: blink 1s step-end infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
.ask-tool-chip {
  display: block;
  margin: 6px 0;
  font-size: 12px;
  color: var(--muted);
}
.ask-tool-chip summary {
  cursor: pointer;
  padding: 6px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-block;
  font-weight: 600;
}
.ask-tool-status { font-weight: 400; }
.ask-error { color: #b91c1c; }
.ask-warn { color: #b45309; font-weight: 600; }
.ask-new-chat {
  margin-left: 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  color: var(--ink);
}
.ask-new-chat:hover { border-color: var(--ink); }

/* Ask context bar: meta left, + New chat pinned right */
.ask-context-bar { display: flex; align-items: center; gap: 10px; }
.ask-context-bar .ask-new-chat { margin-left: auto; font-weight: 700; }

/* Ask history dropdown */
.ask-context-bar { position: relative; }
.ask-bar-actions { margin-left: auto; display: flex; gap: 8px; }
.ask-context-bar .ask-new-chat { margin-left: 0; }
.ask-history-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(420px, 90vw);
  max-height: 340px;
  overflow-y: auto;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lifted);
  padding: 6px;
  z-index: 30;
  text-transform: none;
  letter-spacing: 0;
}
.ask-history-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
}
.ask-history-item:hover { background: var(--paper); }
.ask-history-item.current { outline: 1px solid var(--ink); }
.ask-history-title {
  display: block;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ask-history-meta { display: block; color: var(--muted); margin-top: 2px; font-size: 11px; }

/* ── Fee vs volume scatter (reports panel) ── */
.scatter-head { margin-top: 18px; }
.scatter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.scatter-chips .chip { padding: 6px 11px; font-size: 11.5px; }
.fee-scatter { padding: 8px 4px 14px; }
.fee-scatter svg { width: 100%; height: auto; display: block; }
.fee-scatter circle.dot {
  fill: var(--ink);
  fill-opacity: 0.45;
  cursor: pointer;
}
.fee-scatter circle.dot:hover { fill-opacity: 0.9; stroke: var(--ink); stroke-width: 1.5; }
.fee-scatter circle.dot.sel { fill: var(--accent); fill-opacity: 0.95; stroke: var(--ink); stroke-width: 1.5; }

/* ── Market lifecycle UI: LIVE tag, scope toggles, resolved badge ── */
.live-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-right: 8px;
  animation: live-pulse 1.6s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes live-pulse { 50% { opacity: 0.45; } }
.resolved-tag {
  display: inline-block;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: 1px;
}
.scope-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--soft-2);
  border-radius: 999px;
  padding: 2px;
  margin-right: 10px;
  vertical-align: middle;
}
.scope-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.scope-btn.on { background: var(--ink); color: var(--paper); }
.scope-toggle-sm .scope-btn { padding: 3px 8px; font-size: 10px; }
.cmp-row-archived { cursor: default; }

/* compare sort + pair edge */
.cmp-sort {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 10px;
}
.cmp-sort select {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 3px 6px;
  font-size: 11px;
  margin-left: 4px;
}
.sd-edge strong span { margin-left: 8px; color: var(--muted); font-weight: 600; }
.sd-edge strong .edge-pos { color: var(--ink); font-weight: 800; }

/* ── Compare bands (overview lens) ── */
.band {
  background: var(--soft);
  border: 1px solid rgba(17,17,17,0.07);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.band-head {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.band-fixture { margin-bottom: 12px; }
.band-fixture-head {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 0;
}
.band-fixture-head small { color: var(--muted); font-weight: 600; margin-left: 8px; }
.band-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}
.band-row.cmp-clickable { cursor: pointer; }
.band-row.cmp-clickable:hover { background: var(--paper); }
.band-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.band-nums { color: var(--muted); font-size: 12px; white-space: nowrap; }
.band-more summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
}
.boost-tag { color: var(--muted); margin-right: 7px; font-size: 12px; cursor: help; }
.soon-tag {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-right: 8px;
  white-space: nowrap;
}
.cmp-load-more { margin: 14px auto 4px; display: block; }
.cmp-end-note { text-align: center; font-size: 11px; padding: 12px; }
@media (max-width: 900px) {
  .band-row { grid-template-columns: minmax(0, 1fr) auto; }
  .band-row .delta-sm { display: none; }
}


/* ── PULSE wordmark: P and S filled, U L E outlined ── */
.mark-word {
  width: auto;
  min-width: 0;
  height: auto;
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  display: block;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 4px 0;
  user-select: none;
}
.mark-word b { color: var(--ink); }
.mark-word span {
  color: transparent;
  -webkit-text-stroke: 1.4px var(--ink);
  text-stroke: 1.4px var(--ink);
}
@media (max-width: 900px) {
  .mark-word { font-size: 19px; padding: 0; margin-bottom: 0; }
}

.band-soon-toggle { cursor: pointer; }
.band-soon-toggle:hover { background: var(--paper); }
.band-soon-markets { margin: 2px 0 8px 18px; border-left: 2px solid var(--soft-2); padding-left: 8px; }
.band-loading { font-size: 12px; padding: 8px 10px; }
.modal-head .mark-word { font-size: 20px; }

/* wordmark letters must stay inline (global b{display:block} is for stats) */
.mark-word b, .mark-word span {
  display: inline;
  margin: 0;
  font-size: inherit;
  letter-spacing: inherit;
  font-weight: inherit;
}

/* bands fill the full workspace width: up to 3 columns */
.bands-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}
.bands-1 { grid-template-columns: 1fr; }
.bands-2 { grid-template-columns: 1fr 1fr; }
.bands-3 { grid-template-columns: 1fr 1fr 1fr; }
.bands-grid .band { margin-bottom: 0; }
@media (max-width: 900px) {
  .bands-grid { grid-template-columns: 1fr; }
}

/* compare-grid stopped being a card grid long ago — full-width block so
   the bands grid and table panel use the whole workspace. NO !important:
   the MM/Mappings tab switcher hides this element via inline style. */
.compare-grid { display: block; }

.detail-refresh {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  cursor: pointer;
  margin-left: 8px;
  color: var(--ink);
}
.detail-refresh:hover { border-color: var(--ink); }
.detail-refresh:disabled { opacity: 0.55; cursor: wait; }

.detail-meta-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  margin-bottom: 12px;
  color: var(--ink);
}
.detail-meta-bar em { color: var(--muted); font-style: normal; font-size: 11px; }
.detail-meta-bar .scope-toggle { margin-left: auto; margin-right: 0; }
.detail-meta-bar .lifecycle-actions { margin-left: 0; }
