/* ===== MyEvents — дизайн-система «гранат + шафран» (референс v0) ===== */

:root {
  color-scheme: light;
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Manrope', sans-serif;

  --bg: #f7f4f4;
  --fg: #1f1418;
  --card: #ffffff;
  --card-fg: #1f1418;
  --primary: #c3193d;
  --primary-fg: #ffffff;
  --accent: #f4b63f;
  --accent-fg: #1f1418;
  --secondary: #ece6e7;
  --secondary-fg: #1f1418;
  --muted: #ece6e7;
  --muted-fg: #6e6064;
  --border: #e3dcdd;
  --destructive: #c3193d;
  --ink: #1f1418;
  --ink-fg: #ffffff;
  --ok: #4c9a57;
  --radius: 12px;
}

:root[data-scheme="dark"] {
  color-scheme: dark;
  --bg: #1d1517;
  --fg: #f7f0f1;
  --card: #2a2023;
  --card-fg: #f7f0f1;
  --primary: #e8395c;
  --primary-fg: #ffffff;
  --accent: #f4b63f;
  --accent-fg: #1f1418;
  --secondary: #3a2e31;
  --secondary-fg: #f7f0f1;
  --muted: #3a2e31;
  --muted-fg: #b3a3a7;
  --border: #3a2e31;
  --destructive: #e8395c;
  --ink: #0f0a0b;
  --ink-fg: #ffffff;
  --ok: #63b574;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* Никаких ограничений прокрутки на корневом скроллере:
   overscroll-behavior/overflow на body ломают колесо в Telegram Desktop. */
html, body { overflow-y: auto; }

body.modal-open { overflow: hidden; }

#app {
  max-width: 480px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
}

.font-display { font-family: var(--font-display); }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 16px;
  min-height: 48px; padding: 12px 20px;
  font-family: var(--font-sans); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: transform .08s ease, opacity .15s ease, background .15s ease;
  white-space: nowrap; color: var(--fg);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:active { opacity: .9; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--fg); }
.btn-ghost { background: var(--muted); color: var(--fg); }
.btn-danger { background: color-mix(in srgb, var(--destructive) 14%, transparent); color: var(--destructive); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 8px 14px; font-size: 13.5px; border-radius: 12px; }

.mini-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--card); color: var(--fg);
  border-radius: 12px; padding: 7px 12px; font-size: 12.5px; font-weight: 700;
  font-family: var(--font-sans); cursor: pointer;
}
.mini-btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.mini-btn.danger { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 40%, transparent); }
.row-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Шапка страницы (подстраницы) ---------- */

.header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg);
}
.header-title {
  font-family: var(--font-display);
  margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--fg);
  cursor: pointer; flex: 0 0 auto;
}

/* ---------- Контент ---------- */

.view { padding-bottom: calc(env(safe-area-inset-bottom) + 96px); }

/* ---------- Поиск ---------- */
.searchbar { position: relative; display: flex; align-items: center; }
.searchbar .search-ico {
  position: absolute; left: 14px; display: flex; color: var(--muted-fg); pointer-events: none;
}
.searchbar input {
  width: 100%; height: 50px; padding: 0 46px;
  border-radius: 18px; border: 1px solid var(--border);
  background: var(--card); color: var(--card-fg);
  font-family: var(--font-sans); font-size: 15.5px; outline: none;
  box-shadow: 0 1px 2px rgba(31,20,24,.04);
}
.searchbar input:focus { border-color: var(--primary); }
.searchbar input::placeholder { color: var(--muted-fg); }
.search-clear {
  position: absolute; right: 10px; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: var(--muted); color: var(--muted-fg);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ---------- Фильтры: категории + кнопка-фильтр ---------- */

.filters-row { display: flex; align-items: center; gap: 8px; padding: 2px 0 12px; }
.chips-row {
  display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0;
  scrollbar-width: none; padding: 2px;
}
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 38px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--fg);
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip .chip-check { margin-right: 6px; }

.filter-btn {
  position: relative; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--card); color: var(--fg);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.filter-btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.filter-btn .dot {
  position: absolute; top: -4px; right: -4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--primary); border: 2px solid var(--bg);
}

/* ---------- Карусель «Главное на неделе» ---------- */

