/*
 * Единая тема интерфейса (в духе Битрикс24) поверх Bootstrap 4.
 * Все разделы используют одни и те же компоненты Bootstrap — здесь задаётся их общий вид.
 */
:root {
  --app-bg: #eef2f4;
  --app-surface: #ffffff;
  --app-surface-muted: #f6f8fa;
  --app-border: #e1e6eb;
  --app-border-strong: #cfd6dd;
  --app-text: #2f3a45;
  --app-muted: #75808b;
  --app-primary: #2067b0;
  --app-primary-hover: #1a5796;
  --app-primary-soft: #e7f0fa;
  --app-accent: #2fc6f6;
  --app-success: #4caf50;
  --app-danger: #e5484d;
  --app-warning: #f5a524;
  --app-sidebar-bg: #1f3044;
  --app-sidebar-bg-2: #172433;
  --app-sidebar-text: rgba(255, 255, 255, 0.78);
  --app-sidebar-active: rgba(255, 255, 255, 0.12);
  --app-sidebar-width: 244px;
  --app-topbar-height: 60px;
  --app-radius: 10px;
  --app-radius-sm: 6px;
  --app-shadow: 0 1px 2px rgba(31, 48, 68, 0.06), 0 1px 6px rgba(31, 48, 68, 0.04);
  --app-shadow-lg: 0 10px 30px rgba(31, 48, 68, 0.16);
}

/* ---------- совместимость: несколько утилит Bootstrap 5, встречающихся в шаблонах ---------- */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.form-label { display: inline-block; margin-bottom: 0.5rem; }
.text-start { text-align: left !important; }

/* ---------- основа ---------- */
html,
body {
  min-width: 320px;
}

body {
  background: var(--app-bg);
  color: var(--app-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9375rem;
  overflow-x: hidden;
}

a {
  color: var(--app-primary);
}

a:hover {
  color: var(--app-primary-hover);
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.25em;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

/* ---------- каркас: левое меню ---------- */
.app-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  display: flex;
  width: var(--app-sidebar-width);
  flex-direction: column;
  background: linear-gradient(180deg, var(--app-sidebar-bg), var(--app-sidebar-bg-2));
  color: var(--app-sidebar-text);
  overflow-y: auto;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  height: var(--app-topbar-height);
  padding: 0 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.app-brand:hover {
  color: #fff;
  text-decoration: none;
}

.app-brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--app-accent);
  color: #0f2233;
  font-size: 0.95rem;
  font-weight: 700;
}

.app-brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.75rem 0.6rem;
}

.app-menu-title {
  padding: 0.9rem 0.75rem 0.35rem;
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-menu-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: var(--app-sidebar-text);
  font-weight: 500;
}

.app-menu-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-decoration: none;
}

.app-menu-link.active {
  background: var(--app-sidebar-active);
  color: #fff;
}

.app-menu-link.active::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: -0.6rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--app-accent);
  content: "";
}

.app-menu-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

.app-menu-badge-danger {
  background: var(--app-danger);
}

.task-overdue {
  color: var(--app-danger);
  font-weight: 600;
}

.task-today {
  color: #b76e00;
  font-weight: 600;
}

.task-done-title {
  color: var(--app-muted);
  text-decoration: line-through;
}

.task-title-link {
  color: inherit;
}

.task-checklist-box {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.activity-feed {
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-feed li {
  display: flex;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--app-border);
}

.activity-feed li:last-child {
  border-bottom: 0;
}

.activity-time {
  flex: 0 0 110px;
  color: var(--app-muted);
  font-size: 0.8125rem;
}

.app-menu-bottom {
  margin-top: auto;
  padding-bottom: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---------- каркас: верхняя панель и контент ---------- */
.app-main {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin-left: var(--app-sidebar-width);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--app-topbar-height);
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
}

.app-burger {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--app-text);
}

.app-burger:hover {
  background: var(--app-surface-muted);
}

.app-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 520px;
  margin: 0;
}

.app-search .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--app-muted);
  transform: translateY(-50%);
}

.app-search input {
  width: 100%;
  height: 38px;
  padding: 0 0.9rem 0 2.4rem;
  border: 1px solid transparent;
  border-radius: 19px;
  background: var(--app-surface-muted);
  color: var(--app-text);
}

.app-search input:focus {
  border-color: var(--app-primary);
  background: #fff;
  outline: 0;
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}

.app-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.app-user-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--app-text);
}

.app-user-toggle:hover,
.app-user-toggle:focus {
  background: var(--app-surface-muted);
  outline: 0;
}

