/* ================================================================
   MacroDashboard — Design System
   Dark-first · data-dense · zero decoration
   Based on DESIGN.md specification
================================================================ */

:root {
  --bg:      #000000;
  --bg2:     #111111;
  --bg3:     #1a1a1a;
  --bg4:     #222222;
  --border:  #2a2a2a;
  --border2: #333333;
  --accent:  #c41e3a;
  --accent2: #e8294a;
  --green:   #34c759;
  --red:     #ff3b30;
  --yellow:  #ffd60a;
  --orange:  #ff9500;
  --purple:  #af52de;
  --cyan:    #30d5c8;
  --blue:    #0a84ff;
  --pink:    #ff2d79;
  --text:    #ffffff;
  --text2:   #ebebeb;
  --muted:   #8e8e93;
  --dim:     #3a3a3c;
  /* legacy aliases */
  --text3:   #8e8e93;
  --r:       12px;
  --r-sm:    8px;
}

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

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.5;
  padding: 0;
}

/* ── Page content wrapper ── */
.page-content {
  padding: 16px 18px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Header ── */
.header {
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.header-brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.header-brand-text h1 span { color: var(--accent); }

.header-brand-text p {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.2;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-meta {
  font-size: 11px;
  color: var(--muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

/* ── Status dot ── */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
.dot.err { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Nav tabs ── */
.tab-nav {
  display: none;
  gap: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  position: sticky;
  top: 56px;
  z-index: 99;
  overflow-x: auto;
}

.tab-btn {
  flex: 0 0 auto;
  height: 48px;
  padding: 0 16px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover:not(.active) {
  color: var(--text2);
  background: transparent;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ── Body padding area (below sticky header+nav) ── */
.status-bar,
.selector-section,
.error-box,
.grid,
.section,
.section-sep,
.sector-header,
.footer,
#hist-block,
#mc-section {
  /* rely on parent container padding */
}

/* Direct body children get padding via body */
body > .status-bar,
body > .selector-section,
body > .error-box,
body > .section,
body > .footer,
body > #hist-block,
body > #mc-section,
body > .an-wrap,
body > .stats-main-section {
  margin-left: 18px;
  margin-right: 18px;
}

body > .status-bar    { margin-top: 16px; }
body > .selector-section { margin-top: 12px; }
body > .section       { /* margin-bottom handled per element */ }
body > .footer        { margin-bottom: 18px; }

/* fallback — wrap content inside body */
body > .tab-nav + * { margin-top: 0; }

/* ── Status bar ── */
.status-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11px;
  color: var(--muted);
}

/* ── Selector section ── */
.selector-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.selector-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
}

.selector-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.selector-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selector-group-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── Chips / Range tabs ── */
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 3px 11px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  user-select: none;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text2);
}

.chip.active {
  background: rgba(196, 30, 58, 0.18);
  border-color: var(--accent);
  color: var(--text);
}

.chip.active-green {
  background: rgba(52, 199, 89, 0.18);
  border-color: var(--green);
  color: var(--text);
}

.chip-sm {
  padding: 2px 9px;
  font-size: 11px;
}

.chip-disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* ── Grid presets ── */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.g2  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.g4  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.g5  { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.g6  { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.g32 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.g23 { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }

/* ── Card ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.card:hover { border-color: var(--border2); }

.card-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.card-change {
  font-size: 11px;
  margin-top: 6px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-change.positive {
  color: #fff !important;
  background: rgba(52, 199, 89, 0.75);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  display: inline-flex;
}

.card-change.negative {
  color: #fff !important;
  background: rgba(255, 59, 48, 0.75);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  display: inline-flex;
}

.card-change.neutral {
  color: var(--muted) !important;
}

/* ── Section / Panel ── */
.section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 14px;
  padding: 16px 18px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-title-inline {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Panel badge */
.panel-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent2);
  background: rgba(196, 30, 58, 0.12);
  border: 1px solid rgba(196, 30, 58, 0.25);
}

/* ── Badges ── */
.badge-buy {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(52, 199, 89, 0.12);
  border: 1px solid rgba(52, 199, 89, 0.25);
  color: var(--green);
}
.badge-sell {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(196, 30, 58, 0.12);
  border: 1px solid rgba(196, 30, 58, 0.25);
  color: var(--accent2);
}
.badge-neutral {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(142, 142, 147, 0.12);
  border: 1px solid rgba(142, 142, 147, 0.25);
  color: var(--muted);
}

/* ── Buttons ── */
.btn {
  padding: 8px 20px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
}
.btn:hover:not(:disabled) { background: #0066cc; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-success { background: #30d158; color: #fff; }
.btn-success:hover:not(:disabled) { background: #28b84a; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }

.btn-sm {
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--border); color: var(--text); }
.btn-sm.danger { border-color: rgba(255, 59, 48, 0.3); color: rgba(255, 59, 48, 0.7); }
.btn-sm.danger:hover { background: rgba(255, 59, 48, 0.1); color: var(--red); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dim);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s ease;
  line-height: 1;
}
.btn-icon:hover { color: var(--red); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }

th {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
  padding: 7px 12px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

td {
  font-size: 12px;
  font-weight: 400;
  color: var(--text2);
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.03); }

/* ── Section sep title ── */
.section-sep {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.sector-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 22px 0 8px;
}

/* ── Color helpers ── */
.positive { color: var(--green) !important; }
.negative { color: var(--red)   !important; }
.neutral  { color: var(--muted) !important; }
.warn     { color: var(--yellow)!important; }
.mono     { font-family: 'SF Mono', 'Fira Code', monospace; }

/* ── Chart container ── */
.chart-container { position: relative; height: 320px; }

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.legend-dot {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

.chart-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

/* ── Error box ── */
.error-box {
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 14px;
  display: none;
}
.error-box.show { display: block; }
.error-box p { color: var(--red); font-size: 13px; margin-bottom: 4px; }
.error-box small { color: var(--muted); font-size: 11px; }

/* ── Footer ── */
.footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 16px 0;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ── Feedback FAB ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  border: none;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  box-shadow: 0 4px 16px rgba(196, 30, 58, 0.4);
}
.fab:hover { background: var(--accent2); }

/* ── Signal grid ── */
.signal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.signal-item {
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color 0.15s ease;
}
.signal-item:hover { border-color: var(--border2); }

.signal-item-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

.signal-item-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ── Sparklines ── */
.spark-wrap {
  position: relative;
  height: 80px;
  margin-top: 10px;
  overflow: hidden;
  cursor: crosshair;
}

.sparkline {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ── Percentile bar ── */
.pct-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.pct-label-inline { margin-bottom: 0; }
.pct-scale-chips  { display: flex; gap: 4px; flex-wrap: wrap; }

.pct-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text);
  margin-bottom: 6px;
}

.pct-bar {
  position: relative;
  height: 8px;
  border-radius: 4px;
  overflow: visible;
  display: flex;
  margin-top: 10px;
}

.pct-zone { height: 100%; flex-shrink: 0; }
.pct-zone-short   { width: 15%; background: rgba(255, 59, 48, 0.7); border-radius: 4px 0 0 4px; }
.pct-zone-neutral { width: 70%; background: rgba(52, 199, 89, 0.35); }
.pct-zone-long    { width: 15%; background: rgba(255, 59, 48, 0.7); border-radius: 0 4px 4px 0; }

#pct-marker {
  position: absolute !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 13px !important;
  height: 13px !important;
  border-radius: 50% !important;
  background: #fff !important;
  border: 2px solid rgba(0,0,0,0.4) !important;
  box-shadow: 0 0 8px rgba(0,0,0,0.5) !important;
  transition: left .5s ease, background .3s ease, box-shadow .3s ease !important;
  z-index: 2;
}

#pct-marker-label {
  position: absolute;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
  transition: left .5s ease, color .3s ease;
}

.pct-labels {
  position: relative;
  height: 18px;
  margin-top: 6px;
  font-size: 10px;
}
.pct-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.pct-lbl-ext { color: var(--red); font-weight: 700; }
.pct-lbl-mid { color: var(--green); font-weight: 700; }

.pct-desc {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
}

#sig-sec {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.sig-delta { font-size: 11px; margin-top: 5px; }

/* ── Histogram panels ── */
#hist-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.hist-pane-wrap {
  position: relative;
  height: 200px;
  width: 100%;
  background: var(--bg2);
  overflow: visible;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(196, 30, 58, 0.45);
  transition: border-left-color 0.2s, border-color 0.2s;
}
.hist-pane-wrap:hover {
  border-color: var(--border2);
  border-left-color: var(--accent);
}

