/* Money4Gamers trade-up calculator
 * Everything is scoped to .m4g so it cannot break your theme.
 * Colours: edit the variables below. Rarity colours are the in-game ones.
 */
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 400; font-display: swap;
  src: url("fonts/barlow-semi-condensed-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap;
  src: url("fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }

.m4g {
  --panel: #1c2026;
  --panel-2: #242a32;
  --line: #333a44;
  --text: #dfe3e8;
  --muted: #929ba6;
  --brand: #00ba00;      /* same green as your menu bar */
  --pos: #43c75e;
  --neg: #ef5b5f;
  --r-consumer: #b0c3d9; --r-industrial: #5e98d9; --r-milspec: #4b69ff;
  --r-restricted: #8847ff; --r-classified: #d32ce6; --r-covert: #eb4b4b;
  --rar: var(--line);

  font-family: "Barlow Semi Condensed", "Arial Narrow", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  margin: 0 0 32px;
}
.m4g *, .m4g *::before, .m4g *::after { box-sizing: border-box; }
.m4g button, .m4g input, .m4g select { font: inherit; color: inherit; }
.m4g [hidden] { display: none !important; }
.m4g :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.m4g .pos { color: var(--pos); }
.m4g .neg { color: var(--neg); }

.m4g .r-consumer { --rar: var(--r-consumer); }
.m4g .r-industrial { --rar: var(--r-industrial); }
.m4g .r-milspec { --rar: var(--r-milspec); }
.m4g .r-restricted { --rar: var(--r-restricted); }
.m4g .r-classified { --rar: var(--r-classified); }
.m4g .r-covert { --rar: var(--r-covert); }

/* ───────── filter bar ───────── */
.m4g-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px;
  padding-bottom: 14px; margin: 0 0 12px; border-bottom: 1px solid var(--line);
}
.m4g-f { display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--muted); position: relative; }
.m4g-f input, .m4g-f select {
  height: 36px; padding: 0 10px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; color: var(--text);
}
.m4g-f select { padding-right: 6px; }
.m4g-f input::placeholder { color: #6f7883; }
.m4g-f-search { flex: 1 1 200px; }
.m4g-f-num input { width: 110px; }
.m4g-f-ex { flex: 0 1 190px; }
.m4g-check { display: flex; align-items: center; gap: 6px; height: 36px; font-size: 15px; }
.m4g-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.m4g-reset {
  height: 36px; padding: 0 12px; background: none; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; color: var(--muted);
}
.m4g-reset:hover { color: var(--text); border-color: var(--muted); }

.m4g-ex-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin: 2px 0 0; padding: 0; list-style: none;
  background: var(--panel-2); border: 1px solid var(--muted); border-radius: 3px; max-height: 260px; overflow-y: auto;
}
.m4g-ex-list li { padding: 7px 10px; cursor: pointer; color: var(--text); font-size: 15px; }
.m4g-ex-list li:hover { background: var(--line); }
.m4g-chips { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.m4g-chips:empty { display: none; }
.m4g-chips button {
  padding: 3px 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; font-size: 14px;
}
.m4g-chips button span { color: var(--neg); margin-left: 2px; }

.m4g-status { margin: 0 0 10px; font-size: 15px; color: var(--muted); }
.m4g-count { color: var(--text); font-weight: 600; }

/* ───────── main table ───────── */
.m4g-scroll { overflow-x: auto; }
.m4g-table { width: 100%; border-collapse: collapse; margin: 0; border: 0; font-variant-numeric: tabular-nums; }
.m4g-table th, .m4g-table td { border: 0; padding: 0; background: none; text-align: left; vertical-align: middle; }
.m4g-table thead th {
  font-weight: 400; font-size: 14px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.m4g-table th button { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; }
.m4g-table th button:hover, .m4g-table th button.on { color: var(--text); }
.m4g-table th button.on::after { content: ""; display: inline-block; margin-left: 5px; border: 4px solid transparent; vertical-align: middle; }
.m4g-table th button.desc::after { border-top-color: currentColor; margin-top: 4px; }
.m4g-table th button.asc::after { border-bottom-color: currentColor; margin-top: -4px; }
.m4g .c-num { text-align: right; white-space: nowrap; }
.m4g .m4g-sm { display: none; }

.m4g-row { cursor: pointer; border-bottom: 1px solid var(--line); }
.m4g-row:hover, .m4g-row.is-open { background: var(--panel-2); }
.m4g-row td { padding: 6px 10px; }
.m4g-row td.c-item { padding-left: 0; }
.m4g-row .c-rar { color: var(--muted); font-size: 15px; white-space: nowrap; }
.m4g-row td.c-num { font-size: 17px; }

.m4g-open {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; padding: 0 0 0 12px; cursor: pointer; text-align: left;
}
.m4g-thumb {
  flex: 0 0 64px; height: 48px; display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border-bottom: 2px solid var(--rar);
}
.m4g-row:hover .m4g-thumb, .m4g-row.is-open .m4g-thumb { background: var(--line); }
.m4g-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.m4g-name { display: flex; flex-direction: column; min-width: 0; }
.m4g-skin { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m4g-sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m4g-st { color: #cf6a32; font-weight: 600; }
.m4g-var { display: inline-block; margin: 4px 0 0 88px; font-size: 13px; color: var(--muted); }

.m4g.is-loading tbody { opacity: .5; }
.m4g-empty { padding: 24px 10px; color: var(--muted); margin: 0; }
.m4g-more {
  display: block; width: 100%; margin: 12px 0 0; height: 40px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; font-weight: 600;
}
.m4g-more:hover { border-color: var(--brand); }
.m4g-note { margin: 16px 0 0; font-size: 14px; color: var(--muted); max-width: 75ch; }

/* ───────── opened trade-up ───────── */
.m4g-detail > td { padding: 0; border-bottom: 1px solid var(--line); }
.m4g-d { padding: 16px 14px 20px; background: #181b20; cursor: auto; }
.m4g-d-loading { margin: 0; color: var(--muted); }
.m4g-d h3 { font-size: 17px; font-weight: 600; margin: 22px 0 10px; color: var(--text); font-family: inherit; }
.m4g-small { font-size: 14px; color: var(--muted); margin: 6px 0 0; }

.m4g-variants { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 14px; }
.m4g-variants > span { color: var(--muted); margin-right: 4px; }
.m4g-variants button {
  padding: 4px 9px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; font-size: 14px;
}
.m4g-variants button.on { border-color: var(--brand); }

.m4g-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--line); border: 1px solid var(--line); }
.m4g-sum div { background: var(--panel); padding: 8px 12px; }
.m4g-sum dt { font-size: 14px; color: var(--muted); }
.m4g-sum dd { margin: 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* the 10 slots, laid out like the in-game trade-up contract */
.m4g-contract { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; max-width: 640px; }
.m4g-contract li {
  margin: 0; background: var(--panel-2); border-bottom: 3px solid var(--rar);
  display: flex; flex-direction: column; align-items: center; padding: 6px 4px 4px;
}
.m4g-contract img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; display: block; }
.m4g-contract .m4g-noimg { width: 100%; aspect-ratio: 4 / 3; }
.m4g-contract li > span:last-child { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.m4g-sub-t { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; margin: 0; border: 0; font-variant-numeric: tabular-nums; }
.m4g-sub-t th, .m4g-sub-t td { border: 0; background: none; padding: 6px 10px 6px 0; text-align: left; vertical-align: middle; }
.m4g-sub-t th { font-weight: 400; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.m4g-sub-t tbody tr { border-bottom: 1px solid #2a3038; }
.m4g-sub-t td:first-child { width: 100%; }
.m4g-sub-t .m4g-skin { font-size: 16px; }
.m4g-oitem { display: flex; align-items: center; gap: 10px; }
.m4g-oitem img { width: 48px; height: 36px; object-fit: contain; background: var(--panel-2); border-bottom: 2px solid var(--rar); flex: 0 0 48px; }
.m4g-oitem > span { display: flex; flex-direction: column; min-width: 0; }

.m4g-buy { display: flex; gap: 3px; white-space: nowrap; }
.m4g-buy a { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; }
.m4g-buy a:hover { border-color: var(--brand); }
.m4g-buy img { width: 16px; height: 16px; object-fit: contain; }

.m4g-sim { margin-top: 8px; }
.m4g-sim h3 { margin-top: 24px; }
.m4g-sim-run {
  height: 36px; padding: 0 14px; cursor: pointer; font-weight: 600; margin: 8px 0 14px;
  background: var(--brand); color: #06210a; border: 0; border-radius: 3px;
}
.m4g-sim-run:hover { filter: brightness(1.1); }

.m4g-chart { background: var(--panel); border: 1px solid var(--line); padding: 10px 12px 4px; margin-bottom: 12px; max-width: 760px; }
.m4g-chart-head { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; min-height: 22px; color: var(--muted); }
.m4g-now { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m4g-total { white-space: nowrap; }
.m4g-total strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.m4g-plot svg { display: block; width: 100%; height: auto; }
.m4g .g-txt { fill: var(--muted); font-size: 12px; font-family: inherit; }
.m4g .g-grid { stroke: #2a3038; stroke-width: 1; }
.m4g .g-zero { stroke: #5b6572; stroke-width: 1; stroke-dasharray: 4 4; }
.m4g .g-line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.m4g .g-area-pos { fill: rgba(67, 199, 94, .22); }
.m4g .g-area-neg { fill: rgba(239, 91, 95, .22); }
.m4g .g-win { fill: var(--pos); }
.m4g .g-loss { fill: var(--neg); }
.m4g-sum.is-six { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 760px; }

/* ───────── small screens ─────────
 * Below 760px the table turns into a grid per row: skin name + cost, profit, chance.
 */
@media (max-width: 760px) {
  .m4g { padding: 12px 10px; border-left: 0; border-right: 0; border-radius: 0; }
  .m4g-bar { gap: 8px 10px; }
  .m4g-f-search { flex-basis: 100%; }
  .m4g-f, .m4g-f-ex { flex: 1 1 140px; }
  .m4g-f-num input { width: 100%; }

  .m4g-table, .m4g-table thead, .m4g-table tbody { display: block; }
  .m4g-table tr { display: grid; grid-template-columns: minmax(0, 1fr) 64px 72px 46px; align-items: center; }
  .m4g-table .c-rar, .m4g-table .c-ret, .m4g-table .c-outs { display: none; }
  .m4g .m4g-lg { display: none; }
  .m4g .m4g-sm { display: inline; }
  .m4g-table thead th { padding: 6px 4px; font-size: 13px; }
  .m4g-table thead th.c-item { padding-left: 8px; }
  .m4g-row td { padding: 6px 4px; }
  .m4g-row td.c-num { font-size: 15px; }
  .m4g-table tr.m4g-detail { display: block; }
  .m4g-detail > td { display: block; }
  .m4g-open { gap: 8px; padding-left: 8px; }
  .m4g-thumb { flex-basis: 48px; height: 36px; }
  .m4g-skin { font-size: 15px; }
  .m4g-var { margin-left: 64px; }

  .m4g-d { padding: 14px 10px 18px; }
  .m4g-sum, .m4g-sum.is-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m4g-sum dd { font-size: 19px; }
  .m4g-contract { gap: 4px; }

  .m4g-sub-t { display: block; overflow: visible; }
  .m4g-sub-t thead { display: none; }
  .m4g-sub-t tbody { display: block; }
  .m4g-sub-t tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 8px 0; }
  .m4g-sub-t td { padding: 0; }
  .m4g-sub-t td:first-child { flex-basis: 100%; }
  .m4g-sub-t .m4g-skin { white-space: normal; }
  .m4g-sub-t td[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-size: 13px; }
  .m4g-sub-t td:last-child { margin-left: auto; }
}
@media (max-width: 420px) {
  .m4g-table tr { grid-template-columns: minmax(0, 1fr) 60px 68px 42px; }
  .m4g-thumb { display: none; }
  .m4g-row td.c-item { box-shadow: inset 3px 0 0 var(--rar); }
  .m4g-var { margin-left: 8px; }
}
@media (prefers-reduced-motion: reduce) { .m4g * { transition: none !important; } }
.m4g-sv { color: #d4a72c; font-weight: 600; }
.m4g-contract li.is-souv span { color: #d4a72c; }