/* ==========================================================================
   ЦЕНТР+ сборы — современный слой оформления
   Подключается последним: уточняет и объединяет стили всех модулей.
   ========================================================================== */

:root {
  /* Палитра */
  --c-bg: #f4f6fb;
  --c-surface: #ffffff;
  --c-surface-2: #f8fafc;
  --c-border: #e6eaf2;
  --c-border-strong: #d5dceb;
  --c-text: #0f172a;
  --c-text-2: #475569;
  --c-muted: #7c8798;
  --c-brand: #2563eb;
  --c-brand-2: #1d4ed8;
  --c-brand-soft: #eff4ff;
  --c-success: #059669;
  --c-warning: #d97706;
  --c-danger: #dc2626;
  --c-radius: 14px;
  --c-radius-sm: 10px;
  --c-radius-lg: 20px;
  --c-shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --c-shadow: 0 4px 16px -4px rgba(15, 23, 42, .10), 0 2px 6px -2px rgba(15, 23, 42, .06);
  --c-shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .22);
  --c-ring: 0 0 0 3px rgba(37, 99, 235, .22);
  --c-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sidebar-w: 272px;
}

body.dark-theme {
  --c-bg: #0b1220;
  --c-surface: #131c2e;
  --c-surface-2: #0f172a;
  --c-border: #24314a;
  --c-border-strong: #31405c;
  --c-text: #e6edf7;
  --c-text-2: #a9b6c9;
  --c-muted: #7d8ba1;
  --c-brand: #3b82f6;
  --c-brand-2: #2563eb;
  --c-brand-soft: #16233c;
  --c-success: #34d399;
  --c-warning: #fbbf24;
  --c-danger: #f87171;
  --c-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --c-shadow: 0 6px 20px -6px rgba(0, 0, 0, .55);
  --c-shadow-lg: 0 28px 60px -16px rgba(0, 0, 0, .7);
  --c-ring: 0 0 0 3px rgba(96, 165, 250, .28);
}

/* ---------- База ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--c-font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.dark-theme { background: var(--c-bg); color: var(--c-text); }
body.dark-theme .main-content { background: var(--c-bg); }

::selection { background: rgba(37, 99, 235, .18); }

*:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Скроллбары */
* { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--c-muted); background-clip: content-box; }

/* ---------- Каркас ---------- */
.app-container { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  box-shadow: none;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar.collapsed { flex-basis: 80px; }
.sidebar-header {
  padding: 16px;
  gap: 8px;
  border-bottom: 1px solid var(--c-border);
  min-height: 72px;
}
.sidebar-logo-img {
  max-height: 40px;
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
  max-width: calc(var(--sidebar-w) - 88px);
  object-fit: contain;
}
.toggle-btn { color: var(--c-text-2); border-radius: 10px; width: 36px; height: 36px; flex: 0 0 36px; display: inline-flex; align-items: center; justify-content: center; }
.toggle-btn:hover { background: var(--c-brand-soft); color: var(--c-brand); }

.sidebar-nav { padding: 14px 10px; gap: 2px; }
.nav-item {
  padding: 10px 12px;
  border-radius: var(--c-radius-sm);
  color: var(--c-text-2);
  font-weight: 500;
  font-size: .93rem;
  gap: 11px;
  transition: background .16s ease, color .16s ease;
}
.nav-item i { width: 20px; font-size: 1rem; color: var(--c-muted); transition: color .16s ease; }
.nav-item:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-item:hover i { color: var(--c-brand); }
.nav-item.active,
body.dark-theme .nav-item.active,
.nav-group.active > .nav-item {
  background: var(--c-brand);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .65);
}
.nav-item.active i, .nav-item.active span,
.nav-group.active > .nav-item i, .nav-group.active > .nav-item span { color: #fff; }

.sub-item { padding-left: 43px !important; font-size: .88rem; }
.submenu { border-left: 1px solid var(--c-border); margin-left: 22px; padding-left: 0; }
.submenu .nav-item { border-radius: 8px; }
.sidebar-footer { border-top: 1px solid var(--c-border); padding: 10px 12px; }

body.dark-theme .sidebar { background: var(--c-surface); border-right-color: var(--c-border); }
body.dark-theme .sidebar-header, body.dark-theme .sidebar-footer { border-color: var(--c-border); }
body.dark-theme .nav-item { color: var(--c-text-2); }
body.dark-theme .nav-item i { color: var(--c-muted); }
body.dark-theme .nav-item:hover { background: var(--c-surface-2); color: var(--c-text); }

/* ---------- Контент ---------- */
.main-content { background: var(--c-bg); padding: 22px 32px 48px; min-width: 0; }
.content-header { margin-bottom: 20px; }
.content-header h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.02em;
  background: none;
  -webkit-background-clip: border-box;
  color: var(--c-text);
}
body.dark-theme .content-header h1 { background: none; color: var(--c-text); }