.hist-pane {
  height: 100%;
  width: 100%;
  overflow: hidden;
  border-radius: 1px;
}

.hist-pane-label {
  position: absolute;
  top: 9px;
  left: 14px;
  z-index: 10;
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
  letter-spacing: 1px;
  line-height: 1;
}

/* ── Histogram local tooltip ── */
.hist-local-tooltip {
  display: none;
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: rgba(26, 26, 26, 0.97);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 9px 12px 8px;
  min-width: 158px;
  box-shadow: 0 6px 22px rgba(0,0,0,.85);
}
.hist-local-tooltip.is-visible { display: block; }

.htt-header { margin-bottom: 7px; }
.htt-title {
  display: block;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
  white-space: nowrap;
}
.htt-date {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
  line-height: 1;
  white-space: nowrap;
}
.htt-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 6px;
}
.htt-body { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.htt-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.htt-label { font-size: 8.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap; }
.htt-val { font-size: 11px; font-weight: 700; color: var(--text); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.htt-pos { color: var(--green) !important; }
.htt-neg { color: var(--red)   !important; }
.htt-footer { display: flex; justify-content: flex-end; }
.htt-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 6px;
  border-radius: 100px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.6;
}
.htt-pill-pos { background: rgba(52,199,89,0.18); border: 1px solid rgba(52,199,89,0.5); color: var(--green); }
.htt-pill-neg { background: rgba(255,59,48,0.18);  border: 1px solid rgba(255,59,48,0.5);  color: var(--red); }
.htt-pill-arrow { font-size: 7px; line-height: 1; }

/* ── Sparkline tooltip ── */
.spark-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  min-width: 126px;
  box-shadow: 0 4px 18px rgba(0,0,0,.6);
}
.stt-date  { font-size: 10px; color: var(--muted); margin-bottom: 5px; letter-spacing: 0.3px; white-space: nowrap; }
.stt-row   { display: flex; justify-content: space-between; align-items: center; gap: 10px; line-height: 1.6; }
.stt-label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.stt-value { font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; }
.stt-chg   { font-size: 11px; font-weight: 600; white-space: nowrap; }
.stt-chg.positive { color: var(--green); }
.stt-chg.negative { color: var(--red); }
.stt-chg.neutral  { color: var(--muted); }