.app-avatar {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--app-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

.app-user-name {
  max-width: 200px;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-content {
  flex: 1 0 auto;
  padding: 1.5rem;
}

.app-container {
  max-width: 1480px;
  margin: 0 auto;
}

.app-footer {
  padding: 1rem 1.5rem;
  color: var(--app-muted);
  font-size: 0.85rem;
  text-align: center;
}

.app-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1035;
  display: none;
  background: rgba(15, 25, 36, 0.45);
}

/* страница входа */
.app-guest {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--app-sidebar-bg) 0%, #2d5a87 100%);
}

.app-guest-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--app-shadow-lg);
}

/* ---------- типографика и шапки страниц ---------- */
main h1,
main .h1 {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.25;
}

main h2,
main .h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

main h3,
main .h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

main h4,
main .h4,
main h5,
main .h5 {
  font-weight: 600;
}

.text-muted {
  color: var(--app-muted) !important;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin-bottom: 0.15rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.app-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  color: var(--app-muted);
  font-size: 0.875rem;
}

.app-back:hover {
  color: var(--app-primary);
  text-decoration: none;
}

/* ---------- компоненты Bootstrap ---------- */
.card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.card-header {
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface);
  font-weight: 600;
}

.card-header:first-child {
  border-radius: calc(var(--app-radius) - 1px) calc(var(--app-radius) - 1px) 0 0;
}

.card-title {
  font-weight: 600;
}

