.group-threads-panel {
  margin-top: 8px;
  padding: 0;
  background: transparent;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.max-group-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  text-decoration: none;
  text-align: center;
}
.new-group-thread-actions {
  margin: 0;
}
.new-group-thread-toggle {
  width: 100%;
}
.new-group-thread-form {
  display: grid;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.new-group-thread-form input {
  width: 100%;
  box-sizing: border-box;
}
.new-group-thread-form-buttons {
  display: flex;
  gap: 8px;
}
.new-group-thread-form-buttons > button {
  flex: 1;
  min-width: 0;
}
#closeSummaryInput {
  width: 100%;
  margin: 8px 0 12px;
}
.ticket-actions-bar {
  width: 100%;
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid #e2e8f0;
  margin-top: 4px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
  padding-bottom: 8px;
}
.ticket-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  justify-content: stretch;
  width: 100%;
}
.close-chat-btn {
  flex-shrink: 0;
  font-weight: 600;
}
.close-chat-btn--ready:not(:disabled) {
  box-shadow: 0 0 0 2px #fecaca;
}
.composer-actions .close-chat-btn {
  margin-left: auto;
}
.close-hint.error {
  color: #b00020;
}
.composer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.hidden-from-user-check {
  flex: 1;
  min-width: 200px;
}
.bubble.internal {
  background: #fef3c7;
  border: 1px dashed #d97706;
  color: #78350f;
}
.bubble-internal-badge {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
  opacity: 0.9;
}

*,
*::before,
*::after { box-sizing: border-box; }