/* ── Compare grid ── */
.cmp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.cmp-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  transition: border-color 0.15s ease;
}
.cmp-card:hover { border-color: var(--border2); }
.cmp-card-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin-bottom: 10px; }
.cmp-dir  { font-size: 15px; font-weight: 700; margin-bottom: 6px; letter-spacing: 0.3px; }
.cmp-mom  { font-size: 12px; color: var(--muted); }
.cmp-g2   { font-size: 12px; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.cmp-pct  { font-size: 11px; margin-top: 8px; }
.cmp-pct-track { height: 6px; background: var(--bg4); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.cmp-pct-fill  { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.cmp-label-muted { color: var(--muted); font-weight: 400; }
#cmp-summary { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* ── Events ── */
.events-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.events-legend { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); line-height: 1.7; }

.event-card { padding: 13px 14px; border-radius: var(--r-sm); border: 1px solid var(--border); border-left-width: 3px; transition: border-color 0.15s, background 0.15s; }
.event-card:hover { background: rgba(255,255,255,.02); }
.event-card-fed     { border-left-color: var(--accent); }
.event-card-ecb     { border-left-color: var(--blue); }
.event-card-boe     { border-left-color: var(--purple); }
.event-card-nfp     { border-left-color: var(--green); }
.event-card-quarter { border-left-color: var(--yellow); }
.event-card-month   { border-left-color: var(--muted); }
.event-card-expiry  { border-left-color: var(--border2); }
.event-card-near { border-color: var(--yellow); border-left-color: var(--yellow); background: rgba(255,214,10,0.04); }

.event-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.event-name   { font-size: 12px; font-weight: 600; color: var(--text); letter-spacing: -0.1px; }
.event-days   { font-size: 11px; color: var(--muted); white-space: nowrap; margin-left: 8px; background: var(--bg3); padding: 1px 7px; border-radius: 10px; }
.event-days-near { color: var(--yellow); background: rgba(255,214,10,.12); }
.event-date   { font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.event-desc   { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ── Table legend ── */
.tbl-legend { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); line-height: 1.8; }
.tbl-legend-scale { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.tbl-legend-bar { height: 5px; width: 140px; border-radius: 3px; background: linear-gradient(to right, rgba(255,59,48,.55), rgba(255,59,48,.15), transparent, rgba(52,199,89,.15), rgba(52,199,89,.55)); }

.tbl-date  { color: var(--muted); font-size: 11px; }
.tbl-num   { text-align: right; font-weight: 400; }
.tbl-main  { font-weight: 600; color: var(--text); }
.tbl-delta { color: var(--muted); font-size: 11px; }
.tbl-oi    { color: var(--muted); }
.overflow-x { overflow-x: auto; }

.tbl-row-latest td { background: rgba(52, 199, 89, 0.03); }
.tbl-row-latest td:first-child { border-left: 2px solid var(--green); padding-left: 9px; }

/* ── MC input ── */
.mc-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s ease;
}
.mc-input:focus { border-color: var(--blue); }
.mc-input[type=number]::-webkit-inner-spin-button { opacity: 0.4; }

/* ── MC Sidebar ── */
.mc-sidebar {
  font-family: 'Inter', sans-serif;
  border-right: 1px solid var(--border);
}
.mc-sidebar > h1 {
  font-size: 11px !important;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 2px !important;
}
.mc-sidebar > p {
  font-size: 9px !important;
  letter-spacing: 1px;
  color: var(--muted) !important;
  text-transform: uppercase;
  margin-bottom: 16px !important;
}

.mc-group-label {
  font-size: 9px !important;
  font-weight: 700 !important;
  color: var(--muted) !important;
  text-transform: uppercase !important;
  letter-spacing: 2px !important;
  margin: 0 0 8px !important;
}

/* ── MC DDOF toggles ── */
#mc-ddof-1, #mc-ddof-0 {
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}

/* ── Run button ── */
#mc-run-btn {
  background: var(--blue) !important;
  border: 1px solid transparent !important;
  border-radius: var(--r-sm) !important;
  color: #fff !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: 1px !important;
  text-transform: uppercase !important;
  padding: 12px !important;
  transition: background 0.15s, box-shadow 0.15s;
}
#mc-run-btn:hover:not(:disabled) {
  background: #0066cc !important;
  box-shadow: 0 0 20px rgba(10,132,255,0.25);
}
#mc-run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Drop zones ── */
#mc-drop-stops, #mc-drop-takes {
  border-radius: var(--r-sm) !important;
  padding: 12px 10px !important;
  transition: border-color 0.2s, background 0.2s;
}