.featured { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 6px; }
.featured-title {
  font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0; padding: 0 16px;
}
.featured-scroll {
  display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 6px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.featured-scroll::-webkit-scrollbar { display: none; }
.featured-card {
  position: relative; flex: 0 0 76%; aspect-ratio: 4 / 5;
  border-radius: 24px; overflow: hidden; border: 0; padding: 0;
  scroll-snap-align: center; cursor: pointer; text-align: left;
}
.featured-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.featured-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(15,10,11,.92) 0%, rgba(15,10,11,.25) 45%, transparent 70%);
}
.featured-price {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--accent); color: var(--accent-fg);
  border-radius: 999px; padding: 6px 12px;
  font-size: 12px; font-weight: 800;
}
.featured-info { position: absolute; inset-inline: 0; bottom: 0; z-index: 2; padding: 14px; color: #fff; }
.featured-when { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; opacity: .85; margin-bottom: 4px; }
.featured-name { font-family: var(--font-display); font-size: 18.5px; font-weight: 700; line-height: 1.25; }
.featured-venue { font-size: 13px; opacity: .85; margin-top: 4px; }

/* ---------- Секции по дням ---------- */

.day-section { margin: 0 0 18px; }
.day-title {
  font-family: var(--font-display); font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--muted-fg);
  margin: 0 16px 8px;
}
.list { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }

/* ---------- Карточка события ---------- */

.card {
  background: var(--card); color: var(--card-fg);
  border: 1px solid var(--border); border-radius: 24px;
}
.event-card {
  display: flex; gap: 12px; padding: 8px; cursor: pointer;
  transition: transform .08s ease, opacity .12s ease;
}
.event-card:active { transform: scale(.988); }
.event-card.past { opacity: .55; }

.event-thumb {
  position: relative; flex: 0 0 96px; width: 96px; height: 96px;
  border-radius: 18px; overflow: hidden;
}
.event-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.event-thumb.noimg {
  display: flex; align-items: center; justify-content: center; font-size: 40px;
  background: var(--secondary);
}
.event-thumb .time-badge {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(247,244,244,.92); color: var(--ink);
  font-family: var(--font-display); font-size: 11.5px; font-weight: 700;
  border-radius: 10px; padding: 3px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  line-height: 1.2; text-align: center; white-space: nowrap;
}
.event-thumb .time-badge .tb-date { font-size: 10px; font-weight: 600; opacity: .85; }
:root[data-scheme="dark"] .event-thumb .time-badge { background: rgba(42,32,35,.92); color: #f7f0f1; }

.event-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 4px 2px; }
.event-cat { font-size: 11.5px; font-weight: 800; color: var(--primary); letter-spacing: .4px; text-transform: uppercase; margin-bottom: 3px; }
.event-title {
  font-size: 15px; font-weight: 700; line-height: 1.3; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.event-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.event-venue {
  display: flex; align-items: center; gap: 5px; min-width: 0;
  font-size: 13px; color: var(--muted-fg);
}
.event-venue svg { flex: 0 0 auto; }
.event-venue span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-price { flex: 0 0 auto; font-weight: 800; font-size: 14.5px; }
.event-price .free { color: var(--ok); }
.event-left {
  font-size: 11.5px; font-weight: 700; color: var(--muted-fg);
  background: var(--muted); border-radius: 999px; padding: 4px 9px; margin-top: 6px;
  align-self: flex-start;
}

/* ---------- Пустые состояния / загрузка ---------- */

.empty { text-align: center; padding: 48px 20px; }
.empty-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 24px;
  padding: 36px 22px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--muted-fg);
}
.empty-emoji { font-size: 44px; }
.empty-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--fg); }
.empty-text { font-size: 14px; }
.loading { text-align: center; padding: 40px 0; color: var(--muted-fg); }
.hint { color: var(--muted-fg); font-weight: 400; font-size: 12.5px; }

/* ---------- Деталь события ---------- */

