/* ==========================================================================
   Компоненты: навбар, карточки, кнопки, бейджи, таблицы, тосты, модалки
   ========================================================================== */

/* --- Стеклянная панель --- */

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--sh);
}

/* --- Навигация --- */

.navbar {
  min-height: var(--nav-h);
  background: var(--glass) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--sh-xs);
  transition: min-height var(--t) var(--ease),
              box-shadow var(--t) var(--ease);
  padding: .5rem 0;
}

.navbar.scrolled {
  min-height: 56px;
  box-shadow: var(--sh);
}

.navbar .container-fluid { padding-left: 1.25rem; padding-right: 1.25rem; }

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -.02em;
  color: var(--text) !important;
  transition: transform var(--t) var(--ease-spring);
}

.navbar-brand:hover { transform: translateY(-1px); }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--grad-brand);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.125rem;
  box-shadow: 0 4px 14px -4px rgba(99, 102, 241, .6);
  flex-shrink: 0;
}

.brand-text small {
  display: block;
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.2;
}

.navbar-nav { gap: .125rem; }

.navbar .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: .4375rem;
  padding: .5rem .8125rem;
  border-radius: var(--r-sm);
  font-weight: 550;
  font-size: .875rem;
  color: var(--text-2);
  transition: color var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease);
}

.navbar .nav-link:hover {
  color: var(--text);
  background-color: var(--surface-3);
}

.navbar .nav-link.active {
  color: var(--brand-600);
  background: var(--brand-50);
  font-weight: 650;
}

.navbar .nav-link.active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  width: 18px;
  height: 2.5px;
  border-radius: var(--r-full);
  background: var(--grad-brand);
}

[data-bs-theme="dark"] .navbar .nav-link.active { color: var(--brand-300); }

.navbar .nav-link .badge {
  font-size: .625rem;
  padding: .125rem .375rem;
  border-radius: var(--r-full);
}

.dropdown-menu {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  padding: .375rem;
  min-width: 210px;
  animation: menuIn .18s var(--ease-out);
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.dropdown-item {
  border-radius: var(--r-sm);
  padding: .5rem .6875rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: .5rem;
  transition: all var(--t-fast) var(--ease);
}

.dropdown-item:hover {
  background: var(--brand-50);
  color: var(--brand-600);
  padding-left: .8125rem;
}

.dropdown-item.text-danger:hover { background: var(--danger-soft); color: var(--danger); }
.dropdown-item i { width: 1.125rem; text-align: center; opacity: .85; }
.dropdown-header { font-size: .6875rem; font-weight: 700; text-transform: uppercase;
                   letter-spacing: .08em; color: var(--text-muted); }
.dropdown-divider { border-color: var(--border); margin: .375rem .25rem; }

/* --- Переключатель темы --- */

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-size: .9375rem;
  flex-shrink: 0;
  transition: all var(--t) var(--ease-spring);
}

.theme-toggle:hover {
  color: var(--brand-600);
  border-color: var(--brand-400);
  background: var(--brand-50);
  transform: rotate(-15deg) scale(1.08);
}

.theme-toggle:active { transform: rotate(0) scale(.94); }

.theme-toggle .icon-sun { display: none; }
[data-bs-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
[data-bs-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --- Аватар --- */

.avatar {
  width: var(--size, 36px);
  height: var(--size, 36px);
  border-radius: var(--r-full);
  background: var(--avatar, var(--brand-600));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: calc(var(--size, 36px) * .36);
  letter-spacing: .02em;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
  user-select: none;
}

.avatar-sm { --size: 30px; }
.avatar-lg { --size: 64px; }
.avatar-xl { --size: 96px; }

/* --- Карточки --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  transition: box-shadow var(--t) var(--ease),
              transform var(--t) var(--ease),
              border-color var(--t) var(--ease);
}

.card-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
  border-color: var(--brand-200);
}

.card-glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-brd);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 650;
}

.card-header h5, .card-header h6 { margin: 0; font-size: .9375rem; font-weight: 650; }
.card-header .subtitle { font-size: .75rem; color: var(--text-muted); font-weight: 500; }
.card-body { padding: 1.25rem; }
.card-footer {
  background: transparent;
  border-top: 1px solid var(--border);
  padding: .875rem 1.25rem;
}

/* --- Карточка статистики --- */

.stat-card {
  position: relative;
  padding: 1.25rem 1.375rem;
  border-radius: var(--r-lg);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition: transform var(--t) var(--ease-out), box-shadow var(--t) var(--ease-out);
  height: 100%;
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--grad-brand);
  opacity: 0;
  transition: opacity var(--t) var(--ease);
}

.stat-card:hover { transform: translateY(-4px); box-shadow: var(--sh-lg); }
.stat-card:hover::before { opacity: 1; }

.stat-card .stat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: 1.125rem;
  flex-shrink: 0;
  transition: transform var(--t) var(--ease-spring);
}

