/* ============================================================
   GameSnap — утилитарный интерфейс
   Стиль: плотный, монохромный, акцент только на действии
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0b;
  --bg-1:      #101012;
  --bg-2:      #16161a;
  --bg-3:      #1c1c21;

  --line:      #232329;
  --line-2:    #2e2e36;

  --fg:        #ededf0;
  --fg-2:      #a1a1aa;
  --fg-3:      #6b6b76;
  --fg-4:      #4a4a54;

  --accent:    #a78bfa;
  --accent-2:  #8b5cf6;
  --accent-bg: rgba(167, 139, 250, 0.10);

  --green:     #4ade80;
  --red:       #f87171;

  --r-sm: 4px;
  --r:    6px;
  --r-md: 8px;

  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}

::selection { background: var(--accent); color: #0a0a0b; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 0;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-4); }

/* ---------- Layout ---------- */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Верхняя навигация ---------- */
.nav {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(10, 10, 11, 0.85);
  backdrop-filter: blur(12px);
  z-index: 30;
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.brand-mark {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
}
.brand-mark svg { width: 14px; height: 14px; color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-links a {
  color: var(--fg-2);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--fg); background: var(--bg-2); }

/* ---------- Заголовок страницы ---------- */
.page-head {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.page-head h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.page-head p {
  color: var(--fg-2);
  font-size: 14px;
  max-width: 640px;
}

/* ---------- Сетка ---------- */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
  padding-bottom: 80px;
}
.col-main { min-width: 0; }
.col-side {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Панели / карточки ---------- */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-2);
  letter-spacing: 0.02em;
}
.panel-body { padding: 16px; }

/* ---------- Форма поиска ---------- */
.search-form {
  display: flex;
  gap: 8px;
}
.field {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.field svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--fg-3);
  pointer-events: none;
}
.field:focus-within svg { color: var(--fg-2); }

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input[type="number"] { padding-left: 12px; }
input::placeholder { color: var(--fg-4); }
input:hover { border-color: var(--line-2); }
input:focus {
  border-color: var(--accent-2);
  background: var(--bg-1);
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--r);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  color: var(--fg);
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--fg);
  color: #0a0a0b;
  border-color: var(--fg);
}
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-2);
  border-color: var(--line-2);
  color: var(--fg);
}
.btn-secondary:hover { background: var(--bg-3); border-color: #3a3a44; }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--fg-2);
}
.btn-ghost:hover {
  background: var(--bg-2);
  border-color: var(--line-2);
  color: var(--fg);
}

.btn-refresh {
  background: transparent;
  border-color: var(--line);
  color: var(--fg-2);
}
.btn-refresh:hover:not(:disabled) {
  background: var(--bg-2);
  border-color: var(--accent-2);
  color: var(--fg);
}
.btn-refresh:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-refresh.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tg-btn {
  border-color: rgba(41, 171, 226, 0.3);
  color: #6ec7f0;
}
.tg-btn:hover {
  background: rgba(41, 171, 226, 0.1);
  border-color: rgba(41, 171, 226, 0.5);
  color: #fff;
}

/* ---------- Статус ---------- */
.status {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 13px;
  color: var(--fg-2);
  margin-bottom: 12px;
}
.status.visible { display: flex; }
.status.error {
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--red);
}
.status .spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ---------- Профиль ---------- */
.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--r);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
}
.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-stats {
  display: flex;
  gap: 28px;
  margin-left: auto;
  padding-left: 24px;
  border-left: 1px solid var(--line);
  flex-wrap: wrap;
}
.stat-label {
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}
.stat-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Действия ---------- */
.actions {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.actions .grow { flex: 1; }

/* ---------- Обновлено ---------- */
.meta-line {
  font-size: 12px;
  color: var(--fg-3);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
}
.meta-line .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

/* ---------- Таблица ---------- */
.table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 500;
}
.table-head .count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-3);
  font-weight: 400;
}
.table-scroll { max-height: 600px; overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-3);
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-2); }
tbody td {
  padding: 10px 16px;
  color: var(--fg-2);
  vertical-align: middle;
}
tbody td.name { color: var(--fg); font-weight: 500; }
tbody td.num {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.appid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-3);
}
.hours {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.hours .unit { color: var(--fg-3); }
.recent { color: var(--accent); font-weight: 500; }

/* ---------- Сайдбар блоки ---------- */
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-2);
}
.side-head svg { width: 13px; height: 13px; color: var(--fg-3); }

