:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #111827;
  --text: #111827;
  --muted: #6b7280;
  --line: #d8dee9;
  --accent: #1677ff;
  --accent-dark: #075fcc;
  --success: #16803c;
  --danger: #c2410c;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.balance-box,
.stat,
.panel,
.program-card,
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.balance-box {
  min-width: 132px;
  padding: 12px 14px;
  text-align: right;
}

.balance-box span,
.stat span,
.copy-field span,
label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.balance-box strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  border-color: var(--surface-strong);
  background: var(--surface-strong);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.section-head p {
  color: var(--muted);
}

.section-head.compact {
  margin-bottom: 12px;
}

.program-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.program-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.program-card p {
  color: var(--muted);
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef5ff;
  color: var(--accent-dark);
  font-weight: 800;
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 0;
  text-decoration: none;
  font-weight: 800;
}

.primary-button,
.primary-link {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.primary-link:hover {
  background: var(--accent-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.finance-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  padding: 14px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.panel {
  padding: 16px;
  margin-bottom: 12px;
}

.list {
  display: grid;
  gap: 10px;
}

.list:empty::before {
  content: "Пока пусто";
  display: block;
  padding: 12px 0;
  color: var(--muted);
}

.list-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.list-item header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.list-item small,
.subtext {
  color: var(--muted);
  line-height: 1.4;
}

.text-link {
  color: var(--accent-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
  text-decoration: none;
}

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

.info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px;
}

.info-grid > div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}

.info-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.info-grid p {
  color: var(--text);
  line-height: 1.4;
}

.copy-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 14px;
}

.copy-field span {
  grid-column: 1 / -1;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.14);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.44);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(520px, 100%);
  padding: 18px;
}

.icon-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: #fff;
  box-shadow: var(--shadow);
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status.pending {
  color: var(--danger);
}

.status.approved {
  color: var(--success);
}

.event-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.event-badge,
.event-type {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.event-type.registration,
.event-badge.registration {
  background: #eef5ff;
  color: var(--accent-dark);
}

.event-type.first_deposit,
.event-badge.first_deposit {
  background: #ecfdf3;
  color: var(--success);
}

.event-type.reward,
.event-badge.reward {
  background: #fff7ed;
  color: var(--danger);
}

.event-type.qualification_check,
.event-badge.qualification_check {
  background: #f5f3ff;
  color: #5b21b6;
}

.money-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.money-row span {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.money-row strong {
  color: var(--text);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  .balance-box {
    text-align: left;
  }

  .program-grid,
  .stats-grid,
  .finance-grid,
  .money-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .copy-field {
    grid-template-columns: 1fr;
  }
}