.stat-card:hover .stat-icon { transform: scale(1.1) rotate(-6deg); }

.stat-value {
  font-size: 2.125rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  margin-bottom: .375rem;
}

.stat-name {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.35;
}

.stat-meta {
  margin-top: .875rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .75rem;
  color: var(--text-muted);
}

.stat-spark {
  position: absolute;
  right: 1rem;
  bottom: .875rem;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 26px;
  opacity: .55;
}

.stat-spark i {
  width: 3px;
  border-radius: var(--r-full);
  background: var(--grad-brand);
  transition: height var(--t-slow) var(--ease-out);
}

/* --- Цветовые варианты --- */

.tone-brand  { background: rgba(99,102,241,.12);  color: var(--brand-600); }
.tone-cyan   { background: rgba(6,182,212,.12);   color: var(--cyan-600); }
.tone-ok     { background: var(--ok-soft);        color: var(--ok); }
.tone-warn   { background: var(--warn-soft);      color: var(--amber-600); }
.tone-danger { background: var(--danger-soft);    color: var(--danger); }
.tone-ink    { background: var(--surface-3);      color: var(--text-2); }

[data-bs-theme="dark"] .tone-cyan { color: var(--cyan-400); }

/* --- Кнопки --- */

.btn {
  --btn-py: .5625rem;
  --btn-px: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4375rem;
  padding: var(--btn-py) var(--btn-px);
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: .875rem;
  line-height: 1.4;
  border: 1.5px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t) var(--ease),
              background-color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
  white-space: nowrap;
}

.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }

/* Блик пробегает по кнопке */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, transparent 20%,
              rgba(255,255,255,.28) 50%, transparent 80%);
  transform: translateX(-130%);
  transition: transform var(--t-slow) var(--ease);
}

.btn:hover:not(:disabled)::after { transform: translateX(130%); }

.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 2px 8px -2px rgba(79, 70, 229, .5);
}
.btn-primary:hover:not(:disabled) {
  color: #fff;
  box-shadow: 0 8px 22px -6px rgba(79, 70, 229, .65);
  transform: translateY(-1px);
}

.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; color: #fff;
  box-shadow: 0 8px 22px -8px rgba(16,185,129,.6); transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #DC2626; color: #fff;
  box-shadow: 0 8px 22px -8px rgba(239,68,68,.6); transform: translateY(-1px); }

