:root {
  --bg: var(--tg-theme-bg-color, #0f1419);
  --text: var(--tg-theme-text-color, #e7ecf1);
  --hint: var(--tg-theme-hint-color, #8b98a5);
  --link: var(--tg-theme-link-color, #6ab3f3);
  --btn: var(--tg-theme-button-color, #2aabee);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --secondary: var(--tg-theme-secondary-bg-color, #1a2332);
  --accent: #3dd68c;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.loader {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--hint);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--secondary);
  border-top-color: var(--btn);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 2rem;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
}

.muted {
  color: var(--hint);
  font-size: 0.85rem;
}

.nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.nav-btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 6px;
  background: var(--secondary);
  color: var(--text);
  font-size: 0.72rem;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}

.nav-btn.active {
  background: var(--btn);
  color: var(--btn-text);
}

.nav-btn:active {
  transform: scale(0.97);
}

.main {
  flex: 1;
}

.card {
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.card p {
  margin: 6px 0;
  line-height: 1.45;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--btn);
  color: var(--btn-text);
  margin-top: 8px;
}

.btn.secondary {
  background: transparent;
  border: 1px solid var(--hint);
  color: var(--text);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  margin: 8px 0;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-value {
  font-weight: 600;
  text-align: right;
}

.positive {
  color: var(--accent);
}

.negative {
  color: var(--danger);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.chip {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.chip.active {
  background: var(--btn);
  color: var(--btn-text);
}

.bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--btn), var(--accent));
  border-radius: 999px;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.alert.ok {
  background: rgba(61, 214, 140, 0.15);
  color: var(--accent);
}

.back {
  background: none;
  border: none;
  color: var(--link);
  padding: 0;
  margin-bottom: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

.footer {
  text-align: center;
  margin-top: 16px;
  font-size: 0.75rem;
}

.docs-body {
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.5;
}

.list-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.list-item:last-child {
  border-bottom: none;
}
