body {
  background: #f4f6fb;
  font-size: 0.93rem;
}

/* ===== Верхняя панель (Bitrix24-style) ===== */
:root { --accent: #0d6efd; }

body.has-sidebar { background: #eef2f7; }

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border-bottom: 1px solid #e6ebf2;
  padding: 0 18px;
  height: 56px;
  box-shadow: 0 1px 4px rgba(40,60,90,.05);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: #2a3b4d;
  text-decoration: none;
  margin-right: 10px;
  flex-shrink: 0;
}
.app-logo-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }

.app-menu { display: flex; align-items: center; flex: 1; gap: 6px; min-width: 0; }
.app-topbar-right { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.app-burger { display: none; background: none; border: none; font-size: 24px; color: #2a3b4d; padding: 4px 8px; cursor: pointer; }

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: #5a6b7d;
  text-decoration: none;
  white-space: nowrap;
}
.app-nav-item i { font-size: 16px; flex-shrink: 0; }
.app-nav-item:hover { background: #f2f6fc; color: #2a3b4d; }
.app-nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }
.app-nav-item.tg-ok { color: #198754; }
.app-nav-item.tg-warn { color: #fd7e14; }

.app-main { min-height: calc(100vh - 56px); }
.app-content { padding: 20px 24px; }

@media (max-width: 767.98px) {
  .app-content { padding: 14px; }
  /* навигация → бургер + выпадающее вертикальное меню */
  .app-burger { display: block; margin-left: auto; }
  .app-menu {
    display: none;
    position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: #fff; border-bottom: 1px solid #e6ebf2;
    box-shadow: 0 6px 16px rgba(40,60,90,.12);
    padding: 8px; max-height: calc(100dvh - 56px); overflow-y: auto;
  }
  .app-topbar.menu-open .app-menu { display: flex; }
  .app-nav { flex-direction: column; overflow: visible; gap: 2px; }
  .app-nav-item { padding: 11px 14px; font-size: 15px; }
  .app-topbar-right { flex-direction: column; align-items: stretch; gap: 2px; border-top: 1px solid #eef2f7; margin-top: 4px; padding-top: 4px; }
  /* под-вкладки (Дела) — горизонтальный скролл вместо переноса */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link { white-space: nowrap; padding: 8px 11px; }
  /* под-вкладки (Дела) — горизонтальный скролл вместо переноса */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link { white-space: nowrap; padding: 8px 11px; }
  /* метрики компактнее */
  .metric-card { min-width: 90px; padding: 10px 12px; }
  .metric-card .n { font-size: 19px; }
  /* заголовки страниц меньше */
  h4 { font-size: 1.15rem; }
  /* модалки шире на телефоне */
  .modal-dialog { margin: 0.5rem; }
}

.card {
  border: 1px solid #e6ebf2;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(40,60,90,.05);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #eef2f7;
  border-radius: 12px 12px 0 0 !important;
}

.msg-card:hover {
  border-color: #86b7fe;
  box-shadow: 0 2px 10px rgba(13,110,253,.1) !important;
  transition: border-color .15s, box-shadow .15s;
}

/* Метрики-плашки (дашборд) */
.metric-row { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.metric-card {
  flex: 1; min-width: 110px;
  background: #fff; border: 1px solid #e6ebf2; border-radius: 12px;
  padding: 13px 16px; box-shadow: 0 1px 3px rgba(40,60,90,.05);
}
.metric-card .n { font-size: 22px; font-weight: 700; color: #2a3b4d; line-height: 1.1; }
.metric-card .l { font-size: 11.5px; color: #8794a3; margin-top: 3px; }
.metric-card.danger .n { color: #dc3545; }
.metric-card.accent .n { color: var(--accent); }

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.opacity-60 {
  opacity: 0.6;
}

.table th {
  font-weight: 600;
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6c757d;
}

.badge {
  font-weight: 500;
}

.form-label {
  font-weight: 500;
  margin-bottom: .3rem;
}

/* Login page */
.card.shadow-sm {
  box-shadow: 0 4px 20px rgba(0,0,0,.08) !important;
}

/* Scrollable modals on small screens */
.modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

/* Tighter navbar */
.navbar .nav-link {
  padding-top: .4rem;
  padding-bottom: .4rem;
}

/* Announcement thumbnails */
.msg-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.thumb-wrap {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.thumb-placeholder {
  width: 80px;
  height: 80px;
  background: #f0f2f5;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #adb5bd;
  flex-shrink: 0;
}

/* Analytics drop zone */
.analytics-drop-zone {
  border: 2px dashed #c0c8d8;
  border-radius: 8px;
  background: #f8f9fc;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.analytics-drop-zone:hover,
.analytics-drop-zone-active {
  border-color: #0d6efd;
  background: #edf3ff;
}

/* Contact avatars */
.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-ph {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #adb5bd;
  flex-shrink: 0;
}
