/* ═══════════════════════════════════════════════
   Polymarket Paper Trader — Dark Terminal Theme
═══════════════════════════════════════════════ */

:root {
  --bg:          #080c17;
  --bg2:         #0d1221;
  --surface:     #111827;
  --surface2:    #1a2235;
  --border:      #1f2d45;
  --text:        #cbd5e1;
  --text-bright: #e2e8f0;
  --text-dim:    #64748b;

  --green:       #10b981;
  --green-dim:   #052e1c;
  --green-mid:   #065f46;
  --red:         #ef4444;
  --red-dim:     #2d0a0a;
  --red-mid:     #7f1d1d;
  --blue:        #3b82f6;
  --blue-dim:    #0f2342;
  --yellow:      #f59e0b;
  --yellow-dim:  #2d1a00;
  --purple:      #a78bfa;
  --purple-dim:  #2d1f5e;

  --font-mono: 'Courier New', Consolas, monospace;
  --radius: 6px;
  --radius-lg: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ════════════════════ SCROLLBAR ════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ════════════════════ LAYOUT ════════════════════ */
#app { display: flex; flex-direction: column; height: 100vh; }

/* ════════════════════ HEADER ════════════════════ */
#header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-shrink: 0;
  height: 56px;
}

.header-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo { font-size: 22px; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--text-bright); letter-spacing: 0.3px; }
.badge {
  background: var(--yellow-dim);
  color: var(--yellow);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 1.5px;
  border: 1px solid #5a3a00;
}

.header-stats { display: flex; gap: 24px; flex: 1; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 15px; font-weight: 700; font-family: var(--font-mono); color: var(--text-bright); }

