html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Обсуждения-чат в карточке позиции: цвета по роли автора, «мои» сообщения справа */
.chat-block {
  border: 1px solid #c7d2e0;
  border-radius: .6rem;
  overflow: hidden;
  margin-top: 1rem;
  box-shadow: 0 2px 8px rgba(33, 37, 41, .08);
}

.chat-block-header {
  background: linear-gradient(90deg, #e8eef7, #f6f9fd);
  border-bottom: 1px solid #d5deea;
  padding: .45rem .75rem;
  font-weight: 600;
}

.chat-panel {
  background: #f8f9fb;
  padding: .75rem;
  max-height: 60vh;
  overflow-y: auto;
}

.chat-empty {
  color: #6c757d;
  font-size: .9rem;
}

.chat-msg {
  max-width: 80%;
  width: fit-content;
  margin: .25rem auto .5rem 0;
  padding: .45rem .65rem;
  border: 1px solid rgba(0, 0, 0, .07);
  border-radius: .65rem;
}

.chat-msg.mine {
  margin-left: auto;
  margin-right: 0;
}

.chat-msg .chat-meta {
  font-size: .75rem;
  color: #6c757d;
  margin-bottom: .15rem;
}

.chat-msg .chat-text {
  white-space: pre-wrap;
}

/* светло-жёлтый — аккаунт-менеджер */
.chat-role-manager { background: #fff6cf; }
/* светло-зелёный — закупка */
.chat-role-procurement { background: #e3f4e6; }
/* светло-голубой — QC */
.chat-role-qc { background: #dcecf9; }
/* светло-красный — администраторы */
.chat-role-admin { background: #fbe3e3; }
.chat-role-other { background: #eef0f2; }

/* Превью позиции: миниатюра 1×1 см рядом с кодом позиции */
.position-preview {
  width: 1cm;
  height: 1cm;
  object-fit: cover;
  vertical-align: middle;
  margin-right: .25rem;
  border: 1px solid #ced4da;
  border-radius: .2rem;
  background: #f8f9fa;
}

/* Превью в интерфейсе приёмки склада: ровно 5×5 см, маленькое изображение растягивается */
.position-preview-warehouse {
  width: 5cm;
  height: 5cm;
  object-fit: fill;
  margin-right: 0;
  border-radius: .35rem;
  flex-shrink: 0;
}

/* Большое превью в карточке позиции (2×2 см) */
.position-preview-lg {
  width: 2cm;
  height: 2cm;
  object-fit: cover;
  border: 1px solid #ced4da;
  border-radius: .3rem;
  background: #f8f9fa;
}

/* Квадрат загрузки превью 2×2 см (клик или перетаскивание) */
.position-preview-drop {
  position: relative;
  width: 2cm;
  height: 2cm;
  border: 2px dashed #adb5bd;
  border-radius: .4rem;
  background: #f8f9fa;
  color: #6c757d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.position-preview-drop.file-drop-active {
  border-color: #0d6efd;
  color: #0d6efd;
  background: #f0f7ff;
}

.position-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.1;
  font-size: .6rem;
}

.position-preview-plus {
  font-size: 1.15rem;
  font-weight: 600;
}

.position-preview-picked {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.position-preview-clear {
  position: absolute;
  top: 0;
  right: 0;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: 0;
  border-radius: 0 0 0 .35rem;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: .85rem;
  line-height: 1;
}

/* Файлы позиции: компактные плитки с миниатюрой изображения или типом файла. */
.position-file-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.position-file-tile {
  width: 5.4rem;
  color: inherit;
  text-decoration: none;
  text-align: center;
}

.position-file-tile:hover {
  color: #0d6efd;
}

.position-file-tile img,
.position-file-icon {
  display: flex;
  width: 5.4rem;
  height: 4rem;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  border: 1px solid #ced4da;
  border-radius: .3rem;
  background: #f8f9fa;
}

.position-file-icon {
  color: #495057;
  font-size: .78rem;
  font-weight: 700;
}

.position-file-name {
  display: block;
  margin-top: .2rem;
  overflow: hidden;
  font-size: .72rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Личный checklist: закреплённая кнопка с пером и компактный чат на desktop. */
.checklist-fab {
  position: fixed;
  z-index: 1030;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid #5d4531;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4c6688, #1f304a 68%);
  box-shadow: 0 .35rem .9rem rgba(0, 0, 0, .28);
  color: #fff;
  font-size: 1.5rem;
}

.checklist-fab:hover { filter: brightness(1.12); }

.checklist-pencil {
  width: 1.55rem;
  height: 1.55rem;
  fill: currentColor;
  vertical-align: middle;
}

.checklist-pencil-title { width: 1.2rem; height: 1.2rem; color: #294766; }

.checklist-dialog {
  width: 20vw;
  min-width: 260px;
  max-width: 420px;
  margin-right: 1.25rem;
  margin-left: auto;
}

.checklist-chat {
  min-height: 12rem;
  max-height: 52vh;
  background: #f5f1e9;
}

.checklist-message {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .35rem;
  margin-bottom: .5rem;
}

.checklist-bubble {
  max-width: 86%;
  padding: .45rem .65rem;
  border-radius: .8rem .8rem .15rem .8rem;
  background: #d8ecff;
  border: 1px solid #b8d7f0;
  white-space: pre-wrap;
  word-break: break-word;
}

.checklist-delete button { filter: grayscale(.15); }
.checklist-add { display: flex; flex-wrap: nowrap; gap: .35rem; }

/* Системные уведомления: почтовая кнопка над checklist и чат уведомлений. */
.notifications-fab {
  bottom: 5.25rem;
  background: radial-gradient(circle at 35% 30%, #2f7d6d, #19483e 68%);
  border-color: #143d34;
}

.notification-mail {
  width: 1.55rem;
  height: 1.55rem;
  fill: currentColor;
  vertical-align: middle;
}

.notification-mail-title { width: 1.2rem; height: 1.2rem; color: #1f5c4f; }

.notification-count {
  position: absolute;
  top: -.2rem;
  right: -.2rem;
  min-width: 1.2rem;
  padding: .1rem .25rem;
  border-radius: 999px;
  background: #dc3545;
  color: #fff;
  font-size: .65rem;
  line-height: 1.1;
  text-align: center;
}

.notifications-dialog {
  width: 25vw;
  min-width: 300px;
  max-width: 520px;
}

.notifications-chat { background: #eef7f4; }

.notification-message {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: .15rem .35rem;
  align-items: start;
  margin-bottom: .65rem;
}

.notification-meta {
  grid-column: 1;
  grid-row: 1;
  font-size: .72rem;
  color: #6c757d;
}

.notification-bubble {
  grid-column: 1;
  grid-row: 2;
  display: block;
  max-width: 100%;
  padding: .45rem .65rem;
  border: 1px solid #b9ddd3;
  border-radius: .15rem .8rem .8rem .8rem;
  background: #dff1eb;
  color: inherit;
  text-decoration: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.notification-bubble:hover { background: #cfe9e1; color: inherit; }

.notification-message .checklist-delete {
  grid-column: 2;
  grid-row: 1 / span 2;
}

@media (max-width: 767.98px) {
  .checklist-dialog { width: 100vw; min-width: 0; max-width: none; height: 100%; margin: 0; }
  .checklist-dialog .modal-content { min-height: 100vh; border-radius: 0; }
  .checklist-chat { max-height: none; flex: 1 1 auto; }
  .notifications-dialog { width: 100vw; min-width: 0; max-width: none; }
}

/* Красная точка на пунктах меню с новой рабочей очередью. */
.nav-alert-link { position: relative; }
.nav-alert-dot {
  display: inline-block;
  width: .5rem;
  height: .5rem;
  margin-left: .3rem;
  border-radius: 50%;
  vertical-align: super;
  background: #dc3545;
  box-shadow: 0 0 0 1px #fff;
}

/* Пагинация и фильтры без полной перезагрузки */
.ajax-navigation-pending [data-ajax-region],
.ajax-navigation-pending [data-position-region] { opacity: .55; pointer-events: none; transition: opacity .15s ease; }