.btn-warning { background: var(--amber-500); color: #451A03; }
.btn-warning:hover:not(:disabled) { background: var(--amber-600); color: #fff; }

.btn-soft {
  background: var(--surface-3);
  color: var(--text-2);
  border-color: var(--border);
}
.btn-soft:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.btn-outline-primary { border-color: var(--brand-400); color: var(--brand-600); background: transparent; }
.btn-outline-primary:hover:not(:disabled) {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff;
  box-shadow: 0 6px 18px -6px rgba(79,70,229,.5);
}

.btn-outline-secondary { border-color: var(--border-strong); color: var(--text-2); }
.btn-outline-secondary:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-lg { --btn-py: .75rem; --btn-px: 1.5rem; font-size: .9375rem; border-radius: var(--r); }
.btn-sm { --btn-py: .3125rem; --btn-px: .625rem; font-size: .8125rem; border-radius: var(--r-xs); }
.btn-icon { --btn-px: .5rem; --btn-py: .5rem; width: 36px; height: 36px; border-radius: var(--r-sm); }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-icon.btn-lg { width: 44px; height: 44px; }
.btn-block { width: 100%; }

/* --- Бейджи и пилюли --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3125rem;
  padding: .25rem .5625rem;
  border-radius: var(--r-full);
  font-size: .6875rem;
  font-weight: 650;
  letter-spacing: .01em;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-soft-brand  { background: rgba(99,102,241,.12);  color: var(--brand-600); }
.badge-soft-cyan   { background: rgba(6,182,212,.12);   color: var(--cyan-600); }
.badge-soft-ok     { background: var(--ok-soft);        color: #047857; }
.badge-soft-warn   { background: var(--warn-soft);      color: #B45309; }
.badge-soft-danger { background: var(--danger-soft);    color: #B91C1C; }
.badge-soft-ink    { background: var(--surface-3);      color: var(--text-2); }

[data-bs-theme="dark"] .badge-soft-ok     { color: #34D399; }
[data-bs-theme="dark"] .badge-soft-warn   { color: #FBBF24; }
[data-bs-theme="dark"] .badge-soft-danger { color: #F87171; }
[data-bs-theme="dark"] .badge-soft-cyan   { color: var(--cyan-400); }

.badge-pulse {
  position: relative;
}
.badge-pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: .35;
  animation: badgePulse 2s var(--ease) infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); opacity: .35; }
  50%      { transform: scale(1.35); opacity: 0; }
}

.plate {
  display: inline-flex;
  align-items: center;
  gap: .3125rem;
  font-family: 'Roboto Mono', 'SF Mono', ui-monospace, monospace;
  font-weight: 700;
  font-size: .8125rem;
  letter-spacing: .04em;
  padding: .1875rem .5rem;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
}

/* --- Прогресс --- */

.progress {
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  height: 8px;
}
.progress-bar {
  background: var(--grad-brand);
  border-radius: var(--r-full);
  transition: width var(--t-slow) var(--ease-out);
}
.progress-bar.bar-ok   { background: var(--grad-ok); }
.progress-bar.bar-warn { background: linear-gradient(90deg, var(--amber-500), #F97316); }

/* --- Таблицы --- */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--surface-2);
  margin-bottom: 0;
  font-size: .875rem;
}

.table > thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: .75rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.table > tbody td {
  padding: .875rem 1rem;
  border-color: var(--border);
  vertical-align: middle;
}

.table > tbody tr { transition: background-color var(--t-fast) var(--ease); }
.table > tbody tr:hover { background: var(--surface-2); }
.table > tbody tr:last-child td { border-bottom: none; }
.table-responsive { border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* --- Модалки --- */

.modal-backdrop.show { opacity: .5; backdrop-filter: blur(3px); }

.modal-content {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  animation: modalIn .28s var(--ease-out);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.125rem 1.5rem;
  align-items: center;
}
.modal-title { font-size: 1.0625rem; font-weight: 700; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  gap: .5rem;
}
.modal-header .btn-close,
.modal-header .btn-close-white { opacity: .5; transition: opacity var(--t-fast); }
.modal-header .btn-close:hover { opacity: 1; }

/* --- Тосты --- */

.toast-container { z-index: 1090; }

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  overflow: hidden;
  animation: toastIn .32s var(--ease-spring);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(110%); }
  to   { opacity: 1; transform: none; }
}

.toast.toast-hide { animation: toastOut .22s var(--ease) forwards; }

@keyframes toastOut {
  to { opacity: 0; transform: translateX(110%); }
}

.toast-body {
  padding: .8125rem 1rem;
  display: flex;
  align-items: center;
  gap: .625rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
}

.toast .toast-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  font-size: .875rem;
  flex-shrink: 0;
}

.toast.t-success { border-left: 3px solid var(--ok); }
.toast.t-error   { border-left: 3px solid var(--danger); }
.toast.t-warning { border-left: 3px solid var(--amber-500); }
.toast.t-info    { border-left: 3px solid var(--cyan-500); }

/* --- Флеш-уведомления (страница) --- */

.flash-stack {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  right: 16px;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: min(380px, calc(100vw - 32px));
}

.flash-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .8125rem 1rem;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-lg);
  font-size: .875rem;
  font-weight: 500;
  animation: toastIn .34s var(--ease-spring);
}

.flash-item .flash-icon {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  font-size: .8125rem;
  flex-shrink: 0;
}
.flash-item .flash-body { flex: 1; min-width: 0; line-height: 1.45; }
.flash-item .btn-close { font-size: .625rem; opacity: .4; }
.flash-item.leaving { animation: toastOut .2s var(--ease) forwards; }
.flash-item.f-success { border-left: 3px solid var(--ok); }
.flash-item.f-error   { border-left: 3px solid var(--danger); }
.flash-item.f-warning { border-left: 3px solid var(--amber-500); }
.flash-item.f-info    { border-left: 3px solid var(--cyan-500); }

