:root {
  --bg: #070b16;
  --bg-2: #111827;
  --card: rgba(255, 255, 255, 0.08);
  --card-strong: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.13);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #a3e635;
  --accent-2: #38bdf8;
  --danger: #fb7185;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.26), transparent 32%),
    radial-gradient(circle at top right, rgba(163, 230, 53, 0.18), transparent 28%),
    linear-gradient(180deg, #070b16 0%, #101827 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 18px 96px;
}

.app-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.add-habit-btn {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #020617;
  font-size: 31px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 40px rgba(56, 189, 248, 0.28);
}

.days-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 18px 0 18px;
  scrollbar-width: none;
}

.days-strip::-webkit-scrollbar {
  display: none;
}

.day-pill {
  min-width: 54px;
  padding: 10px 8px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  text-align: center;
  color: var(--muted);
}

.day-pill strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 18px;
}

.day-pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #020617;
  border-color: transparent;
}

.day-pill.active strong {
  color: #020617;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 2px 14px;
}

.section-title h2 {
  font-size: 22px;
}

.section-title span {
  color: var(--muted);
  font-weight: 700;
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

.habit-list {
  display: grid;
  gap: 12px;
}

.habit-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card-strong), var(--card));
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, opacity 0.18s ease, border-color 0.18s ease;
}

.habit-card:active {
  transform: scale(0.985);
}

.habit-card.done {
  border-color: rgba(163, 230, 53, 0.38);
  opacity: 0.82;
}

.habit-check {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.34);
  color: #020617;
  font-weight: 900;
}

.habit-card.done .habit-check {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.habit-icon {
  font-size: 24px;
}

.habit-content {
  min-width: 0;
  flex: 1;
}

.habit-title {
  font-size: 17px;
  font-weight: 800;
  transition: color 0.18s ease;
}

.habit-card.done .habit-title {
  color: var(--muted);
  text-decoration: line-through;
}

.habit-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  margin-top: 28px;
  padding: 28px 22px;
  border: 1px dashed var(--border);
  border-radius: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
}

.empty-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
}

.stats-grid,
.admin-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card-strong), var(--card));
  box-shadow: var(--shadow);
}

.stat-card.wide {
  grid-column: 1 / -1;
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  font-size: 28px;
}

.progress-line {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-line div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

.achievement-list,
.admin-user-list {
  display: grid;
  gap: 12px;
}

.achievement-card,
.admin-user-card {
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card-strong), var(--card));
}

.achievement-card.locked {
  opacity: 0.45;
  filter: grayscale(1);
}

.achievement-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 17px;
}

.achievement-card p,
.admin-user-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 20;
  width: min(calc(100% - 28px), 500px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 26px;
  border: 1px solid var(--border);
  background: rgba(7, 11, 22, 0.82);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.bottom-nav.has-admin {
  grid-template-columns: repeat(4, 1fr);
}

.nav-btn {
  border: none;
  border-radius: 19px;
  padding: 12px 6px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.nav-btn.active {
  color: #020617;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.52);
}

.modal-card {
  width: min(100%, 500px);
  padding: 20px;
  border-radius: 30px;
  border: 1px solid var(--border);
  background: #101827;
  box-shadow: var(--shadow);
}

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

.modal-header button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  font-size: 26px;
}

.field-label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.text-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 15px 16px;
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.text-input:focus {
  border-color: rgba(56, 189, 248, 0.7);
}

.save-btn {
  width: 100%;
  margin-top: 20px;
  border: none;
  border-radius: 20px;
  padding: 15px;
  color: #020617;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
}

.hidden {
  display: none !important;
}

/* ===== Admin redesign fix ===== */

#tabAdmin .section-title {
  margin-top: 4px;
}

.admin-user-list {
  gap: 12px;
  padding-bottom: 18px;
}

.admin-user-card.clickable {
  width: 100%;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.1), transparent 38%),
    rgba(255, 255, 255, 0.065);
  color: var(--text);
  text-align: left;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
}

.admin-user-main {
  display: grid;
  grid-template-columns: 42px 1fr 30px;
  align-items: center;
  gap: 12px;
}

.admin-user-mini-avatar {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #020617;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 18px;
  font-weight: 900;
}

.admin-user-name {
  display: block;
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.15;
}

.admin-user-id {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.admin-user-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-2);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.admin-user-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-user-meta strong {
  color: var(--text);
  font-size: 12px;
}

.admin-detail-card {
  max-height: 82vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 30px 30px 24px 24px;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 40%),
    #0f172a;
}

.admin-detail-card .modal-header h2 {
  font-size: 26px;
}

.admin-detail {
  margin-top: 16px;
}

.admin-profile-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.065);
}

