/* ---------------------------
   GLOBAL SETTINGS
----------------------------*/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

body {
  background: #f7f8fa;
  color: #333;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.sidebar-open {
  overflow: hidden;
}

/* ---------------------------
   MOBILE TOP BAR
----------------------------*/
.mobile-topbar {
  display: none;
  height: 56px;
  background: white;
  border-bottom: 1px solid #e6e6e6;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-btn {
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
}

.mobile-title {
  font-size: 18px;
  font-weight: 600;
}

/* ---------------------------
   LAYOUT
----------------------------*/
.app-container {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* ---------------------------
   SIDEBAR
----------------------------*/
.sidebar {
  width: 270px;
  background: white;
  border-right: 1px solid #e5e7eb;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-title {
  padding-left: 20px;
  margin-bottom: 4px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
}
.sidebar-title:first-of-type {
  margin-top: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 4px 20px;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.sidebar-section-header .sidebar-title {
  margin: 0;
  padding: 0;
}

/* Аккордеон сайдбара: только один блок раскрыт (и на ПК, и на мобиле) */
.sidebar-accordion-section {
  flex-shrink: 0;
}
.sidebar-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 10px 20px;
  margin: 0;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  font: inherit;
  color: #6b7280;
  text-align: left;
}
.sidebar-accordion-trigger .sidebar-title {
  margin: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
}
.sidebar-accordion-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sidebar-accordion-heading .sidebar-title {
  margin: 0;
}
.sidebar-accordion-trigger-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-accordion-icon {
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}
.sidebar-accordion-content {
  overflow: hidden;
}
.sidebar-accordion-section:not(.expanded) .sidebar-accordion-icon {
  transform: rotate(-90deg);
}
/* На ПК: та же логика аккордеона — свёрнутый контент скрыт, раскрытый скроллится */
@media (min-width: 901px) {
  .sidebar-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .sidebar-accordion-section.expanded .sidebar-accordion-content {
    max-height: 80vh;
    overflow-y: auto;
  }
  #sidebar-accordion-lists.expanded #category-list,
  #sidebar-accordion-staff.expanded #staff-list {
    max-height: 78vh;
    overflow-y: auto;
  }
  /* Компактнее для 24" экрана: списки помещаются без скролла */
  .sidebar-accordion-trigger {
    padding: 8px 14px 8px 20px;
  }
  .category-item {
    padding: 4px 14px;
    margin: 1px 10px;
    font-size: 13px;
  }
  .staff-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
  /* Сотрудники — чуть ниже, чтобы списки были приоритетнее */
  #sidebar-accordion-staff {
    margin-top: 4px;
  }
  .sidebar-logout-btn {
    margin: 10px 10px 8px;
    padding: 6px 10px;
    font-size: 12px;
  }
  #staff-list {
    margin-bottom: 8px;
  }
}

.sidebar-add-category-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.sidebar-add-category-btn:hover {
  background: #f9fafb;
}
.sidebar-add-category-btn.icon-only {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.category-list {
  list-style: none;
  margin-bottom: 0;
}

.category-item {
  padding: 5px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 10px;
  font-size: 13px;
  transition: 0.2s ease;
}

.category-item:hover {
  background: #f0f0f5;
}

.category-item.active {
  background: #eef2ff;
}

.category-item .category-name {
  flex: 1;
  min-width: 0;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 5px;
  flex-shrink: 0;
}

.category-actions {
  position: relative;
  flex-shrink: 0;
}

.category-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.category-btn:hover {
  background: #e5e7eb;
  color: #374151;
}
.category-btn svg {
  display: block;
  pointer-events: none;
}

.category-drag-handle {
  flex-shrink: 0;
  width: 20px;
  color: #9ca3af;
  font-size: 14px;
  cursor: grab;
  display: none;
}
.category-item[draggable="true"] .category-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.category-item-dragging {
  opacity: 0.6;
}
.category-item-dragging .category-drag-handle {
  cursor: grabbing;
}
.category-item-drag-over {
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px #93c5fd;
}
.category-drag-handle-spacer {
  width: 20px;
  min-width: 20px;
  visibility: hidden;
  pointer-events: none;
}
/* Иконка «Мои задачи» (список с галочками) — не перемещается, не переименовывается */
.category-item-icon-wrap {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
}
.category-item-my .category-item-icon {
  display: block;
}

/* Сотрудники: аватар с инициалами */
.staff-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.staff-item .staff-name {
  flex: 1;
  min-width: 0;
}

/* Модальное окно действий со списком */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 5000;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
}
.modal-overlay.open {
  display: flex;
}
.modal-card {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.modal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #f3f4f6;
}
.modal-card-title {
  font-size: 17px;
  font-weight: 600;
  color: #111;
  margin: 0;
}
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
}
.modal-close:hover {
  background: #e5e7eb;
  color: #374151;
}
.modal-card-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-btn {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}
.modal-btn-rename {
  background: #f3f4f6;
  color: #374151;
}
.modal-btn-rename:hover {
  background: #eef2ff;
  color: #2563eb;
}
.modal-btn-delete {
  background: #fef2f2;
  color: #b91c1c;
}
.modal-btn-delete:hover {
  background: #fee2e2;
}

