/* ==========================================================================
   СБОРЫ — окно школ, список сборов, формы
   ========================================================================== */

/* ---------- Список сборов ---------- */
.collections-table-container { padding: 0; }
.collections-table { font-size: .85rem; table-layout: fixed; }
.collections-table thead th {
  position: sticky; top: 0; z-index: 1;
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--c-muted, #7c8798); font-weight: 700;
  padding: 10px 10px; border-bottom: 1px solid var(--c-border, #e6eaf2);
  background: var(--c-surface-2, #f8fafc);
}
.collections-table tbody td { padding: 11px 10px; border-bottom: 1px solid var(--c-border, #e6eaf2); }
.collections-table tbody tr:last-child td { border-bottom: none; }
.collections-table thead th, .collections-table tbody td { overflow: hidden; text-overflow: ellipsis; }
.coll-idx { width: 4%; text-align: center; color: var(--c-muted, #7c8798); font-weight: 600; }
.coll-date { width: 8%; white-space: nowrap; font-weight: 600; }
.coll-type { width: 8%; white-space: nowrap; }
.coll-status { width: 8%; white-space: nowrap; }
.coll-unit { width: 6%; white-space: nowrap; }
.coll-cmd { width: 10.5%; white-space: nowrap; }
.coll-teacher { width: 14%; white-space: nowrap; }
.coll-num { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; padding-left: 6px !important; padding-right: 6px !important; }
.coll-schools, .coll-plan, .coll-percent { width: 4.5%; }
.coll-arrived { width: 6%; }
.coll-missing { width: 6.5%; }
.coll-ok { color: var(--c-success, #059669); }
.coll-bad { color: var(--c-danger, #dc2626); }
.coll-actions { width: 7%; text-align: right; white-space: nowrap; }
.coll-actions .edit-btn, .coll-actions .delete-btn { width: 30px; height: 30px; border-radius: 8px; }
.collections-table tbody tr.collection-row { box-shadow: none !important; }
.collections-table tbody tr.collection-row td { background: transparent; transition: background .12s ease; }
.collections-table tbody tr.collection-row:hover td { background: var(--c-brand-soft, #eff4ff) !important; }
.collections-table td:first-child { border-radius: 10px 0 0 10px; }
.collections-table td:last-child { border-radius: 0 10px 10px 0; }

/* ---------- Модальное окно «Список школ» ---------- */
#schoolsModal .modal-content.sm-dialog {
  width: min(1240px, 96vw);
  max-width: 1240px;
  height: 86vh;
  display: flex;
  flex-direction: row;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
}

.sm-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sm-side {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  background: var(--c-surface-2, #f8fafc);
  border-left: 1px solid var(--c-border, #e6eaf2);
  overflow: hidden;
}

.sm-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--c-border, #e6eaf2);
}
.sm-head__title { flex: 1; min-width: 0; }
.sm-head__title h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.sm-head__title h2 i { color: var(--c-brand, #2563eb); }
.sm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  font-size: .82rem;
  color: var(--c-muted, #7c8798);
}
.sm-meta b { color: var(--c-text-2, #475569); font-weight: 600; }
.sm-head__actions { display: flex; gap: 4px; flex-shrink: 0; }

.sm-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border, #e6eaf2);
}
.sm-stat {
  display: flex; align-items: center; gap: 10px;
  background: var(--c-surface-2, #f8fafc);
  border-radius: 11px;
  padding: 10px 12px;
}
.sm-stat__icon {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tone-bg, #eff4ff); color: var(--tone-color, #2563eb);
  font-size: .85rem;
}
.sm-stat__value { font-size: 1.15rem; font-weight: 700; line-height: 1.1; }
.sm-stat__label { font-size: .7rem; color: var(--c-muted, #7c8798); font-weight: 600; margin-top: 2px; }

.sm-list { flex: 1; overflow-y: auto; padding: 8px 12px 12px; }

.sm-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.sm-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--c-surface, #fff);
  color: var(--c-muted, #7c8798);
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 10px 8px;
  border-bottom: 1px solid var(--c-border, #e6eaf2);
  white-space: nowrap;
  text-align: left;
}
.sm-table thead th.is-center { text-align: center; }
.sm-table tbody td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--c-border, #e6eaf2);
  vertical-align: middle;
}
.sm-table tbody tr:last-child td { border-bottom: none; }
.sm-table tbody tr { cursor: pointer; transition: background .12s ease; }
.sm-table tbody tr:hover td { background: var(--c-brand-soft, #eff4ff); }
.sm-school-name {
  font-weight: 600;
  line-height: 1.3;
  display: flex; align-items: center; gap: 7px;
  min-width: 0;
}
.sm-school-name span { overflow: hidden; text-overflow: ellipsis; }
.sm-school-name i { flex: 0 0 auto; font-size: .82rem; }
.sm-num { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.sm-num--ok { color: var(--c-success, #059669); }
.sm-num--bad { color: var(--c-danger, #dc2626); }
.sm-row-actions { text-align: right; white-space: nowrap; }
.sm-row-actions button {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent;
  cursor: pointer; color: var(--c-text-2, #475569); font-size: .85rem;
  transition: background .15s ease, color .15s ease;
}
.sm-row-actions button:hover { background: var(--c-surface-2, #f1f5f9); color: var(--c-text, #0f172a); }
.sm-row-actions button.is-danger:hover { background: rgba(220, 38, 38, .12); color: var(--c-danger, #dc2626); }

.sm-foot {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--c-border, #e6eaf2);
  background: var(--c-surface, #fff);
}
.sm-foot .lg-btn, .sm-foot .btn { flex: 0 0 auto; }
.sm-foot__spacer { flex: 1; }

/* Кнопки в стиле раздела */
.sm-btn {
  border: none; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600;
  border-radius: 10px; padding: 9px 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.sm-btn--primary { background: var(--c-brand, #2563eb); color: #fff; box-shadow: 0 2px 8px -2px rgba(37, 99, 235, .5); }
.sm-btn--primary:hover { background: var(--c-brand-2, #1d4ed8); }
.sm-btn--ghost { background: var(--c-surface, #fff); color: var(--c-text-2, #475569); border: 1px solid var(--c-border, #e6eaf2); }
.sm-btn--ghost:hover { background: var(--c-surface-2, #f8fafc); color: var(--c-text, #0f172a); }
.sm-btn--success { background: rgba(5, 150, 105, .12); color: #047857; border: 1px solid rgba(5, 150, 105, .28); }
.sm-btn--success:hover { background: rgba(5, 150, 105, .2); }
.sm-btn--danger { background: var(--c-surface, #fff); color: #b91c1c; border: 1px solid rgba(220, 38, 38, .4); }
.sm-btn--danger:hover { background: rgba(220, 38, 38, .1); }
.sm-hint { font-size: .76rem; color: var(--c-muted, #7c8798); margin-left: 10px; }
.sm-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Панель статусов ---------- */
.sm-side__head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 16px 18px 10px;
}
.sm-side__head h3 { margin: 0; font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sm-side__head h3 i { color: var(--c-brand, #2563eb); }

.sm-timeline { padding: 4px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; }
.sm-timeline .status-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 18px;
}
.sm-timeline .status-item:last-child { padding-bottom: 0; }
.sm-timeline .status-icon {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; z-index: 1;
  box-shadow: 0 0 0 3px var(--c-surface-2, #f8fafc);
}
.sm-timeline .status-content { min-width: 0; padding-top: 2px; }
.sm-timeline .status-name { font-size: .82rem; font-weight: 600; color: var(--c-muted, #7c8798); line-height: 1.3; }
.sm-timeline .status-date { font-size: .72rem; color: var(--c-muted, #7c8798); opacity: .85; margin-top: 2px; }
.sm-timeline .status-item.active .status-name { color: var(--c-text, #0f172a); }
.sm-timeline .status-line {
  position: absolute;
  left: 14px; top: 30px; bottom: 0;
  width: 2px; border-radius: 2px;
}

.sm-empty { padding: 44px 20px; text-align: center; color: var(--c-muted, #7c8798); }
.sm-empty i { font-size: 1.8rem; opacity: .45; display: block; margin-bottom: 8px; }
.sm-empty__hint { font-size: .8rem; opacity: .8; margin-top: 4px; }

/* ---------- Формы сбора ---------- */
.cm-dialog { max-width: 640px; width: 100%; }
.cm-form { display: flex; flex-direction: column; gap: 14px; padding: 18px 22px 0; }
.cm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cm-label { font-size: .78rem; font-weight: 600; color: var(--c-text-2, #475569); }
.cm-label em { color: var(--c-danger, #dc2626); font-style: normal; margin-left: 2px; }
.cm-input {
  border: 1px solid var(--c-border, #e6eaf2);
  border-radius: 10px; padding: 10px 12px;
  font: inherit; font-size: .9rem; width: 100%; min-width: 0;
  background-color: var(--c-surface, #fff); color: var(--c-text, #0f172a);
}
.cm-input:focus { outline: none; border-color: var(--c-brand, #2563eb); box-shadow: var(--c-ring, 0 0 0 3px rgba(37,99,235,.2)); }
.cm-input--locked { background-color: var(--c-surface-2, #f1f5f9); color: var(--c-muted, #7c8798); }
.cm-hint { font-size: .72rem; color: var(--c-muted, #7c8798); }
.cm-error {
  background: rgba(220, 38, 38, .08); color: #b91c1c;
  border-radius: 10px; padding: 10px 12px; font-size: .84rem;
}
.cm-error[hidden] { display: none; }
.cm-actions {
  margin: 4px -22px 0; padding: 14px 22px;
  border-top: 1px solid var(--c-border, #e6eaf2);
  background: var(--c-surface-2, #f8fafc);
  border-radius: 0 0 18px 18px;
}

@media (max-width: 640px) {
  .cm-grid { grid-template-columns: 1fr; }
  .cm-form { padding: 14px 16px 0; }
  .cm-actions { margin-left: -16px; margin-right: -16px; padding: 12px 16px; }
}

/* ---------- Модалка участников ---------- */
#peopleModal .modal-content { width: min(1300px, 96vw) !important; min-width: 0 !important; height: 88vh; }

.pm-sort { display: inline-flex; padding: 3px; background: var(--c-surface-2, #f1f5f9); border-radius: 10px; }
.pm-sort__btn {
  border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--c-text-2, #475569);
  padding: 7px 12px; border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}
.pm-sort__btn.is-active { background: var(--c-surface, #fff); color: var(--c-brand, #2563eb); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }

#peopleModal .schools-table-row { cursor: pointer; }
#peopleModal .schools-table-row td { background: transparent; }
#peopleModal .schools-table-row:hover td { background: var(--c-brand-soft, #eff4ff); }
#peopleModal .status-badge { font-size: .72rem; font-weight: 600; }
#peopleModal input[type="search"], #peopleModal input[type="text"] { border-radius: 10px; }
#peopleModal table th:last-child, #peopleModal table td:last-child { white-space: nowrap; width: 92px; text-align: center; }
#peopleModal .schools-table-edit, #peopleModal .schools-table-delete {
  width: 30px; height: 30px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; vertical-align: middle;
}
#peopleModal .schools-table-edit:hover { background: var(--c-brand-soft, #eff4ff); }
#peopleModal .schools-table-delete:hover { background: rgba(220, 38, 38, .1); }
#peopleModal table th { font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; color: var(--c-muted, #7c8798); }

#peopleInfo .people-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
#peopleInfo .people-sub { font-size: .85rem; color: var(--c-text-2, #475569); margin-top: 2px; }

/* ---------- Модалка добавления школы ---------- */
#addSchoolModal .modal-content {
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#addSchoolModal .modal-content > div {
  overflow-y: auto;
  min-height: 0;
}
#addSchoolModal .form-actions-sm {
  position: sticky;
  bottom: -16px;
  background: var(--c-surface, #fff);
  padding: 12px 0 16px;
  margin-bottom: -16px;
  border-top: 1px solid var(--c-border, #e6eaf2);
  z-index: 1;
}
.supervisor-row input {
  border: 1px solid var(--c-border, #e6eaf2);
  border-radius: 9px; padding: 8px 10px;
  font: inherit; font-size: .86rem; min-width: 0;
  background-color: var(--c-surface, #fff); color: var(--c-text, #0f172a);
}
.supervisor-row input:focus { outline: none; border-color: var(--c-brand, #2563eb); box-shadow: var(--c-ring, 0 0 0 3px rgba(37, 99, 235, .2)); }
#addSchoolModal textarea {
  border: 1px solid var(--c-border, #e6eaf2) !important;
  border-radius: 10px !important;
  background-color: var(--c-surface, #fff);
  color: var(--c-text, #0f172a);
  font-size: .86rem;
}
#addSchoolModal textarea:focus { outline: none; border-color: var(--c-brand, #2563eb) !important; box-shadow: var(--c-ring, 0 0 0 3px rgba(37, 99, 235, .2)); }
.cm-word-btn {
  width: 100%; border: 1px solid rgba(37, 99, 235, .35);
  background: var(--c-brand-soft, #eff4ff); color: var(--c-brand, #2563eb);
  border-radius: 10px; padding: 9px 12px; cursor: pointer;
  font: inherit; font-size: .86rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s ease, border-color .15s ease;
}
.cm-word-btn:hover { background: rgba(37, 99, 235, .14); border-color: var(--c-brand, #2563eb); }

.form-group-sm { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-group-sm label { font-size: .74rem; font-weight: 600; color: var(--c-text-2, #475569); }
.form-group-sm input, .form-group-sm select, .form-group-sm textarea {
  border: 1px solid var(--c-border, #e6eaf2); border-radius: 9px;
  padding: 8px 10px; font: inherit; font-size: .86rem; width: 100%;
  background-color: var(--c-surface, #fff); color: var(--c-text, #0f172a);
}
.form-group-sm input:focus, .form-group-sm select:focus, .form-group-sm textarea:focus {
  outline: none; border-color: var(--c-brand, #2563eb); box-shadow: var(--c-ring, 0 0 0 3px rgba(37, 99, 235, .2));
}
.form-row-sm { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 720px) {
  .form-row-sm { grid-template-columns: 1fr; }
}

/* ---------- База данных школ ---------- */
.schools-db-table { table-layout: fixed; min-width: 0; font-size: .8rem; }
.schools-db-table th { white-space: normal; vertical-align: bottom; }
.schools-db-table th, .schools-db-table td { padding: 9px 6px; }
.schools-db-table td { white-space: normal; overflow-wrap: anywhere; vertical-align: middle; }
.schools-db-table th:nth-child(1) { width: 4%; }
.schools-db-table th:nth-child(2) { width: 17%; }
.schools-db-table th:nth-child(3) { width: 11%; }
.schools-db-table th:nth-child(4) { width: 10%; }
.schools-db-table th:nth-child(5) { width: 10%; }
.schools-db-table th:nth-child(6) { width: 9%; }
.schools-db-table th:nth-child(7) { width: 10%; }
.schools-db-table th:nth-child(8) { width: 9%; }
.schools-db-table th:nth-child(9) { width: 7%; }
.schools-db-table th:nth-child(10) { width: 7%; }
.schools-db-table th:nth-child(11) { width: 6%; }
.schools-db-table tbody tr { cursor: pointer; }
.schools-db-table tbody tr:hover td { background: var(--c-brand-soft, #eff4ff) !important; }

/* ---------- Счета ---------- */
.inv-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 34px 20px; color: var(--c-muted, #7c8798);
}
.inv-empty i { font-size: 1.6rem; opacity: .45; }
.inv-empty__hint { font-size: .78rem; opacity: .85; }

/* На узких экранах таблицам нужна горизонтальная прокрутка, а не сжатие */
@media (max-width: 900px) {
  .collections-table { min-width: 980px; }
  .schools-db-table { min-width: 1100px; }
}
@media (max-width: 1100px) {
  #schoolsModal .modal-content.sm-dialog { width: 96vw; height: 90vh; flex-direction: column; }
  .sm-side { flex: 0 0 auto; max-height: 40%; border-left: none; border-top: 1px solid var(--c-border, #e6eaf2); }
  .sm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  #schoolsModal .modal-content.sm-dialog { width: 100vw; height: 100vh; border-radius: 0; }
  .sm-head { padding: 14px; }
  .sm-stats { padding: 10px 14px; gap: 8px; }
  .sm-list { padding: 4px 6px 8px; }
  .sm-foot { padding: 10px 14px; flex-wrap: wrap; }
  .sm-meta { font-size: .76rem; }
  .sm-table thead th:nth-child(3) { display: none; }
  .sm-table tbody td:nth-child(3) { display: none; }
}