.theme-toggle {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-2);
  width: 42px; height: 42px;
  border-radius: 12px;
  box-shadow: var(--c-shadow-sm);
}
.theme-toggle:hover { background: var(--c-brand-soft); border-color: var(--c-brand); color: var(--c-brand); transform: none; }
body.dark-theme .theme-toggle { background: var(--c-surface); color: var(--c-warning); border-color: var(--c-border); }

/* ---------- Кнопки ---------- */
.btn {
  border-radius: var(--c-radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  font-size: .88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.2;
  box-shadow: none;
  transition: background .16s ease, box-shadow .16s ease, color .16s ease, border-color .16s ease;
}
.btn.add, .btn.primary {
  background: var(--c-brand);
  color: #fff;
  box-shadow: 0 2px 8px -2px rgba(37, 99, 235, .55);
}
.btn.add:hover, .btn.primary:hover { background: var(--c-brand-2); transform: none; filter: none; }
.btn.cancel { background: var(--c-surface); color: var(--c-text-2); border: 1px solid var(--c-border); }
.btn.cancel:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
body.dark-theme .btn.cancel { background: var(--c-surface-2); color: var(--c-text-2); border-color: var(--c-border); }

.edit-btn, .delete-btn { width: 34px; height: 34px; border-radius: 9px; }
.edit-btn:hover, .delete-btn:hover { transform: none; }
.edit-btn { color: var(--c-brand); }
.edit-btn:hover { background: var(--c-brand-soft); }
.delete-btn { color: var(--c-danger); }
.delete-btn:hover { background: rgba(220, 38, 38, .1); }
body.dark-theme .edit-btn:hover { background: #1c2f52; }
body.dark-theme .delete-btn:hover { background: rgba(248, 113, 113, .14); }

/* ---------- Таблицы ---------- */
.table-container, .collections-table-container, .employees-table-container,
.invoices-table-container, .requests-table-container, .schools-table-container {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  box-shadow: var(--c-shadow-sm);
  overflow-x: auto;
}
.modern-table, .collections-table, .employees-table, .invoices-table {
  font-size: .88rem;
  border-collapse: collapse;
}
.modern-table th, .collections-table th, .employees-table th, .invoices-table th {
  background: var(--c-surface-2);
  color: var(--c-muted);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.modern-table td, .collections-table td, .employees-table td, .invoices-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
  vertical-align: middle;
}
.modern-table tbody tr:last-child td, .collections-table tbody tr:last-child td,
.employees-table tbody tr:last-child td, .invoices-table tbody tr:last-child td { border-bottom: none; }
.modern-table tbody tr, .collections-table tbody tr, .employees-table tbody tr, .invoices-table tbody tr { transition: background .12s ease; }
.modern-table tbody tr:hover td, .collections-table tbody tr:hover td,
.employees-table tbody tr:hover td, .invoices-table tbody tr:hover td { background: var(--c-brand-soft); }
body.dark-theme .table-container, body.dark-theme .collections-table-container,
body.dark-theme .employees-table-container, body.dark-theme .invoices-table-container { background: var(--c-surface); border-color: var(--c-border); }
body.dark-theme .modern-table th, body.dark-theme .collections-table th,
body.dark-theme .employees-table th, body.dark-theme .invoices-table th { background: var(--c-surface-2); color: var(--c-muted); border-bottom-color: var(--c-border); }
body.dark-theme .modern-table td, body.dark-theme .collections-table td,
body.dark-theme .employees-table td, body.dark-theme .invoices-table td { color: var(--c-text); border-bottom-color: var(--c-border); }
body.dark-theme .modern-table tbody tr:hover td, body.dark-theme .collections-table tbody tr:hover td,
body.dark-theme .employees-table tbody tr:hover td, body.dark-theme .invoices-table tbody tr:hover td { background: var(--c-brand-soft); }

.collection-row { cursor: pointer; }
.collection-row:hover td { background: var(--c-brand-soft) !important; }

/* Таблица сотрудников: не сжимать ФИО и должность */
.employees-table th { white-space: normal; }
.employees-table td { word-break: normal; }
.employees-table th, .employees-table td { padding: 10px 8px; }
.employees-table th:nth-child(2), .employees-table td:nth-child(2) { min-width: 110px; }
.employees-table th:nth-child(3), .employees-table td:nth-child(3) { min-width: 190px; }
.employees-table th:last-child, .employees-table td:last-child { width: 76px; min-width: 76px; }

/* Плотность и переносы: цифры и даты не ломаются по строкам */
.collections-table th, .collections-table td { white-space: nowrap; }
.collections-table td:nth-child(5), .collections-table td:nth-child(6),
.collections-table td:nth-child(7), .collections-table td:nth-child(13) { white-space: normal; }
.collections-table td:nth-child(6), .collections-table td:nth-child(7) { min-width: 140px; }
.collections-table td:last-child { width: 1%; }
.collections-table td:last-child .edit-btn, .collections-table td:last-child .delete-btn { vertical-align: middle; }

/* ---------- Оценки ---------- */
.btn.calc-final, body.dark-theme .btn.calc-final { background: var(--c-brand); color: #fff; }
.btn.calc-final:hover, body.dark-theme .btn.calc-final:hover { background: var(--c-brand-2); }
.btn.export-excel, body.dark-theme .btn.export-excel { background: var(--c-surface); color: var(--c-text-2); border: 1px solid var(--c-border); }
.btn.export-excel:hover, body.dark-theme .btn.export-excel:hover { background: var(--c-surface-2); color: var(--c-text); }

/* ---------- Документы ---------- */
.doc-btn {
  border-radius: 10px;
  padding: 8px 14px;
  font-size: .84rem;
  font-weight: 600;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.doc-btn.generate { background: var(--c-brand); color: #fff; box-shadow: none; }
.doc-btn.generate:hover { background: var(--c-brand-2); transform: none; box-shadow: none; }
.doc-btn.print { background: var(--c-surface); color: var(--c-text-2); border: 1px solid var(--c-border); }
.doc-btn.print:hover { background: var(--c-surface-2); color: var(--c-text); transform: none; }
body.dark-theme .doc-btn.print { background: var(--c-surface); color: var(--c-text-2); border-color: var(--c-border); }
body.dark-theme .doc-btn.print:hover { background: var(--c-surface-2); color: var(--c-text); }
.doc-item-title { font-weight: 600; }

/* ---------- Бейджи ---------- */
.badge, .status-badge, .type-badge, .priority-badge, .role-badge, .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

/* ---------- Сводка ---------- */
.collections-summary { gap: 12px; background: transparent; border: none; padding: 0; }
body.dark-theme .collections-summary { background: transparent; border: none; }
.summary-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  box-shadow: var(--c-shadow-sm);
  padding: 14px 18px;
  min-width: 150px;
  transition: box-shadow .16s ease, transform .16s ease;
}
.summary-card:hover { box-shadow: var(--c-shadow); transform: translateY(-1px); }
.summary-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); font-weight: 600; white-space: nowrap; }
.summary-value { font-size: 1.6rem; font-weight: 700; color: var(--c-text); letter-spacing: -.02em; }
body.dark-theme .summary-card { background: var(--c-surface); border-color: var(--c-border); }
body.dark-theme .summary-value { color: var(--c-text); }

.collections-filter-panel {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius) !important;
  box-shadow: var(--c-shadow-sm);
  padding: 12px 16px !important;
}
.filter-date-input, .filter-input {
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius-sm);
  padding: 8px 12px;
  font-family: inherit;
  font-size: .88rem;
  background: var(--c-surface);
  color: var(--c-text);
}
.filter-date-input:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--c-ring); }