/* --- Скелетоны --- */

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%,
              var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-xs);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}

@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.skel-line { height: 12px; margin-bottom: 8px; }
.skel-title { height: 20px; width: 45%; margin-bottom: 14px; }
.skel-avatar { width: 36px; height: 36px; border-radius: var(--r-full); }

/* --- Пустое состояние --- */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  animation: fadeUp .45s var(--ease-out);
}

.empty-state .empty-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 1.25rem;
  border-radius: var(--r-xl);
  background: var(--brand-50);
  color: var(--brand-500);
  display: grid;
  place-items: center;
  font-size: 2rem;
}

.empty-state h3 { font-size: 1.0625rem; font-weight: 700; margin-bottom: .4375rem; }
.empty-state p { color: var(--text-muted); font-size: .875rem; max-width: 34ch;
                 margin: 0 auto 1.25rem; }

/* --- Разделитель --- */

.divider { height: 1px; background: var(--border); border: none; opacity: 1; margin: 0; }
.divider-text {
  display: flex; align-items: center; gap: .75rem;
  color: var(--text-muted); font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; margin: 1.25rem 0;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* --- Страница --- */

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 1.5rem) 1.25rem 3rem;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-head h1 { margin: 0 0 .3125rem; }
.page-head p { margin: 0; color: var(--text-muted); font-size: .875rem; }

/* --- Подвал --- */

.footer {
  flex-shrink: 0;
  padding: 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-size: .8125rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer a { color: var(--text-muted); text-decoration: none; }
.footer a:hover { color: var(--brand-600); }

/* --- Пагинация --- */

.pagination { gap: .25rem; margin: 0; }
.page-link {
  border-radius: var(--r-sm) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-2) !important;
  background: var(--surface) !important;
  padding: .4375rem .75rem !important;
  font-size: .8125rem !important;
  font-weight: 600 !important;
  transition: all var(--t-fast) var(--ease);
}
.page-link:hover { background: var(--surface-3) !important; color: var(--text) !important;
                  border-color: var(--brand-300) !important; }
.page-item.active .page-link {
  background: var(--grad-brand) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 2px 8px -2px rgba(79,70,229,.5);
}
.page-item.disabled .page-link { opacity: .4; }

/* --- Лента активности --- */

.activity-feed { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  gap: .8125rem;
  padding: .75rem 0;
  position: relative;
}

.activity-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 42px;
  bottom: -4px;
  width: 1.5px;
  background: var(--border);
}

.activity-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  font-size: .8125rem;
  flex-shrink: 0;
  z-index: 1;
}

.activity-text { flex: 1; min-width: 0; font-size: .875rem; line-height: 1.45; }
.activity-text strong { font-weight: 650; }
.activity-time { font-size: .6875rem; color: var(--text-muted); margin-top: .1875rem; }

/* --- Анимации появления --- */

.fade-up { animation: fadeUp .5s var(--ease-out) both; }
.stagger > * { animation: fadeUp .5s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: .04s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .12s; }
.stagger > *:nth-child(4) { animation-delay: .16s; }
.stagger > *:nth-child(5) { animation-delay: .2s; }
.stagger > *:nth-child(6) { animation-delay: .24s; }
.stagger > *:nth-child(7) { animation-delay: .28s; }
.stagger > *:nth-child(8) { animation-delay: .32s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Команданая палитра --- */

.cmdk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1085;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 1rem;
  animation: fadeIn .18s var(--ease);
}

.cmdk-panel {
  width: min(600px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xl);
  overflow: hidden;
  animation: cmdkIn .26s var(--ease-out);
}

@keyframes cmdkIn {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.cmdk-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 1rem 1.125rem;
  font-size: 1rem;
  color: var(--text);
  outline: none;
}

.cmdk-input::placeholder { color: var(--text-muted); }

.cmdk-results {
  max-height: 340px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding: .375rem;
}

.cmdk-group-label {
  font-size: .625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
  padding: .5rem .625rem .25rem;
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .75rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-2);
  transition: background-color var(--t-fast) var(--ease);
}