/* ── MC main area ── */
.mc-main {
  padding: 28px 32px !important;
  background: var(--bg) !important;
  overflow-y: auto;
}

/* ── MC Section titles ── */
.mc-section-title {
  font-size: 10px !important;
  font-weight: 700 !important;
  color: var(--muted) !important;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  margin-bottom: 16px !important;
  padding-bottom: 10px !important;
  border-bottom: 1px solid var(--border) !important;
}

.mc-chart-desc {
  font-size: 10px !important;
  color: var(--muted) !important;
  letter-spacing: 0.5px;
  margin-bottom: 12px !important;
  line-height: 1.6;
}

/* ── MC Bento grid ── */
.mc-bento {
  display: grid !important;
  gap: 1px !important;
  background: var(--border) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  overflow: hidden !important;
  margin-bottom: 16px !important;
}
.mc-bento .card {
  background: var(--bg2) !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 14px 16px !important;
  transition: background 0.15s;
}
.mc-bento .card:hover { background: var(--bg3) !important; }
.mc-bento .card-label {
  font-size: 9px !important;
  font-weight: 600 !important;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted) !important;
  margin-bottom: 8px !important;
}
.mc-bento .card-value {
  font-size: 20px !important;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.mc-bento .card-change {
  font-size: 10px !important;
  margin-top: 5px !important;
  color: var(--muted) !important;
  background: none !important;
  padding: 0 !important;
  display: block !important;
}

/* ── MC Risk bar ── */
.mc-risk-bar { height: 2px; background: var(--border); border-radius: 0; margin-top: 10px; overflow: hidden; }
.mc-risk-fill { height: 100%; transition: width .7s cubic-bezier(0.23,1,0.32,1); }
.mc-risk-fill.safe   { background: var(--green); box-shadow: 0 0 6px rgba(52,199,89,0.5); }
.mc-risk-fill.warn   { background: var(--yellow); box-shadow: 0 0 6px rgba(255,214,10,0.5); }
.mc-risk-fill.danger { background: var(--red); box-shadow: 0 0 6px rgba(255,59,48,0.5); }

/* ── MC Chart box ── */
.mc-chart-box {
  position: relative;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px;
}

/* ── MC SQN quality badge ── */
#mc-sqn-quality {
  background: rgba(52, 199, 89, 0.04) !important;
  border: 1px solid var(--border) !important;
  border-left: 2px solid var(--green) !important;
  border-radius: var(--r-sm) !important;
  font-size: 11px;
  color: var(--text2) !important;
  letter-spacing: 0.3px;
  line-height: 1.6;
  padding: 10px 14px;
}