.header-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--border); color: var(--text-bright); }
.btn-danger-sm {
  background: transparent;
  border: 1px solid var(--red-mid);
  color: var(--red);
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}
.btn-danger-sm:hover { background: var(--red-mid); }
.update-time { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ════════════════════ TAB NAV ════════════════════ */
#tab-nav {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 10px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--text-bright); background: var(--surface); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ════════════════════ TAB CONTENT ════════════════════ */
.tab-content { display: none; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; flex-direction: column; }

/* ════════════════════ MARKETS LAYOUT ════════════════════ */
.markets-layout { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.markets-sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-controls {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--blue); }
.search-input::placeholder { color: var(--text-dim); }
.filter-row { display: flex; gap: 6px; }
.select-sm {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

/* Market List */
.market-list { flex: 1; overflow-y: auto; }
.market-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.market-item:hover { background: var(--surface); }
.market-item.selected { background: var(--blue-dim); border-left: 3px solid var(--blue); }
.market-question {
  font-size: 12px;
  color: var(--text-bright);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.market-metrics { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.price-tag-yes {
  background: var(--green-dim);
  color: var(--green);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--green-mid);
}
.price-tag-no {
  background: var(--red-dim);
  color: var(--red);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--red-mid);
}
.vol-tag { color: var(--text-dim); font-size: 11px; }
.signal-tag { font-size: 10px; padding: 2px 5px; border-radius: 3px; font-weight: 700; letter-spacing: 0.5px; }
.sig-arb { background: var(--yellow-dim); color: var(--yellow); border: 1px solid #5a3a00; }
.sig-hot { background: var(--red-dim); color: var(--red); border: 1px solid var(--red-mid); }
.sig-close { background: var(--purple-dim); color: var(--purple); border: 1px solid #4a2d99; }

/* Market Detail */
.market-detail { flex: 1; overflow-y: auto; padding: 24px; }
.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  gap: 10px;
  text-align: center;
}
.placeholder-icon { font-size: 48px; opacity: 0.3; }

.detail-question {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-bright);
  line-height: 1.4;
  margin-bottom: 8px;
}
.detail-meta {
  display: flex;
  gap: 16px;
  color: var(--text-dim);
  font-size: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.price-display { display: flex; gap: 12px; margin-bottom: 20px; }
.price-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.price-box.yes { border-top: 3px solid var(--green); }
.price-box.no  { border-top: 3px solid var(--red); }
.price-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; display: block; }
.price-value { font-size: 36px; font-weight: 700; font-family: var(--font-mono); display: block; }
.price-box.yes .price-value { color: var(--green); }
.price-box.no  .price-value { color: var(--red); }
.price-implied { font-size: 12px; color: var(--text-dim); margin-top: 6px; display: block; }

.detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.stat-box .stat-label { display: block; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-box .stat-value { font-size: 15px; font-weight: 600; font-family: var(--font-mono); color: var(--text-bright); }

.arb-alert {
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--yellow);
  line-height: 1.6;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  margin-top: 20px;
}

.orderbook { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.ob-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ob-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 6px 10px;
  background: var(--surface2);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ob-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  border-top: 1px solid var(--border);
}
.ob-side.bids .ob-row .price { color: var(--green); }
.ob-side.asks .ob-row .price { color: var(--red); }
.ob-note { font-size: 12px; color: var(--text-dim); padding: 10px 0; }

.trade-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn-buy-yes {
  flex: 1; padding: 13px;
  background: var(--green-dim); border: 1px solid var(--green);
  color: var(--green); border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 700;
  transition: all 0.2s;
}
.btn-buy-yes:hover { background: var(--green); color: #000; }
.btn-buy-no {
  flex: 1; padding: 13px;
  background: var(--red-dim); border: 1px solid var(--red);
  color: var(--red); border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 700;
  transition: all 0.2s;
}
.btn-buy-no:hover { background: var(--red); color: #fff; }

/* ════════════════════ OPPORTUNITIES ════════════════════ */
.opps-layout { padding: 20px 24px; overflow-y: auto; flex: 1; }
.opps-header { margin-bottom: 20px; }
.opps-header h2 { font-size: 20px; color: var(--text-bright); margin-bottom: 4px; }
.signal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.signal-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.signal-section h3 { font-size: 14px; color: var(--text-bright); margin-bottom: 4px; }
.section-hint { font-size: 11px; color: var(--text-dim); margin-bottom: 12px; line-height: 1.5; }

.signal-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.signal-card:hover { border-color: var(--blue); }
.signal-card:last-child { margin-bottom: 0; }
.s-question {
  font-size: 12px;
  color: var(--text-bright);
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.s-meta { font-size: 11px; color: var(--text-dim); line-height: 1.5; }
.score-high { color: var(--green); font-weight: 700; }
.score-med  { color: var(--yellow); font-weight: 700; }
.score-low  { color: var(--text-dim); }

/* ════════════════════ PORTFOLIO ════════════════════ */
.portfolio-layout { padding: 20px 24px; overflow-y: auto; flex: 1; }
.portfolio-summary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.card-label { display: block; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.card-value { font-size: 17px; font-weight: 700; font-family: var(--font-mono); color: var(--text-bright); }

.portfolio-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.portfolio-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 420px;
  overflow-y: auto;
}
.portfolio-panel h3 { font-size: 14px; color: var(--text-bright); margin-bottom: 12px; }

.position-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.pos-question { font-size: 12px; color: var(--text-bright); margin-bottom: 5px; line-height: 1.4; }
.pos-meta { display: flex; gap: 10px; font-size: 11px; flex-wrap: wrap; align-items: center; }
.pos-side-yes { color: var(--green); font-weight: 700; }
.pos-side-no  { color: var(--red); font-weight: 700; }
.pos-pnl-pos { color: var(--green); }
.pos-pnl-neg { color: var(--red); }
.btn-close-pos {
  background: var(--red-dim);
  border: 1px solid var(--red-mid);
  color: var(--red);
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  margin-top: 6px;
  transition: all 0.2s;
}
.btn-close-pos:hover { background: var(--red-mid); }

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.history-item:last-child { border-bottom: none; }
.hist-left { flex: 1; min-width: 0; }
.hist-market {
  font-size: 12px;
  color: var(--text-bright);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hist-detail { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.hist-right { text-align: right; flex-shrink: 0; }
.hist-pnl { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.hist-date { font-size: 11px; color: var(--text-dim); }

/* ════════════════════ DATA LAB ════════════════════ */
.lab-layout { padding: 20px 24px; overflow-y: auto; flex: 1; }
.lab-header { margin-bottom: 20px; }
.lab-header h2 { font-size: 20px; color: var(--text-bright); margin-bottom: 4px; }
.lab-rows { display: flex; flex-direction: column; gap: 16px; }
.lab-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.lab-section h3 { font-size: 14px; color: var(--text-bright); margin-bottom: 4px; }

.endpoint-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; margin-bottom: 12px; }
.endpoint-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  flex-wrap: wrap;
}
.method { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 3px; flex-shrink: 0; }
.method.get { background: #0a2a18; color: var(--green); border: 1px solid var(--green-mid); }
.endpoint-item code { flex: 1; font-family: var(--font-mono); font-size: 11px; color: var(--text); word-break: break-all; }
.endpoint-item code em { color: var(--text-dim); font-style: normal; }
.btn-test {
  background: var(--blue-dim);
  border: 1px solid var(--blue);
  color: var(--blue);
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-test:hover { background: var(--blue); color: #fff; }

.response-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; font-family: var(--font-mono); }
.raw-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.ref-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.ref-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.ref-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.ref-table tr:last-child td { border-bottom: none; }
.ref-table td:first-child { font-family: var(--font-mono); color: var(--blue); }
.ref-table td:nth-child(2) { color: var(--text-dim); }
.ref-table td:nth-child(3) { font-family: var(--font-mono); font-size: 11px; color: var(--green); }
.ref-table td:nth-child(4) { color: var(--text); font-size: 11px; }

.explainer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.explainer-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.explainer-card h4 { font-size: 12px; color: var(--blue); margin-bottom: 8px; }
.explainer-card p { font-size: 12px; color: var(--text); line-height: 1.6; }

/* ════════════════════ MODAL ════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
}
.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 460px;
  max-width: 95vw;
  padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; color: var(--text-bright); font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; line-height: 1; padding: 2px; }
.modal-close:hover { color: var(--text-bright); }

.modal-question { font-size: 13px; color: var(--text); line-height: 1.5; margin-bottom: 12px; }
.modal-prices { display: flex; gap: 8px; margin-bottom: 16px; }

.side-selector { display: flex; gap: 8px; margin-bottom: 16px; }
.side-btn {
  flex: 1;
  padding: 11px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.2s;
  border: 2px solid transparent;
  opacity: 0.5;
}
#side-yes { background: var(--green-dim); border-color: var(--green); color: var(--green); }
#side-yes.active { background: var(--green); color: #000; opacity: 1; }
#side-no  { background: var(--red-dim);  border-color: var(--red);  color: var(--red); }
#side-no.active  { background: var(--red);  color: #fff; opacity: 1; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--blue); }

.trade-preview {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text);
}
.preview-row span:last-child { font-family: var(--font-mono); }
.preview-row.highlight {
  color: var(--green);
  font-weight: 700;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
}

.modal-actions { display: flex; gap: 10px; }
.btn-secondary {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--text-dim); }
.btn-execute {
  flex: 2;
  background: var(--blue);
  border: 1px solid var(--blue);
  color: #fff;
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: opacity 0.2s;
}
.btn-execute:hover { opacity: 0.85; }

/* ════════════════════ UTILITIES ════════════════════ */
.loading-msg { color: var(--text-dim); text-align: center; padding: 24px; font-size: 13px; }
.error-msg   { color: var(--red);      text-align: center; padding: 24px; font-size: 13px; line-height: 1.6; }
.empty-msg   { color: var(--text-dim); text-align: center; padding: 24px; font-size: 13px; }
.hint { color: var(--text-dim); font-size: 12px; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.neutral  { color: var(--text-dim); }

/* ════════════════════ BTC ALGO TAB ════════════════════ */

/* ── MM Strategy Card ── */
.mm-strategy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  overflow: hidden;
}
.mm-panel-empty { color: var(--text-dim); font-size: 12px; padding: 12px 0; text-align: center; }
.mm-pull-alert {
  background: var(--red-dim);
  border: 1px solid var(--red-mid);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--red);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}
.mm-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 6px;
}
.mm-action-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.mm-score-badge  { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }

.mm-quote-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 10px; }
.mm-quote-table thead tr { background: var(--bg2); }
.mm-quote-table th {
  text-align: left;
  padding: 4px 6px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}
.mm-quote-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(31,45,69,0.6);
  font-size: 11px;
  color: var(--text);
}
.mm-quote-table tr:last-child td { border-bottom: none; }

.mm-totals-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.mm-total-cell {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 8px;
  text-align: center;
}
.mm-total-highlight { border-color: var(--green-mid); background: var(--green-dim); }
.mm-total-label { font-size: 9px; text-transform: uppercase; color: var(--text-dim); letter-spacing: 0.3px; margin-bottom: 3px; }
.mm-total-val   { font-size: 14px; font-weight: 700; font-family: var(--font-mono); color: var(--text-bright); }

.mm-edge-notes { margin-bottom: 8px; }
.mm-edge-note  { font-size: 11px; color: var(--text-dim); padding: 2px 0; line-height: 1.6; }
.mm-edge-note::before { content: '→ '; }

.mm-formula-reminder {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  line-height: 1.6;
}

/* ── Layout ── */
.btc-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  height: 100%;
  overflow-y: auto;
}

/* ── Top bar ── */
.btc-topbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.btc-price-display { display: flex; align-items: baseline; gap: 12px; }
.btc-symbol { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.btc-price  { font-size: 26px; font-weight: 700; font-family: var(--font-mono); color: var(--text-bright); }
.btc-change { font-size: 14px; font-family: var(--font-mono); color: var(--text-dim); }
.btc-status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.algo-note { font-size: 11px; color: var(--text-dim); font-style: italic; }

.btn-auto-off, .btn-auto-on {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.2s;
}
.btn-auto-off {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-auto-off:hover { border-color: var(--green); color: var(--green); }
.btn-auto-on {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

/* ── Main two-column layout ── */
.btc-main {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  min-height: 0;
}
.btc-left, .btc-right { display: flex; flex-direction: column; gap: 14px; }

/* ── Chart card ── */
.btc-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.btc-chart-card canvas { display: block; width: 100%; height: auto; }
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Indicator cards ── */
.signal-indicators {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.indicator-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
}
.ind-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.ind-value { font-size: 18px; font-weight: 700; font-family: var(--font-mono); color: var(--text-bright); margin-bottom: 6px; }
.ind-bar { background: var(--bg2); border-radius: 2px; height: 4px; margin-bottom: 6px; overflow: hidden; }
.ind-fill { height: 100%; border-radius: 2px; background: var(--blue); transition: width 0.4s, background 0.4s; }
.ind-signal { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-dim); }

/* ── Composite score ── */
.composite-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.comp-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.comp-body { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 14px; }
.comp-score-wrap { text-align: center; min-width: 80px; }
.comp-score { font-size: 48px; font-weight: 900; font-family: var(--font-mono); color: var(--text-bright); line-height: 1; }
.comp-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.comp-breakdown { font-size: 11px; color: var(--text-dim); line-height: 2; font-family: var(--font-mono); }

.comp-gauge { display: flex; align-items: center; gap: 8px; }
.gauge-min, .gauge-max { font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.gauge-track { flex: 1; height: 6px; background: linear-gradient(to right, var(--red), var(--text-dim) 40%, var(--text-dim) 60%, var(--green)); border-radius: 3px; position: relative; }
.gauge-cursor {
  position: absolute;
  top: -4px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--bg);
  transform: translateX(-50%);
  transition: left 0.5s;
  left: 50%;
}

/* ── Market card (right column) ── */
.market-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}
.market-countdown {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
}
.mkt-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.mkt-row:last-of-type { border-bottom: none; }
.mkt-label { color: var(--text-dim); flex-shrink: 0; margin-right: 10px; }
.mkt-val   { color: var(--text-bright); text-align: right; font-size: 12px; }
.mkt-question { font-size: 12px; color: var(--text); text-align: right; max-width: 220px; }
.mkt-prices { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.mkt-side { flex: 1; text-align: center; padding: 10px; border-radius: var(--radius); }
.mkt-yes  { background: var(--green-dim); border: 1px solid var(--green-mid); }
.mkt-no   { background: var(--red-dim);   border: 1px solid var(--red-mid); }
.mkt-side-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin-bottom: 4px; }
.mkt-yes .mkt-side-label { color: var(--green); }
.mkt-no  .mkt-side-label { color: var(--red); }
.mkt-side-price { font-size: 22px; font-weight: 900; font-family: var(--font-mono); }
.mkt-yes .mkt-side-price { color: var(--green); }
.mkt-no  .mkt-side-price { color: var(--red); }
.mkt-side-sub { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.mkt-vs { color: var(--text-dim); font-size: 12px; }

/* ── Liquidity Rewards box ── */
.mm-rewards-box {
  margin-top: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.mm-header { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--yellow); margin-bottom: 8px; }
.mm-note {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}
.mm-table { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--font-mono); margin-bottom: 8px; }
.mm-table th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 3px 6px; border-bottom: 1px solid var(--border); }
.mm-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); color: var(--text); }
.mm-table tr:last-child td { border-bottom: none; }
.mm-totals { font-size: 12px; font-family: var(--font-mono); color: var(--text); margin-bottom: 8px; line-height: 1.8; }
.mm-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(16,185,129,0.15);
  color: var(--green);
  border: 1px solid var(--green-mid);
  margin-left: 6px;
}
.mm-badge.mm-single { background: var(--yellow-dim); color: var(--yellow); border-color: var(--yellow); }
.mm-sub { font-size: 11px; color: var(--text-dim); line-height: 1.8; font-family: var(--font-mono); }