.cmdk-item.active { background: var(--brand-50); color: var(--brand-600); }
.cmdk-item i.cmdk-icon {
  width: 30px; height: 30px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  display: grid; place-items: center;
  font-size: .8125rem; flex-shrink: 0;
}
.cmdk-item.active i.cmdk-icon { background: var(--brand-500); color: #fff; }
.cmdk-item .cmdk-main { flex: 1; min-width: 0; }
.cmdk-item .cmdk-title { font-weight: 600; color: var(--text); }
.cmdk-item.active .cmdk-title { color: var(--brand-600); }
.cmdk-item .cmdk-sub {
  font-size: .75rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cmdk-footer {
  display: flex; gap: 1rem; padding: .5rem .875rem;
  border-top: 1px solid var(--border);
  font-size: .6875rem; color: var(--text-muted);
  background: var(--surface-2);
}

.cmdk-footer kbd {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 .25rem;
  font-size: .625rem;
  font-family: inherit;
}

/* --- Мобильные таблицы как карточки --- */

@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td {
    display: block; width: 100%;
  }
  .table-cards tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: .75rem;
    padding: .875rem 1rem;
    box-shadow: var(--sh-xs);
  }
  .table-cards td {
    padding: .3125rem 0 !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
  .table-cards td::before {
    content: attr(data-label);
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .table-cards td:empty { display: none; }
}

/* --- Планшет --- */

@media (max-width: 991.98px) {
  :root { --nav-h: 62px; }
  .navbar-collapse {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-top: .625rem;
    padding: .5rem;
    box-shadow: var(--sh-lg);
    max-height: calc(100vh - var(--nav-h) - 2rem);
    overflow-y: auto;
  }
  .navbar .nav-link { padding: .6875rem .875rem; }
  .page { padding-left: 1rem; padding-right: 1rem; }
}

/* --- Телефон --- */

@media (max-width: 575.98px) {
  :root { --nav-h: 58px; }

  .page { padding: calc(var(--nav-h) + 1rem) .875rem 5rem; }

  .btn:not(.btn-sm):not(.btn-icon) { font-size: .8125rem; }
  .btn-block-sm { width: 100%; }

  .card { border-radius: var(--r); }
  .card-body { padding: 1rem; }

  .page-head { flex-direction: column; align-items: stretch; gap: .875rem; }
  .page-head .btn { width: 100%; }

  .stat-value { font-size: 1.75rem; }
  .stat-card { padding: 1rem 1.125rem; }
  .stat-icon { width: 34px; height: 34px; font-size: 1rem; }

  .flash-stack {
    top: auto;
    bottom: 1rem;
    right: .75rem;
    left: .75rem;
    max-width: none;
  }

  .modal-dialog { margin: .75rem; }
  .modal-content { border-radius: var(--r-lg); }
  .modal-body { padding: 1.125rem; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }

  .footer-inner { flex-direction: column; text-align: center; gap: .5rem; }

  .form-control, .form-select { font-size: 16px; min-height: 44px; } /* без зума на iOS */

  .cmdk-backdrop { padding: 8vh .75rem .75rem; }

  .fab {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1030;
    width: 56px;
    height: 56px;
    border-radius: var(--r-full);
    background: var(--grad-brand);
    color: #fff;
    border: none;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    box-shadow: 0 10px 28px -8px rgba(79, 70, 229, .7);
    transition: transform var(--t) var(--ease-spring);
  }
  .fab:active { transform: scale(.9); }
  .fab d-none { display: none !important; }
}

/* Минимум 44px для касаний на телефоне */
@media (max-width: 767.98px) {
  .btn, .nav-link, .page-link, .form-select, .form-control {
    min-height: var(--tap);
  }
  .btn-sm, .btn-icon.btn-sm { min-height: 34px; }
  .btn-icon { width: 40px; height: 40px; }
}

/* ==========================================================
   Предпросмотр печатного бланка на странице настроек
   Повторяет .sheet-head из print.css, чтобы предпросмотр
   совпадал с настоящим бланком
   ========================================================== */
.preview-sheet {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-radius: .5rem;
  background: var(--surface-2);
}

.preview-org {
  font-size: .8125rem;
  line-height: 1.4;
  color: var(--text-2);
}
.preview-org strong {
  display: block;
  font-size: .9375rem;
  margin-bottom: .1875rem;
  color: var(--text);
}
.preview-org span { display: block; }
.preview-org span[hidden] { display: none; }

.preview-title { text-align: right; }
.preview-doc {
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text);
  line-height: 1.3;
}
.preview-no {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}