/* ── MC Tables ── */
#mc-section table th {
  font-size: 9px !important;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase !important;
  color: var(--muted) !important;
  padding: 8px 12px !important;
  border-bottom: 1px solid var(--border) !important;
}
#mc-section table td {
  font-size: 12px !important;
  padding: 9px 12px !important;
  border-bottom: 1px solid rgba(42,42,42,0.7) !important;
  font-variant-numeric: tabular-nums;
}
#mc-section table tr:last-child td { border-bottom: none !important; }

/* ── MC Info tooltips ── */
.mc-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--muted); font-size: 9px; cursor: default;
  margin-left: 5px; font-style: normal; position: relative;
  vertical-align: middle; flex-shrink: 0; line-height: 1;
}
.mc-info::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: 11px; color: var(--text);
  white-space: normal; min-width: 190px; max-width: 270px;
  pointer-events: none; opacity: 0; z-index: 9999;
  line-height: 1.55; transition: opacity 0.15s;
  text-transform: none; font-weight: 400; letter-spacing: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
}
.mc-info:hover::after { opacity: 1; }

/* ── MC Modal ── */
.mc-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 10000;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.mc-modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 28px 30px; width: min(760px,96vw); max-height: 92vh; overflow-y: auto;
}
.mc-modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.mc-modal-subtitle { font-size: 12px; color: var(--muted); margin-bottom: 22px; }
.mc-modal-label { display: block; font-size: 12px; color: var(--text2); font-weight: 500; margin-bottom: 5px; }
.mc-modal-preview {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 14px 16px; font-size: 12px; margin-bottom: 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.mc-modal-preview-col {}
.mc-modal-preview-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 6px; }
.mc-modal-kv { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(42,42,42,0.5); }
.mc-modal-kv:last-child { border-bottom: none; }
.mc-modal-k { color: var(--muted); }
.mc-modal-v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── MC Summary ── */
.mc-sum-card { padding: 18px 20px; }
.mc-sum-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 14px; }
.mc-sum-block { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; }
.mc-sum-block-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 10px; }
.mc-sum-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; border-bottom: 1px solid rgba(42,42,42,0.5); }
.mc-sum-row:last-child { border-bottom: none; }
.mc-sum-key { color: var(--muted); }
.mc-sum-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.mc-sum-saved { font-size: 11px; color: var(--dim); margin-top: 8px; }

