/* ============================================================
   CONNECTO SHELL — единый layer для всех v2/v3 страниц
   Импортируется КАЖДОЙ страницей (desktop-v2, stats-v3, settings-v2,
   login-v2, register-v2, setup-v2). Содержит:
   - дизайн-токены
   - body + glass-эллипс + бумажная текстура
   - универсальный хедер (логотип + nav-пилюля + иконки)
   - попап уведомлений + меню профиля
   ============================================================ */

/* ---------- DESIGN TOKENS ---------- */
:root {
  /* Surfaces */
  --page-bg:              #e3e4e8;
  --surface-inner:        #f6f6f6;
  --surface-glass:        rgba(252, 252, 252, 0.70);
  --surface-glass-hover:  rgba(252, 252, 252, 0.90);
  --surface-dark:         #303030;
  /* Accent */
  --accent:               #FED861;
  --accent-hover:         #f5cc4a;
  --accent-on:            #303030;
  /* Semantic */
  --danger:               #F7785B;
  --danger-hover:         #e05e43;
  --danger-on:            #ffffff;
  --success-bg:           rgba(148, 214, 100, 0.28);
  --success-on:           #212121;
  /* Text */
  --fg:                   #303030;
  --fg-2:                 rgba(48, 48, 48, 0.80);
  --fg-3:                 rgba(48, 48, 48, 0.70);
  --fg-4:                 rgba(48, 48, 48, 0.55);
  --fg-on-dark:           rgba(255, 255, 255, 0.80);
  --fg-on-dark-max:       #ffffff;
  /* Blur */
  --blur-sm: 4px;
  --blur-md: 6px;
  --blur-lg: 8px;
  /* Radii */
  --r-mini:   16px;
  --r-pill:   20px;
  --r-panel:  30px;
  --r-card:   28px;
  --r-input:  41px;
  --r-nav:    64px;
  /* Glow */
  --glow-inner: rgba(254, 216, 97, 0.73);
  /* Aliases */
  --dark: var(--fg);
  --search-bg: var(--surface-inner);
  /* Divider (точка/штрих внутри карточек) */
  --divider: rgba(48, 48, 48, 0.70);
  /* Шрифт */
  --font-sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Длительности и easing */
  --dur-fast: 0.15s;
  --dur-base: 0.18s;
  --dur-slow: 0.22s;
  --ease: ease;
  /* Layout */
  --pad-x: 30px;
  --pad-y: 22px;
  --header-max: 1680px;
}

/* CRITICAL: [hidden] должен побеждать любой display: на CSS-классе. */
[hidden] { display: none !important; }

/* ---------- BODY + ТЕКСТУРА ----------
   Чтобы шелл применился — на <body> ставится class="connecto-shell".
   ---------- */
body.connecto-shell {
  background-color: var(--page-bg);
  color: var(--dark);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  letter-spacing: -0.3px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* paper noise — единая текстура на всех страницах
     bg-color → blend(multiply) с шумом → паперный эффект */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch' seed='4'/><feColorMatrix values='0 0 0 0 0.18  0 0 0 0 0.18  0 0 0 0 0.18  0 0 0 0.55 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  background-repeat: repeat;
  background-attachment: fixed;
  background-blend-mode: multiply;
}

/* ---------- BG ELLIPSE (жёлтый глоу) ---------- */
.bg-ellipse {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    ellipse 64% 70% at 68% 89%,
    var(--glow-inner) 0%,
    transparent 70%
  );
}

/* ============================================================
   UNIFIED HEADER — лого + nav-пилюля + иконки
   Применяется когда хедер — прямой child body (.header) ИЛИ
   когда хедер внутри .page (desktop-v2). Селекторы покрывают оба случая.
   ============================================================ */
header.header,
body > .header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 57px;
  max-width: var(--header-max);
  margin: 0 auto;
  padding: var(--pad-y) var(--pad-x) 4px;
  position: relative;
  z-index: 100;
}
header.header .logo,
body > .header .logo {
  display: inline-flex;
  align-items: center;
  color: var(--dark);
  flex-shrink: 0;
  height: 34px;
  transform: translateY(6px);
}
header.header .logo svg,
body > .header .logo svg {
  height: 100%; width: auto; display: block;
}