.detail { padding-bottom: 110px; }
.detail-back {
  position: fixed; top: calc(env(safe-area-inset-top) + 12px); left: 14px; z-index: 25;
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(15,10,11,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.detail-hero { position: relative; aspect-ratio: 16 / 10.5; overflow: hidden; }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-hero .noimg {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 84px; background: var(--secondary);
}
.detail-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.detail-cat { font-size: 12px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .6px; }
.detail-title {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  line-height: 1.25; letter-spacing: -.4px; margin: -8px 0 0;
}
.detail-desc { font-size: 15px; color: var(--fg); opacity: .92; white-space: pre-line; margin: 0; }

.info-grid {
  display: grid; gap: 1px; overflow: hidden;
  background: var(--border); border: 1px solid var(--border); border-radius: 18px;
}
.info-row { display: flex; align-items: flex-start; gap: 12px; background: var(--card); padding: 12px; }
.info-ico {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px;
  background: var(--muted); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.info-label { font-size: 11.5px; color: var(--muted-fg); }
.info-value { font-size: 14.5px; font-weight: 700; }
.info-sub { font-size: 13px; color: var(--muted-fg); font-weight: 500; }

.organizer-block {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 12px 14px;
}
.org-avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: var(--primary-fg);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px;
  font-family: var(--font-display);
}
.org-name { font-weight: 700; font-size: 14.5px; }
.org-sub { font-size: 12.5px; color: var(--muted-fg); }

.detail-cta {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 15;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
}
.detail-cta .price-block { display: flex; flex-direction: column; flex: 0 0 auto; }
.detail-cta .price-label { font-size: 11.5px; color: var(--muted-fg); }
.detail-cta .price-value { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.detail-cta .btn { flex: 1; }

/* ---------- Нижняя навигация (пилюля) ---------- */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 12px);
}
.nav-pill {
  max-width: 448px; margin: 0 auto;
  display: flex; align-items: center; gap: 2px;
  background: var(--fg); color: var(--bg);
  border-radius: 999px; padding: 6px;
  box-shadow: 0 12px 32px rgba(15,10,11,.25);
}
.nav-item {
  flex: 1; height: 46px; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: color-mix(in srgb, var(--bg) 68%, transparent);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 700;
  transition: background .15s ease, color .15s ease;
}
.nav-item.active { background: var(--bg); color: var(--fg); }
.nav-plus {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Модалки (по центру экрана) ---------- */

.modal {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .18s ease;
}
.modal.show { opacity: 1; }
.modal-dialog {
  position: relative; width: 100%; max-width: 420px; max-height: min(84dvh, 640px);
  background: var(--bg); color: var(--fg);
  border-radius: 24px; overflow: hidden;
  display: flex; flex-direction: column;
  transform: scale(.94) translateY(8px); transition: transform .18s ease;
  box-shadow: 0 24px 64px rgba(15,10,11,.35);
}
.modal.show .modal-dialog { transform: scale(1) translateY(0); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 18px 12px; flex: 0 0 auto;
}
.modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0; }
.modal-close {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--muted); color: var(--muted-fg);
  display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 4px 18px 18px; overflow-y: auto; }
.modal-body .sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-body .sheet-actions .btn { flex: 1; }
.sheet-text { margin: 0 0 14px; font-size: 14.5px; color: var(--fg); opacity: .92; }

/* ---------- Покупка / успех / QR ---------- */

.purchase { display: flex; flex-direction: column; gap: 10px; }
.purchase-event {
  font-weight: 800; font-size: 15.5px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 12px;
  display: flex; gap: 10px; align-items: center;
}
.purchase-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.purchase-row span { color: var(--muted-fg); }
.purchase-row b { font-weight: 700; text-align: right; }
.purchase-note {
  margin: 12px 0 4px; padding: 10px 12px; border-radius: 14px;
  background: var(--muted); font-size: 12.5px; color: var(--muted-fg);
}
.success { text-align: center; padding: 4px 0; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.success-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.success-date { color: var(--muted-fg); font-size: 13.5px; }
.qr {
  width: 210px; height: 210px; border-radius: 18px; background: #fff;
  padding: 12px; border: 1px solid var(--border);
}
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px; font-weight: 700; letter-spacing: 1px;
  background: var(--muted); border-radius: 10px; padding: 8px 12px;
}

/* ---------- Мои чеки ---------- */