.card dt {
  color: var(--app-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.card dd {
  margin-bottom: 0.7rem;
}

.btn {
  border-radius: var(--app-radius-sm);
  font-weight: 500;
}

.btn-primary {
  border-color: var(--app-primary);
  background-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active {
  border-color: var(--app-primary-hover);
  background-color: var(--app-primary-hover);
}

.btn-outline-primary {
  border-color: #b9cfe6;
  color: var(--app-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:not(:disabled):not(.disabled):active {
  border-color: var(--app-primary);
  background-color: var(--app-primary);
}

.btn-outline-secondary {
  border-color: var(--app-border-strong);
  color: #52606d;
}

.btn-outline-secondary:hover {
  border-color: #aeb8c2;
  background-color: var(--app-surface-muted);
  color: var(--app-text);
}

.btn-light {
  border-color: var(--app-border);
  background: var(--app-surface);
}

.btn-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.form-control,
.custom-select {
  border-color: var(--app-border-strong);
  border-radius: var(--app-radius-sm);
}

.form-control:focus,
.custom-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}

label {
  color: #4a5561;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert {
  border: 0;
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.alert-success {
  border-left: 4px solid var(--app-success);
  background: #eef8ef;
  color: #235d27;
}

.alert-danger {
  border-left: 4px solid var(--app-danger);
  background: #fdeeee;
  color: #8e1c20;
}

.alert-warning {
  border-left: 4px solid var(--app-warning);
  background: #fff7e6;
  color: #7a4d00;
}

.alert-info {
  border-left: 4px solid var(--app-accent);
  background: #eaf8fd;
  color: #1c5870;
}

.modal-content {
  border: 0;
  border-radius: 14px;
  box-shadow: var(--app-shadow-lg);
}

.modal-header,
.modal-footer {
  border-color: var(--app-border);
}

.badge {
  border-radius: 20px;
  font-weight: 500;
  padding: 0.3em 0.65em;
}

.badge-soft {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.dropdown-menu {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-lg);
}

/* ---------- выпадающий список с поиском ---------- */
.app-combobox {
  position: relative;
}

.app-combobox.has-edit input {
  padding-right: 2.4rem;
}

.app-combobox-edit {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--app-primary);
  transform: translateY(-50%);
}

.app-combobox-edit:hover {
  background: var(--app-primary-soft);
}

.app-combobox-list {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  left: 0;
  z-index: 1060;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.25rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-lg);
}

.app-combobox-option,
.app-combobox-empty {
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
}

.app-combobox-option {
  cursor: pointer;
}

.app-combobox-option.active {
  background: var(--app-primary-soft);
}

.app-combobox-option.selected {
  font-weight: 600;
}

.app-combobox-empty {
  color: var(--app-muted);
}

.js-auto-submit-form.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ---------- таблицы ---------- */
main .table-responsive {
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

main .table-responsive > .table {
  margin-bottom: 0;
}

main .table {
  background: var(--app-surface);
  color: var(--app-text);
}

main .table thead th {
  border-top: 0;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface-muted);
  color: #5d6975;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

main .table td,
main .table th {
  border-color: var(--app-border);
  vertical-align: middle;
}

main .table-hover tbody tr:hover {
  background: #f3f7fb;
}

main .table thead .btn-link {
  color: inherit !important;
  font-size: inherit;
  font-weight: inherit;
}

/* широкие таблицы с фиксированной раскладкой (табель) прокручиваются, а не сжимаются */
main table[style*="table-layout: fixed"] {
  min-width: 1380px;
}

/* таблицы внутри карточек и вкладок не нуждаются в своей рамке */
.card .table-responsive,
.tab-content .table-responsive {
  border-radius: var(--app-radius-sm);
  box-shadow: none;
}

/* ---------- вкладки карточек ---------- */
main .nav-tabs {
  flex-wrap: wrap;
  padding: 0 0.5rem;
  border: 1px solid var(--app-border);
  border-bottom: 0;
  border-radius: var(--app-radius) var(--app-radius) 0 0;
  background: var(--app-surface);
}

main .nav-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0;
  padding: 0.8rem 0.95rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--app-muted);
  font-weight: 500;
}

main .nav-tabs .nav-link:hover {
  color: var(--app-text);
}

main .nav-tabs .nav-link.active {
  border-bottom-color: var(--app-primary);
  background: transparent;
  color: var(--app-primary);
}

main .nav-tabs + .tab-content {
  padding: 1.25rem !important;
  border: 1px solid var(--app-border) !important;
  border-radius: 0 0 var(--app-radius) var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

.nav-tab-add {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  margin: 0.4rem 0 0.4rem auto;
  padding: 0;
  border: 1px dashed var(--app-border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--app-primary);
}

.nav-tab-add:hover {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}

.ws-scope {
  color: var(--app-muted);
}

/* ---------- панели разделов (pills) ---------- */
main .nav-pills .nav-link {
  border-radius: 18px;
  color: var(--app-muted);
  font-weight: 500;
}

main .nav-pills .nav-link.active {
  background: var(--app-primary);
  color: #fff;
}

/* ---------- главная ---------- */
.home-navigation {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.home-navigation-link {
  display: flex;
  min-height: 108px;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
  color: var(--app-text);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.home-navigation-link:hover {
  color: var(--app-text);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--app-shadow-lg);
}

.home-navigation-icon {
  display: inline-flex;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.home-navigation-icon .icon {
  width: 24px;
  height: 24px;
}

.home-navigation-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
}

.home-navigation-description {
  display: block;
  margin-top: 0.2rem;
  color: var(--app-muted);
  font-size: 0.875rem;
}

.stat-card {
  padding: 1rem 1.25rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

.stat-card-value {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.2;
}

.stat-card-label {
  color: var(--app-muted);
  font-size: 0.85rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
}

/* ---------- админка ---------- */
.admin-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.admin-nav {
  position: sticky;
  top: calc(var(--app-topbar-height) + 1.5rem);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  white-space: nowrap;
  border-radius: 7px;
  color: var(--app-text);
  font-weight: 500;
}

.admin-nav a .icon {
  color: var(--app-muted);
}

.admin-nav a:hover {
  background: var(--app-surface-muted);
  text-decoration: none;
}

.admin-nav a.active {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.admin-nav a.active .icon {
  color: var(--app-primary);
}

/* ---------- конструктор вкладок ---------- */
.ws-values {
  display: grid;
  grid-template-columns: minmax(160px, 260px) minmax(0, 1fr);
  margin: 0;
}

.ws-values-compact {
  grid-template-columns: minmax(110px, 42%) minmax(0, 1fr);
}

.ws-values dt,
.ws-values dd {
  margin: 0;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--app-border);
}

.ws-values dt {
  padding-right: 1rem;
  color: var(--app-muted);
  font-weight: 500;
}

.ws-values > :nth-last-child(-n + 2) {
  border-bottom: 0;
}

/* Поиск по вкладкам карточки */
.card-search {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}
.card-search .form-control {
  max-width: 36rem;
}
.card-search-hidden {
  display: none !important;
}
.nav-link.card-search-miss {
  opacity: .55;
}

.ws-empty {
  padding: 2rem 1rem;
  border: 1px dashed var(--app-border-strong);
  border-radius: var(--app-radius);
  color: var(--app-muted);
  text-align: center;
}

.ws-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ws-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.ws-type-option {
  display: block;
  height: 100%;
  margin: 0;
  padding: 0.8rem;
  border: 1px solid var(--app-border-strong);
  border-radius: var(--app-radius-sm);
  cursor: pointer;
}

.ws-type-option input {
  margin-right: 0.35rem;
}

.ws-type-option small {
  display: block;
  margin-top: 0.2rem;
  color: var(--app-muted);
  font-weight: 400;
}

.ws-type-option:has(input:checked) {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}

/* ---------- режим «только просмотр» ---------- */
body[data-readonly] main form[method="post"],
body[data-readonly] main form[method="POST"],
body[data-readonly] main .js-confirm-delete,
body[data-readonly] main .js-edit-only,
body[data-readonly] main a[href*="/add/"],
body[data-readonly] main a[href*="/edit/"],
body[data-readonly] main a[href*="/delete/"],
body[data-readonly] main a[href*="/merge/"],
body[data-readonly] main a[href*="/import/"],
body[data-readonly] main a[href*="/match/"],
body[data-readonly] main a[href*="/mappings/"],
body[data-readonly] main a[href*="/quick-add/"],
body[data-readonly] main a[href*="/bulk-add/"],
body[data-readonly] main a[href*="/bulk-delete/"],
body[data-readonly] main a[href*="/unlink/"],
body[data-readonly] main a[href*="/unassign/"] {
  display: none !important;
}

/* ---------- мобильные ---------- */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  body.sidebar-open .app-sidebar {
    transform: none;
    box-shadow: var(--app-shadow-lg);
  }

  body.sidebar-open .app-backdrop {
    display: block;
  }

  .app-main {
    margin-left: 0;
  }

  .app-burger {
    display: inline-flex;
  }

  .admin-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-body {
    min-width: 0;
  }

  .admin-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
  }

  .admin-nav a {
    white-space: nowrap;
  }
}

@media (max-width: 767.98px) {
  .app-topbar {
    gap: 0.5rem;
    padding: 0 0.75rem;
  }

  .app-user-name {
    display: none;
  }

  .app-idea-label {
    display: none;
  }

  .app-idea {
    padding: 0.4rem;
    border-radius: 50%;
  }

  .app-content {
    padding: 1rem 0.75rem;
  }

  main h1,
  main .h1 {
    font-size: 1.4rem;
  }

  .ws-values {
    grid-template-columns: 1fr;
  }

  .ws-values dt {
    padding-bottom: 0;
    border-bottom: 0;
  }
}

/* Порядок строк перетаскиванием (static_dev/js/app.js, data-sortable) */
.sort-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--app-muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1;
}
.sort-handle:hover,
.sort-handle:focus {
  background: var(--app-primary-soft);
  color: var(--app-primary);
  outline: none;
}
.sort-moving {
  background: var(--app-primary-soft) !important;
  outline: 2px solid var(--app-primary);
  outline-offset: -2px;
  position: relative;
  z-index: 1;
}
.sort-moving .sort-handle {
  cursor: grabbing;
}
[data-sort-lock]:not(.sort-unlocked) [data-sort-handle] {
  display: none;
}
.sort-notice {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 1rem);
  padding: .5rem 1rem;
  border-radius: 999px;
  background: #1f2d3d;
  color: #fff;
  font-size: .875rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 2000;
}
.sort-notice.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.sort-notice.is-error {
  background: #b42318;
}

/* Кнопка «Предложить улучшение» в верхней панели. */
.app-idea {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--app-border, #dfe3e8);
  border-radius: 18px;
  background: transparent;
  color: var(--app-text);
  font-size: 0.875rem;
  white-space: nowrap;
}

.app-idea:hover,
.app-idea:focus {
  background: var(--app-surface-muted);
  outline: 0;
}

.app-idea + .app-user {
  margin-left: 0.5rem;
}

.improvement-dock {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1040;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--app-border, #dfe3e8);
  border-radius: 999px;
  background: var(--app-surface, #fff);
  color: inherit;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.improvement-dock[hidden] {
  display: none;
}

.improvement-text {
  white-space: pre-wrap;
}

.improvement-command {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--app-surface-muted);
  font-family: SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
}

.improvement-command code {
  flex: 1 1 16rem;
  color: var(--app-text);
  white-space: normal;
}

/* PWA: плашка «Нет связи / Не отправлено обходов» (static_dev/js/pwa.js) */
.pwa-banner {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 1080;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  max-width: calc(100% - 2rem);
  padding: .5rem .75rem;
  border-radius: 10px;
  background: #1f3044;
  color: #fff;
  box-shadow: 0 6px 24px rgba(15, 34, 51, .3);
  font-size: .9rem;
}

.pwa-banner[hidden] {
  display: none;
}

body.has-pwa-banner {
  padding-bottom: 6rem;
}