header.header .nav,
body > .header .nav {
  display: inline-flex;
  background: var(--search-bg);
  border-radius: var(--r-nav);
  padding: 7px 8px;
  gap: 4px;
  flex-shrink: 0;
  transform: translateY(6px);
}
header.header .nav__item,
body > .header .nav__item {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--dark);
  text-decoration: none;
  padding: 10px 28px;
  border-radius: 50px;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
}
header.header .nav__item:hover:not(.is-active):not(.is-disabled),
body > .header .nav__item:hover:not(.is-active):not(.is-disabled) {
  background: rgba(48, 48, 48, 0.06);
}
header.header .nav__item.is-active,
body > .header .nav__item.is-active {
  background: var(--dark);
  color: rgba(255, 255, 255, 0.92);
}
header.header .nav__item.is-disabled,
body > .header .nav__item.is-disabled {
  position: relative;
  pointer-events: none;
  color: var(--fg-4);
}
header.header .nav__soon,
body > .header .nav__soon {
  position: absolute;
  top: -3px;
  right: -8px;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 100px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(254, 216, 97, 0.5);
}

header.header .header__icons,
body > .header .header__icons {
  justify-self: end;
  display: inline-flex;
  gap: 10px;
  flex-shrink: 0;
  align-items: center;
  transform: translateY(6px);
  position: relative;
  z-index: 60;
}
header.header .icon-btn,
body > .header .icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--dark);
  color: #fff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}
header.header .icon-btn:hover,
body > .header .icon-btn:hover {
  background: #444;
  transform: translateY(-1px);
}
.icon-btn__avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.icon-btn.has-avatar { background: transparent; padding: 0; }
.icon-btn.has-avatar .icon-btn__svg { display: none; }

.notif-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 18px; height: 18px;
  background: var(--danger);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  border: 2px solid var(--page-bg);
  box-sizing: content-box;
}
.notif-badge[hidden] { display: none !important; }

/* Адаптив хедера */
@media (max-width: 1080px) {
  header.header .nav__item,
  body > .header .nav__item { padding: 9px 16px; font-size: 14px; }
}
@media (max-width: 820px) {
  header.header,
  body > .header { padding: 16px 18px 4px; }
  header.header .nav,
  body > .header .nav { order: 3; grid-column: 1 / -1; justify-self: center; margin-top: 8px; }
}

/* ============================================================
   NOTIFICATION POPUP
   ============================================================ */