.check-card { align-items: center; }
.check-poster {
  flex: 0 0 64px; width: 64px; height: 64px; border-radius: 16px; overflow: hidden; position: relative;
}
.check-poster img { width: 100%; height: 100%; object-fit: cover; }
.check-poster .noimg {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; background: var(--secondary);
}
.check-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.check-foot .code { font-size: 11px; padding: 4px 8px; margin: 0; letter-spacing: .5px; }

/* ---------- Профиль ---------- */

.profile { padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.profile-card { text-align: center; padding: 24px 16px; }
.profile-avatar {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 12px;
  background: var(--primary); color: var(--primary-fg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 26px; font-weight: 800;
}
.profile-name { font-weight: 800; font-size: 18px; }
.profile-username { color: var(--muted-fg); font-size: 14px; margin: 2px 0 10px; }
.profile-role { display: flex; justify-content: center; }

.section-title {
  font-family: var(--font-display); font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted-fg); margin: 14px 4px 8px;
}

.form { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 16px 14px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted-fg); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; border-radius: 13px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font-size: 15px; font-family: inherit; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.poster-row { display: flex; flex-wrap: wrap; gap: 6px; }
.poster-choice {
  width: 40px; height: 40px; font-size: 20px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
}
.poster-choice.active { border: 2px solid var(--primary); background: var(--muted); }

.menu { padding: 4px 0; }
.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--border);
  padding: 13px 14px; color: var(--fg); text-align: left; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px;
}
.menu-row:last-child { border-bottom: 0; }
.menu-row div { flex: 1; display: flex; flex-direction: column; }
.menu-row small { color: var(--muted-fg); font-size: 12px; }
.menu-row b { font-weight: 700; }
.chev { color: var(--muted-fg); }

.about { padding: 10px 6px 30px; text-align: center; }
.about-line { font-size: 12px; color: var(--muted-fg); margin-bottom: 4px; }
.about code { background: var(--muted); padding: 1px 6px; border-radius: 6px; }

/* ---------- Панели ---------- */

.panel { padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.stats-row, .stats-grid, .checks-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 13px 10px; text-align: center;
}
.stat-card b { display: block; font-family: var(--font-display); font-size: 16.5px; margin-bottom: 3px; }
.stat-card span { font-size: 11.5px; color: var(--muted-fg); }

.org-event .event-info { padding-right: 2px; }
.org-event .event-foot { display: flex; justify-content: space-between; margin-top: 6px; }

.issue-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  margin-bottom: 10px; overflow: hidden;
}
.issue-box summary { padding: 13px 14px; font-weight: 700; font-size: 14.5px; cursor: pointer; }
.checks-list { display: flex; flex-direction: column; gap: 6px; }
.check-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 13px; font-size: 13px;
}
.check-row .code { font-size: 12px; padding: 0; background: none; margin: 0; letter-spacing: .5px; }
.check-row small { color: var(--muted-fg); }
.check-row.sold { opacity: .6; }

.mod-card { padding: 14px; }
.mod-row { display: flex; gap: 10px; align-items: flex-start; }
.mod-row .checkbox { display: flex; padding-top: 3px; }
.mod-row .checkbox input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.bulk-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.agent-tag {
  background: var(--muted); border-radius: 8px; padding: 2px 8px;
  font-size: 12px; color: var(--primary); font-weight: 700;
}
.agent-card { padding: 14px; font-size: 13.5px; }
.agent-status { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.agent-status .badge { margin-left: 0; }

/* Переключатель источника */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--muted); border: 1px solid var(--border);
  transition: background .18s ease; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  left: 2px; top: 2px; background: var(--card); box-shadow: 0 1px 3px rgba(15,10,11,.3);
  transition: transform .18s ease;
}
.switch input:checked + .slider { background: var(--ok); border-color: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.agent-card pre {
  background: var(--muted); border-radius: 12px; padding: 10px 12px;
  font-size: 12.5px; overflow-x: auto;
}
.list-flat { padding: 0 14px; }
.user-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.user-row:last-child { border-bottom: 0; }
.user-row small { display: block; color: var(--muted-fg); font-size: 12px; }
.role-select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 10px; font-size: 13px; font-family: inherit; outline: none;
}

