/* UniMate Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,100..900;1,100..900&display=swap');
:root {
  --primary: #3b82f6;
  --primary-contrast: #ffffff;
  --primary-hover: #2563eb;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active-bg: #1e293b;
  --sidebar-offset: 20px;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 72px;
  --sidebar-vertical-offset: 1.2vh;
  --content-max: 1120px;
  --sidebar-width-base: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Exo 2', -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }

.container { max-width: var(--content-max); margin: 0 auto; padding: 0 16px; }
/* Расширяем контейнер, когда сайдбар уже (коллапс/ресайз) */
.layout-with-sidebar .container {
  /* Ширина контейнера как у хедера: без ограничения, края по margin */
  max-width: none;
  transition: max-width 0.28s ease;
}
.sidebar-collapsed.layout-with-sidebar .container {
  /* При сжатом сайдбаре ширина контейнера как у хедера (без ограничения) */
  max-width: none;
  width: auto;
}

/* Единые внешние отступы контента под шапкой */
.layout-with-sidebar .main .container {
  margin: 0 20px; /* совпадает с отступами header */
  padding: 12px 0 0;     /* единый верхний отступ контента как на dashboard */
}

/* Layout with sidebar */
.layout-with-sidebar .main-wrapper {
  margin-left: calc(var(--sidebar-offset) + var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.28s ease;
}
.main { flex: 1; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--sidebar-vertical-offset); left: var(--sidebar-offset);
  transform: none;
  width: var(--sidebar-width); height: calc(100vh - (2 * var(--sidebar-vertical-offset))); max-height: calc(100vh - (2 * var(--sidebar-vertical-offset)));
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.25));
  color: #1f2937;
  padding: 18px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.35);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.18);
  z-index: 1000;
  overflow: hidden;
  transition: width 0.28s ease, transform 0.28s ease, box-shadow 0.28s ease;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar-collapsed.layout-with-sidebar .main-wrapper { margin-left: calc(var(--sidebar-offset) + var(--sidebar-collapsed-width)); }