.modal-rename-form .modal-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}
.modal-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 16px;
  box-sizing: border-box;
}
.modal-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.modal-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal-btn-secondary {
  background: #f3f4f6 !important;
  color: #374151 !important;
}
.modal-btn-secondary:hover {
  background: #e5e7eb !important;
}
.modal-btn-primary {
  background: #2563eb !important;
  color: #fff !important;
}
.modal-btn-primary:hover {
  background: #1d4ed8 !important;
}
.modal-confirm-text {
  margin: 0 0 20px 0;
  font-size: 15px;
  color: #374151;
  line-height: 1.4;
}
.modal-btn-success {
  background: #16a34a !important;
  color: #fff !important;
}
.modal-btn-success:hover {
  background: #15803d !important;
}

/* ---------------------------
   MAIN CONTENT
----------------------------*/
.main {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 32px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Линия на границе с правой панелью и полупрозрачный логотип в правой пустой зоне */
.main-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.main-watermark-line {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e5e7eb;
}

.main-title {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.filters-accordion-section {
  margin-bottom: 16px;
  border: 1px solid #e6e6e6;
  border-radius: 12px;
  background: #fafafa;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.filters-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 0;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  font: inherit;
  color: #555;
  text-align: left;
  transition: background 0.2s;
}

.filters-accordion-trigger:hover {
  background: #f0f0f0;
}

.filters-accordion-trigger:active {
  background: #eee;
}

.filters-accordion-title {
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filters-badge {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
}

.filters-badge.active {
  display: block;
}

.filters-counter {
  font-size: 13px;
  color: #6b7280;
  margin-top: 0;
  margin-bottom: 12px;
  min-height: 0;
  overflow: hidden;
  display: none;
}

.filters-counter.visible {
  display: block;
}

@media (max-width: 900px) {
  .filters-badge {
    width: 10px;
    height: 10px;
  }
  .filters-counter {
    font-size: 14px;
    margin-bottom: 14px;
  }
}

.filters-accordion-icon {
  opacity: 0.7;
  transition: transform 0.25s ease;
}

.filters-accordion-section:not(.expanded) .filters-accordion-icon {
  transform: rotate(-90deg);
}

.filters-accordion-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.filters-accordion-section.expanded .filters-accordion-content {
  max-height: 280px;
}

.filters-accordion-content .filters-inner {
  padding: 14px 16px 18px;
  background: white;
  border-top: 1px solid #e6e6e6;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.filters-row-reset {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #eee;
  justify-content: flex-start;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filters-label {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.filter-select {
  padding: 6px 10px;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  font-size: 13px;
  background: white;
  min-width: 0;
  width: auto;
}

.filter-select#filter-status,
.filter-select#filter-priority,
.filter-select#filter-urgent,
.filter-select#filter-date,
.filter-select#filter-tag {
  width: 100px;
}

.filter-select#filter-assignee {
  min-width: 100px;
  width: 140px;
}

.filter-select:focus {
  outline: none;
  border-color: #3b82f6;
}

.filter-reset-btn {
  padding: 6px 12px;
  font-size: 13px;
  flex-shrink: 0;
  color: #666;
  background: #f5f5f5;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.filter-reset-btn:hover {
  background: #eee;
  color: #333;
}

@media (max-width: 700px) {
  .filter-select#filter-assignee {
    max-width: none;
  }
}

@media (max-width: 600px) {
  .filter-select {
    font-size: 16px;
  }
}

/* Мобильная версия фильтров — аккуратная сетка */
@media (max-width: 900px) {
  .filters-accordion-section.expanded .filters-accordion-content {
    max-height: 420px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .filters-accordion-content .filters-inner {
    padding: 16px 18px 20px;
  }

  .filters-row:not(.filters-row-reset) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
  }

  .filter-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .filters-label {
    font-size: 12px;
    font-weight: 500;
    color: #555;
  }

  .filter-select {
    width: 100% !important;
    max-width: none !important;
    padding: 10px 12px;
    font-size: 16px;
  }

  .filters-row-reset {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e8e8e8;
  }

  .filter-reset-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
  }
}

.add-task-input {
  width: 100%;
  background: white;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  margin-bottom: 20px;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: 0.2s;
}

.add-task-input:hover {
  background: #fafafa;
}

.add-task-input span {
  font-size: 22px;
  font-weight: 600;
}

/* ---------------------------
   TASK LIST + CARDS
----------------------------*/
.task-card {
  background: white;
  border-radius: 16px;
  padding: 18px 20px;
  border: 1px solid #e6e6e6;
  margin-bottom: 14px;
  transition: 0.2s;

  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-card-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.task-card-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-card-assignees {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.task-card-done-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #86efac;
  border-radius: 10px;
  background: #f0fdf4;
  color: #166534;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.task-card-done-btn:hover {
  background: #dcfce7;
  border-color: #4ade80;
}
.task-card-done-btn svg {
  display: block;
}

.task-card:hover {
  background: #fafafa;
}

.task-card.active {
  background: #eef4ff;
  border-left: 4px solid #3b82f6;
}

.task-title {
  font-size: 17px;
  font-weight: 500;
}
.task-card-priority-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-card-priority-high {
  background: #b91c1c;
}
.task-card-priority-low {
  background: #9ca3af;
}

.task-subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.3;
  color: #8a8a8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-card-tags {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.task-tag {
  font-size: 11px;
  color: #6366f1;
  background: #eef2ff;
  padding: 2px 6px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-card-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.completed-title {
  margin-top: 40px;
  margin-bottom: 14px;
  font-size: 16px;
  color: #777;
}

.completed .task-title {
  text-decoration: line-through;
  color: #888;
}

.completed-load-more-wrap {
  margin-top: 16px;
  margin-bottom: 24px;
  text-align: center;
}
.completed-load-more-btn {
  padding: 10px 24px;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.completed-load-more-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

/* ---------------------------
   RIGHT PANEL SLOT (зона, где при открытии задачи показывается редактор; когда закрыт — логотип)
----------------------------*/
.right-panel-slot {
  flex: 0 0 552px;
  width: 552px;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.right-panel-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-left: 1px solid #e5e7eb;
}

.right-panel-watermark-logo {
  max-width: 70%;
  max-height: 55%;
  object-fit: contain;
  opacity: 0.07;
}

/* ---------------------------
   RIGHT PANEL (редактор задачи)
----------------------------*/
.right-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 552px;
  background: white;
  border-left: 1px solid #e6e6e6;
  padding: 0 24px 24px 24px;
  overflow-y: auto;
  z-index: 1;

  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.right-panel.open {
  transform: translateX(0);
}

.right-panel-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  margin: 0 -24px 20px -24px;
  padding: 14px 24px 14px;
  border-bottom: 1px solid #e6e6e6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);

  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
}
.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Кнопки шапки панели: единый стиль, одна высота, иконки */
.panel-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.panel-header-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}
.panel-header-btn-icon {
  flex-shrink: 0;
  display: block;
}
.panel-header-btn-text {
  line-height: 1;
}
.panel-header-btn-done {
  padding: 0;
  width: 40px;
  min-width: 40px;
}
.panel-header-btn-reopen {
  padding: 0;
  width: 40px;
  min-width: 40px;
  color: #2563eb;
}
.panel-header-btn-reopen:hover {
  color: #1d4ed8;
}
.panel-header-btn-save {
  padding: 0;
  width: 40px;
  min-width: 40px;
}

.right-panel > .panel-section:first-of-type {
  margin-top: 20px;
}

/* Удалить задачу — внизу панели */
.panel-section-delete {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}
.panel-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fff;
  color: #b91c1c;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}
.panel-delete-btn:hover {
  background: #fef2f2;
  border-color: #f87171;
}
.panel-delete-btn svg {
  flex-shrink: 0;
}

.panel-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  color: #2563eb;
  flex-shrink: 0;
}
.panel-back-btn:hover {
  background: #f1f5f9;
  color: #1d4ed8;
}
.panel-back-btn-icon {
  display: block;
}

