/* Матрица выплат: партнерский кабинет (вкладка «Выплаты») и админ-панель
   (вкладка «Матрица»). Разметку строит web/assets/matrix-view.js.
   .mx-wide — компьютер (таблица + карточка справа), .mx-full — широкий экран
   (в таблице есть колонки «Статус» и «Кандидату»). */

.mx-root {
  --mx-surface: #192223;
  --mx-surface-2: #151E1F;
  --mx-row: #172021;
  --mx-row-active: #1E2928;
  --mx-text-2: #D4D0BC;
  --mx-muted: #B5B3A2;
  --mx-faint: #A8A796;
  --mx-olive-light: #C9CC86;
  --mx-warn: #E0A685;
  display: grid;
  gap: 16px;
  color: var(--cream);
}

.mx-root button:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

/* ---------- Заголовок, темп, фильтры ---------- */

.mx-top {
  display: grid;
  gap: 14px;
}

.mx-wide .mx-top {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
}

.mx-title {
  margin: 0;
  padding: 0;
  color: var(--cream);
  font-size: 26px;
  font-weight: 850;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.mx-title::before {
  display: none;
}

.mx-wide .mx-title {
  font-size: 30px;
}

.mx-lead {
  max-width: 600px;
  margin: 6px 0 0;
  color: var(--mx-muted);
  font-size: 14px;
  line-height: 1.45;
}

.mx-tier-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(167, 170, 99, .18);
  border-radius: 16px;
  background: var(--mx-surface-2);
}

.mx-tier-label {
  color: var(--mx-text-2);
  font-size: 13px;
  font-weight: 700;
}

.mx-tiers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mx-wide .mx-tiers {
  grid-template-columns: repeat(4, 64px);
}

.mx-tier {
  min-height: 44px;
  border: 1px solid rgba(234, 230, 210, .16);
  border-radius: 11px;
  color: var(--mx-text-2);
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}

.mx-tier.is-active {
  border-color: var(--olive);
  color: var(--ink);
  background: var(--olive);
}

