:root {
  color-scheme: light;
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #f2f2f4;
  --card-bg: rgba(255, 255, 255, 0.94);
  --border: rgba(18, 18, 22, 0.1);
  --text: #111116;
  --muted: #5c5d66;
  --accent: #14141a;
  --accent-secondary: #ebebed;
  --accent-ring: rgba(20, 20, 26, 0.35);
  --accent-ring-strong: rgba(20, 20, 26, 0.48);
  --accent-soft: rgba(20, 20, 26, 0.06);
  --accent-soft-border: rgba(20, 20, 26, 0.12);
  --accent-mid: rgba(20, 20, 26, 0.42);
  --accent-pill-bg: rgba(20, 20, 26, 0.1);
  --warning: #e85d4f;
  --shadow: 0 24px 56px rgba(0, 0, 0, 0.07);
  --radius-2xs: 6px;
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 13px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f2 42%, #f5f5f7 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px 16px 64px;
  color: var(--text);
}

.auth-shell {
  width: min(420px, 100%);
  flex-shrink: 0;
}

.auth-card {
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.auth-hero-banner {
  width: 100%;
  aspect-ratio: 2.15 / 1;
  max-height: 176px;
  background: linear-gradient(145deg, #e8e8ec, #f4f4f6);
}

.auth-hero-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-card-body {
  padding: 22px 24px 32px;
}

.auth-brand-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 4px;
  text-align: left;
}

.auth-brand-row__logo {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand-row__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-brand-row__text {
  min-width: 0;
}

.auth-brand-row__name {
  margin: 0 0 4px;
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.auth-brand-row__tagline {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.consent-brand-hint {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.consent-brand-hint strong {
  color: var(--text);
  font-weight: 600;
}

.auth-header h2 {
  margin: 8px 0 6px;
  font-size: 1.4rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0 12px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
}

.input-field input {
  height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 29, 59, 0.15);
  padding: 0 16px;
  font-size: 1rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.9);
}

.input-field select {
  height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 29, 59, 0.15);
  padding: 0 14px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  appearance: none;
}

.input-field input:focus {
  outline: 2px solid var(--accent-ring);
  border-color: var(--accent-ring-strong);
}

.primary-btn {
  height: 52px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(152deg, #4a4d53 0%, #393d43 54%, #2f3338 100%);
  color: #f4f5f6;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(30, 33, 37, 0.18);
}

.primary-btn:active {
  transform: translateY(1px);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.form-hint {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.form-hint a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.consent-group {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.92rem;
  color: #4c576a;
}

.checkbox-field {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.3;
  cursor: pointer;
}

.checkbox-field input[type='checkbox'] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-field a {
  color: var(--accent);
  text-decoration: underline;
}

.checkbox-field a:hover {
  text-decoration: none;
}

.app-shell {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-btn {
  height: 32px;
  padding: 0 18px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-btn:active {
  transform: translateY(1px);
}

.glass-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header h1 {
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.28;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.edit-name-icon {
  font-size: 0.75rem;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.2s;
  user-select: none;
}

.edit-name-icon:hover {
  opacity: 1;
}

.edit-name-input {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.edit-name-input input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
}

.edit-name-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.edit-name-check,
.edit-name-cancel {
  font-size: 0.875rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  transition: background 0.2s;
  user-select: none;
}

.edit-name-check {
  color: #28a745;
}

.edit-name-check:hover {
  background: rgba(40, 167, 69, 0.1);
}

.edit-name-cancel {
  color: #dc3545;
}

.edit-name-cancel:hover {
  background: rgba(220, 53, 69, 0.1);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(180deg, #8cffba, #1fd167);
  box-shadow: 0 0 12px rgba(31, 209, 103, 0.6);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-secondary);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.avatar-upload {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.avatar-upload__icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.avatar-upload:hover .avatar-upload__icon {
  opacity: 1;
}

.avatar-upload.has-photo .avatar {
  background-size: cover;
  background-position: center;
}

.avatar-upload__loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  z-index: 10;
  backdrop-filter: blur(2px);
}

.avatar-upload__loading span {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.secret-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 142, 94, 0.12);
  color: #ff6a3d;
  font-weight: 500;
  cursor: pointer;
}

.secret-inline__text {
  cursor: pointer;
}

.secret-inline__icon {
  font-size: 14px;
  cursor: pointer;
}

.secret-inline__input {
  border: none;
  background: transparent;
  outline: none;
  min-width: 80px;
  max-width: 180px;
  font: inherit;
  color: inherit;
}

.secret-inline__check {
  font-size: 15px;
  cursor: pointer;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.card-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.alias-card {
  padding: 0;
}

.alias-content {
  padding: 22px 24px 24px;
}

.alias-card__title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.alias-card__hint {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.alias-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

.important-badge {
  display: inline-block;
  background: #fff3cd;
  color: #856404;
  font-weight: 600;
  font-size: 0.4375rem;
  padding: 2px 4px;
  border-radius: var(--radius-2xs);
  margin-right: 4px;
  border: 0.5px solid #ffc107;
}

.alias-text strong {
  font-weight: 700;
  color: var(--text);
}

.alias-name {
  display: inline-block;
  font-weight: 700;
  margin-left: 4px;
  color: var(--accent);
}

.alias-caption {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.lead-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lead-form-note {
  margin: -2px 0 0;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--muted);
}

.lead-toggle-btn {
  width: 100%;
  margin-top: 6px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  min-height: 44px;
  padding: 0;
  font: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}

.lead-toggle-btn__label {
  font-size: 1.38rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.lead-toggle-btn__icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #9fae9d;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 500;
  color: #ffffff;
  line-height: 1;
  transition: transform 0.2s ease;
}

.lead-transfer-collapse {
  margin-top: 12px;
}

.lead-toggle-btn[aria-expanded="true"] .lead-toggle-btn__icon {
  transform: rotate(45deg);
}

.lead-form .input-field input {
  background: rgba(255, 255, 255, 0.55);
}

.input-field textarea {
  min-height: 112px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 29, 59, 0.15);
  padding: 14px 16px;
  font-size: 1rem;
  line-height: 1.45;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.55);
  resize: vertical;
}

.input-field textarea:focus {
  outline: 2px solid var(--accent-ring);
  border-color: var(--accent-ring-strong);
}

.lead-form-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.balance-card .card-header {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

.balance-head {
  width: 100%;
}

.balance {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 4px 0 10px;
}

.pending {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--accent-soft-border);
  background: rgba(255, 255, 255, 0.55);
}

.pending-chip__label {
  font-size: 0.8rem;
  color: var(--muted);
}

.pending-chip__value {
  font-size: 0.95rem;
  color: var(--text);
}

.badge {
  background: #fff4d4;
  color: #b46b00;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.badge-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-md);
  background: #ffd27c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.tab-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.tab-panels {
  margin-top: 18px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.pill-btn {
  height: 46px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(18, 18, 22, 0.12);
  background: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.pill-btn.filled {
  color: #f4f5f6;
  background: linear-gradient(152deg, #4a4d53 0%, #393d43 54%, #2f3338 100%);
  border: none;
  box-shadow: 0 12px 24px rgba(30, 33, 37, 0.18);
}

.stat-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

.stats-table-wrap {
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.42);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.stats-table th,
.stats-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(15, 29, 59, 0.08);
}

.stats-table th {
  text-align: left;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.28);
}

.stats-table tr:last-child td {
  border-bottom: none;
}

.stats-table__value {
  text-align: right;
  font-weight: 700;
  color: var(--text);
}

.stats-table__empty {
  text-align: center;
  color: var(--muted);
}

.clients-table-wrap {
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-md);
  overflow: auto;
  background: rgba(255, 255, 255, 0.45);
}

.partner-status-row {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-soft-border);
  background: rgba(255, 255, 255, 0.45);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.partner-status-row__label {
  color: var(--muted);
  font-size: 0.84rem;
}

.partner-status-row__value {
  font-size: 0.95rem;
}

.partner-status-row__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.partner-status-info-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(17, 17, 22, 0.2);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.partner-levels-modal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.partner-levels-modal-list__item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(17, 17, 22, 0.08);
  background: rgba(255, 255, 255, 0.6);
}

.partner-levels-modal-list__item.is-achieved {
  background: rgba(152, 187, 154, 0.3);
}

.partner-levels-modal-list__name {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.partner-levels-modal-list__meta {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.partner-levels-modal-list__hint {
  font-size: 0.75rem;
  color: var(--muted);
  align-self: center;
  text-align: right;
}

.stat-chip {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-value {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(15, 29, 59, 0.08);
}

.history-item:last-child {
  border-bottom: none;
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-date {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-text {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.history-amount {
  font-weight: 600;
  font-size: 1rem;
}

.history-amount.positive {
  color: #13b26b;
}

.history-amount.negative {
  color: #f15b44;
}

.rewards-card .card-label {
  margin-bottom: 4px;
}

.rewards-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.reward-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(248, 248, 249, 0.95);
  border: 1px solid rgba(15, 29, 59, 0.08);
}

.reward-title {
  margin: 0 0 6px;
  font-weight: 600;
}

.reward-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 600;
}

.card-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.ghost-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 29, 59, 0.12);
  background: transparent;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost-btn.active {
  color: var(--accent);
  border-color: var(--accent-mid);
}

.progress-track {
  margin-top: 18px;
  height: 8px;
  border-radius: 999px;
  background: rgba(18, 18, 22, 0.08);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6a6a72, #1c1c22 45%, #0e0e12 100%);
}

.card-chip {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: #fff1e9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chip-icon {
  color: #ff8b45;
  font-size: 1.2rem;
}

.warning {
  border: 1px solid rgba(255, 141, 79, 0.35);
  background: linear-gradient(180deg, rgba(255, 243, 236, 0.9), rgba(255, 252, 249, 0.95));
}

.detail-card {
  background: var(--card-bg);
}

.detail-body {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(15, 29, 59, 0.04);
  border: 1px dashed rgba(15, 29, 59, 0.15);
}

.detail-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

#adminPanel {
  width: min(960px, 100%);
}

#adminPanel .app-shell {
  width: 100%;
}

.admin-header h2 {
  margin: 6px 0 0;
}

.admin-summary-card {
  padding: 24px 24px 28px;
}

.admin-assign-card {
  padding: 24px 24px 28px;
}

.admin-table-card {
  padding: 20px 0 0;
  overflow: visible;
}

.table-head {
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
  padding: 0 24px 24px;
  -webkit-overflow-scrolling: touch;
}

.table-scroll::-webkit-scrollbar {
  height: 8px;
}

.table-scroll::-webkit-scrollbar-track {
  background: rgba(15, 29, 59, 0.05);
  border-radius: var(--radius-sm);
}

.table-scroll::-webkit-scrollbar-thumb {
  background: rgba(15, 29, 59, 0.2);
  border-radius: var(--radius-sm);
}

.table-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 29, 59, 0.3);
}

table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: auto;
}

/* Компактные столбцы для таблицы администраторов */
#adminsTable table {
  min-width: 1200px;
}

#adminsTable th {
  font-size: 0.65rem;
  padding: 8px 4px;
  max-width: 120px;
}

th,
td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(15, 29, 59, 0.08);
  white-space: nowrap;
}

/* Разрешаем перенос для длинных столбцов */
td:nth-child(1), /* Участник */
td:nth-child(2), /* Телефон */
td:nth-child(3), /* Псевдоним */
td:nth-child(7), /* Администратор */
td:nth-child(8) { /* Регистрация */
  white-space: normal;
  max-width: 120px;
  word-wrap: break-word;
}

th:nth-child(1),
th:nth-child(2),
th:nth-child(3),
th:nth-child(7),
th:nth-child(8) {
  max-width: 120px;
}

th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.3;
  padding: 10px 6px;
}

tbody tr:last-child td {
  border-bottom: none;
}

#adminPanel .card {
  border-radius: var(--radius-md);
}