.panel-title {
  font-size: 18px;
  font-weight: 600;
}


/* ---------------------------
   FORM
----------------------------*/
.panel-section {
  margin-bottom: 24px;
}

.panel-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Исполнители (назначить на задачу) */
.assignees-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: 20px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 13px;
}
.assignee-chip-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.assignee-chip-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assignee-chip-remove {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.assignee-chip-remove:hover {
  background: #fee2e2;
  color: #b91c1c;
}
.assignee-select {
  width: 100%;
  max-width: 260px;
}

.panel-section input,
.panel-section textarea,
.panel-section select {
  width: 100%;
  padding: 12px;
  border: 1px solid #dedede;
  border-radius: 12px;
  background: #fafafa;
}

textarea {
  min-height: 90px;
  resize: none;
  font-size: 15px;
  line-height: 1.4;
}

.char-counter {
  font-size: 12px;
  color: #999;
  text-align: right;
  margin-top: 4px;
}

.task-title-preview {
  padding: 12px;
  border: 1px solid #dedede;
  border-radius: 12px;
  background: #fafafa;
  font-weight: 600;
}

/* address layout */
.address-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}

.field input:focus {
  background: #ffffff;
  border-color: #3b82f6;
  outline: none;
}

/* History compact */
.history-compact-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.history-compact-row {
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 6px;
}

