:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #111111;
  --ink-muted: #6b6b6b;
  --line: #e6e4dd;
  --accent: #111111;
  --accent-ink: #ffffff;
  --gold: #b58900;
  --silver: #8a8a8a;
  --bronze: #a1662f;
  --danger: #b00020;
  --success: #0a7a3b;
  --radius: 14px;
  --radius-sm: 10px;
  --pad: 20px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

header.top h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}

header.top .sub {
  color: var(--ink-muted);
  font-size: 13px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

label {
  display: block;
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

textarea { min-height: 96px; resize: vertical; }

.field { margin-bottom: 14px; }

button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 500;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  transition: transform .05s ease, opacity .15s ease;
}
button:hover { opacity: .92; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }

.hint { color: var(--ink-muted); font-size: 13px; margin-top: 8px; }
.error {
  color: var(--danger);
  background: #fff5f6;
  border: 1px solid #f4d4d8;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.success {
  color: var(--success);
  background: #f2faf5;
  border: 1px solid #cfe9d9;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}

.tabs {
  display: flex;
  gap: 4px;
  background: #efece5;
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.tabs button {
  flex: 1;
  background: transparent;
  color: var(--ink-muted);
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  width: auto;
}
.tabs button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.rank-list { display: flex; flex-direction: column; gap: 8px; }

.rank-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: fade-up .28s ease both;
}
.rank-row .place { font-variant-numeric: tabular-nums; color: var(--ink-muted); font-weight: 500; }
.rank-row .name { font-weight: 500; display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank-row .name span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .value {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  text-align: right;
}
.rank-row .value small { display: block; color: var(--ink-muted); font-family: var(--sans); font-size: 12px; margin-top: 2px; }

.rank-row.top1 {
  background: linear-gradient(180deg, #fff9e6 0%, #fff 100%);
  border-color: #f0d97a;
}
.rank-row.top1 .place::before { content: '★ '; color: var(--gold); }

/* Своя строка в рейтинге кабинета — приглушённая подсветка, не спорит с top1 */
.rank-row.self {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}
.rank-row.self .name .n { font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  background: #fafaf7;
  font-weight: 500;
  letter-spacing: .02em;
}
.badge.gold   { color: var(--gold);   border-color: #ecd68a; background: #fff8e2; }
.badge.silver { color: var(--silver); border-color: #dcdcdc; background: #f6f6f6; }
.badge.bronze { color: var(--bronze); border-color: #e2c19e; background: #fbf1e5; }

.empty {
  text-align: center;
  color: var(--ink-muted);
  padding: 32px 8px;
  font-size: 14px;
}
.loading {
  text-align: center;
  color: var(--ink-muted);
  padding: 24px 8px;
  font-size: 14px;
}

footer.bottom {
  margin-top: 28px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 12px;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 560px) {
  header.top h1 { font-size: 26px; }
  .page { padding: 36px 16px 72px; }
}

/* ---------- Админка ---------- */

.page.wide { max-width: 900px; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.toolbar button {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
}
.toolbar button:hover { color: var(--ink); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 {
  font-size: 16px;
  margin: 0;
  letter-spacing: -0.005em;
}
.section-head button.primary {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}

.list { display: flex; flex-direction: column; gap: 10px; }

.row-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  animation: fade-up .22s ease both;
}

/* партнёр — компактная строка */
.partner-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: baseline;
}
.partner-row .main { min-width: 0; }
.partner-row .main .n { font-weight: 500; }
.partner-row .main .meta {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 2px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.partner-row .main .meta code {
  font-family: var(--mono);
  background: #f2efe7;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}
.partner-row .stats {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
}
.partner-row .stats small {
  display: block;
  color: var(--ink-muted);
  font-size: 12px;
  font-family: var(--sans);
}
.partner-row .actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.partner-row .actions button {
  width: auto;
  padding: 7px 12px;
  font-size: 13px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.partner-row .actions button:hover { background: #f5f3ed; }

/* сделка — блочная карточка */
.deal-row .head {
  display: flex;
  justify-content: space-between;
  gap: 8px 12px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.deal-row .head .who {
  font-weight: 500;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.deal-row .head .when {
  color: var(--ink-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* SHORT_ID — совпадает с #ID из текста WhatsApp; заметно, но не громко */
.short-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: #f2efe7;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* Источник сделки */
.src-badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-weight: 500;
  letter-spacing: 0.02em;
  background: #fafaf7;
  color: var(--ink-muted);
}
.src-badge.src-whatsapp  { background: #eaf6ee; border-color: #cde6d3; color: #1a6b34; }
.src-badge.src-instagram { background: #fbecf2; border-color: #f2ccdb; color: #a63373; }
.src-badge.src-form      { background: #eef2f7; border-color: #d9e0ea; color: #47598a; }

/* Inline-edit клиентского имени / контакта. В view-режиме — обычный inline,
   чтобы длинный контакт (11 цифр) переносился, а не резался. Без сдвигающих
   padding/margin — иначе пустое поле визуально смещается относительно ячейки. */
.inline-editable {
  cursor: pointer;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.inline-editable:not(.editing) .val {
  border-bottom: 1px dashed transparent;
  transition: border-color .12s ease, color .12s ease;
}
.inline-editable:hover:not(.editing) .val { border-bottom-color: var(--line); }
.inline-editable:hover:not(.editing) .val.empty { color: var(--ink); }
.inline-editable:hover:not(.editing) .pencil { opacity: 1; color: var(--ink); }
.inline-editable.editing {
  display: inline-block;
  width: 100%;
  max-width: 100%;
  cursor: default;
}
.inline-editable .val.empty {
  color: var(--ink-muted);
  font-style: italic;
  font-weight: 400;
}
.inline-editable .pencil {
  color: var(--ink-muted);
  font-size: 12px;
  margin-left: 4px;
  opacity: .55;
  transition: opacity .12s ease, color .12s ease;
}

.inline-edit {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
  max-width: 340px;
}
.inline-edit input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}
.inline-edit button {
  width: auto;
  padding: 7px 12px;
  font-size: 13px;
  flex-shrink: 0;
}
.inline-edit button.cancel {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  padding: 6px 10px;
  min-width: 32px;
}
.inline-edit button.cancel:hover { color: var(--ink); background: #f5f3ed; }

/* ---------- Плашка «К выплате» + панель массовой отметки ---------- */

.debt-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #fff9de;
  border: 1px solid #f2e6b0;
  border-radius: var(--radius);
  color: #5c4a12;
  font-size: 14px;
  margin-bottom: 12px;
}
.debt-bar .amt {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
  color: #3b2f0b;
}
.debt-bar.debt-err {
  background: #fff5f6;
  border-color: #f4d4d8;
  color: var(--danger);
}

.pay-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--accent-ink);
  padding: 8px 10px 8px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  z-index: 40;
  max-width: calc(100% - 32px);
}
.pay-bar[hidden] { display: none; }
.pay-bar .pay-bar-count {
  font-size: 13px;
  opacity: .8;
  white-space: nowrap;
}
.pay-bar button {
  width: auto;
  background: #fff;
  color: var(--ink);
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 999px;
  white-space: nowrap;
}
.pay-bar button:hover { opacity: .92; }

.pay-check-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin-right: 4px;
}
.pay-check-wrap input.pay-check {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.paid-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eaf6ee;
  border: 1px solid #cde6d3;
  color: #1a6b34;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.paid-badge .unpay-link {
  width: auto;
  background: transparent;
  color: #1a6b34;
  padding: 0;
  font-size: 11px;
  text-decoration: underline;
  text-decoration-color: rgba(26,107,52,.35);
  text-underline-offset: 2px;
  border-radius: 0;
  opacity: .8;
}
.paid-badge .unpay-link:hover { opacity: 1; text-decoration-color: #1a6b34; }

/* ---------- Фильтры сделок ---------- */

.deals-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.filters-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.filter-group > label {
  color: var(--ink-muted);
  font-size: 12px;
  margin: 0;
}
.filter-group select {
  padding: 8px 10px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.filter-group select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

.filter-group-period .period-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.date-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-inputs input[type="date"] {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  outline: none;
}
.date-inputs input[type="date"]:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.date-inputs .dash { color: var(--ink-muted); font-size: 12px; }

.chip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { height: 4px; }
.chip-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.chip-row-labeled { align-items: baseline; }
.chip-row .filter-label {
  color: var(--ink-muted);
  font-size: 12px;
  flex-shrink: 0;
  padding-right: 4px;
  align-self: center;
}
.chip-row .chip {
  width: auto;
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  flex-shrink: 0;
  white-space: nowrap;
  transition: color .12s ease, background-color .12s ease, border-color .12s ease;
}
.chip-row .chip:hover { color: var(--ink); background: #f5f3ed; }
.chip-row .chip.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.filter-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--ink-muted);
  font-size: 13px;
}
.filter-count { font-variant-numeric: tabular-nums; }
.filter-reset {
  width: auto;
  padding: 5px 12px;
  font-size: 12px;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.filter-reset:hover { color: var(--ink); background: #f5f3ed; }

@media (min-width: 640px) {
  .filters-row { grid-template-columns: minmax(180px, 1fr) minmax(280px, 2fr); }
  .date-inputs input[type="date"] { max-width: 160px; }
}


.deal-row .field-line {
  display: flex;
  gap: 8px;
  font-size: 14px;
  padding: 3px 0;
}
.deal-row .field-line .k {
  color: var(--ink-muted);
  min-width: 84px;
}
.deal-row .field-line .v {
  color: var(--ink);
  min-width: 0;
  word-break: break-word;
}
.deal-row .field-line .v code {
  font-family: var(--mono);
  background: #f2efe7;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 4px;
}
.stage-btn {
  width: auto;
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  transition: all .12s ease;
}
.stage-btn:hover { color: var(--ink); background: #f5f3ed; }
.stage-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.stage-btn.saving { opacity: .5; }

.amount-block {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.amount-block input {
  flex: 1;
  padding: 9px 12px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.amount-block button {
  width: auto;
  padding: 9px 14px;
  font-size: 13px;
}
.reward-preview {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.reward-preview.set { color: var(--ink); }

.row-error {
  margin-top: 8px;
  color: var(--danger);
  background: #fff5f6;
  border: 1px solid #f4d4d8;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* форма добавления партнёра — collapsible */
.collapsible[hidden] { display: none; }
.collapsible {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.inline-form { display: grid; gap: 10px; }
.inline-form .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.inline-form .actions {
  display: flex;
  gap: 8px;
}
.inline-form .actions button.secondary {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
}
.inline-form .actions button { width: auto; padding: 10px 14px; font-size: 14px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

@media (min-width: 640px) {
  .inline-form .row { grid-template-columns: 1fr 1fr 1fr; }
  .deal-row .field-line .k { min-width: 110px; }
}

/* ---------- /apply — клик-флоу ---------- */

.apply-page .lead {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cta {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  padding: 16px 18px;
  border-radius: var(--radius);
  transition: transform .05s ease, opacity .15s ease, background-color .15s ease, border-color .15s ease;
}

.cta:disabled { opacity: .55; cursor: default; transform: none; }
.cta:not(:disabled):active { transform: translateY(1px); }

.cta .cta-label {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.cta .cta-hint {
  font-size: 12.5px;
  font-weight: 400;
  opacity: .72;
  letter-spacing: 0;
}

.cta-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  padding: 18px 20px;
}

.cta-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.cta-secondary:not(:disabled):hover { background: #f5f3ed; }

.fallback-link {
  margin: 18px 0 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
}
.fallback-link a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}
.fallback-link a:hover { text-decoration-color: var(--ink); }

#cta-status:empty,
#form-status:empty { display: none; }

@media (min-width: 560px) {
  .cta { padding: 18px 22px; }
  .cta-primary { padding: 20px 22px; }
  .cta .cta-label { font-size: 18px; }
}

/* ---------- /partner — кабинет партнёра ---------- */

.link-block > label {
  color: var(--ink-muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.link-block .link-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.link-block .link-row input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  padding: 10px 12px;
  font-family: var(--mono);
  background: #faf9f5;
}
.link-block .link-row button {
  width: auto;
  padding: 10px 14px;
  font-size: 13px;
  white-space: nowrap;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.stats-row .stat {
  padding: 6px 4px;
}
.stats-row .stat + .stat {
  border-left: 1px solid var(--line);
}
.stats-row .stat-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}
.stats-row .stat-label {
  color: var(--ink-muted);
  font-size: 12px;
  margin-top: 4px;
}

/* 4 плитки — 2×2 на мобильном (выплачено / к выплате в нижнем ряду),
   в 4 колонки на десктопе. Разделительная граница между stat'ами перерисовывается. */
.stats-row-4 {
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.stats-row-4 .stat {
  padding: 8px 4px;
  border: 0;
}
.stats-row-4 .stat + .stat { border-left: 0; }
.stats-row-4 .stat:nth-child(2n) { border-left: 1px solid var(--line); }
.stats-row-4 .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
.stats-row-4 .stat-paid .stat-value { color: var(--success); }
.stats-row-4 .stat-due  .stat-value { color: var(--ink); }

@media (min-width: 560px) {
  .stats-row-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  .stats-row-4 .stat:nth-child(n+3) { border-top: 0; }
  .stats-row-4 .stat + .stat { border-left: 1px solid var(--line); }
}

.partner-deal .payout-line {
  margin-top: 4px;
}
.partner-deal .payout-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid var(--line);
  background: #fafaf7;
  color: var(--ink-muted);
}
.partner-deal .payout-badge.payout-paid {
  background: #eaf6ee;
  border-color: #cde6d3;
  color: #1a6b34;
}
.partner-deal .payout-badge.payout-due {
  background: #f4f2ec;
  border-color: var(--line);
  color: var(--ink-muted);
}

.partner-deal .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.partner-deal .head .who {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.partner-deal .head .when {
  color: var(--ink-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.partner-deal .stage-line {
  font-size: 14px;
  color: var(--ink);
  margin-top: 2px;
}
.partner-deal .stage-line.stage-closed  { color: var(--success); font-weight: 500; }
.partner-deal .stage-line.stage-rejected { color: var(--ink-muted); }
.partner-deal .stage-line.stage-wip     { color: var(--ink); }

.partner-deal .reward-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.partner-deal .reward-line .reward-range {
  color: var(--ink-muted);
}
.partner-deal .reward-line strong {
  color: var(--ink);
  font-weight: 600;
}

@media (min-width: 560px) {
  .stats-row .stat-value { font-size: 22px; }
}