.admin-avatar {
  width: 54px;
  height: 54px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  color: #020617;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 22px;
  font-weight: 950;
}

.admin-profile-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  line-height: 1.15;
}

.admin-profile-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
}

.admin-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.admin-info-item {
  min-width: 0;
  padding: 13px;
  border-radius: 19px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.055);
}

.admin-info-item.wide {
  grid-column: 1 / -1;
}

.admin-info-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.admin-info-item strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  word-break: break-word;
}

.admin-block-title {
  margin: 18px 2px 10px;
  color: var(--text);
  font-size: 19px;
  line-height: 1.2;
}

.admin-habits-list {
  display: grid;
  gap: 10px;
}

.admin-habit-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.055);
}

.admin-habit-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
}

.admin-habit-title span {
  font-size: 20px;
}

.admin-habit-row p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.admin-habit-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  text-align: left;
}

.admin-habit-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 800;
}

.admin-habit-chip.accent {
  color: #020617;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.admin-loading,
.admin-empty {
  padding: 16px;
  border-radius: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  text-align: center;
  font-size: 14px;
}

@media (max-width: 380px) {
  .admin-info-grid {
    grid-template-columns: 1fr;
  }

  .admin-info-item.wide {
    grid-column: auto;
  }

  .admin-user-main {
    grid-template-columns: 38px 1fr 28px;
  }

  .admin-user-mini-avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
  }
}

/* ===== Habit actions / delete ===== */

.habit-card {
  position: relative;
  width: 100%;
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
}

.habit-menu-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.habit-menu-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.12);
}

.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: end center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(8px);
}

.action-sheet-card {
  width: min(100%, 500px);
  padding: 12px;
  border-radius: 28px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 38%),
    #0f172a;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.45);
}

.action-sheet-handle {
  width: 42px;
  height: 5px;
  margin: 4px auto 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.action-sheet-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  color: var(--text);
}

.action-sheet-title span {
  font-size: 24px;
}

.action-sheet-title strong {
  font-size: 18px;
  line-height: 1.25;
}

.danger-action,
.cancel-action {
  width: 100%;
  min-height: 50px;
  border: none;
  border-radius: 18px;
  font-weight: 900;
}

.danger-action {
  color: #fff;
  background: rgba(251, 113, 133, 0.16);
  border: 1px solid rgba(251, 113, 133, 0.32);
}

.cancel-action {
  margin-top: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

/* ===== Achievements v2 ===== */

.achievements-summary {
  display: grid;
  grid-template-columns: 1fr 74px;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 26px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background:
    radial-gradient(circle at top right, rgba(163, 230, 53, 0.16), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.065));
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.25);
}

.achievements-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.achievements-summary strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 28px;
  line-height: 1.1;
}

.achievement-summary-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #020617;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 16px;
  font-weight: 950;
  box-shadow: 0 14px 34px rgba(56, 189, 248, 0.22);
}

.achievement-group-title {
  margin: 18px 2px 2px;
  color: var(--text);
  font-size: 18px;
}

.achievement-card-v2 {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 13px;
  padding: 15px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.09), transparent 44%),
    rgba(255, 255, 255, 0.065);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.2);
}

.achievement-card-v2.unlocked {
  border-color: rgba(163, 230, 53, 0.32);
}

.achievement-card-v2.locked {
  opacity: 0.74;
}

.achievement-icon {
  width: 52px;
  height: 52px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  font-size: 26px;
}

.achievement-card-v2.unlocked .achievement-icon {
  background: linear-gradient(135deg, rgba(163, 230, 53, 0.95), rgba(56, 189, 248, 0.95));
}

.achievement-body {
  min-width: 0;
}

.achievement-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.achievement-topline strong {
  color: var(--text);
  font-size: 16px;
  line-height: 1.2;
}

.achievement-topline span {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.achievement-body p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.achievement-progress {
  height: 9px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.achievement-progress div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.achievement-status {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.achievement-card-v2.unlocked .achievement-status {
  color: var(--accent);
}

/* ===== VK link card ===== */

.vk-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 42%),
    rgba(255, 255, 255, 0.065);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.22);
}

.vk-link-card h3 {
  margin: 0;
  font-size: 20px;
}

.vk-link-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.vk-link-card button {
  flex: 0 0 auto;
  border: none;
  border-radius: 18px;
  padding: 12px 14px;
  color: #020617;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 13px;
  font-weight: 900;
}

.link-actions {
  display: grid;
  gap: 8px;
}

.link-actions button {
  width: 100%;
}

.link-code-box {
  margin-top: 16px;
  padding: 18px;
  border-radius: 22px;
  text-align: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.link-code-box span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.link-code-box strong {
  display: block;
  margin-top: 8px;
  font-size: 42px;
  letter-spacing: 0.08em;
}

.link-code-box p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