.open-history-btn {
  margin-top: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #2563eb;
  font-weight: 600;
}

/* saved flash */
.task-card.saved-flash {
  animation: savedFlash 0.5s ease;
}

@keyframes savedFlash {
  0% { background: #dcfce7; }
  100% { background: white; }
}

/* ---------------------------
   HISTORY PANEL (overlay)
----------------------------*/
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 552px;
  height: 100%;
  background: #ffffff;
  border-left: 1px solid #e6e6e6;
  padding: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.history-panel.open {
  transform: translateX(0);
}

.history-header {
  position: sticky;
  top: 0;
  background: white;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e6e6e6;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #2563eb;
  padding: 0;
  flex-shrink: 0;
}
.history-back:hover {
  background: #f1f5f9;
  color: #1d4ed8;
}
.history-back-icon {
  display: block;
}

.history-title {
  font-size: 16px;
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.history-item {
  font-size: 14px;
  color: #333;
  padding-bottom: 12px;
  border-bottom: 1px dashed #e5e7eb;
}

.history-item-details {
  margin-top: 6px;
  padding-left: 8px;
  border-left: 2px solid #e5e7eb;
}
.history-item-line {
  font-size: 13px;
  color: #475569;
  margin-top: 2px;
  line-height: 1.35;
}
.history-item-line:first-child {
  margin-top: 0;
}
.history-meta {
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
}

/* ---------------------------
   MOBILE
----------------------------*/
@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    box-sizing: border-box;
  }
  .app-container {
    padding-top: calc(56px + env(safe-area-inset-top, 0px));
    min-height: 100vh;
  }
  .main {
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }
  .sidebar {
    position: fixed;
    top: 56px;
    left: -100%;
    bottom: 0;
    height: auto;
    z-index: 1000;
    transition: 0.3s;
  }

  .sidebar.open { left: 0; }

  /* На мобиле: Списки / Сотрудники — минималистичные строки, стрелка справа, без кнопки + */
  .sidebar-add-category-btn.icon-only,
  .sidebar .sidebar-add-category-btn {
    display: none !important;
  }
  .sidebar-accordion-section {
    margin: 0 0 2px 0;
  }
  .sidebar-accordion-trigger-right {
    margin-left: auto;
  }
  .sidebar-accordion-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #94a3b8;
    transition: transform 0.22s ease;
    flex-shrink: 0;
  }
  .sidebar-accordion-icon svg {
    display: block;
    width: 16px;
    height: 16px;
  }
  .sidebar-accordion-section.expanded .sidebar-accordion-icon {
    transform: rotate(0deg);
    color: #64748b;
  }
  .sidebar-accordion-section:not(.expanded) .sidebar-accordion-icon {
    transform: rotate(-90deg);
  }
  .sidebar-accordion-trigger {
    margin: 0;
    padding: 14px 16px 14px 20px;
    min-height: 48px;
    box-sizing: border-box;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    transition: background 0.15s ease;
  }
  .sidebar-accordion-trigger:active {
    background: #f8fafc;
  }
  .sidebar-accordion-section.expanded .sidebar-accordion-trigger {
    background: #fafafa;
    border-bottom-color: #f1f5f9;
  }
  .sidebar-accordion-section.expanded .sidebar-accordion-trigger .sidebar-title {
    color: #334155;
    font-weight: 600;
  }
  .sidebar-accordion-section.expanded .sidebar-accordion-content {
    padding: 0 0 12px 0;
  }

  /* На мобиле: аккордеон — только один блок раскрыт */
  .sidebar-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .sidebar-accordion-section.expanded .sidebar-accordion-content {
    max-height: 70vh;
    overflow-y: auto;
  }
  .sidebar-accordion-section.expanded .sidebar-accordion-content .category-list {
    overflow-y: visible;
  }
  #sidebar-accordion-lists.expanded #category-list,
  #sidebar-accordion-staff.expanded #staff-list {
    max-height: 65vh;
    overflow-y: auto;
  }

  .right-panel-slot {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    overflow: visible;
  }
  .right-panel-watermark {
    display: none;
  }
  .right-panel {
    position: fixed;
    right: -100%;
    top: 0;
    height: 100%;
    width: 100%;
    max-width: none;
    z-index: 2000;
    padding-left: 16px;
    padding-right: 16px;
  }

  .right-panel.open { right: 0; transform: none; }

  .right-panel-header {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .panel-header-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .panel-header-btn {
    height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }
  .panel-header-btn-done,
  .panel-header-btn-reopen,
  .panel-header-btn-save {
    width: 36px;
    min-width: 36px;
  }
  .panel-header-btn-icon {
    width: 16px;
    height: 16px;
  }
  .panel-title {
    font-size: 14px;
    font-weight: 600;
  }

  .history-panel {
    width: 85%;
    max-width: 552px;
    z-index: 4000;
  }

  .main {
    padding: 20px;
    padding-top: max(20px, 12px + env(safe-area-inset-top, 0px));
  }

  .address-grid { grid-template-columns: 1fr; }

  /* Кнопка «Ещё»: запас прокрутки снизу, чтобы полностью помещалась до overscroll */
  .completed-load-more-wrap {
    padding: 16px 20px 24px;
    padding-bottom: max(120px, calc(80px + env(safe-area-inset-bottom, 0px)));
  }
  .completed-load-more-btn {
    padding: 14px 32px;
    font-size: 16px;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
  }
  .main {
    overscroll-behavior-y: contain;
    /* Запас прокрутки: последняя задача и кнопка «Ещё» полностью видны до overscroll */
    padding-bottom: max(140px, calc(100px + env(safe-area-inset-bottom, 0px)));
  }
}

