/* Login screen */
.login-wrap {
  position: relative; z-index: 1; height: 100%; height: 100dvh; height: calc(var(--vh, 1vh) * 100);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-radius: 32px; padding: 32px 26px; text-align: center; box-shadow: var(--shadow);
}
.login-card .eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pink); font-weight: 700; }
.login-card h1 { font-size: 21px; margin: 0 0 20px; font-weight: 800; }
.login-card input {
  width: 100%; font-family: inherit; font-size: 16px; color: var(--text); text-align: center;
  background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border-soft);
  border-radius: 14px; padding: 14px; letter-spacing: 0.08em; margin-bottom: 14px;
}
.login-card input:focus { outline: none; border-color: var(--pink); }
#tgWidgetBox { display: flex; justify-content: center; min-height: 40px; align-items: center; }
.login-code-toggle {
  display: block; margin: 18px auto 0; background: none; border: none; cursor: pointer;
  color: var(--text-faint); font-family: inherit; font-size: 12.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px; padding: 4px;
}
.login-code-toggle:active { color: var(--text-soft); }
#loginForm { margin-top: 16px; }
.login-error { color: #ff8f9e; font-size: 13px; margin: 10px 0 0; }
.login-error.shake { animation: shake 0.4s; }

/* App shell */
.wrap {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  height: 100%; height: 100dvh; height: calc(var(--vh, 1vh) * 100); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px calc(env(safe-area-inset-bottom, 0px) + 24px);
}

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.avatar {
  width: 46px; height: 46px; border-radius: 16px; flex: none; overflow: hidden; padding: 0;
  background: linear-gradient(155deg, var(--pink), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 18px; font-weight: 700; color: #1a0e16;
  border: none; box-shadow: var(--shadow); cursor: pointer;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topbar-title { flex: 1; min-width: 0; }
.eyebrow {
  margin: 0; font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--pink); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subtitle { margin: 2px 0 0; font-size: 15px; color: var(--text-soft); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle b { color: var(--text); font-weight: 700; }

/* Hero stat card */
.hero {
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-radius: 32px; padding: 26px 22px 20px; text-align: center; box-shadow: var(--shadow); margin-bottom: 16px;
}
.hero-label { margin: 0; font-size: 13px; color: var(--text-soft); font-weight: 600; }
.hero-number {
  font-size: clamp(44px, 14vw, 58px); font-weight: 800; line-height: 1.05;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(170deg, #ffffff, var(--pink) 130%);
  -webkit-background-clip: text; background-clip: text; color: transparent; margin: 2px 0;
}
.hero-sub { margin: 0 0 16px; font-size: 13px; color: var(--text-faint); font-weight: 500; }
.hero-divider { height: 1px; background: var(--glass-border-soft); margin-bottom: 14px; }
.hero-stats-row { display: flex; align-items: center; justify-content: center; gap: 0; }
.hero-stat { flex: 1; }
.hero-stat .v { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-stat .l { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; font-weight: 500; }
.hero-sep { width: 1px; height: 30px; background: var(--glass-border-soft); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 12px; padding: 0 2px; }
.section-head h2 { font-size: 16px; margin: 0; font-weight: 700; }
.section-head span { font-size: 12.5px; color: var(--text-faint); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

/* Toolbar row: filter pills (left) + add button (right, hidden for owner) */
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.add-btn {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(155deg, #ffb6cf 0%, var(--pink) 45%, var(--pink-strong) 100%);
  color: #1a0e16; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 16px -6px rgba(255,95,158,0.6), 0 1px 0 rgba(255,255,255,0.35) inset;
  transition: transform 0.15s var(--ease);
}
.add-btn svg { width: 20px; height: 20px; }
.add-btn:active { transform: scale(0.9) rotate(45deg); }

/* Role visibility */
.role-partner .owner-only, .preview-partner .owner-only { display: none !important; }

.preview-badge {
  position: fixed; z-index: 60;
  top: calc(env(safe-area-inset-top, 0px) + 12px); right: 14px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 7px 6px 14px; border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--pink-strong));
  color: #1a0e16; font-size: 12px; font-weight: 700;
  box-shadow: var(--shadow);
}
.preview-badge button {
  width: 22px; height: 22px; flex: none; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; border: none; border-radius: 50%; cursor: pointer;
  background: rgba(26,14,22,0.18); color: #1a0e16;
  transition: transform 0.15s var(--ease);
}
.preview-badge button svg { width: 12px; height: 12px; }
.preview-badge button:active { transform: scale(0.88); }