.mc-sum-charts { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.mc-sum-chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 12px; }
.mc-sum-chart-block { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; transition: border-color 0.2s; }
.mc-sum-chart-block--wide { width: 100%; }
.mc-sum-chart-block:hover { border-color: var(--border2); }
.mc-sum-chart-title { font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); padding: 8px 14px; background: var(--bg3); border-bottom: 1px solid var(--border); }
.mc-sum-chart-img { width: 100%; display: block; background: var(--bg); }

/* ── Save bar ── */
#mc-save-bar { border-radius: var(--r-sm) !important; }
#mc-save-bar > div > div:first-child { font-size: 12px !important; font-weight: 700; letter-spacing: 0.5px; }

/* ── MC hist breakdown ── */
#mc-hist-breakdown > div { border-radius: var(--r-sm) !important; }
#mc-legend-box { font-size: 11px; line-height: 1.8; }

/* ── MC empty state ── */
#mc-empty-state h3 { font-size: 12px !important; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text2) !important; }
#mc-empty-state details summary { font-size: 11px !important; letter-spacing: 1px; }
#mc-empty-state p { color: var(--muted) !important; font-size: 12px !important; }

/* ── Statistics module ── */
.stats-main-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 24px; overflow: hidden; }
.stats-main-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.stats-section-title { font-size: 13px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; cursor: text; padding: 4px 8px; border-radius: var(--r-sm); transition: background 0.15s; outline: none; }
.stats-section-title:hover { background: rgba(10,132,255,0.07); }
.stats-section-title:focus { background: var(--bg3); box-shadow: inset 0 0 0 1px var(--blue); color: var(--text); }
.stats-subs-grid { padding: 16px 16px 0; display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.stats-subs-full { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.stats-sub { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.stats-sub-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.stats-sub-title { font-size: 14px; font-weight: 600; cursor: text; outline: none; padding: 2px 6px; border-radius: 4px; transition: background 0.15s; }
.stats-sub-title:hover { background: rgba(10,132,255,0.07); }
.stats-sub-title:focus { background: var(--bg2); box-shadow: inset 0 0 0 1px var(--blue); }
.stats-count-badge { display: inline-block; padding: 2px 8px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; font-size: 11px; color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }
.stats-sub-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.stats-sub-body { overflow-x: auto; max-height: 260px; overflow-y: auto; }
.stats-sub-body table { width: 100%; }
.stats-sub-body th { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--bg3); z-index: 1; }
.stats-sub-body td { font-size: 11px; padding: 5px 8px; border-bottom: 1px solid rgba(42,42,42,0.6); font-variant-numeric: tabular-nums; }
.stats-sub-body tr:last-child td { border-bottom: none; }
.stats-sub-body .st-cell { padding: 5px 8px !important; white-space: nowrap; }

/* ── Editable cells ── */
.st-cell { cursor: text; border-radius: 4px; padding: 10px 12px !important; transition: background 0.15s; white-space: nowrap; }
.st-cell:hover { background: rgba(10,132,255,0.07); }
.st-cell:focus { outline: none; background: var(--bg3); box-shadow: inset 0 0 0 1px var(--blue); }
.st-win  td { background: rgba(52,199,89,0.03); }
.st-loss td { background: rgba(255,59,48,0.03); }

/* ── Animations ── */
@keyframes cot-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cot-page-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.cot-page { animation: cot-page-in 0.35s cubic-bezier(0.22,1,0.36,1) both; }
.cot-page.fading { opacity: 0; transform: translateY(-4px); transition: opacity .25s ease, transform .25s ease; animation: none; }

/* Entry animations for cards */
.card { animation: cot-fade 0.3s ease both; }
.card:nth-child(1) { animation-delay: .04s; }
.card:nth-child(2) { animation-delay: .08s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .16s; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .stats-subs-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .cmp-grid { grid-template-columns: 1fr 1fr; }
  .signal-grid { grid-template-columns: 1fr; }
  .stats-subs-grid { grid-template-columns: 1fr; }
  #compare-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .cmp-grid { grid-template-columns: 1fr; }
  .selector-row { flex-direction: column; }
  #compare-grid { grid-template-columns: 1fr !important; }
  .tab-btn { padding: 0 12px; font-size: 11px; }
}