/* ============================================
   Address row: house / apartment / line
============================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px; /* ← ВОТ ЭТО */
}

.panel-section {
  margin-bottom: 24px;
}

.address-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.address-row .field {
  margin-bottom: 0;
}


/* ============================================
   Switch (IP / PORT)
============================================ */

.switch-grid {
  display: grid;
  grid-template-columns: 2fr 1fr; /* IP шире, PORT уже */
  gap: 12px;
}

.switch-grid input {
  padding: 12px;
  border: 1px solid #dedede;
  border-radius: 12px;
  background: #fafafa;
  font-size: 15px;
}

.switch-grid input:focus {
  background: #ffffff;
  border-color: #3b82f6;
  outline: none;
}

/* ============================================
   Subscriber info (Login / MAC / Switch)
============================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

/* Блок адреса: ул. + д. кв. лин. — аккуратное оформление */
.field-with-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field-with-prefix:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.field-prefix {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  min-width: 44px;
  justify-content: center;
}
.field-with-prefix input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: 14px;
  color: #1e293b;
}
.field-with-prefix input::placeholder {
  color: #94a3b8;
}
.field-with-prefix input:focus {
  outline: none;
}
/* Маленькие поля д./кв./лин. — компактнее */
.address-row .field-with-prefix .field-prefix {
  padding: 8px 10px;
  font-size: 12px;
  min-width: 38px;
}
.address-row .field-with-prefix input {
  padding: 8px 10px;
  font-size: 14px;
}