.assign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.assign-grid .full-width {
  grid-column: 1 / -1;
}

.assign-grid .primary-btn {
  margin-top: 4px;
}

.full-width {
  width: 100%;
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: var(--text);
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  body {
    padding: 24px 14px 48px;
  }

  .header-right {
    gap: 8px;
  }

  .admin-btn {
    padding: 0 14px;
  }

  .glass-card,
  .card {
    border-radius: var(--radius-md);
    padding: 20px;
  }

  .balance {
    font-size: 2.3rem;
  }
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 29, 59, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 48px rgba(15, 29, 59, 0.2);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-content.modal-wide {
  max-width: 960px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.modal-close:hover {
  background: rgba(15, 29, 59, 0.08);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-footer .ghost-btn,
.modal-footer .primary-btn {
  margin: 0;
}

/* Action button in table */
.action-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: white;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--accent);
  color: white;
}

.action-btn.delete-btn {
  border-color: var(--warning);
  color: var(--warning);
  background: white;
}

.action-btn.delete-btn:hover {
  background: var(--warning);
  color: white;
}

.table-link-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.table-link-btn:hover {
  text-decoration: underline;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.pending {
  background: var(--accent-pill-bg);
  color: var(--accent);
}

.status-pill.credited {
  background: rgba(38, 194, 129, 0.14);
  color: #13824b;
}

.status-pill.cancelled,
.status-pill.reversed {
  background: rgba(255, 125, 116, 0.14);
  color: #c03a31;
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.detail-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(15, 29, 59, 0.02);
}

.detail-value {
  margin: 6px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.detail-section:first-child {
  margin-top: 0;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table th,
.detail-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.detail-table th {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

.detail-history-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(15, 29, 59, 0.02);
}

.detail-history-item p {
  margin: 0;
}

.detail-history-item .history-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.modal-footer-between {
  justify-content: space-between;
  align-items: center;
}

.detail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

@media (max-width: 720px) {
  .detail-grid-two {
    grid-template-columns: 1fr;
  }

  .modal-footer-between {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

/* Autocomplete styles */
.autocomplete-container {
  position: relative;
}

.autocomplete-container input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 29, 59, 0.15);
  padding: 0 16px;
  font-size: 1rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.9);
}

.autocomplete-container input:focus {
  outline: 2px solid var(--accent-ring);
  border-color: var(--accent-ring-strong);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid rgba(15, 29, 59, 0.15);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(15, 29, 59, 0.12);
  list-style: none;
  padding: 8px 0;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
}

.autocomplete-dropdown li {
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.autocomplete-dropdown li:hover,
.autocomplete-dropdown li.selected {
  background: var(--accent-soft);
}

.autocomplete-dropdown li .participant-name {
  font-weight: 600;
  color: var(--text);
  display: block;
}

.autocomplete-dropdown li .participant-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Admin select in table */
.admin-select-cell {
  position: relative;
}

.admin-select-cell {
  min-width: 140px;
}

.admin-select-cell select {
  width: 100%;
  min-width: 140px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: white;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-select-cell select:focus {
  outline: 2px solid var(--accent-ring);
  border-color: var(--accent-ring-strong);
}

.customization-preview {
  margin-top: 8px;
  min-height: 0;
}

.customization-preview img {
  max-height: 64px;
  max-width: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.customization-preview--banner img {
  max-width: 100%;
  max-height: 120px;
  width: 100%;
  object-fit: cover;
}

/* Темы брендинга (партнёрский вход и админка) */
html[data-brand-theme="slate"] {
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1e293b;
  --accent-secondary: #e2e8f0;
  --border: rgba(15, 23, 42, 0.12);
  --accent-ring: rgba(30, 41, 59, 0.35);
  --accent-ring-strong: rgba(30, 41, 59, 0.5);
  --accent-soft: rgba(30, 41, 59, 0.06);
  --accent-soft-border: rgba(30, 41, 59, 0.14);
  --accent-mid: rgba(30, 41, 59, 0.42);
  --accent-pill-bg: rgba(30, 41, 59, 0.11);
}

html[data-brand-theme="slate"] body {
  background: linear-gradient(180deg, #f8fafc 0%, #e8eef4 42%, #f1f5f9 100%);
}

html[data-brand-theme="slate"] .primary-btn,
html[data-brand-theme="slate"] .pill-btn.filled {
  background: linear-gradient(152deg, #334155 0%, #1e293b 52%, #0f172a 100%);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.22);
}

html[data-brand-theme="warm"] {
  --text: #1c1917;
  --muted: #57534e;
  --accent: #292524;
  --accent-secondary: #ece8e5;
  --border: rgba(41, 37, 36, 0.12);
  --accent-ring: rgba(41, 37, 36, 0.32);
  --accent-ring-strong: rgba(41, 37, 36, 0.46);
  --accent-soft: rgba(41, 37, 36, 0.06);
  --accent-soft-border: rgba(41, 37, 36, 0.13);
  --accent-mid: rgba(41, 37, 36, 0.4);
  --accent-pill-bg: rgba(41, 37, 36, 0.1);
}

html[data-brand-theme="warm"] body {
  background: linear-gradient(180deg, #fafaf9 0%, #f0ebe8 42%, #f5f2f0 100%);
}

html[data-brand-theme="warm"] .primary-btn,
html[data-brand-theme="warm"] .pill-btn.filled {
  background: linear-gradient(152deg, #44403c 0%, #292524 52%, #1c1917 100%);
  box-shadow: 0 18px 38px rgba(28, 25, 23, 0.2);
}

html[data-brand-theme="evergreen"] {
  --text: #0f1f17;
  --muted: #4d5c54;
  --accent: #142920;
  --accent-secondary: #e4ebe7;
  --border: rgba(20, 41, 32, 0.11);
  --accent-ring: rgba(20, 41, 32, 0.32);
  --accent-ring-strong: rgba(20, 41, 32, 0.46);
  --accent-soft: rgba(20, 41, 32, 0.06);
  --accent-soft-border: rgba(20, 41, 32, 0.13);
  --accent-mid: rgba(20, 41, 32, 0.4);
  --accent-pill-bg: rgba(20, 41, 32, 0.1);
}

html[data-brand-theme="evergreen"] body {
  background: linear-gradient(180deg, #f7faf8 0%, #e8f0ec 42%, #f0f5f2 100%);
}

html[data-brand-theme="evergreen"] .primary-btn,
html[data-brand-theme="evergreen"] .pill-btn.filled {
  background: linear-gradient(152deg, #1a3d2e 0%, #142920 52%, #0a1812 100%);
  box-shadow: 0 18px 38px rgba(10, 24, 18, 0.22);
}