.side-list { padding: 6px; }
.side-row {
  display: grid;
  grid-template-columns: 18px 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--fg-2);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.side-row:hover { background: var(--bg-2); }
.side-row.is-me {
  background: var(--accent-bg);
  color: var(--fg);
}

.rank {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-4);
  text-align: center;
}
.side-row.top-1 .rank { color: var(--accent); }
.side-row.top-2 .rank { color: var(--fg-2); }
.side-row.top-3 .rank { color: var(--fg-2); }

.mini-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase;
  border: 1px solid var(--line-2);
}

.side-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.side-row.is-me .side-name::after {
  content: "you";
  margin-left: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.side-value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.side-row.top-1 .side-value { color: var(--accent); }

/* ---------- Пустые состояния ---------- */
.side-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-3);
}

/* ---------- Донат ---------- */
.donate-body { padding: 16px; }
.donate-body p {
  font-size: 13px;
  color: var(--fg-3);
  margin-bottom: 14px;
  line-height: 1.5;
}
.donors {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  max-height: 160px;
  overflow-y: auto;
}
.donor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.donor-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.donor-amount {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.donate-btn { width: 100%; }

/* ---------- Скелетоны ---------- */
.sk {
  height: 30px;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.sk + .sk { margin-top: 3px; }
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ---------- Тост ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font-size: 13px;
  color: var(--fg);
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  animation: toast-in 0.2s ease;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.error { border-color: rgba(248, 113, 113, 0.4); color: var(--red); }
.toast.success { border-color: rgba(74, 222, 128, 0.3); color: var(--green); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Модалка ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade 0.15s ease;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  max-width: 400px;
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 24px;
  position: relative;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-3);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--bg-2); color: var(--fg); }

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.modal-desc {
  font-size: 13px;
  color: var(--fg-3);
  margin-bottom: 20px;
  line-height: 1.5;
}
.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.presets button {
  padding: 9px 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--fg-2);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.presets button:hover { border-color: var(--line-2); color: var(--fg); }
.presets button.active {
  background: var(--accent-bg);
  border-color: var(--accent-2);
  color: var(--accent);
}
.custom-amount { display: block; margin-bottom: 16px; }
.custom-amount span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-3);
  margin-bottom: 6px;
}
.modal-foot {
  font-size: 11px;
  color: var(--fg-4);
  text-align: center;
  margin-top: 12px;
}

/* ---------- Футер ---------- */
.foot {
  border-top: 1px solid var(--line);
  padding: 20px 0;
  margin-top: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--fg-3);
}
.foot a {
  color: var(--fg-2);
  text-decoration: none;
  border-bottom: 1px solid var(--line-2);
}
.foot a:hover { color: var(--fg); border-bottom-color: var(--fg-3); }
.foot-links { display: flex; gap: 16px; align-items: center; }

/* ---------- Empty ---------- */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--fg-3);
  font-size: 13px;
}
.empty svg {
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
  opacity: 0.3;
}

/* ---------- Утилиты ---------- */
.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--fg-3); }

/* ---------- Адаптив ---------- */
@media (max-width: 920px) {
  .grid { grid-template-columns: 1fr; gap: 24px; }
  .col-side { position: static; }
  .search-form { flex-direction: column; }
  .actions .btn span { display: none; }
  .actions .btn { padding: 9px; }
  .actions .btn-refresh span,
  .actions .tg-btn span { display: inline; }
  .profile { flex-wrap: wrap; }
  .profile-stats {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    padding-top: 12px;
    width: 100%;
    gap: 20px;
  }
  .hide-sm { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}