body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; margin: 0; background: #e8ecf3; color: #1e293b; }
.app-root { height: 100vh; display: grid; grid-template-rows: auto 1fr; min-height: 0; }
/* Очередь и объявления в одной ячейке — переключение через data-workspace на #workspaceHost */
.workspace-host {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
#workspaceHost[data-workspace="chats"] #chatsWorkspace {
  display: grid;
  height: 100%;
  min-height: 0;
}
#workspaceHost[data-workspace="chats"] #announcementsWorkspace {
  display: none !important;
}
#workspaceHost[data-workspace="announcements"] #chatsWorkspace {
  display: none !important;
}
#workspaceHost[data-workspace="announcements"] #announcementsWorkspace {
  display: grid !important;
  height: 100%;
  min-height: 0;
}
.top-menu {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #d8deea;
  background: #ffffff;
}
.app-header {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.app-header-brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-header-title { font-weight: 700; font-size: 16px; color: #0f172a; letter-spacing: -0.02em; }
.app-header-sub { font-size: 12px; }
.app-header-nav { display: flex; gap: 8px; flex-shrink: 0; }
.menu-btn {
  width: auto;
  background: #e2e8f0;
  color: #1e293b;
}
.menu-btn-active {
  background: #1e4eb8;
  color: #fff;
}
/* Классический двухколоночный макет для объявлений */
.layout { display: grid; grid-template-columns: 340px 1fr; height: 100%; min-height: 0; }
/* Рабочее место оператора: фильтры | очередь | карточка (переписка только после выбора) */
.desk-layout {
  display: grid;
  grid-template-columns: minmax(240px, 270px) minmax(260px, 36vw) minmax(320px, 1fr);
  height: 100%;
  min-height: 0;
  background: #fff;
}
.desk-sidebar {
  border-right: 1px solid #cfd8e6;
  background: #f8fafc;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.desk-queue {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid #cfd8e6;
  background: #fff;
}
.queue-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.queue-toolbar-main {
  flex: 1;
  min-width: 0;
}
.sidebar-toggle-btn {
  flex-shrink: 0;
  width: 36px;
  min-width: 36px;
  padding: 7px 6px;
  line-height: 1;
  font-size: 14px;
}
.desk-layout.desk-sidebar-collapsed {
  grid-template-columns: 0 minmax(280px, 42vw) minmax(320px, 1fr);
}
.desk-layout.desk-sidebar-collapsed .desk-sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  border-right-width: 0;
  overflow: hidden;
  visibility: hidden;
}
.queue-heading {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
.queue-hint { margin: 0; line-height: 1.35; }
.queue-filters {
  flex-shrink: 0;
  padding: 10px 14px 10px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.queue-filters-row {
  margin-bottom: 6px;
}
.queue-filters-row > input {
  flex: 1 1 120px;
  min-width: 0;
}
.queue-filters-row > select {
  flex: 0 1 160px;
  min-width: 130px;
}
.queue-filters-unread {
  margin: 0;
  font-size: 13px;
}
.chats-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 12px;
  min-height: 0;
}
.desk-ticket-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: #f1f5f9;
}
.ticket-pane-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.ticket-pane-empty-inner {
  max-width: 420px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 28px 24px;
  background: #fff;
}
.ticket-pane-empty-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}
.ticket-pane-empty-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #475569;
}
.ticket-pane-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  margin-left: -1px;
}
.ticket-toolbar {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
}
.ticket-toolbar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ticket-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  word-break: break-word;
}
.ticket-status-line { margin: 0; }
.status-editor {
  --status-control-height: 38px;
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}
.status-editor select,
.status-editor #changeStatusBtn {
  height: var(--status-control-height);
  box-sizing: border-box;
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
}
.status-editor select {
  flex: 0 1 38%;
  width: auto;
  min-width: 120px;
  max-width: none;
  padding: 0 10px;
}
.status-editor #changeStatusBtn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  padding: 0 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.desk-back-btn {
  flex-shrink: 0;
  padding: 7px 12px;
  font-size: 13px;
}
.ticket-messages { background: #f8fafc; }
.ticket-composer { background: #fff; }
.layout > .sidebar {
  border-right: 1px solid #d8deea;
  background: #fff;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.user-panel { padding: 10px; }
.user-panel-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
#currentUserBox { width: 100%; min-width: 0; line-height: 1.4; }
/* Узкий сайдбар: кнопки в колонку на всю ширину, без обрезки справа */
.user-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.user-actions button {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  box-sizing: border-box;
}
.user-logout { width: 100%; }
.secondary-btn { background: #e2e8f0; color: #1e293b; }
.secondary-btn:hover { background: #cbd5e1; }
.user-bound-orgs { margin-top: 2px; }
.user-bound-orgs .section-title { margin-bottom: 4px; }
.user-bound-orgs-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: #334155;
  line-height: 1.45;
}
.user-bound-orgs-list .org-name { font-weight: 600; color: #1e293b; }
.content { display: flex; flex-direction: column; }
.toolbar { padding: 12px; background: #fff; border-bottom: 1px solid #d8deea; display: flex; gap: 8px; align-items: center; }
.messages { flex: 1; padding: 12px; overflow-y: auto; }
.history-box { flex: 1; padding: 12px; overflow-y: auto; background: #fff; }
.composer { padding: 12px; background: #fff; border-top: 1px solid #d8deea; display: flex; gap: 8px; }
.tabs-row { padding: 8px 12px; border-bottom: 1px solid #d8deea; background: #fff; display: flex; gap: 8px; }
.tab-btn { background: #e9eef8; color: #1f2937; }
.tab-btn.tab-active { background: #2f6fed; color: #fff; }
.event-item { border: 1px solid #e4e9f3; border-radius: 8px; padding: 8px; margin-bottom: 8px; background: #fafcff; }
.rating-panel { padding: 10px 12px; background: #fff; border-top: 1px solid #d8deea; display: grid; gap: 8px; }
.rating-row { display: flex; align-items: center; gap: 8px; }
.rating-row label { min-width: 62px; color: #445; }
.rating-row select { max-width: 220px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: grid; place-items: center; z-index: 1000; }
.modal-card { width: min(420px, calc(100vw - 32px)); background: #fff; border-radius: 12px; padding: 16px; border: 1px solid #d8deea; position: relative; display: grid; gap: 12px; }
.modal-wide { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.admin-users-table-wrap { overflow-x: auto; }
.admin-users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-users-table th,
.admin-users-table td { border: 1px solid #e2e8f0; padding: 6px 8px; text-align: left; vertical-align: top; }
.admin-users-table th { background: #f8fafc; color: #475569; font-weight: 600; }
.admin-users-table .cell-actions { white-space: nowrap; }
.modal-close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 999px; padding: 0; line-height: 1; background: #eef2f7; color: #334155; }
.ticket-queue-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 10px 8px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.ticket-queue-item:hover {
  border-color: #94a3b8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.ticket-queue-item.active {
  border-color: #1e4eb8;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #1e4eb8 inset;
}
.ticket-queue-item .chat-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.chat-row-id {
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
}
.chat-row-title {
  font-size: 13px;
  color: #334155;
  line-height: 1.35;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-row-meta {
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
  margin-bottom: 2px;
}
.chat-row-time {
  font-size: 11px;
  color: #94a3b8;
}
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #1e4eb8;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.status-badge { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.status-active { background: #e8f1ff; color: #195ec8; }
.status-in_progress { background: #e8f1ff; color: #195ec8; }
.status-analysis { background: #ede9fe; color: #5b21b6; }
.status-acceptance { background: #ecfeff; color: #0e7490; }
.status-closed { background: #edf2f7; color: #4a5568; }
.status-new { background: #fff4e5; color: #9a5900; }
.bubble { max-width: 70%; border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.in { background: #fff; border: 1px solid #d8deea; }
.out { background: #dff0dd; margin-left: auto; }
.meta { font-size: 12px; color: #667; }
.hidden { display: none !important; }
input, button, textarea, select { font-size: 14px; }
input, textarea, select { width: 100%; padding: 8px; border-radius: 6px; border: 1px solid #cbd5e1; }
input.readonly-field, textarea.readonly-field { background: #f1f5f9; color: #475569; cursor: default; }
button { padding: 8px 12px; border: 0; border-radius: 6px; background: #2f6fed; color: #fff; cursor: pointer; }
button.danger-outline-btn {
  background: #fff;
  color: #b42318;
  border: 1px solid #f0b4ad;
}
button.danger-outline-btn:hover:not(:disabled) {
  background: #fef2f2;
}
button.danger-outline-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.panel { border: 1px solid #d8deea; border-radius: 10px; padding: 10px; background: #fff; display: grid; gap: 8px; }
.panel-intro {
  padding: 6px 8px;
  gap: 4px;
}
.panel-intro h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}
.panel-intro .meta {
  margin: 0;
  line-height: 1.35;
}
#adminPanel {
  padding: 8px 10px 10px;
  gap: 6px;
}
#adminPanel > h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: #0f172a;
}
.admin-section { border-top: 1px solid #e5eaf3; padding-top: 8px; margin-top: 4px; display: grid; gap: 8px; }
.admin-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.section-title { font-size: 12px; color: #5b6578; text-transform: uppercase; letter-spacing: 0.04em; }
.field-grid { display: grid; gap: 8px; }
.field-grid.two-cols { grid-template-columns: 1fr 1fr; }
.button-row { display: flex; gap: 8px; }
.button-row > button { flex: 1; }
.logout-btn { background: #64748b; }
.logout-btn:hover { background: #475569; }
.danger-btn { background: #b42318; }
.danger-btn:hover { background: #912018; }
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row > input { flex: 1; }
.search-row > select { max-width: 140px; }
.announce-schedule {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.announce-schedule > select {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.announce-scheduled-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.announce-scheduled-title {
  margin: 0;
  font-weight: 600;
  color: #475569;
}
.announce-scheduled-fields {
  display: grid;
  gap: 8px;
}
.announce-scheduled-field {
  display: grid;
  gap: 4px;
}
.announce-field-label {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}
.announce-scheduled-field input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.announce-scheduled-hint {
  margin: 0;
  line-height: 1.35;
}
.file-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 4px 0 2px;
}
.file-picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
label.file-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
  padding: 8px 14px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  box-sizing: border-box;
  white-space: nowrap;
  background: #e2e8f0;
  color: #1e293b;
  user-select: none;
}
label.file-picker-btn:hover {
  background: #cbd5e1;
}
label.file-picker-btn:active {
  background: #b8c4d4;
}
.file-picker-name {
  flex: 1 1 120px;
  min-width: 0;
  font-size: 13px;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.announce-image-preview {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}
.admin-users-filters {
  margin-top: 2px;
  flex-wrap: wrap;
}
.admin-users-filters > input {
  min-width: 220px;
}
.admin-users-filters > select {
  max-width: 200px;
}
.admin-users-filters > button {
  min-width: 100px;
}
.incoming-feed-filters {
  display: grid;
  gap: 8px;
  width: 100%;
}
.incoming-feed-filters > input,
.incoming-feed-filters > select,
.incoming-feed-filters > button {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  box-sizing: border-box;
}
.incoming-feed-filters > button {
  justify-self: stretch;
}
#incomingFeedPanel .section-title {
  margin: 0;
}
.incoming-feed-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  background: #fafcff;
}
.incoming-item {
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 2px;
}
.incoming-item:last-child {
  border-bottom: none;
}
.incoming-item button {
  margin-top: 6px;
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}
.announcement-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  background: #fafcff;
}
.announcement-item {
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 2px;
}
.announcement-item:last-child {
  border-bottom: none;
}
.announcement-item button {
  margin-top: 6px;
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}
.announcement-details {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
}
.checkbox-row { display: flex; gap: 8px; align-items: center; color: #445; font-size: 13px; }
.checkbox-row input[type="checkbox"] { width: auto; margin: 0; }
.metrics { margin-top: 0; }
.ml-auto { margin-left: auto; }
.error { color: #b00020; margin-top: 8px; }
.login-card { max-width: 360px; margin: 120px auto; background: #fff; padding: 16px; border: 1px solid #d8deea; border-radius: 10px; display: grid; gap: 8px; }
/* Рабочая область под сетку app-root (1fr) — корректная прокрутка внутри колонок */
#chatsWorkspace.desk-layout,
#announcementsWorkspace.layout {
  min-height: 0;
}