/* ---------- Бейджи ---------- */

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800; vertical-align: middle; margin-left: 2px;
}
.badge-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge-warn { background: color-mix(in srgb, var(--accent) 22%, transparent); color: color-mix(in srgb, var(--accent) 70%, var(--fg)); }
.badge-muted { background: var(--muted); color: var(--muted-fg); }
.badge-link { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }

/* ---------- Тосты ---------- */

#toasts {
  position: fixed; top: calc(env(safe-area-inset-top) + 14px); left: 50%;
  transform: translateX(-50%); z-index: 100; width: min(92%, 420px);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--fg); color: var(--bg);
  padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 700;
  box-shadow: 0 12px 32px rgba(15,10,11,.3);
  opacity: 0; transform: translateY(-8px); transition: all .22s ease;
  max-width: 100%; text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-err { background: var(--destructive); color: #fff; }

/* ---------- Десктопный превью ---------- */

@media (min-width: 520px) {
  body { background: var(--secondary); }
  #app { box-shadow: 0 0 48px rgba(15,10,11,.18); }
}

/* ===== ТЗ: верхняя панель (режим + Бабл мап) ===== */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}
.mode-switch {
  display: flex; background: var(--muted); border-radius: 999px; padding: 3px; gap: 2px;
}
.mode-btn {
  border: 0; border-radius: 999px; padding: 8px 14px;
  background: transparent; color: var(--muted-fg);
  font-family: var(--font-sans); font-size: 13px; font-weight: 800;
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.mode-btn.active { background: var(--card); color: var(--fg); box-shadow: 0 1px 4px rgba(15,10,11,.12); }
.bubble-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px;
  background: var(--card); color: var(--fg);
  font-family: var(--font-sans); font-size: 13px; font-weight: 800; cursor: pointer;
  white-space: nowrap;
}
.bubble-btn:active { background: var(--muted); }

/* ---------- Лента: категории в два ряда ---------- */

.cats-wrap { display: flex; flex-direction: column; gap: 8px; padding: 0 0 4px; }
.cats-wrap .chips-row { padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.cats-wrap .chips-row::-webkit-scrollbar { display: none; }

.filter-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 16px; margin: 0 16px 12px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--fg);
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.filter-chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.filter-chip .dot {
  position: absolute; top: -4px; right: -4px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--primary); border: 2px solid var(--bg);
}
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- Вкладки ---------- */

.tabs {
  display: flex; gap: 4px; background: var(--muted); border-radius: 14px; padding: 4px; margin: 2px 0 10px;
}
.tab {
  flex: 1; border: 0; border-radius: 11px; padding: 9px 6px;
  background: transparent; color: var(--muted-fg);
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 800; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab.active { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(15,10,11,.12); }

/* ---------- Реакции (лайки/дизлайки) ---------- */

.event-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.event-foot .event-left { margin-top: 0; }
.event-foot .event-counters { margin-top: 0; }
.event-counters {
  display: inline-flex; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--muted-fg);
}
.reactions { display: inline-flex; gap: 6px; margin-left: auto; }
.react-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px;
  background: var(--card); color: var(--muted-fg);
  font-family: var(--font-sans); font-size: 12px; font-weight: 800; cursor: pointer;
}
.react-btn b { font-size: 12px; font-weight: 800; }
.react-btn.on { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, transparent); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.react-btn.big { padding: 9px 16px; font-size: 14px; }
.detail-reactions { display: flex; align-items: center; gap: 8px; }

/* ---------- Купоны ---------- */

.coupon-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 12px 14px; margin-bottom: 8px;
}
.coupon-row-info { flex: 1; min-width: 0; }
.coupon-row-info b { display: block; font-size: 14px; }
.coupon-row-info small { color: var(--muted-fg); font-size: 12px; }

/* ---------- Организатор на странице события ---------- */

.org-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.org-actions .btn:disabled { opacity: .45; }
.social-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.social-btn {
  width: 42px; height: 42px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--muted); color: var(--primary);
  font-weight: 800; font-size: 13px; text-decoration: none;
}
.social-btn:active { transform: scale(.96); }
.org-avatar.big { width: 64px; height: 64px; font-size: 24px; }

/* ---------- Поддержка ---------- */

.support-user {
  text-align: center; font-family: var(--font-display); font-size: 20px; font-weight: 700;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; margin-bottom: 4px;
}