.field-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

.switch-row {
  display: flex;
  gap: 10px;
}

.switch-ip {
  flex: 2;
}

.switch-port {
  flex: 1;
}

/* ============================================
   Search panel (overlay)
============================================ */

.search-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 552px;
  height: 100%;
  background: #ffffff;
  border-left: 1px solid #e6e6e6;
  padding: 0;
  z-index: 2500;
  display: flex;
  flex-direction: column;

  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.search-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 24px 16px;
}
.search-panel-footer {
  flex-shrink: 0;
  padding: 16px 24px 24px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

/* открыто */
.search-panel.open {
  transform: translateX(0);
}

/* header */
.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 20px;
  flex-shrink: 0;
  border-bottom: 1px solid #e5e7eb;
}

.search-title {
  font-size: 18px;
  font-weight: 600;
}

.search-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

/* body */
.search-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* address: как в редакторе — длинная улица, снизу д. кв. лин. */
.search-address-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

/* inputs */
.search-panel input {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #dedede;
  background: #fafafa;
  font-size: 14px;
}

.search-panel input:focus {
  background: #ffffff;
  border-color: #3b82f6;
  outline: none;
}

/* search submit button — в стиле сайта */
.search-submit-btn {
  width: 100%;
  height: 44px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.search-submit-btn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.search-submit-btn:active {
  background: #1e40af;
}

/* legacy */
.search-btn {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: #2563eb;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.search-btn:hover {
  background: #1e4fd8;
}

/* mobile */
@media (max-width: 900px) {
  .search-panel {
    width: 100%;
  }
  /* font-size 16px — предотвращает авто-зум iOS при фокусе на input */
  .search-panel input {
    font-size: 16px;
  }
}

/* ============================================
   Sidebar search button
============================================ */

.sidebar-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 6px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s, border-color 0.2s, transform 0.15s ease;
}
.sidebar-search-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}
.sidebar-search-btn:active {
  transform: scale(0.96);
}
.sidebar-search-icon {
  flex-shrink: 0;
  color: #6b7280;
  width: 14px;
  height: 14px;
}
.sidebar-search-label {
  white-space: nowrap;
}

/* Кнопка «+» у Сотрудники (админка) — как у Списки */
.sidebar-admin-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-admin-btn:hover {
  background: #f9fafb;
  color: #374151;
}
.sidebar-admin-btn.icon-only {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
.sidebar-logout-btn {
  margin: 12px 10px 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #e6e6e6;
  background: #fff;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  width: calc(100% - 20px);
}
.sidebar-logout-btn:hover {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.sidebar-logout-btn {
  margin-top: auto;
  flex-shrink: 0;
}
/* Отступ между блоком «Сотрудники» и кнопкой «Выйти» */
#staff-list {
  margin-bottom: 16px;
}

/* ---------------------------
   TOAST (уведомления вместо alert)
----------------------------*/
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  max-width: 90%;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.toast.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