.mx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(234, 230, 210, .16);
  border-radius: 999px;
  color: var(--mx-muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.mx-chip span {
  font-weight: 600;
  opacity: .75;
}

.mx-chip.is-active {
  border-color: rgba(167, 170, 99, .6);
  color: var(--cream);
  background: rgba(167, 170, 99, .18);
}

/* ---------- Значки статуса ---------- */

.mx-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.mx-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.mx-badge--prime {
  border-color: var(--olive);
  color: var(--ink);
  background: var(--olive);
}

.mx-badge--priority {
  border-color: rgba(167, 170, 99, .45);
  color: var(--mx-olive-light);
  background: rgba(167, 170, 99, .14);
}

.mx-badge--open {
  border-color: rgba(234, 230, 210, .28);
  color: var(--mx-text-2);
}

.mx-badge--none {
  border-color: rgba(234, 230, 210, .16);
  color: var(--mx-faint);
}

.mx-badge--avoid {
  border-color: rgba(224, 166, 133, .45);
  color: var(--mx-warn);
  background: rgba(224, 166, 133, .10);
}

.mx-badge--hidden {
  border-style: dashed;
  border-color: rgba(234, 230, 210, .38);
  color: var(--mx-text-2);
}

.mx-chevron {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Телефон: карточки регионов ---------- */

.mx-cards {
  display: grid;
  gap: 10px;
}

.mx-card {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 1px solid rgba(167, 170, 99, .18);
  border-radius: 18px;
  color: var(--cream);
  background: var(--mx-surface);
  text-align: left;
  cursor: pointer;
}

.mx-card:active {
  transform: scale(.99);
}

.mx-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mx-card-top .mx-chevron {
  color: var(--mx-faint);
}

.mx-card-title {
  display: grid;
  gap: 2px;
}

.mx-card-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.mx-card-sub {
  color: var(--mx-faint);
  font-size: 13px;
}

.mx-card-rate {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.mx-card-amount {
  color: var(--mx-olive-light);
  font-size: 32px;
  font-weight: 850;
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.mx-card-unit {
  color: var(--mx-muted);
  font-size: 13px;
}

.mx-card-nopay {
  color: var(--mx-text-2);
  font-size: 15px;
  font-weight: 700;
}

.mx-scale {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mx-scale-cell {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 6px 0;
  border-radius: 10px;
  color: var(--mx-text-2);
  background: rgba(234, 230, 210, .06);
}

.mx-scale-cell b {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mx-scale-cell small,
.mx-tile small {
  color: var(--mx-faint);
  font-size: 11px;
  font-weight: 600;
}

.mx-scale-cell.is-active,
.mx-tile.is-active {
  color: var(--ink);
  background: var(--olive);
}

.mx-scale-cell.is-active small,
.mx-tile.is-active small {
  color: var(--ink);
}

.mx-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mx-fact {
  padding: 4px 9px;
  border-radius: 999px;
  color: #CFCBB8;
  background: rgba(234, 230, 210, .07);
  font-size: 12.5px;
  font-weight: 600;
}

/* ---------- Примечания ---------- */

.mx-notes {
  display: grid;
  gap: 8px;
}

.mx-note {
  margin: 0;
  color: var(--mx-faint);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-line;
}

.mx-note--center {
  text-align: center;
}

.mx-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed rgba(234, 230, 210, .2);
  border-radius: 16px;
  color: var(--mx-muted);
  font-size: 14px;
}

/* ---------- Карточка региона ---------- */

.mx-detail {
  display: grid;
  gap: 16px;
}

.mx-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 14px 0 8px;
  border: 1px solid rgba(167, 170, 99, .25);
  border-radius: 12px;
  color: var(--cream);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.mx-detail-head {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.mx-detail-name {
  margin: 0;
  color: var(--cream);
  font-size: 28px;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.mx-detail-sub {
  margin: 0;
  color: var(--mx-faint);
  font-size: 14px;
  line-height: 1.4;
}

.mx-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(167, 170, 99, .22);
  border-radius: 18px;
  background: var(--mx-surface);
}

.mx-box--empty {
  border-style: dashed;
  border-color: rgba(234, 230, 210, .22);
  background: transparent;
}

.mx-box-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.mx-box-head span {
  color: var(--mx-faint);
  font-size: 12px;
}

.mx-box-title {
  margin: 0;
  color: var(--cream);
  font-size: 15px;
  font-weight: 800;
}

.mx-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mx-tile {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
  min-height: 64px;
  padding: 8px 4px;
  border: 1px solid rgba(234, 230, 210, .12);
  border-radius: 12px;
  color: var(--cream);
  background: rgba(234, 230, 210, .05);
  cursor: pointer;
}

.mx-tile.is-active {
  border-color: var(--olive);
}

.mx-tile b {
  font-size: 20px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.mx-hint {
  margin: 0;
  color: var(--mx-faint);
  font-size: 12.5px;
  line-height: 1.45;
}

.mx-text {
  margin: 0;
  color: var(--mx-text-2);
  font-size: 14px;
  line-height: 1.45;
}

.mx-paynote {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--mx-warn);
  background: rgba(224, 166, 133, .10);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.mx-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid rgba(234, 230, 210, .08);
}

.mx-kv span {
  color: var(--mx-muted);
  font-size: 14px;
}

.mx-kv b {
  font-size: 15px;
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mx-total {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(167, 170, 99, .14);
}

.mx-total span {
  font-size: 14px;
  font-weight: 700;
}

.mx-total b {
  color: var(--mx-olive-light);
  font-size: 20px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.mx-dl {
  display: grid;
  margin: 0;
}

.mx-dl > div {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid rgba(234, 230, 210, .08);
}

.mx-dl dt {
  color: var(--mx-faint);
  font-size: 12.5px;
  font-weight: 600;
}

.mx-dl dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.mx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mx-actions > button {
  flex: 1 1 160px;
  min-height: 50px;
  font-size: 15px;
}

/* ---------- Компьютер: таблица + карточка справа ---------- */

.mx-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.mx-full .mx-split {
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
}

.mx-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.mx-aside {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(167, 170, 99, .22);
  border-radius: 20px;
  background: var(--mx-surface-2);
  overscroll-behavior: contain;
}

.mx-table-scroll {
  overflow-x: auto;
}

.mx-table {
  display: grid;
  gap: 6px;
  min-width: 480px;
}

.mx-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, 58px);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 8px 12px;
  border: 1px solid rgba(234, 230, 210, .06);
  border-radius: 12px;
  color: var(--cream);
  background: var(--mx-row);
  text-align: left;
  cursor: pointer;
}

.mx-full .mx-row {
  grid-template-columns: minmax(0, 1fr) 160px repeat(4, 60px) 84px;
}

.mx-row--head {
  min-height: 0;
  padding: 0 12px 4px;
  border: 0;
  color: var(--mx-faint);
  background: transparent;
  cursor: default;
  font-size: 12px;
  font-weight: 700;
}

.mx-row.is-selected {
  border-color: rgba(167, 170, 99, .6);
  background: var(--mx-row-active);
}

.mx-col-status,
.mx-col-lump {
  display: none;
}

.mx-full .mx-col-status,
.mx-full .mx-col-lump {
  display: block;
}

.mx-full .mx-name-badge {
  display: none;
}

.mx-col-name {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mx-col-name b {
  font-size: 15px;
  font-weight: 750;
}

.mx-col-name small {
  color: var(--mx-faint);
  font-size: 12px;
}

.mx-name-badge {
  margin-top: 4px;
}

.mx-col-lump {
  color: var(--mx-text-2);
  font-size: 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mx-row--head .mx-col-lump {
  color: var(--mx-faint);
  font-size: 12px;
}

.mx-col-tier {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  color: var(--mx-faint);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.mx-col-tier.is-active {
  color: var(--ink);
  background: var(--olive);
}

.mx-cell {
  padding: 7px 0;
  border-radius: 8px;
  color: var(--mx-muted);
  font-size: 15px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mx-cell.is-active {
  color: var(--mx-olive-light);
  background: rgba(167, 170, 99, .14);
  font-weight: 800;
}

@media (hover: hover) and (pointer: fine) {
  .mx-card:hover,
  .mx-row:not(.mx-row--head):hover {
    border-color: rgba(167, 170, 99, .38);
  }

  .mx-chip:hover,
  .mx-tier:not(.is-active):hover,
  .mx-tile:not(.is-active):hover,
  .mx-back:hover {
    border-color: rgba(167, 170, 99, .45);
  }
}

/* Партнерский кабинет на широком экране: матрице нужно больше места,
   чем остальным вкладкам, — раздвигаем только ее. */
@media (min-width: 1000px) {
  .app-shell #matrix .mx-root {
    position: relative;
    left: 50%;
    width: min(1180px, calc(100vw - 48px));
    transform: translateX(-50%);
  }
}

/* ---------- Админ-панель: форма региона ---------- */

.mx-admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.mx-admin-toolbar .muted {
  flex: 1 1 260px;
  margin: 0;
  font-size: 13px;
}

.mx-form {
  display: grid;
  gap: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.mx-form fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(167, 170, 99, .2);
  border-radius: 16px;
}

.mx-form legend {
  padding: 0 6px;
  color: var(--cream);
  font-size: 14px;
  font-weight: 800;
}

.mx-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.mx-form textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(167, 170, 99, .20);
  border-radius: var(--radius-sm);
  color: var(--cream);
  background: rgba(18, 26, 27, .70);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
}

.mx-form textarea:focus {
  border-color: var(--olive);
  outline: none;
}

.mx-form .field-hint {
  margin-top: -4px;
}

.mx-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid rgba(167, 170, 99, .2);
  background: var(--ink);
}

.mx-form-error {
  min-height: 20px;
  margin: 0;
  color: var(--cream);
  font-size: 13px;
  font-weight: 650;
}

/* Атрибут hidden должен побеждать display из правил выше. */
.mx-admin-toolbar[hidden],
.mx-form [hidden] {
  display: none;
}