.notif-wrap, .profile-wrap { position: relative; display: inline-flex; }
.notif-pop {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 540px;
  display: flex;
  flex-direction: column;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
  border-radius: var(--r-panel);
  box-shadow: 0 24px 60px rgba(48, 48, 48, 0.20), 0 0 0 1px rgba(48, 48, 48, 0.06);
  z-index: 1100;
  overflow: hidden;
  animation: connectoPopFadeIn 0.18s ease-out;
}
@keyframes connectoPopFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.notif-pop__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(48, 48, 48, 0.06);
}
.notif-pop__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.4px;
}
.notif-pop__readall {
  background: none; border: none;
  color: var(--fg-3);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.notif-pop__readall:hover { background: rgba(48, 48, 48, 0.06); color: var(--fg); }
.notif-pop__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 8px 12px;
}
.notif-group { margin-bottom: 6px; }
.notif-group__label {
  padding: 10px 12px 4px;
  font-size: 10px;
  font-weight: 800;
  color: var(--fg-4);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.notif-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  position: relative;
  transition: background 0.15s;
}
.notif-item:hover { background: rgba(48, 48, 48, 0.04); }
.notif-item.is-unread { background: rgba(254, 216, 97, 0.10); }
.notif-item.is-unread:hover { background: rgba(254, 216, 97, 0.16); }
.notif-item.is-unread::before {
  content: '';
  position: absolute;
  left: 4px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.notif-item__icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-item__icon--lead    { background: rgba(148, 214, 100, 0.28); color: #2f6b1c; }
.notif-item__icon--missed  { background: rgba(247, 120, 91, 0.18); color: #b94626; }
.notif-item__icon--ai      { background: rgba(254, 216, 97, 0.32); color: #876d10; }
.notif-item__icon--auto    { background: rgba(48, 48, 48, 0.10); color: var(--fg); }
.notif-item__icon--task    { background: rgba(148, 214, 100, 0.28); color: #2f6b1c; }
.notif-item__icon--overdue { background: rgba(247, 120, 91, 0.18); color: #b94626; }
.notif-item__icon--stats   { background: rgba(96, 165, 250, 0.20); color: #1e4a82; }
.notif-item__icon--system  { background: rgba(48, 48, 48, 0.08); color: var(--fg-2); }
.notif-item__body { min-width: 0; }
.notif-item__title {
  font-size: 13px; font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.2px;
  line-height: 1.25;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-item__text {
  font-size: 11px; font-weight: 500;
  color: var(--fg-3);
  letter-spacing: -0.1px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-item__time {
  font-size: 10px; font-weight: 600;
  color: var(--fg-4);
  letter-spacing: -0.1px;
  flex-shrink: 0;
  margin-top: 2px;
}
.notif-pop__foot {
  border-top: 1px solid rgba(48, 48, 48, 0.06);
  padding: 10px 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.4);
}
.notif-pop__all {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg-2);
  text-decoration: none;
  letter-spacing: -0.2px;
}
.notif-pop__all:hover { color: var(--fg); }
.notif-pop__body::-webkit-scrollbar { width: 6px; }
.notif-pop__body::-webkit-scrollbar-thumb {
  background: rgba(48, 48, 48, 0.18);
  border-radius: 3px;
}

/* ============================================================
   PROFILE POPUP — меню аватара
   ============================================================ */
.profile-pop {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
  border-radius: var(--r-panel);
  box-shadow: 0 24px 60px rgba(48, 48, 48, 0.20), 0 0 0 1px rgba(48, 48, 48, 0.06);
  z-index: 1100;
  overflow: hidden;
  animation: connectoPopFadeIn 0.18s ease-out;
  padding: 8px;
}
.profile-pop__head {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 12px 14px;
  border-bottom: 1px solid rgba(48, 48, 48, 0.06);
  margin-bottom: 6px;
}
.profile-pop__avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background-size: cover;
  background-position: center;
}
.profile-pop__avatar.has-avatar { color: transparent; }
.profile-pop__info { min-width: 0; }
.profile-pop__name {
  font-size: 14px; font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.3px;
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-pop__email {
  font-size: 11px; font-weight: 500;
  color: var(--fg-3);
  letter-spacing: -0.1px;
  margin-bottom: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-pop__tenant {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--fg-2);
  letter-spacing: -0.1px;
  background: rgba(48, 48, 48, 0.06);
  padding: 3px 8px 3px 7px;
  border-radius: 10px;
}
.profile-pop__tenant-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #94d664;
  flex-shrink: 0;
}
.profile-pop__menu { display: flex; flex-direction: column; gap: 1px; }
.profile-pop__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  font-family: inherit;
  font-size: 13px; font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.2px;
  transition: background 0.15s, color 0.15s;
}
.profile-pop__item:hover { background: rgba(48, 48, 48, 0.06); }
.profile-pop__item svg { color: var(--fg-3); flex-shrink: 0; }
.profile-pop__item:hover svg { color: var(--fg); }
.profile-pop__item span { flex: 1; }
.profile-pop__badge {
  flex: 0 0 auto !important;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 8px;
  letter-spacing: -0.1px;
}
.profile-pop__divider {
  height: 1px;
  background: rgba(48, 48, 48, 0.06);
  margin: 6px 4px;
}
.profile-pop__item--danger { color: var(--danger); }
.profile-pop__item--danger svg { color: var(--danger); }
.profile-pop__item--danger:hover { background: rgba(247, 120, 91, 0.10); color: var(--danger); }
.profile-pop__item--danger:hover svg { color: var(--danger); }