.filter-search { position: relative; display: flex; align-items: center; flex: 1 1 240px; min-width: 200px; }
.filter-search i { position: absolute; left: 12px; color: var(--c-muted); font-size: .85rem; pointer-events: none; }
.filter-search .filter-input { width: 100%; padding-left: 34px; }
.filter-search .filter-input:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--c-ring); }

th.sortable { transition: color .12s ease, background .12s ease; }
th.sortable:hover { color: var(--c-brand) !important; background: var(--c-brand-soft); }

/* ---------- Формы и модалки ---------- */
.form-group input, .form-group select, .form-group textarea,
.modal input[type="text"], .modal input[type="date"], .modal input[type="number"],
.modal input[type="tel"], .modal input[type="email"], .modal select {
  border-radius: var(--c-radius-sm);
  border: 1px solid var(--c-border);
  background-color: var(--c-surface);
  color: var(--c-text);
  padding: 11px 13px;
  font-size: .9rem;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.form-group select, .modal select, .cm-input:is(select) {
  padding-right: 34px;
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus,
.modal input:focus, .modal select:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: var(--c-ring);
}
.form-group label { color: var(--c-text-2); font-weight: 600; font-size: .82rem; }

.modal { background: rgba(9, 14, 26, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-content {
  border-radius: var(--c-radius-lg);
  box-shadow: var(--c-shadow-lg);
  border: 1px solid var(--c-border);
  animation: modal-in .18s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-header { padding: 20px 24px 14px; border-bottom: 1px solid var(--c-border); }
.modal-header h2 { font-size: 1.18rem; font-weight: 650; letter-spacing: -.01em; }
.modal-header h2 i { color: var(--c-brand); }
.close-modal { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }
.close-modal:hover { background: rgba(220, 38, 38, .1); color: var(--c-danger); }
.form-actions { background: var(--c-surface-2); border-radius: 0 0 var(--c-radius-lg) var(--c-radius-lg); }
body.dark-theme .modal-content { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }body.dark-theme .modal-header, body.dark-theme .form-actions { border-color: var(--c-border); }
body.dark-theme .form-actions { background: var(--c-surface-2); }
body.dark-theme .form-group input, body.dark-theme .form-group select, body.dark-theme .form-group textarea { background: var(--c-surface-2); border-color: var(--c-border); color: var(--c-text); }
body.dark-theme select { background-color: var(--c-surface-2); border-color: var(--c-border); color: var(--c-text); }

/* Тёмная тема: гасим жёстко прописанные белые фоны в разметке модулей */
body.dark-theme [style*="background:white"],
body.dark-theme [style*="background: white"],
body.dark-theme [style*="background:#fff"],
body.dark-theme [style*="background: #fff"] { background: var(--c-surface) !important; }

/* ---------- Пустые состояния ---------- */
.empty-message, .loading-cell, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px !important;
  color: var(--c-muted);
  font-size: .92rem;
  text-align: center;
}
.empty-state i { font-size: 2rem; opacity: .5; }

/* ---------- Тосты ---------- */
#toastStack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-brand);
  border-radius: 12px;
  padding: 13px 15px;
  box-shadow: var(--c-shadow-lg);
  font-size: .88rem;
  line-height: 1.45;
  animation: toast-in .22s cubic-bezier(.2, .8, .3, 1);
}
.toast.is-leaving { animation: toast-out .18s ease-in forwards; }
.toast i { font-size: 1rem; margin-top: 2px; color: var(--c-brand); }
.toast--success { border-left-color: var(--c-success); }
.toast--success i { color: var(--c-success); }
.toast--error { border-left-color: var(--c-danger); }
.toast--error i { color: var(--c-danger); }
.toast--warning { border-left-color: var(--c-warning); }
.toast--warning i { color: var(--c-warning); }
.toast__body { flex: 1; }
.toast__title { font-weight: 650; margin-bottom: 2px; }
.toast__close { background: none; border: none; color: var(--c-muted); cursor: pointer; font-size: 1rem; padding: 0 2px; line-height: 1; }
.toast__close:hover { color: var(--c-text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }

/* Когда открыта боковая панель задачи, уведомления не должны закрывать
   кнопки «Сохранить / Завершить» в её нижней части. */
body.dv-no-scroll #toastStack {
  right: calc(min(460px, 100vw) + 16px);
  bottom: 20px;
  transition: right .2s ease, left .2s ease, bottom .2s ease;
}
body.sp-no-scroll #toastStack {
  right: calc(min(540px, 100vw) + 16px);
  bottom: 20px;
  transition: right .2s ease, left .2s ease, bottom .2s ease;
}

@media (max-width: 1280px) {
  body.dv-no-scroll #toastStack,
  body.sp-no-scroll #toastStack {
    right: 12px;
    left: auto;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    max-width: min(380px, calc(100vw - 24px));
  }
}