/* ── Settings card ── */
.algo-settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.setting-row { display: flex; flex-direction: column; gap: 5px; }
.setting-row label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.setting-row input, .setting-row select {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-mono);
  outline: none;
}
.setting-row input:focus, .setting-row select:focus { border-color: var(--blue); }
.setting-row select option { background: var(--surface2); }
.algo-last-action {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 0 0;
  font-family: var(--font-mono);
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

/* ── Signal log card ── */
.log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 180px;
}
.btn-text {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
}
.btn-text:hover { color: var(--text); }
.signal-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.log-entry { font-size: 11px; font-family: var(--font-mono); padding: 3px 0; border-bottom: 1px solid rgba(31,45,69,0.5); line-height: 1.5; }
.log-info { color: var(--text-dim); }
.log-buy  { color: var(--green); }
.log-warn { color: var(--yellow); }

/* ── Strategy reference ── */
/* Collapsible strategy reference */
.strategy-reference-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 8px;
}
.strategy-reference-summary {
  list-style: none;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.strategy-reference-summary::-webkit-details-marker { display: none; }
.strategy-reference-summary::after {
  content: '▼';
  font-size: 10px;
  margin-left: auto;
  transition: transform 0.2s;
}
.strategy-reference-details[open] .strategy-reference-summary::after {
  transform: rotate(180deg);
}
.strategy-reference-details .strategy-grid {
  padding: 0 16px 16px;
}
.strategy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.strat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.strat-card h4 { font-size: 12px; color: var(--blue); margin-bottom: 8px; }
.strat-card p  { font-size: 12px; color: var(--text); line-height: 1.6; }

/* Portfolio integration and responsive workspace. */
:root { --text-dim:#96a4b9; }
.portfolio-return { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px 20px; padding:8px 20px; border-bottom:1px solid var(--border); background:var(--bg2); font-size:11px; color:var(--text-dim); flex-shrink:0; }
.portfolio-return a { color:var(--text-bright); text-decoration:none; }
.portfolio-return a:hover { text-decoration:underline; }
#app { height:100dvh; min-height:0; }
#header { height:auto; min-height:64px; gap:20px; flex-wrap:wrap; padding:12px 20px; }
.header-stats { flex-wrap:wrap; gap:15px 24px; }
.header-controls { flex-wrap:wrap; }
#tab-nav { overflow-x:auto; scrollbar-width:thin; }
.tab-btn { white-space:nowrap; min-height:44px; }
.tab-content,.markets-layout,.market-list { min-height:0; }
.market-detail,.btc-left,.btc-right,.lab-layout,.opps-layout,.portfolio-layout { min-width:0; }
.market-item:focus-visible { outline:2px solid var(--blue); outline-offset:-3px; }
.market-item[aria-pressed="true"] { border-left:3px solid var(--blue); }
:focus-visible { outline:2px solid #93c5fd; outline-offset:3px; }
.btc-main { grid-template-columns:minmax(0,1fr) minmax(280px,340px); }
.mm-quote-table { display:block; max-width:100%; overflow-x:auto; }
.signal-grid,.portfolio-panels,.explainer-grid,.settings-grid,.strategy-grid { min-width:0; }
@media(max-width:1080px) {
  .header-stats { order:3; flex-basis:100%; }
  .header-controls { margin-left:auto; }
  .portfolio-summary { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .btc-main { grid-template-columns:1fr; }
  .explainer-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:700px) {
  html,body { height:auto; min-height:100%; overflow:auto; }
  #app { height:auto; min-height:100dvh; }
  .portfolio-return { padding:10px 16px; }
  #header { padding:14px 16px; gap:14px; }
  .header-brand { flex-wrap:wrap; gap:8px; }
  .header-controls { margin:0; flex-basis:100%; }
  .header-stats { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
  .tab-btn { padding:12px 15px; }
  .tab-content { overflow:visible; }
  .tab-content.active { display:block; }
  .markets-layout { display:block; overflow:visible; }
  .markets-sidebar { width:100%; border-right:0; border-bottom:1px solid var(--border); }
  .market-list { max-height:310px; overflow-y:auto; overscroll-behavior:contain; }
  .market-detail { padding:20px 16px; overflow:visible; min-height:250px; scroll-margin-top:12px; }
  .market-detail .empty-state { min-height:220px; }
  .opps-layout,.portfolio-layout,.lab-layout { padding:20px 16px; overflow:visible; }
  .signal-grid,.portfolio-panels,.explainer-grid,.strategy-grid { grid-template-columns:minmax(0,1fr); }
  .portfolio-stats,.portfolio-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .detail-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .mm-totals-row { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .btc-layout { height:auto; overflow:visible; padding:16px; }
  .signal-indicators { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .btc-price-display { flex-wrap:wrap; }
  .card-header-row { gap:10px; flex-wrap:wrap; }
  .lab-controls { flex-wrap:wrap; }
  .lab-result,.json-output,pre { max-width:100%; overflow-x:auto; }
  .market-question,.detail-title,.position-question { overflow-wrap:anywhere; }
  input,select { min-width:0; max-width:100%; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto!important; transition:none!important; } }

body {color-scheme:dark;}
