/* ============================================================
   Blackbox Command Center, Monetization screen (js/monetization.js)

   Everything is prefixed .mon- and reads the app's existing tokens (--card,
   --ink, --border, --live, --danger, --warn ...), so light and dark (the
   "chrome" theme in css/chrome.css) both fall out of the same variables. The
   shared .card / .stat / .snapshot / .view-tabs / .pill / .sort-select /
   .chart-wrap classes are reused as they are; css/main.css and
   css/chrome.css are not edited for this screen.
   ============================================================ */

#screen-monetization .mon-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
#screen-monetization .mon-toolbar .view-tabs { margin-bottom: 0; }
#screen-monetization .mon-toolbar .sort-select { min-width: 200px; max-width: 100%; }

.mon-muted { color: var(--muted); }

/* ---------- status banner + health strip ---------- */
.mon-banner {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
  margin-bottom: 14px;
}
.mon-banner-warn {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--ink);
}
.mon-health {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 2px 16px;
}
.mon-health strong { color: var(--ink-soft); font-weight: 600; }
.mon-health-item { white-space: nowrap; }
.mon-health-ok::before,
.mon-health-warn::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.mon-health-ok::before { background: var(--live); }
.mon-health-warn { color: var(--ink-soft); cursor: help; }
.mon-health-warn::before { background: var(--warn); }

/* ---------- snapshot tiles ---------- */
#mon-snapshot { margin-bottom: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
:root[data-theme="dark"] #mon-snapshot .stat-value { font-size: 26px; }
#mon-snapshot .stat-label { white-space: normal; }
@media (max-width: 760px) {
  #mon-snapshot { grid-template-columns: 1fr; }
}

/* ---------- cards ---------- */
.mon-card { margin-bottom: 20px; }
.mon-card .card-title-row { flex-wrap: wrap; row-gap: 4px; }
.mon-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 4px 0 10px;
}
.mon-card .card-title-row + .mon-section-label { margin-top: 14px; }
.mon-card > .mon-section-label:not(:first-child) { margin-top: 22px; }
.mon-foot {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 12px;
}
.mon-plain {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 10px;
  max-width: 78ch;
}
.mon-cross { font-size: 13px; }
.mon-cross-stolen { color: var(--ink); border-left: 3px solid var(--warn); padding-left: 10px; }
.mon-cross-made_up { border-left: 3px solid var(--border); padding-left: 10px; }

.mon-empty { text-align: center; padding: 34px 24px; }
.mon-empty-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.mon-empty p { color: var(--muted); font-size: 13.5px; line-height: 1.5; max-width: 52ch; margin: 0 auto; }
.mon-wait-list { list-style: none; padding: 0; margin: 16px auto 0; max-width: 60ch; text-align: left; font-size: 13px; color: var(--ink-soft); }
.mon-wait-list li { padding: 8px 0; border-top: 1px solid var(--border-soft); line-height: 1.45; }

/* ---------- tables ---------- */
.mon-table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.mon-table,
.mon-compare,
.mon-spots {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.mon-table th,
.mon-compare th,
.mon-spots th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mon-table td,
.mon-compare td,
.mon-compare tbody th,
.mon-spots td,
.mon-spots tbody th {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  color: var(--ink);
}
.mon-table .mon-num,
.mon-table th.mon-num { text-align: right; }
.mon-table td > span:first-child { display: block; }
.mon-table td.mon-verdict > span { display: inline-block; }
.mon-sub { display: block; white-space: nowrap; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.mon-name-text { display: block; font-weight: 600; overflow-wrap: anywhere; }
.mon-kind { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.mon-table tbody tr { cursor: pointer; transition: background 0.14s ease; }
.mon-table tbody tr:hover { background: var(--border-soft); }
.mon-table tbody tr.is-selected { background: var(--tint-active); box-shadow: inset 3px 0 0 var(--ink); }
.mon-table tbody tr:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.mon-table tbody tr:last-child td { border-bottom: 0; }

/* the comparison + spots tables read left to right: numbers right aligned */
.mon-compare th,
.mon-compare td,
.mon-spots th,
.mon-spots td { text-align: right; }
.mon-compare th:first-child,
.mon-compare tbody th,
.mon-spots th:first-child,
.mon-spots tbody th { text-align: left; }
.mon-compare tbody th,
.mon-spots tbody th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: normal;
}
.mon-compare tbody tr:last-child th,
.mon-compare tbody tr:last-child td,
.mon-spots tbody tr:last-child th,
.mon-spots tbody tr:last-child td { border-bottom: 0; }
.mon-compare td:last-child { color: var(--ink-soft); font-weight: 600; }

/* ---------- verdict badge ---------- */
.mon-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid transparent;
}
.mon-badge-helped {
  color: var(--live);
  background: color-mix(in srgb, var(--live) 14%, transparent);
  border-color: color-mix(in srgb, var(--live) 34%, transparent);
}
.mon-badge-hurt {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 13%, transparent);
  border-color: color-mix(in srgb, var(--danger) 34%, transparent);
}
.mon-badge-too_early {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 38%, transparent);
}
.mon-badge-not_enough_data {
  color: var(--muted);
  background: var(--border-soft);
  border-color: var(--border);
}
.mon-verdict-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.mon-verdict-title { font-size: 15px; font-weight: 600; color: var(--ink); }