.sidebar-inner { height: 100%; display: flex; flex-direction: column; }
.sidebar-header { padding: 6px 44px 12px 8px; border-bottom: 1px solid rgba(17,24,39,0.08); display: flex; align-items: center; justify-content: flex-start; gap: 8px; flex-wrap: nowrap; }
.sidebar-logo { color: var(--primary); font-weight: 800; font-size: 22px; letter-spacing: 0.4px; display: inline-flex; align-items: center; gap: 8px; }
.sidebar-logo .logo-icon { color: var(--primary); font-size: 18px; }
.sidebar-logo .logo-img { height: 50px; width: auto; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.sidebar-logo .logo-text { white-space: nowrap; }
.sidebar-toggle { position: absolute; right: -6px; top: 50%; transform: translateY(-50%); border: 1px solid rgba(255,255,255,0.9); background: rgba(255,255,255,0.9); color: #0f172a; border-radius: 12px; padding: 6px 8px; cursor: pointer; box-shadow: 0 6px 14px rgba(15,23,42,0.14); z-index: 1101; }
.sidebar-toggle:hover { background: #fff; color: #0f172a; }
.sidebar-resizer { position: absolute; right: 0; top: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 1100; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-right: 4px; overflow-y: auto; flex: 1; }
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }
.sidebar-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #334155;
  background: rgba(255,255,255,0.45);
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
  border: 1px solid rgba(255,255,255,0.6);
}
.sidebar-nav-item i { width: 20px; text-align: center; color: #64748b; transition: color 0.2s ease; }
.sidebar-nav-item:hover { background: rgba(255,255,255,0.85); color: #0f172a; border-color: rgba(255,255,255,0.9); box-shadow: 0 8px 18px rgba(15,23,42,0.08); }
.sidebar-nav-item:hover i { color: #0f172a; }
.sidebar-nav-item.active {
  color: #0f172a;
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59,130,246,0.35);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.45), 0 8px 24px rgba(59,130,246,0.18);
}
.sidebar-nav-item.active i { color: #0f172a; }
.sidebar-nav-item.active::before {
  content: "";
  position: absolute;
  left: -6px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 4px;
  background: var(--primary);
}

/* Свернутый режим — иконки без текста */
.sidebar.collapsed .sidebar-nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-nav-item span { display: none; }
.sidebar.collapsed .submenu, .sidebar.collapsed .submenu-toggle { display: none !important; }
/* Свернутый режим — лого без текста */
.sidebar.collapsed .logo-text { display: none; }
.sidebar.collapsed .sidebar-header { padding: 6px 20px 12px 20px; justify-content: center; }

/* Плавная анимация размеров хедера при сворачивании сайдбара */
.header { transition: margin 0.28s ease, border-radius 0.28s ease, box-shadow 0.28s ease; }
.header .header-content { transition: padding 0.28s ease; }
.sidebar-collapsed .header .header-content { padding: 8px 12px; }
.sidebar-collapsed .header { border-radius: 14px; box-shadow: 0 8px 22px rgba(2,6,23,0.06); }

/* Submenu styles */
.sidebar-item.has-submenu > .sidebar-nav-item { position: relative; }
.submenu-toggle { margin-left: auto; background: transparent; border: none; color: #64748b; cursor: pointer; }
.submenu {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px 0 0 28px;
  max-height: 0; overflow: hidden; opacity: 0; transform: translateY(-4px);
  transition: all 0.25s ease;
}
.sidebar-item.has-submenu.open .submenu { max-height: 500px; opacity: 1; transform: translateY(0); }
.sidebar-subitem { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; color: #334155; background: rgba(255,255,255,0.55); border: 1px solid rgba(255,255,255,0.7); }
.sidebar-subitem:hover { background: rgba(255,255,255,0.85); color: #0f172a; }
.sidebar-subitem.active { color: #0f172a; background: rgba(59, 130, 246, 0.18); border-color: rgba(59,130,246,0.35); box-shadow: inset 0 0 0 1px rgba(59,130,246,0.35), 0 6px 16px rgba(59,130,246,0.12); }

/* Header — современный стеклянный вариант */
.header {
  position: sticky;
  top: 12px;
  margin: 0 20px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.35));
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 16px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.08);
  z-index: 500;
}
.header .header-content { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }

.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; font-weight: 600; }
.badge-premium { background: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.5); backdrop-filter: blur(8px); color: #111827; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: none; cursor: pointer; background: var(--primary); color: var(--primary-contrast); font-weight: 600; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 6px 10px; font-size: 14px; }
.btn-premium { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: var(--primary-contrast); }

.user-dropdown { position: relative; }
.user-avatar-wrapper { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.user-avatar-initials { width: 34px; height: 34px; border-radius: 50%; background: #e2e8f0; color: #334155; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.premium-badge { position: absolute; right: -6px; bottom: -6px; background: #f59e0b; color: #111; border-radius: 50%; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; border: 2px solid #fff; }
.dropdown-arrow { color: #94a3b8; font-size: 14px; }

/* Inline вариант бейджа премиум для хедера рядом с аватаром */
.premium-badge-inline { position: static; background: transparent; border: none; width: auto; height: auto; color: #f59e0b; display: inline-flex; align-items: center; justify-content: center; }
.premium-badge-inline i { font-size: 16px; }

.user-dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); width: 280px; display: none; overflow: hidden; }
.user-dropdown.open .user-dropdown-menu, .user-avatar-wrapper.active + .user-dropdown-menu { display: block; }
.dropdown-header { display: flex; gap: 10px; padding: 12px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.dropdown-avatar .avatar-img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.avatar-initials { width: 44px; height: 44px; border-radius: 50%; background: #e2e8f0; color: #334155; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.dropdown-user-info { display: flex; flex-direction: column; }
.dropdown-user-name { font-weight: 700; }
.dropdown-user-status { color: var(--muted); font-size: 13px; }
.dropdown-body { padding: 12px; border-bottom: 1px solid var(--border); }
.dropdown-row { display: flex; justify-content: space-between; margin: 6px 0; color: #334155; }
.dropdown-actions { display: flex; gap: 8px; padding: 12px; }

.compact-footer {
  margin: 12px 20px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.35));
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 16px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.08);
  color: #334155;
  transition: box-shadow 0.28s ease, border-radius 0.28s ease, background 0.28s ease;
}
.compact-footer .footer-container { max-width: 1120px; margin: 0 auto; padding: 16px; }
.footer-content { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 800; }
.footer-links { display: inline-flex; gap: 12px; }
.footer-links a { color: #334155; }
.footer-links a:hover { color: #111; }
.footer-social { display: inline-flex; gap: 10px; }
.social-link { width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; color: #334155; display: inline-flex; align-items: center; justify-content: center; }
.social-link:hover { background: #e2e8f0; }
.footer-bottom { margin-top: 8px; font-size: 13px; color: #94a3b8; }
/* Mobile bottom nav (hidden by default) */
.mobile-nav { display: none; }
.mobile-nav .mobile-nav-item { text-align: center; }

/* Cards and common components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,0.04); overflow: hidden; }
.card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.card-title { margin: 0; font-size: 18px; }
.card-body { padding: 16px; }

.page-title { margin: 0 0 12px 0; font-size: 24px; font-weight: 800; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin: 16px 0; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn { padding: 8px 12px; background: #f1f5f9; border: 1px solid var(--border); border-radius: 10px; color: #334155; cursor: pointer; }
.filter-btn.active, .filter-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.detail-badge { display: inline-flex; align-items: center; gap: 8px; background: #eef2ff; color: #3730a3; padding: 6px 10px; border-radius: 10px; font-weight: 600; }

/* CSS-only tooltips via [data-tooltip] to avoid freezing */
@media (hover: hover) {
  [data-tooltip] { position: relative; }
  [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 100%;
    margin-bottom: 8px;
    background: #111827;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 1102;
    transition: opacity .15s ease;
    box-shadow: 0 6px 16px rgba(2,6,23,.18);
  }
  [data-tooltip]::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% - 2px);
    width: 0; height: 0;
    border: 6px solid transparent;
    border-top-color: #111827;
    opacity: 0;
    pointer-events: none;
    z-index: 1102;
    transition: opacity .15s ease;
  }
  [data-tooltip]:hover::after,
  [data-tooltip]:hover::before { opacity: 1; }

  /* Bottom-positioned tooltip variant to avoid clipping by .card overflow */
  [data-tooltip][data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: 100%;
    margin-top: 8px;
    margin-bottom: 0;
  }
  [data-tooltip][data-tooltip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% - 2px);
    border-top-color: transparent;
    border-bottom-color: #111827;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .layout-with-sidebar .main-wrapper { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; top: 0; left: 0; height: 100vh; max-height: 100vh; border-radius: 0; }
  .sidebar.open { transform: translateX(0); }
  .compact-footer { margin: 12px 20px 6px; border-radius: 0; }

  /* Добавляем пространство снизу под плавающий островок навигации */
  .layout-with-sidebar .main { padding-bottom: 92px; }

  /* Островок мобильной навигации */
  .mobile-nav {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.45));
    border: 1px solid rgba(255,255,255,0.55);
    border-radius: 16px;
    padding: 8px 10px;
    box-shadow: 0 12px 26px rgba(2,6,23,0.14);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    z-index: 1103;
    max-width: calc(100% - 24px);
    overflow: visible; /* для вывода панели над островком */
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 60px;
    padding: 10px 12px;
    border-radius: 12px;
    color: #334155;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.4);
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  }
  .mobile-nav-item i { font-size: 18px; color: #64748b; }
  .mobile-nav-item span { font-size: 12px; margin-top: 4px; color: #334155; }
  .mobile-nav-item:hover { background: rgba(255,255,255,0.85); color: #0f172a; }
  .mobile-nav-item.active {
    color: #0f172a;
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59,130,246,0.35);
    box-shadow: inset 0 0 0 1px rgba(59,130,246,0.45);
  }

  /* Контейнер пунктов и кнопка «Меню» */
  .mobile-nav-items { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; max-width: 100%; }
  .mobile-nav-more { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; min-width: 96px; padding: 12px 14px; }
  /* Режим раскрытия: ровная сетка 4 колонки */
  .mobile-nav.expanded .mobile-nav-items { display: grid; grid-template-columns: repeat(4, minmax(64px, 1fr)); column-gap: 8px; row-gap: 10px; }
  .mobile-nav.expanded .mobile-nav-item { min-width: auto; width: 100%; }

  /* Вторичные пункты скрыты по умолчанию, показываем при раскрытии */
  .mobile-nav-items .mobile-nav-item[data-tier="secondary"] { display: none; }
  .mobile-nav.expanded .mobile-nav-items .mobile-nav-item[data-tier="secondary"] { display: inline-flex; }

  /* Панель разделов (как сайдбар) */
  .mobile-nav-panel {
    position: absolute;
    left: 50%;
    bottom: calc(100% - 1px);
    transform: translateX(-50%) translateY(8px) scale(0.98);
    width: min(680px, calc(100vw - 24px));
    max-height: min(62vh, calc(100vh - 220px));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.45));
    border: 1px solid rgba(255,255,255,0.55);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    padding: 12px;
    box-shadow: 0 18px 36px rgba(2,6,23,0.20);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    z-index: 1104;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s cubic-bezier(0.22, 1, 0.36, 1),
                transform .18s cubic-bezier(0.22, 1, 0.36, 1),
                visibility 0s linear .18s;
  }
  .mobile-nav.has-overflow.expanded .mobile-nav-panel {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity .18s cubic-bezier(0.22, 1, 0.36, 1),
                transform .18s cubic-bezier(0.22, 1, 0.36, 1);
  }
  /* Отключаем затемнение фона для островка */
  .mobile-nav-scrim { display: none !important; }

  /* Отключаем двухстрочную раскладку и вторичные пункты внизу */
  .mobile-nav.expanded .mobile-nav-items { display: flex; }
  .mobile-nav.expanded .mobile-nav-items .mobile-nav-item[data-tier="secondary"] { display: none; }
 
  .mobile-group { padding: 10px 8px; border-radius: 12px; }
  .mobile-group + .mobile-group { margin-top: 8px; }
  .mobile-group-title { display: flex; align-items: center; gap: 8px; color: #0f172a; font-weight: 800; padding: 4px 6px; }
  .mobile-group-title i { color: #64748b; }
  .mobile-group-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
  .mobile-group-item { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.7); background: rgba(255,255,255,0.75); color: #334155; }
  .mobile-group-item i { font-size: 18px; color: #64748b; }
  .mobile-group-item:hover { background: rgba(255,255,255,0.95); color: #0f172a; }
  .mobile-group-item.active { background: rgba(59, 130, 246, 0.22); border-color: rgba(59,130,246,0.35); color: #0f172a; }
 
  /* Увеличиваем нижний отступ контента при развороте */
  body.mobile-nav-expanded .layout-with-sidebar .main { padding-bottom: calc(200px + env(safe-area-inset-bottom)); }

  @keyframes mobileSheetIn {
    from { opacity: 0; transform: translateX(-50%) translateY(18px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
  }
}
/* Custom Cursor disabled: revert to native cursor */

/* Duotone icon colors for sidebar */
.sidebar-nav-item i.fa-duotone, .sidebar-subitem i.fa-duotone {
  --fa-primary-color: #64748b;
  --fa-secondary-color: #94a3b8;
  --fa-primary-opacity: 1;
  --fa-secondary-opacity: 0.70;
}
.sidebar-nav-item:hover i.fa-duotone, .sidebar-nav-item.active i.fa-duotone,
.sidebar-subitem:hover i.fa-duotone, .sidebar-subitem.active i.fa-duotone {
  --fa-primary-color: #0f172a;
  --fa-secondary-color: #334155;
}

/* Mobile footer refinements */
@media (max-width: 768px) {
  .compact-footer {
    margin: 12px 12px calc(84px + env(safe-area-inset-bottom));
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(248,250,252,0.6));
    border-color: rgba(226,232,240,0.7);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
  }
  .compact-footer .footer-container { padding: 14px; }
  .footer-content { flex-direction: column; align-items: flex-start; gap: 10px; }
  .footer-logo { font-size: 16px; }
  .footer-tagline { font-size: 13px; color: #64748b; }
  .footer-links { flex-wrap: wrap; gap: 10px; }
  .footer-links a { padding: 6px 10px; border-radius: 10px; background: rgba(241,245,249,0.9); border: 1px solid rgba(226,232,240,0.9); }
  .footer-links a:hover { background: #eef2ff; border-color: #c7d2fe; color: #1f2937; }
  .footer-social { gap: 10px; }
  .social-link { width: 36px; height: 36px; background: rgba(241,245,249,0.9); border: 1px solid rgba(226,232,240,0.9); }
  .footer-bottom { padding-top: 8px; border-top: 1px dashed rgba(226,232,240,0.6); font-size: 12px; }
}

/* Respect safe-area for bottom island nav */
@supports (padding: max(0px)) {
  .mobile-nav { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
}
/* Blue/Sky retheme for mobile island nav and panel */
@media (max-width: 768px) {
  .mobile-nav {
    background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(241,245,249,0.70));
    border-color: rgba(147,197,253,0.65);
    box-shadow: 0 12px 26px rgba(37,99,235,0.14);
  }
  .mobile-nav-item.active {
    background: rgba(37,99,235,0.20);
    border-color: rgba(147,197,253,0.60);
    box-shadow: inset 0 0 0 1px rgba(37,99,235,0.35);
  }
  .mobile-nav-panel {
    background: linear-gradient(180deg, rgba(241,245,249,0.95), rgba(236,254,255,0.70));
    border-color: rgba(147,197,253,0.70);
    box-shadow: 0 20px 40px rgba(37,99,235,0.16);
  }
  .mobile-group-title i { color: #3b82f6; }
  .mobile-group-item {
    border-color: rgba(147,197,253,0.70);
    background: rgba(240,249,255,0.85);
  }
  .mobile-group-item.active {
    background: linear-gradient(180deg, rgba(37,99,235,0.18), rgba(56,189,248,0.18));
    border-color: rgba(147,197,253,0.70);
  }
}
/* Duotone icon palette for mobile */
.mobile-nav-item i.fa-duotone,
.mobile-group-item i.fa-duotone,
.mobile-group-title i.fa-duotone {
  --fa-primary-color: #2563eb; /* blue-600 */
  --fa-secondary-color: #93c5fd; /* sky-300 */
  --fa-primary-opacity: 1;
  --fa-secondary-opacity: 0.85;
}
.mobile-nav-item.active i.fa-duotone,
.mobile-group-item.active i.fa-duotone {
  --fa-primary-color: #0f172a;
  --fa-secondary-color: #3b82f6;
}
.mobile-nav-item:hover i.fa-duotone, .mobile-nav-item.active i.fa-duotone,
.mobile-subitem:hover i.fa-duotone, .mobile-subitem.active i.fa-duotone {
  --fa-primary-color: #0f172a;
  --fa-secondary-color: #334155;
}

/* Mobile footer refinements */
@media (max-width: 768px) {
  .compact-footer {
    margin: 12px 12px calc(84px + env(safe-area-inset-bottom));
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(248,250,252,0.6));
    border-color: rgba(226,232,240,0.7);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
  }
  .compact-footer .footer-container { padding: 14px; }
  .footer-content { flex-direction: column; align-items: flex-start; gap: 10px; }
  .footer-logo { font-size: 16px; }
  .footer-tagline { font-size: 13px; color: #64748b; }
  .footer-links { flex-wrap: wrap; gap: 10px; }
  .footer-links a { padding: 6px 10px; border-radius: 10px; background: rgba(241,245,249,0.9); border: 1px solid rgba(226,232,240,0.9); }
  .footer-links a:hover { background: #eef2ff; border-color: #c7d2fe; color: #1f2937; }
  .footer-social { gap: 10px; }
  .social-link { width: 36px; height: 36px; background: rgba(241,245,249,0.9); border: 1px solid rgba(226,232,240,0.9); }
  .footer-bottom { padding-top: 8px; border-top: 1px dashed rgba(226,232,240,0.6); font-size: 12px; }
}

/* Respect safe-area for bottom island nav */
@supports (padding: max(0px)) {
  .mobile-nav { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
}
/* Premium badge & button refinements */
.header .badge-premium {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(240,249,255,0.85), rgba(224,242,254,0.70));
  border: 1px solid rgba(147,197,253,0.75);
  color: #0f172a; font-weight: 600;
  box-shadow: 0 6px 16px rgba(37,99,235,0.10);
}
.header .badge-premium i.fa-duotone {
  --fa-primary-color: #2563eb; /* blue-600 */
  --fa-secondary-color: #60a5fa; /* sky-400 */
  --fa-primary-opacity: 1; --fa-secondary-opacity: .95;
}
.header .btn.btn-premium {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: linear-gradient(180deg, #2563eb, #60a5fa);
  color: #fff; border: 1px solid rgba(147,197,253,0.75);
  box-shadow: 0 6px 16px rgba(37,99,235,0.18);
}
.header .btn.btn-premium i.fa-duotone {
  --fa-primary-color: #ffffff; --fa-secondary-color: #e2e8f0;
  --fa-primary-opacity: 1; --fa-secondary-opacity: .9;
}
/* Ensure header layout spacing stays tidy */
.header .header-content { display:flex; align-items:center; justify-content: space-between; gap: 10px; }
.header .header-title { display:flex; align-items:center; gap: 10px; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; font-weight: 600; }
.badge-premium { background: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.5); backdrop-filter: blur(8px); color: #111827; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: none; cursor: pointer; background: var(--primary); color: var(--primary-contrast); font-weight: 600; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 6px 10px; font-size: 14px; }
.btn-premium { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: var(--primary-contrast); }

.user-dropdown { position: relative; }
.user-avatar-wrapper { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.user-avatar-initials { width: 34px; height: 34px; border-radius: 50%; background: #e2e8f0; color: #334155; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.premium-badge { position: absolute; right: -6px; bottom: -6px; background: #f59e0b; color: #111; border-radius: 50%; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; border: 2px solid #fff; }
.dropdown-arrow { color: #94a3b8; font-size: 14px; }

/* Inline вариант бейджа премиум для хедера рядом с аватаром */
.premium-badge-inline { position: static; background: transparent; border: none; width: auto; height: auto; color: #f59e0b; display: inline-flex; align-items: center; justify-content: center; }
.premium-badge-inline i { font-size: 16px; }

.user-dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); width: 280px; display: none; overflow: hidden; }
.user-dropdown.open .user-dropdown-menu, .user-avatar-wrapper.active + .user-dropdown-menu { display: block; }
.dropdown-header { display: flex; gap: 10px; padding: 12px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.dropdown-avatar .avatar-img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.avatar-initials { width: 44px; height: 44px; border-radius: 50%; background: #e2e8f0; color: #334155; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.dropdown-user-info { display: flex; flex-direction: column; }
.dropdown-user-name { font-weight: 700; }
.dropdown-user-status { color: var(--muted); font-size: 13px; }
.dropdown-body { padding: 12px; border-bottom: 1px solid var(--border); }
.dropdown-row { display: flex; justify-content: space-between; margin: 6px 0; color: #334155; }
.dropdown-actions { display: flex; gap: 8px; padding: 12px; }

.compact-footer {
  margin: 12px 20px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.35));
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 16px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.08);
  color: #334155;
  transition: box-shadow 0.28s ease, border-radius 0.28s ease, background 0.28s ease;
}
.compact-footer .footer-container { max-width: 1120px; margin: 0 auto; padding: 16px; }
.footer-content { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 800; }
.footer-links { display: inline-flex; gap: 12px; }
.footer-links a { color: #334155; }
.footer-links a:hover { color: #111; }
.footer-social { display: inline-flex; gap: 10px; }
.social-link { width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; color: #334155; display: inline-flex; align-items: center; justify-content: center; }
.social-link:hover { background: #e2e8f0; }
.footer-bottom { margin-top: 8px; font-size: 13px; color: #94a3b8; }
/* Mobile bottom nav (hidden by default) */
.mobile-nav { display: none; }
.mobile-nav .mobile-nav-item { text-align: center; }

/* Cards and common components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,0.04); overflow: hidden; }
.card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.card-title { margin: 0; font-size: 18px; }
.card-body { padding: 16px; }

.page-title { margin: 0 0 12px 0; font-size: 24px; font-weight: 800; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin: 16px 0; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn { padding: 8px 12px; background: #f1f5f9; border: 1px solid var(--border); border-radius: 10px; color: #334155; cursor: pointer; }
.filter-btn.active, .filter-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.detail-badge { display: inline-flex; align-items: center; gap: 8px; background: #eef2ff; color: #3730a3; padding: 6px 10px; border-radius: 10px; font-weight: 600; }

/* CSS-only tooltips via [data-tooltip] to avoid freezing */
@media (hover: hover) {
  [data-tooltip] { position: relative; }
  [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 100%;
    margin-bottom: 8px;
    background: #111827;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 1102;
    transition: opacity .15s ease;
    box-shadow: 0 6px 16px rgba(2,6,23,.18);
  }
  [data-tooltip]::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% - 2px);
    width: 0; height: 0;
    border: 6px solid transparent;
    border-top-color: #111827;
    opacity: 0;
    pointer-events: none;
    z-index: 1102;
    transition: opacity .15s ease;
  }
  [data-tooltip]:hover::after,
  [data-tooltip]:hover::before { opacity: 1; }

  /* Bottom-positioned tooltip variant to avoid clipping by .card overflow */
  [data-tooltip][data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: 100%;
    margin-top: 8px;
    margin-bottom: 0;
  }
  [data-tooltip][data-tooltip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% - 2px);
    border-top-color: transparent;
    border-bottom-color: #111827;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .layout-with-sidebar .main-wrapper { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; top: 0; left: 0; height: 100vh; max-height: 100vh; border-radius: 0; }
  .sidebar.open { transform: translateX(0); }
  .compact-footer { margin: 12px 20px 6px; border-radius: 0; }

  /* Добавляем пространство снизу под плавающий островок навигации */
  .layout-with-sidebar .main { padding-bottom: 92px; }

  /* Островок мобильной навигации */
  .mobile-nav {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.45));
    border: 1px solid rgba(255,255,255,0.55);
    border-radius: 16px;
    padding: 8px 10px;
    box-shadow: 0 12px 26px rgba(2,6,23,0.14);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    z-index: 1103;
    max-width: calc(100% - 24px);
    overflow: visible; /* для вывода панели над островком */
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 60px;
    padding: 10px 12px;
    border-radius: 12px;
    color: #334155;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.4);
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  }
  .mobile-nav-item i { font-size: 18px; color: #64748b; }
  .mobile-nav-item span { font-size: 12px; margin-top: 4px; color: #334155; }
  .mobile-nav-item:hover { background: rgba(255,255,255,0.85); color: #0f172a; }
  .mobile-nav-item.active {
    color: #0f172a;
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59,130,246,0.35);
    box-shadow: inset 0 0 0 1px rgba(59,130,246,0.45);
  }

  /* Контейнер пунктов и кнопка «Меню» */
  .mobile-nav-items { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; max-width: 100%; }
  .mobile-nav-more { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; min-width: 96px; padding: 12px 14px; }
  /* Режим раскрытия: ровная сетка 4 колонки */
  .mobile-nav.expanded .mobile-nav-items { display: grid; grid-template-columns: repeat(4, minmax(64px, 1fr)); column-gap: 8px; row-gap: 10px; }
  .mobile-nav.expanded .mobile-nav-item { min-width: auto; width: 100%; }

  /* Вторичные пункты скрыты по умолчанию, показываем при раскрытии */
  .mobile-nav-items .mobile-nav-item[data-tier="secondary"] { display: none; }
  .mobile-nav.expanded .mobile-nav-items .mobile-nav-item[data-tier="secondary"] { display: inline-flex; }

  /* Панель разделов (как сайдбар) */
  .mobile-nav-panel {
    position: absolute;
    left: 50%;
    bottom: calc(100% - 1px);
    transform: translateX(-50%) translateY(8px) scale(0.98);
    width: min(680px, calc(100vw - 24px));
    max-height: min(62vh, calc(100vh - 220px));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.45));
    border: 1px solid rgba(255,255,255,0.55);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    padding: 12px;
    box-shadow: 0 18px 36px rgba(2,6,23,0.20);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    z-index: 1104;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s cubic-bezier(0.22, 1, 0.36, 1),
                transform .18s cubic-bezier(0.22, 1, 0.36, 1),
                visibility 0s linear .18s;
  }
  .mobile-nav.has-overflow.expanded .mobile-nav-panel {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity .18s cubic-bezier(0.22, 1, 0.36, 1),
                transform .18s cubic-bezier(0.22, 1, 0.36, 1);
  }
  /* Отключаем затемнение фона для островка */
  .mobile-nav-scrim { display: none !important; }

  /* Отключаем двухстрочную раскладку и вторичные пункты внизу */
  .mobile-nav.expanded .mobile-nav-items { display: flex; }
  .mobile-nav.expanded .mobile-nav-items .mobile-nav-item[data-tier="secondary"] { display: none; }
 
  .mobile-group { padding: 10px 8px; border-radius: 12px; }
  .mobile-group + .mobile-group { margin-top: 8px; }
  .mobile-group-title { display: flex; align-items: center; gap: 8px; color: #0f172a; font-weight: 800; padding: 4px 6px; }
  .mobile-group-title i { color: #64748b; }
  .mobile-group-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
  .mobile-group-item { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.7); background: rgba(255,255,255,0.75); color: #334155; }
  .mobile-group-item i { font-size: 18px; color: #64748b; }
  .mobile-group-item:hover { background: rgba(255,255,255,0.95); color: #0f172a; }
  .mobile-group-item.active { background: rgba(59, 130, 246, 0.22); border-color: rgba(59,130,246,0.35); color: #0f172a; }
 
  /* Увеличиваем нижний отступ контента при развороте */
  body.mobile-nav-expanded .layout-with-sidebar .main { padding-bottom: calc(200px + env(safe-area-inset-bottom)); }

  @keyframes mobileSheetIn {
    from { opacity: 0; transform: translateX(-50%) translateY(18px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
  }
}
/* Custom Cursor disabled: revert to native cursor */

/* Duotone icon colors for sidebar */
.sidebar-nav-item i.fa-duotone, .sidebar-subitem i.fa-duotone {
  --fa-primary-color: #64748b;
  --fa-secondary-color: #94a3b8;
  --fa-primary-opacity: 1;
  --fa-secondary-opacity: 0.70;
}
.sidebar-nav-item:hover i.fa-duotone, .sidebar-nav-item.active i.fa-duotone,
.sidebar-subitem:hover i.fa-duotone, .sidebar-subitem.active i.fa-duotone {
  --fa-primary-color: #0f172a;
  --fa-secondary-color: #334155;
}

/* Mobile footer refinements */
@media (max-width: 768px) {
  .compact-footer {
    margin: 12px 12px calc(84px + env(safe-area-inset-bottom));
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(248,250,252,0.6));
    border-color: rgba(226,232,240,0.7);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
  }
  .compact-footer .footer-container { padding: 14px; }
  .footer-content { flex-direction: column; align-items: flex-start; gap: 10px; }
  .footer-logo { font-size: 16px; }
  .footer-tagline { font-size: 13px; color: #64748b; }
  .footer-links { flex-wrap: wrap; gap: 10px; }
  .footer-links a { padding: 6px 10px; border-radius: 10px; background: rgba(241,245,249,0.9); border: 1px solid rgba(226,232,240,0.9); }
  .footer-links a:hover { background: #eef2ff; border-color: #c7d2fe; color: #1f2937; }
  .footer-social { gap: 10px; }
  .social-link { width: 36px; height: 36px; background: rgba(241,245,249,0.9); border: 1px solid rgba(226,232,240,0.9); }
  .footer-bottom { padding-top: 8px; border-top: 1px dashed rgba(226,232,240,0.6); font-size: 12px; }
}

/* Respect safe-area for bottom island nav */
@supports (padding: max(0px)) {
  .mobile-nav { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
}