* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --border: #475569;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --accent: #818cf8;
  --accent2: #6366f1;
  --green: #22c55e;
  --green-bg: #064e3b;
  --red: #ef4444;
  --red-bg: #7f1d1d;
  --yellow: #fbbf24;
  --yellow-bg: #713f12;
  --radius: 10px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Login */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #1a1a2e 100%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.login-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.login-sub { color: var(--text2); font-size: 0.9rem; margin-bottom: 28px; }
.login-card input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%;
  padding: 14px;
  background: var(--accent2);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.login-card button:hover { background: var(--accent); }
.error { color: var(--red); font-size: 0.85rem; margin-top: 8px; }

/* Nav */
.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  margin-right: auto;
}
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 14px;
  color: var(--text2);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent); background: rgba(99,102,241,0.12); }
.nav-logout {
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--surface2);
  color: var(--text2);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}
.nav-logout:hover { border-color: var(--red); color: var(--red); }

/* Pages */
.page { display: none; max-width: 800px; margin: 0 auto; padding: 24px 16px; }
.page.active { display: block; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; }
.subtitle { color: var(--text2); font-size: 0.9rem; margin-top: 4px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; color: var(--text); }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-val { font-size: 1.8rem; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 0.78rem; color: var(--text2); margin-top: 4px; }

/* Status grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.member-status {
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--surface2);
}
.member-status.done { background: var(--green-bg); border-color: var(--green); }
.member-status.partial { background: var(--yellow-bg); border-color: var(--yellow); }
.member-status.missing { background: var(--red-bg); border-color: var(--red); }
.member-name { font-weight: 600; font-size: 1rem; margin-bottom: 6px; }
.member-reqs { font-size: 0.82rem; color: var(--text2); }
.member-reqs .done-icon { color: var(--green); }
.member-reqs .miss-icon { color: var(--red); }

/* Leaderboard */
.lb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--surface2);
}
.lb-row:last-child { border-bottom: none; }
.lb-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  background: var(--surface2);
  color: var(--text2);
  flex-shrink: 0;
}
.lb-rank.first { background: #fbbf24; color: #1e1b4b; }
.lb-name { font-weight: 600; flex: 1; }
.lb-pts { font-weight: 700; color: var(--accent); font-size: 1.1rem; }
.lb-streak { font-size: 0.82rem; color: var(--text2); }
.lb-streak .fire { color: #f97316; }

/* Streak grid */
.streak-member { margin-bottom: 16px; }
.streak-label { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.streak-boxes {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.streak-box {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: var(--surface2);
}
.streak-box.hit { background: var(--green); }
.streak-box.miss { background: var(--red); }
.streak-box.none { background: var(--surface2); opacity: 0.3; }
.streak-box[title] { cursor: help; }

/* Activity feed */
.feed-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--surface2);
}
.feed-item:last-child { border-bottom: none; }
.feed-who { font-weight: 600; font-size: 0.9rem; }
.feed-what { font-size: 0.82rem; color: var(--text2); margin-top: 2px; }
.feed-feedback { font-size: 0.82rem; color: var(--yellow); margin-top: 4px; font-style: italic; }
.feed-pts { font-size: 0.82rem; font-weight: 600; margin-top: 2px; }
.feed-pts.pos { color: var(--green); }
.feed-pts.neg { color: var(--red); }

/* Rules */
.rule-member {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--surface2);
}
.rule-member:last-child { border-bottom: none; padding-bottom: 0; }
.rule-member h4 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.rule-req {
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}
.rule-req .label { font-weight: 600; color: var(--accent); }
.rule-req .detail { color: var(--text2); font-size: 0.8rem; }

.scoring-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.score-item {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}
.score-item .val.pos { color: var(--green); font-weight: 600; }
.score-item .val.neg { color: var(--red); font-weight: 600; }

/* Telegram link */
.tg-link {
  display: block;
  text-align: center;
  padding: 14px;
  background: var(--accent2);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.2s;
}
.tg-link:hover { background: var(--accent); }

/* Empty state */
.empty { text-align: center; color: var(--text2); padding: 24px; font-size: 0.9rem; }

/* Mobile */
@media (max-width: 600px) {
  .nav { flex-wrap: wrap; gap: 8px; }
  .nav-links { order: 3; width: 100%; justify-content: center; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .scoring-grid { grid-template-columns: 1fr; }
  .streak-box { width: 14px; height: 14px; }
}
