/* ── App shell ─────────────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header__logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.3px;
  margin-right: 32px;
  white-space: nowrap;
}

.header__version {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
  vertical-align: middle;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  cursor: pointer;
  background: var(--text-muted);
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.live-dot--unknown { background: #9ca3af; }
.live-dot--ok      { background: #22c55e; }
.live-dot--err     { background: #ef4444; }
.live-dot--changed {
  background: #f59e0b;
  animation: live-pulse 1.5s ease-in-out 2;
}
.live-dot--pulse {
  background: #eab308;
  transform: scale(1.35);
  box-shadow: 0 0 0 3px rgba(234, 179, 8, .25);
}

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Dropdown в шапке (профиль / уведомления). */
.nav-dropdown {
  position: relative;
}
.nav-dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 110;
  display: none;
  flex-direction: column;
}
.nav-dropdown--right .nav-dropdown__menu {
  left: auto;
  right: 0;
}
.nav-dropdown__menu--wide { min-width: 320px; max-width: 360px; }
.nav-dropdown.open .nav-dropdown__menu {
  display: flex;
}
.nav-dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}
.nav-dropdown__item:hover {
  background: var(--surface2);
  text-decoration: none;
}
.nav-dropdown__divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.nav-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.nav-dropdown__trigger:hover {
  background: var(--surface2);
}

/* Bell-иконка с бейджем непрочитанных */
.bell-icon { font-size: 18px; line-height: 1; }
.bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}
.bell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 13px;
}
.bell-list {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bell-list .empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.bell-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  color: var(--text);
}
.bell-item:hover { background: var(--surface2); }
.bell-item--unread { background: var(--primary-light); }
.bell-item--unread:hover { background: var(--primary-light); filter: brightness(.97); }
.bell-item__title { font-weight: 500; font-size: 13px; margin-bottom: 2px; }
.bell-item__body  { font-size: 12px; color: var(--text-muted); }
.bell-item__time  { font-size: 11px; color: var(--text-subtle); margin-top: 2px; }

/* Индикатор интеграции (🔗 + цветной кружок-статус справа снизу).
   Цвет рисуем CSS-кружком, а не `color:` на emoji — emoji-глифы
   рендерятся system color font'ом и игнорируют CSS color. */
.integ-status {
  position: relative;
  display: inline-block;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 4px;
  line-height: 1;
}
.integ-status__dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  transition: background .15s ease;
}
.integ-status--gray   .integ-status__dot { background: #9ca3af; }
.integ-status--green  .integ-status__dot { background: #22c55e; }
.integ-status--yellow .integ-status__dot { background: #eab308; }
.integ-status--red    .integ-status__dot { background: #ef4444; }

.header__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .15s;
  cursor: pointer;
}
.nav-link:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-light); color: var(--primary); }

.header__user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.header__username {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Login page ─────────────────────────────────────────────────────────── */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 360px;
}

.login-card__logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  letter-spacing: -.4px;
}

.login-card__subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Content area ───────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  padding: 24px;
  overflow: auto;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar__title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-right: 8px;
}

.toolbar__spacer { flex: 1; }

/* ── Table ──────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr { transition: background .1s; cursor: pointer; }
tbody tr:hover { background: var(--surface2); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  color: var(--text-subtle);
  text-align: center;
}
.empty-state__icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state__text { font-size: 15px; }

/* ── Alert ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.alert.visible { display: block; }
.alert-error   { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(201,42,42,.2); }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(43,138,62,.2); }
.alert-info    { background: var(--info-light); color: var(--info); border: 1px solid rgba(3,105,161,.2); }