/* ---------- Бабл мап ---------- */

.bubbles-page { padding: 14px 16px 20px; }
.bubbles-hint {
  font-size: 13.5px; color: var(--muted-fg); margin: 0 0 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px;
}
.bubble-create { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.bubble-create textarea {
  width: 100%; padding: 12px 13px; border-radius: 13px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font-size: 15px; font-family: inherit; outline: none; resize: none;
}
.bubble-list { display: flex; flex-direction: column; gap: 8px; }
.bubble-card {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1px solid var(--border); border-radius: 18px; padding: 13px 14px;
  background: var(--card); color: var(--fg); cursor: pointer; text-align: left;
  font-family: var(--font-sans); font-size: 14.5px; font-weight: 600;
  transition: background .15s ease, border-color .15s ease;
}
.bubble-card.supported { background: color-mix(in srgb, var(--ok) 18%, var(--card)); border-color: var(--ok); }
.bubble-card .bubble-count {
  flex: 0 0 auto; min-width: 34px; height: 34px; padding: 0 6px;
  border-radius: 999px; background: var(--muted); color: var(--muted-fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.bubble-card.supported .bubble-count { background: var(--ok); color: #fff; }
.bubble-card .bubble-text { flex: 1; min-width: 0; }
.bubble-card .bubble-check { color: var(--ok); display: flex; }

/* ---------- Панель организатора ---------- */

.org-topmenu {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
.org-topmenu::-webkit-scrollbar { display: none; }
.org-top-btn {
  flex: 0 0 auto; display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 76px; padding: 10px 8px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--card); color: var(--fg);
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 800; cursor: pointer;
}
.org-top-btn:disabled { opacity: .45; }
.balance-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px;
}
.balance-value { font-family: var(--font-display); font-size: 24px; font-weight: 800; margin-top: 2px; }

.team-card { padding: 14px; margin-bottom: 8px; }
.team-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.team-head small { display: block; color: var(--muted-fg); font-size: 12px; }
.perm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.perm-row:last-child { border-bottom: 0; }
.perm-row .hint { font-weight: 400; }

.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 220px; overflow-y: auto; }
.date-chip { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-fg); }
.date-chip input { accent-color: var(--primary); }
.radio-block { display: flex; flex-direction: column; gap: 2px; }
.radio-row { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Публичная страница организатора ---------- */

.orgpage { padding-bottom: 20px; }
.orgpage-photo { max-height: 220px; overflow: hidden; }
.orgpage-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.orgpage-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.orgpage-head { display: flex; gap: 14px; align-items: center; }
.orgpage-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0; }
.orgpage-menu { width: 100%; border-radius: 16px; border: 1px solid var(--border); }

/* ---------- Админка: страница пользователя ---------- */

.user-page { display: flex; flex-direction: column; gap: 8px; }
.user-page-head { display: flex; flex-direction: column; gap: 2px; }
.user-page-head small { color: var(--muted-fg); font-size: 12px; }
.user-row:disabled, .menu-row:disabled, .menu-row[disabled] { opacity: .5; }
.user-row { cursor: pointer; }
.user-row:hover { background: var(--muted); }
.list-flat .user-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); font-family: var(--font-sans); text-align: left; }
.list-flat .user-row:last-child { border-bottom: 0; }

/* ---------- Баннер «не авторизован» ---------- */

.auth-banner {
  background: color-mix(in srgb, var(--accent) 28%, var(--bg));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--fg);
  font-size: 12.5px; font-weight: 600; line-height: 1.4;
  padding: 10px 16px;
}

/* ---------- Десктоп: категории одной прокручиваемой строкой ----------
   (в конце файла, чтобы переопределить базовые правила .cats-wrap) */

@media (min-width: 520px) {
  .cats-wrap {
    flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
    gap: 8px; padding: 2px 16px 8px;
  }
  .cats-wrap .chips-row { flex: 0 0 auto; padding: 0; overflow: visible; scrollbar-width: none; }
  .cats-wrap .chips-row::-webkit-scrollbar { display: none; }
  .cats-wrap::-webkit-scrollbar { height: 6px; }
  .cats-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
  .cats-wrap::-webkit-scrollbar-track { background: transparent; }
}
