/* Боковое меню CRM + умный поиск (главная) */
.crm-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
  touch-action: manipulation;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.crm-menu-btn:hover { background: #fffbeb; border-color: #fcd34d; }
.crm-menu-btn:active { transform: scale(.97); }
.crm-menu-icon,
.crm-menu-icon::before,
.crm-menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: #0f172a;
  position: relative;
}
.crm-menu-icon::before,
.crm-menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}
.crm-menu-icon::before { top: -6px; }
.crm-menu-icon::after { top: 6px; }
.crm-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .22s ease;
}
.crm-nav-backdrop[hidden] { display: none !important; }
.crm-nav-backdrop.visible { opacity: 1; }
.crm-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(340px, 92vw);
  z-index: 46;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  box-shadow: 12px 0 40px rgba(15, 23, 42, 0.14);
  transform: translateX(-105%);
  transition: transform .26s cubic-bezier(.22, 1, .36, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.crm-nav-drawer.open { transform: translateX(0); }
.crm-nav-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 14px 14px;
  background: linear-gradient(135deg, #fffbeb 0%, #fff 55%);
  border-bottom: 1px solid #fef3c7;
}
.crm-nav-brand { font-weight: 800; font-size: 17px; line-height: 1.2; min-width: 0; }
.crm-nav-brand small {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-top: 2px;
}
.crm-nav-close {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.crm-nav-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 16px;
}
.crm-nav-group {
  margin: 14px 4px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #94a3b8;
}
.crm-nav-group:first-child { margin-top: 4px; }
.crm-nav-item.crm-nav-admin-only[hidden] { display: none !important; }
.crm-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  padding: 10px 12px;
  margin-bottom: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, border-color .15s;
}
.crm-nav-item:hover { background: #f8fafc; border-color: #e2e8f0; }
.crm-nav-item.active {
  background: #fffbeb;
  border-color: #fde68a;
  box-shadow: inset 3px 0 0 #f7c948;
}
.crm-nav-item:focus-visible { outline: 2px solid #e9b414; outline-offset: 1px; }
.crm-nav-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}
.crm-nav-item[data-accent="yellow"] .crm-nav-icon { background: #fffbeb; border-color: #fde68a; }
.crm-nav-item[data-accent="blue"] .crm-nav-icon { background: #eff6ff; border-color: #bfdbfe; }
.crm-nav-item[data-accent="green"] .crm-nav-icon { background: #ecfdf5; border-color: #a7f3d0; }
.crm-nav-item[data-accent="violet"] .crm-nav-icon { background: #f5f3ff; border-color: #ddd6fe; }
.crm-nav-text { min-width: 0; flex: 1 1 auto; }
.crm-nav-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
}
.crm-nav-text span {
  display: block;
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
  margin-top: 2px;
}
.crm-nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.crm-nav-foot {
  flex-shrink: 0;
  padding: 12px 16px 14px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.crm-nav-foot-label {
  font-size: 11px;
  text-align: center;
  color: #64748b;
}
.crm-nav-logout-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fff5f5;
  color: #b91c1c;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.crm-nav-logout-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}
body.crm-nav-open { overflow: hidden; }
.page-top .crm-menu-btn { flex-shrink: 0; }

/* Умный поиск (главная) */
.smart-search-wrap {
  position: relative;
  flex: 1 1 260px;
  min-width: 160px;
  max-width: min(520px, 100%);
}
.smart-search-inner {
  position: relative;
  display: flex;
  align-items: center;
}
.smart-search-inner .search-glyph {
  position: absolute;
  left: 11px;
  font-size: 14px;
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
}
.smart-search-wrap input[type="search"] {
  width: 100%;
  padding: 10px 36px 10px 34px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font: inherit;
  color: #0f172a;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.smart-search-wrap input[type="search"]:focus {
  outline: none;
  border-color: #fcd34d;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.25);
}
.smart-search-wrap input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-clear-btn {
  position: absolute;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}
.search-clear-btn:hover { background: #f1f5f9; color: #0f172a; }
.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 55;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
  max-height: min(380px, 52vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.search-suggest[hidden] { display: none !important; }
.search-suggest-head {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #94a3b8;
}
.search-suggest-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font: inherit;
  color: inherit;
}
.search-suggest-item:last-child { border-bottom: none; }
.search-suggest-item:hover,
.search-suggest-item.active { background: linear-gradient(90deg, #fffbeb, #fff); }
.search-suggest-av {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.search-suggest-body { min-width: 0; flex: 1; }
.search-suggest-body strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 2px;
}
.search-suggest-body .meta {
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
}
.search-suggest-body mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}
.search-suggest-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: #64748b;
}
summary.top-summary .crm-menu-btn { order: 1; }
summary.top-summary .brand { order: 2; flex: 1 1 auto; min-width: 0; }
summary.top-summary .top-actions { order: 3; margin-left: auto; }
summary.top-summary .smart-search-wrap { order: 4; flex: 1 1 100%; max-width: 100%; }
summary.top-summary .stage-filter-top { display: none !important; }
@media (max-width: 899px) {
  summary.top-summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "menu brand actions"
      "search search search";
    align-items: center;
  }
  summary.top-summary .crm-menu-btn { grid-area: menu; }
  summary.top-summary .brand {
    grid-area: brand;
    font-size: 17px;
    justify-self: start;
  }
  summary.top-summary .top-actions {
    grid-area: actions;
    margin-left: 0;
    justify-self: end;
  }
  summary.top-summary .smart-search-wrap {
    grid-area: search;
    width: 100%;
    max-width: 100%;
  }
  summary.top-summary .smart-search-wrap input[type="search"] {
    font-size: 16px;
    padding-top: 11px;
    padding-bottom: 11px;
  }
}
@media (min-width: 900px) {
  summary.top-summary .smart-search-wrap { order: 2; flex: 1 1 320px; max-width: 480px; }
  summary.top-summary .brand { order: 1; flex: 0 1 auto; }
  summary.top-summary .top-actions { order: 4; margin-left: auto; }
}
