:root {
  color-scheme: light;
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #f3f5fa;
  --card-bg: rgba(255, 255, 255, 0.92);
  --border: rgba(9, 21, 55, 0.08);
  --text: #0f1d3b;
  --muted: #6e7796;
  --accent: #3773ff;
  --accent-secondary: #dfe6ff;
  --warning: #ff7d74;
  --shadow: 0 25px 60px rgba(15, 29, 59, 0.08);
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f9fbff 0%, #e4ebff 45%, #eff3ff 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: 26px 24px 32px;
  border-radius: 5px;
}

.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: 5px;
  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: 5px;
  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 rgba(55, 115, 255, 0.4);
  border-color: rgba(55, 115, 255, 0.6);
}

.primary-btn {
  height: 52px;
  border: none;
  border-radius: 5px;
  background: linear-gradient(120deg, #4d84ff, #5fd1ff);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 18px 30px rgba(77, 132, 255, 0.4);
}

.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: #3e6ae1;
  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: 5px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-header h1 {
  margin: 8px 0 2px;
  font-size: 1.15rem;
  line-height: 1.35;
}

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

.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: 5px;
  background: linear-gradient(180deg, #8cffba, #1fd167);
  box-shadow: 0 0 12px rgba(31, 209, 103, 0.6);
}

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

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

.avatar-upload__icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  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;
}

.secret-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 5px;
  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: 5px;
  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-art {
  height: 160px;
  width: 100%;
  background-size: cover;
  background-position: center;
  filter: saturate(1.15);
}

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

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

.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;
}

.balance-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.balance {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 6px 0;
}

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

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

.badge-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  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: 5px;
  border: 1px solid rgba(15, 29, 59, 0.1);
  background: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.pill-btn.filled {
  color: white;
  background: linear-gradient(120deg, #4d84ff, #5fd1ff);
  border: none;
  box-shadow: 0 12px 30px rgba(77, 132, 255, 0.4);
}

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

.stat-chip {
  padding: 14px 16px;
  border-radius: 5px;
  background: rgba(55, 115, 255, 0.08);
  border: 1px solid rgba(55, 115, 255, 0.16);
  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: 5px;
  background: rgba(247, 249, 255, 0.9);
  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: 5px;
  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: rgba(55, 115, 255, 0.5);
}

.progress-track {
  margin-top: 18px;
  height: 8px;
  border-radius: 5px;
  background: rgba(15, 29, 59, 0.08);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #51ffe4, #3773ff);
}

.card-chip {
  width: 48px;
  height: 48px;
  border-radius: 5px;
  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: 5px;
  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: 4px;
}

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

.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: 5px;
}

.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: 5px;
  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: 5px;
    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: 12px;
  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-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: 4px;
  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;
}

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

.autocomplete-container input {
  width: 100%;
  height: 48px;
  border-radius: 5px;
  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 rgba(55, 115, 255, 0.4);
  border-color: rgba(55, 115, 255, 0.6);
}

.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: 5px;
  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: rgba(55, 115, 255, 0.08);
}

.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: 4px;
  font-size: 12px;
  background: white;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-select-cell select:focus {
  outline: 2px solid rgba(55, 115, 255, 0.4);
  border-color: rgba(55, 115, 255, 0.6);
}