/* ---------- detail chart ---------- */
.mon-chart-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.mon-chart-wrap { height: 260px; }
.mon-history {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.mon-history-price { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- phone: tables become stacked cards, no sideways scroll ---------- */
@media (max-width: 720px) {
  .mon-table-wrap { overflow-x: visible; margin: 0; padding: 0; }
  .mon-table thead,
  .mon-spots thead { display: none; }
  .mon-table,
  .mon-table tbody,
  .mon-table tr,
  .mon-table td,
  .mon-spots,
  .mon-spots tbody,
  .mon-spots tr,
  .mon-spots th,
  .mon-spots td { display: block; width: 100%; }
  .mon-table tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    margin-bottom: 10px;
  }
  .mon-table tbody tr.is-selected { box-shadow: inset 3px 0 0 var(--ink); }
  .mon-table td,
  .mon-spots td,
  .mon-spots tbody th {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    text-align: right;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-soft);
  }
  .mon-table td:last-child,
  .mon-spots tr td:last-child { border-bottom: 0; }
  .mon-table td::before,
  .mon-spots td::before,
  .mon-spots tbody th::before {
    content: attr(data-label);
    flex-shrink: 0;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .mon-table td > span:first-child { display: inline; }
  .mon-table td .mon-sub { display: block; white-space: nowrap; text-align: right; }
  .mon-table td.mon-conv,
  .mon-table td.mon-chg { flex-wrap: nowrap; }
  .mon-table td.mon-conv > span,
  .mon-table td.mon-chg > span { text-align: right; }
  .mon-table td.mon-name { display: block; text-align: left; padding-top: 8px; }
  .mon-table td.mon-name::before { content: none; }
  .mon-spots tbody tr { border-bottom: 1px solid var(--border); padding: 4px 0 8px; margin-bottom: 4px; }
  .mon-spots tbody tr:last-child { border-bottom: 0; }
  .mon-spots tbody th { color: var(--ink); font-weight: 600; justify-content: flex-start; }
  .mon-spots tbody th::before { content: none; }
  .mon-chart-wrap { height: 230px; }
  #screen-monetization .mon-toolbar .sort-select { flex: 1 1 100%; }
  #screen-monetization .mon-toolbar .view-tabs { width: 100%; }
  #screen-monetization .mon-toolbar .view-tab { flex: 1; }
  .mon-compare-wrap { overflow-x: auto; }
  .mon-compare th { white-space: normal; letter-spacing: 0.03em; font-size: 10px; }
  .mon-compare .mon-sub { white-space: normal; }
  .mon-table td[data-label="Price"] .mon-sub { order: 1; margin-left: auto; }
  .mon-table td[data-label="Price"] > span:first-child { order: 2; margin-left: 8px; }
  .mon-compare { font-size: 12px; table-layout: fixed; }
  .mon-compare th:first-child,
  .mon-compare tbody th { width: 34%; }
  .mon-compare th,
  .mon-compare td { padding: 8px 6px; }
  .mon-compare tbody th { font-size: 12px; }
}
.mon-chg > span { white-space: nowrap; }
