/* Process > Trades — "View matrix" (trades_matrix.js): the trade matrices in a
   modal, light theme, compact tables with a heat tint from the theme colours.
   "Cumulative" (trades_cumulative.js) shares its button, modal and filter row. */

#matrix-open,
#cumulative-open {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
}
#matrix-open:hover,
#cumulative-open:hover { color: var(--text); background: var(--subtle); }

#matrix-modal,
#cumulative-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(19, 23, 34, 0.18);
}
#matrix-modal[hidden],
#cumulative-modal[hidden] { display: none; }
.mx-card {
  width: min(1180px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(19, 23, 34, 0.12);
  color: var(--text);
  font-size: 12px;
}
.mx-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.mx-run { color: var(--text-dim); font-weight: 400; flex: 1; }
#matrix-close,
#cumulative-close {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
}
#matrix-close:hover,
#cumulative-close:hover { color: var(--text); background: var(--subtle); }

.mx-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
}
.mx-filters label { display: inline-flex; align-items: center; gap: 4px; }
.mx-filters input,
.mx-filters select {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 2px 4px;
}
.mx-presets { display: inline-flex; gap: 2px; }
.mx-presets button {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
}
.mx-presets button:hover { color: var(--text); background: var(--subtle); }
.mx-status { margin-left: auto; font-variant-numeric: tabular-nums; }
.mx-help { margin: 0; padding: 4px 10px; color: var(--text-dim); font-size: 11px; }

.mx-body {
  overflow: auto;
  padding: 4px 10px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 10px 16px;
  align-content: start;
}
.mx-block h3 {
  margin: 6px 0 4px;
  font-size: 12px;
  font-weight: 600;
}
.mx-sub { margin-left: 6px; color: var(--text-dim); font-weight: 400; }
.mx-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mx-cap { color: var(--text-dim); font-size: 11px; margin-bottom: 2px; white-space: nowrap; }
.mx-cap b { color: var(--text); font-weight: 600; }

.mx-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.mx-table th,
.mx-table td {
  border: 1px solid var(--border);
  padding: 3px 6px;
  text-align: right;
  white-space: nowrap;
}
.mx-table thead th { color: var(--text-dim); font-weight: 500; font-size: 11px; background: var(--subtle); }
.mx-table tbody th { text-align: left; font-weight: 500; }
.mx-table td.mx-hit { cursor: pointer; }
.mx-table td.mx-hit:hover,
.mx-table td.mx-hit:focus { outline: 1px solid var(--accent); outline-offset: -1px; }
.mx-table td.mx-zero { color: var(--text-dim); }
.mx-table tr.mx-all th,
.mx-table tr.mx-all td { font-weight: 600; }
.mx-n { font-weight: 600; }
.mx-pct { margin-left: 6px; color: var(--text-dim); font-size: 10px; }
.mx-span { min-width: 0; }
.mx-note { margin: 2px 0 0; color: var(--text-dim); font-size: 10px; }
.mx-block.is-outcome .mx-note { color: var(--text); }
.mx-error { grid-column: 1 / -1; margin: 6px 0; color: var(--down); }

/* The skeleton shown until the JSON arrives. */
.mx-skel-box { border: 1px solid var(--border); border-radius: 4px; padding: 6px; }
.mx-skel-line {
  height: 10px;
  margin: 6px 0;
  border-radius: 3px;
  background: var(--subtle);
  animation: mx-pulse 1s ease-in-out infinite alternate;
}
.mx-skel-title { width: 40%; height: 12px; }
@keyframes mx-pulse {
  from { opacity: 1; }
  to { opacity: 0.45; }
}

/* The trades list's chip while a matrix cell filters it. */
#grade-cell {
  margin: 4px 8px 0;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}
#grade-cell[hidden] { display: none; }
#grade-cell b { color: var(--text); font-weight: 600; flex: 1; }
#grade-cell-clear {
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
}
#grade-cell-clear:hover { color: var(--text); }