@media (max-width: 560px) {
  body.dv-no-scroll #toastStack,
  body.sp-no-scroll #toastStack {
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

/* ---------- Индикатор загрузки ---------- */
#topProgress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--c-brand), #60a5fa);
  z-index: 4000;
  opacity: 0;
  transition: width .25s ease, opacity .3s ease;
  box-shadow: 0 0 8px rgba(37, 99, 235, .6);
}
#topProgress.is-active { opacity: 1; }

/* ---------- Скелетоны ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--c-surface-2);
  border-radius: 8px;
  color: transparent !important;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: shimmer 1.4s infinite;
}
body.dark-theme .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- Доступность ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--c-brand);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  z-index: 5000;
  font-weight: 600;
}
.skip-link:focus { left: 0; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Мелочи ---------- */
.fab { box-shadow: 0 8px 24px -6px rgba(37, 99, 235, .6); }
.fab:hover { transform: translateY(-2px); }

a { color: var(--c-brand); }

/* ---------- Адаптивность ---------- */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-2);
  cursor: pointer;
  flex: 0 0 40px;
}
.mobile-menu-btn:hover { background: var(--c-brand-soft); color: var(--c-brand); }

@media (max-width: 900px) {
  .mobile-menu-btn { display: inline-flex; }
  .content-header { display: flex; align-items: center; gap: 12px; }
  .content-header h1 { flex: 1; }
  .main-content { padding: 18px 16px 40px; }
  .content-header h1 { font-size: 1.3rem; }

  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-100%); width: var(--sidebar-w); box-shadow: var(--c-shadow-lg); }
  .sidebar.collapsed .sidebar-logo-img, .sidebar.collapsed .nav-item span { display: initial; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .sidebar.collapsed .sub-item { padding-left: 43px !important; }
  .sidebar.collapsed .sub-item span { display: inline !important; }
  .sidebar.collapsed .sidebar-logo-img { display: block; }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(9, 14, 26, .45);
    backdrop-filter: blur(2px);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }

  .collections-summary { width: 100%; flex-wrap: wrap; }
  .summary-card { flex: 1 1 140px; min-width: 0; }
  .collections-filter-panel { gap: 10px !important; }
  .filter-search { flex: 1 1 100%; }
}

@media (max-width: 640px) {
  .content-header { margin-bottom: 14px; }
  .collections-header { flex-direction: column; align-items: stretch; gap: 14px; }
  .summary-value { font-size: 1.3rem; }
  .filter-date-input { flex: 1 1 100%; }
  #toastStack { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .modal-content { border-radius: 16px; }
  .btn { padding: 10px 14px; }
}

/* ---------- Печать ---------- */
@media print {
  .sidebar, .content-header, .theme-toggle, .fab, #toastStack, #topProgress { display: none !important; }
  .main-content { padding: 0; background: #fff; }
  .modal { position: static; background: none; display: block !important; }
  body { background: #fff; }
}

/* ---------- Компактные таблицы (настройка пользователя) ---------- */
body.compact-tables .modern-table td,
body.compact-tables .collections-table td,
body.compact-tables .employees-table td,
body.compact-tables .invoices-table td,
body.compact-tables .au-table td,
body.compact-tables .au-audit-table td {
  padding-top: 5px;
  padding-bottom: 5px;
}
body.compact-tables .au-request { padding-top: 9px; padding-bottom: 9px; }
body.compact-tables .au-perm-row { padding-top: 2px; padding-bottom: 2px; }

/* ---------- Сотрудники: учётная запись ---------- */
.employees-table--accounts { table-layout: fixed; min-width: 720px; font-size: .82rem; }
.employees-table--accounts th, .employees-table--accounts td { padding: 9px 7px; }
.employees-table--accounts th:nth-child(2), .employees-table--accounts td:nth-child(2),
.employees-table--accounts th:nth-child(3), .employees-table--accounts td:nth-child(3) { min-width: 0; }
.employees-table--accounts th:last-child, .employees-table--accounts td:last-child { width: 90px; min-width: 90px; overflow: visible; text-overflow: clip; white-space: nowrap; }
.employees-table--accounts td { overflow: hidden; text-overflow: ellipsis; }
.employees-table--accounts td:nth-child(7) .status-badge { font-size: .66rem; padding: 2px 7px; }
.employees-table--accounts .employee-account { font-size: .68rem; padding: 2px 5px; gap: 4px; }
.employees-table--accounts .employee-account .ui-avatar--xs { --ui-avatar-size: 18px; }
.employees-table--accounts td:nth-child(5) .status-badge { font-size: .62rem; padding: 1px 5px; }
.employees-table--accounts td:nth-child(2), .employees-table--accounts td:nth-child(3),
.employees-table--accounts td:nth-child(6) { white-space: normal; overflow-wrap: anywhere; }
.employees-table--accounts .employee-account { max-width: 100%; overflow: hidden; }
.employees-table--accounts .employee-account span:last-child { overflow: hidden; text-overflow: ellipsis; }
.employee-exp { display: inline-block; margin-top: 2px; font-size: .66rem; font-weight: 400; color: var(--c-muted); white-space: nowrap; }
body.dark-theme .employee-exp { color: var(--c-muted); }

.employee-account {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 4px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-text-2);
  font: inherit;
  font-size: .74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.employee-account:hover { border-color: var(--c-brand); color: var(--c-brand); background: var(--c-brand-soft); }
.employee-account--empty { border-style: dashed; color: var(--c-muted); padding: 3px 9px; }
.employee-account--empty:hover { border-color: var(--c-brand); color: var(--c-brand); }
.employee-account .ui-avatar { box-shadow: none; }
.employee-account > i { color: var(--c-brand); font-size: .82rem; flex: 0 0 auto; }
body.dark-theme .employee-account { background: var(--c-surface-2); border-color: var(--c-border); color: var(--c-text-2); }
body.dark-theme .employee-account:hover { background: #16233c; border-color: var(--c-brand); }

/* ---------- Сотрудники: адаптивная раскладка ---------- */
.employees-layout { min-width: 0; }
.employees-layout > #birthdayPanel { flex: 0 0 300px; }
@media (max-width: 1000px) {
  .employees-layout { flex-direction: column; }
  .employees-layout > #birthdayPanel { width: 100% !important; flex-basis: auto; }
}
@media (max-width: 1000px) {
  .employees-layout { align-items: stretch !important; }
  .employees-layout > div { max-width: 100%; min-width: 0; }
}
