html.route-guard-pending body {
  visibility: hidden;
  opacity: 0;
}

:root {
  --bg: #f4f8fc;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --sidebar: #0d2348;
  --sidebar-2: #102a55;

  --border: #e7edf5;
  --border-soft: #eef3f8;

  --text: #15284a;
  --text-muted: #7e8da4;
  --text-soft: #9aa8bc;

  --primary: #2f80ed;
  --primary-hover: #226ed4;
  --primary-soft: #eaf2ff;

  --success: #33a464;
  --success-soft: #e6f7ed;

  --danger: #d96464;
  --danger-soft: #fdecec;

  --warning: #c89e2a;
  --warning-soft: #fff5d8;

  --shadow-xs: 0 1px 2px rgba(16, 36, 68, 0.04);
  --shadow-sm: 0 10px 30px rgba(17, 40, 79, 0.06);

  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(80, 139, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #edf4fb 0%, #f7fbff 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  overflow: hidden;
}

#sidebarMount {
  position: relative;
  height: 100vh;
  min-height: 100vh;
}

/* sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #eaf2ff;
  padding: 0 10px 10px;
  overflow: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(173, 191, 223, 0.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(173, 191, 223, 0.68);
  background-clip: padding-box;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0; /* ❗️ КРИТИЧНО */
  gap: 6px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(173, 191, 223, 0.55) transparent;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.sidebar-bottom {
  flex-shrink: 0; /* ❗️ чтобы не сжимался */
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 84px;
  margin: 0 0 8px;
  padding: 8px 10px 8px;
  overflow: visible;
  border-radius: 12px;
  background: transparent;
}

.brand::before {
  content: "";
  position: absolute;
  left: 42px;
  top: 34px;
  width: 84px;
  height: 84px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(180, 255, 70, 0.22) 0%,
    rgba(180, 255, 70, 0.1) 38%,
    rgba(180, 255, 70, 0) 72%
  );
  animation: brandPulseGlow 3.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

.brand::after {
  content: "";
  position: absolute;
  left: 42px;
  top: 38px;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(180, 255, 70, 0.34);
  border-radius: 50%;
  opacity: 0;
  animation: brandRadarPulse 3.2s ease-out infinite;
  pointer-events: none;
  z-index: 1;
}

.brand img {
  position: relative;
  z-index: 2;
  display: block;
  width: 170px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

@keyframes brandPulseGlow {
  0%, 100% {
    transform: translate(-50%, -50%) scale(0.96);
    opacity: 0.7;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.08);
    opacity: 1;
  }
}

@keyframes brandRadarPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.7);
    opacity: 0;
  }
  18% {
    opacity: 0.45;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.8);
    opacity: 0;
  }
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-group + .sidebar-group {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.sidebar-group-title {
  position: relative;
  padding: 0 12px;
  margin-bottom: 2px;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(210, 225, 255, 0.78);
}

.sidebar-group-title::after {
  content: "";
  display: block;
  margin-top: 6px;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(160, 190, 255, 0.35),
    rgba(160, 190, 255, 0)
  );
}

.sidebar-group:last-child::after {
  content: "";
  display: block;
  margin-top: 8px;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(160, 190, 255, 0.3),
    rgba(160, 190, 255, 0)
  );
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 12px;
  color: #d2e0fb;
  text-decoration: none;
  border-radius: 14px;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.sidebar-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.09);
}
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(85, 145, 255, 0.3) 0%, rgba(85, 145, 255, 0.12) 100%);
  color: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(137, 180, 255, 0.24),
    0 8px 22px rgba(10, 30, 72, 0.12);
  backdrop-filter: blur(6px);
}

.sidebar-link.active::before {
  background: #9bc1ff;
  box-shadow: 0 0 10px rgba(155, 193, 255, 0.35);
}

.nav-icon {
  width: 24px;
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.98;
  color: rgba(224, 236, 255, 0.98);
  flex-shrink: 0;
}

.nav-icon svg {
  width: 24px;
  height: 28px;
  stroke: currentColor;
  stroke-width: 1.05;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sidebar-link:hover .nav-icon,
.sidebar-link.active .nav-icon {
  opacity: 1;
  color: #ffffff;
}

.nav-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nav-title {
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.nav-subtitle {
  color: rgba(188, 207, 236, 0.92);
  font-size: 9.5px;
  line-height: 1.28;
  font-weight: 500;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  opacity: 0.92;
}

.sidebar-link:hover .nav-subtitle,
.sidebar-link.active .nav-subtitle {
  color: rgba(220, 233, 252, 0.98);
}

.help-link {
  color: #b9cae8;
}

.help-link .nav-title {
  color: #eef4ff;
}

.help-link .nav-subtitle {
  color: rgba(188, 207, 236, 0.9);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 54px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f1ddd8 0%, #dfc2b8 100%);
  color: #58352e;
  font-weight: 700;
  flex-shrink: 0;
}

.user-avatar.small {
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  max-width: 146px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
}

.user-role {
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.25;
  color: rgba(174, 196, 228, 0.92);
}

.user-caret {
  margin-left: auto;
  color: rgba(174, 196, 228, 0.88);
  align-self: center;
}

/* main */
.main-content {
  min-width: 0;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#topbarMount {
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(20, 40, 74, 0.06);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
}

.topbar-search {
  flex: 1;
  max-width: 300px;
}

.topbar-search input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  padding: 0 12px;
  color: var(--text);
  outline: none;
}

.topbar-search input:focus {
  border-color: #bdd3f6;
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.08);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
}

.topbar-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar-user-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.topbar-user-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.icon-btn,
.btn-secondary,
.btn-primary,
.btn-ghost {
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.16s ease;
  font-weight: 600;
}

.icon-btn {
  width: 40px;
  padding: 0;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
}

.icon-btn:hover {
  background: #fff;
}

.btn-secondary,
.btn-ghost {
  padding: 0 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
}

.btn-secondary:hover,
.btn-ghost:hover {
  background: #fff;
}

.btn-primary {
  padding: 0 14px;
  border: 1px solid var(--primary);
  background: linear-gradient(180deg, #4696ff 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(47, 128, 237, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #358cff 0%, var(--primary-hover) 100%);
}

.users-btn-inline {
  display: inline-flex;
  align-items: center;
}

/* page */
.page {
  padding: 18px 18px 24px;
  min-width: 0;
}

.page > :first-child {
  margin-top: 0;
}

.page-head {
  margin-bottom: 16px;
}

.title {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
  color: #122b57;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: #6f7f9d;
}

/* stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-inline {
  background: #fff;
  border: 1px solid #e7edf5;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(15, 36, 77, 0.04);
}

.stat-inline-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: #7082a3;
}

.stat-inline-value {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1;
  font-weight: 800;
  color: #122b57;
}

.stat-inline-meta {
  margin-top: 6px;
  font-size: 11px;
}

.stat-inline-meta.positive {
  color: var(--success);
}

.stat-inline-meta.negative {
  color: var(--danger);
}

.stat-inline-meta.muted {
  color: var(--text-muted);
}

.stat-mini {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.stat-mini-blue {
  background: #edf4ff;
  color: var(--primary);
}

.stat-mini-red {
  background: #fff0f0;
  color: var(--danger);
}

.stat-mini-green {
  background: #ebfaf1;
  color: var(--success);
}

.stat-mini-yellow {
  background: #fff6df;
  color: var(--warning);
}

/* toolbar */
.toolbar,
.card,
.table-section {
  background: #fff;
  border: 1px solid #e7edf5;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 36, 77, 0.04);
}

.toolbar {
  padding: 10px 12px;
  margin-bottom: 16px;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) repeat(2, minmax(180px, 220px)) auto;
  gap: 12px;
  align-items: end;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  white-space: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-search {
  min-width: 0;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: #7082a3;
}

.field input,
.field select,
.form-grid input,
.form-grid select,
.table-select {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid #d9e3f0;
  border-radius: 12px;
  background: #fff;
  color: #122b57;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.field input::placeholder,
.form-grid input::placeholder {
  color: #98a6bf;
}

.field input:focus,
.field select:focus,
.form-grid input:focus,
.form-grid select:focus,
.table-select:focus {
  border-color: #4d8df7;
  box-shadow: 0 0 0 4px rgba(77, 141, 247, 0.12);
}

.api-line {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.btn-primary,
.btn-ghost {
  min-height: 40px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #4d8df7 0%, #2d6cdf 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(52, 114, 234, 0.24);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-ghost {
  background: #f4f7fb;
  color: #122b57;
  border: 1px solid #dbe4f0;
}

.btn-ghost:hover {
  background: #eef3f9;
}

.btn-primary:disabled,
.btn-ghost:disabled,
.action-btn:disabled,
.table-select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.card-section {
  margin-bottom: 16px;
}

.card {
  padding: 16px;
}

.card-head {
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 800;
  color: #122b57;
}

.card-subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: #7082a3;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
}

/* table section */
.table-section {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1220px;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
}

th {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #7082a3;
  background: #fff;
  border-bottom: 1px solid #e7edf5;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fbfcfe;
}

/* geometry */
th:nth-child(1),
td:nth-child(1) { width: 80px; }

th:nth-child(2),
td:nth-child(2) { width: 180px; white-space: nowrap; }

th:nth-child(3),
td:nth-child(3) { width: 160px; white-space: nowrap; }

th:nth-child(4),
td:nth-child(4) { width: 110px; }

th:nth-child(5),
td:nth-child(5) { width: 130px; }

th:nth-child(6),
td:nth-child(6) { min-width: 280px; }

th:nth-child(7),
td:nth-child(7) { width: 110px; white-space: nowrap; }

th:nth-child(8),
td:nth-child(8) { width: 130px; white-space: nowrap; }

th:nth-child(9),
td:nth-child(9) { width: 120px; white-space: nowrap; }

.table-wrap th:nth-child(1),
.table-wrap td:nth-child(1) {
  width: 16%;
}

.table-wrap th:nth-child(2),
.table-wrap td:nth-child(2) {
  width: 20%;
}

.table-wrap th:nth-child(3),
.table-wrap td:nth-child(3) {
  width: 14%;
}

.table-wrap th:nth-child(4),
.table-wrap td:nth-child(4) {
  width: 12%;
}

.table-wrap th:nth-child(5),
.table-wrap td:nth-child(5) {
  width: 14%;
}

.table-wrap th:nth-child(6),
.table-wrap td:nth-child(6) {
  width: 12%;
}

.table-wrap td:first-child,
.table-wrap td:nth-child(2),
.cell-id {
  word-break: break-word;
  line-height: 1.35;
}

/* badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-negative,
.badge-new {
  background: var(--danger-soft);
  color: #d9534f;
}

.badge-positive,
.badge-done {
  background: var(--success-soft);
  color: #2d8a57;
}

.badge-progress {
  background: #eef4ff;
  color: #315ea8;
}

/* actions */
.row-inline-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-select {
  min-width: 120px;
  max-width: 150px;
  padding-right: 36px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.action-btn {
  min-width: 38px;
  height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d9e3f0;
  border-radius: 14px;
  background: #fff;
  color: #122b57;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.action-btn:hover {
  background: #f5f8fc;
  border-color: #c9d7ea;
}

/* states */
.loading,
.error,
.empty {
  margin: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 11px;
}

.loading {
  color: #7082a3;
}

.error {
  color: #c84545;
  background: #fff7f7;
  border: 1px solid #f0d4d4;
}

.empty {
  color: #7082a3;
  background: #f8fbff;
  border: 1px solid var(--border);
}

.success-box {
  margin-top: 8px;
  background: #eefaf3;
  color: #2f9558;
  border: 1px solid #d8efdf;
}

/* ===== Pages: users / admin ===== */
.users-toolbar-grid {
  grid-template-columns: 1.4fr 1fr 0.8fr auto;
}

/* ===== Chat ===== */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 880px;
  border: 1px solid #d9e2f2;
  border-radius: 18px;
  padding: 14px 16px;
  background: #fff;
}

.chat-bubble-in {
  align-self: flex-start;
}

.chat-bubble-out {
  align-self: flex-end;
  background: #eef4ff;
}

.chat-bubble-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: #6f7f9e;
  font-size: 11px;
  margin-bottom: 8px;
}

.chat-bubble-text {
  color: #14284b;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-extra {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: #6f7f9e;
  font-size: 11px;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 12px;
  min-height: 620px;
  align-items: stretch;
  height: calc(100vh - 164px);
  max-height: calc(100vh - 164px);
}

.inbox-sidebar,
.inbox-thread {
  background: #fff;
  border: 1px solid #dbe4f2;
  border-radius: 24px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.inbox-sidebar-head,
.inbox-thread-head {
  margin-bottom: 12px;
  flex-shrink: 0;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.conversation-item {
  width: 100%;
  text-align: left;
  border: 1px solid #dbe4f2;
  border-radius: 18px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
  transition: 0.15s ease;
}

.conversation-item:hover,
.conversation-item.active {
  border-color: #7ea6ff;
  background: #f4f8ff;
}

.conversation-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #17315c;
  font-size: 11px;
}

.conversation-item-phone {
  color: #17315c;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
}

.conversation-item-preview {
  color: #54698f;
  font-size: 11px;
  line-height: 1.35;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #7b8cab;
  font-size: 11px;
}

.conversation-alert {
  color: #c24b4b;
  font-weight: 700;
}

.thread-messages,
.clean-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scroll-behavior: smooth;
}

.thread-message {
  max-width: 78%;
  border: 1px solid #dbe4f2;
  border-radius: 20px;
  padding: 10px 12px;
}

.thread-message-in {
  align-self: flex-start;
  background: #fff;
}

.thread-message-out {
  align-self: flex-end;
  background: #eef4ff;
}

.thread-message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #7386aa;
  font-size: 11px;
  margin-bottom: 8px;
}

.thread-message-text {
  color: #17315c;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.thread-message-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: #7386aa;
  font-size: 11px;
}

.clean-conversation {
  padding: 14px;
}

.conversation-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversation-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}

.conversation-title {
  color: #17315c;
  font-size: 11px;
  line-height: 1.3;
}

.conversation-time {
  color: #7b8cab;
  font-size: 11px;
  white-space: nowrap;
}

.conversation-phone {
  color: #4f648c;
  font-size: 11px;
}

.conversation-preview {
  color: #17315c;
  font-size: 11px;
  line-height: 1.35;
}

.conversation-flags {
  margin-top: 2px;
}

.conversation-flag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #2b4f92;
  font-size: 11px;
  font-weight: 600;
}

.conversation-flag.danger {
  background: #fff0f0;
  color: #c24b4b;
}

.clean-thread {
  gap: 10px;
  min-height: 420px;
  margin-bottom: 16px;
}

.clean-thread-message {
  max-width: 72%;
  border-radius: 18px;
  padding: 10px 12px;
  border: 1px solid #dbe4f2;
  box-shadow: 0 1px 2px rgba(10, 36, 99, 0.04);
}

.clean-thread .thread-message-in {
  align-self: flex-start;
  background: #ffffff;
}

.clean-thread .thread-message-out {
  align-self: flex-end;
  background: #eef4ff;
}

.thread-message-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: #7b8cab;
  font-size: 11px;
}

.thread-message-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #2b4f92;
  font-weight: 600;
}

.thread-message-chip.danger {
  background: #fff0f0;
  color: #c24b4b;
}

.chat-reply-form {
  flex-shrink: 0;
  margin-top: 12px;
  border-top: 1px solid #e6edf8;
  padding-top: 10px;
  background: #fff;
}

.chat-reply-textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid #cfdcf1;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: #17315c;
  background: #fff;
}

.chat-reply-textarea:focus {
  outline: none;
  border-color: #7ea6ff;
  box-shadow: 0 0 0 3px rgba(126, 166, 255, 0.12);
}

.chat-reply-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* responsive */
@media (max-width: 1280px) {
  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

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

  .users-toolbar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap table {
    min-width: 920px;
  }
}

@media (max-width: 1100px) {
  .inbox-layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .thread-message,
  .clean-thread-message {
    max-width: 100%;
  }

  .inbox-sidebar,
  .inbox-thread {
    height: auto;
    min-height: 0;
  }

  .conversation-list,
  .thread-messages,
  .clean-thread {
    max-height: 420px;
  }

  .chat-reply-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  #sidebarMount,
  .sidebar,
  .main-content {
    position: static;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  #topbarMount {
    position: static;
  }

  .sidebar {
    padding: 0 12px 14px;
  }

  .sidebar-group + .sidebar-group {
    padding-top: 8px;
  }

  .conversation-list,
  .thread-messages,
  .clean-thread {
    max-height: none;
  }
}

@media (max-width: 768px) {
  .page {
    padding: 20px 16px 24px;
  }

  .title {
    font-size: 30px;
  }

  .subtitle {
    font-size: 13px;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .toolbar-grid,
  .users-toolbar-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary,
  .btn-ghost {
    width: 100%;
  }

  .card,
  .toolbar {
    padding: 16px;
  }
}
/* ===== TOPBAR UPGRADE ===== */
.topbar.topbar-upgraded {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(20, 40, 74, 0.06);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.topbar-upgraded .topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.topbar-context-card {
  min-width: 180px;
  max-width: 270px;
  padding: 9px 12px;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 6px 18px rgba(15, 36, 77, 0.05);
}

.topbar-context-label {
  font-size: 11px;
  line-height: 1.15;
  font-weight: 500;
  color: #7b8cab;
  margin-bottom: 4px;
}

.topbar-context-value {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  color: #17315c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-icon-btn {
  width: 40px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #ffffff;
  border: 1px solid #2d6cdf;
  background: linear-gradient(180deg, #4d8df7 0%, #2d6cdf 100%);
  box-shadow: 0 8px 18px rgba(52, 114, 234, 0.2);
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.topbar-icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(52, 114, 234, 0.26);
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.topbar-upgraded .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.topbar-scope {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-scope-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
}

.topbar-scope-label {
  font-size: 11px;
  line-height: 1.15;
  font-weight: 500;
  color: #6f7f9d;
  padding-left: 2px;
}

.topbar-select,
.topbar-badge {
  min-width: 126px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #d9e3f0;
  background: #fff;
  color: #17315c;
  font-size: 11px;
  font-weight: 500;
  box-sizing: border-box;
}

.topbar-select {
  padding: 0 12px;
  outline: none;
}

.topbar-select:focus {
  border-color: #4d8df7;
  box-shadow: 0 0 0 4px rgba(77, 141, 247, 0.12);
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: #f8fbff;
}

.topbar-empty {
  display: none;
  min-height: 18px;
  font-size: 11px;
  color: #8b99b2;
  align-items: center;
}

.topbar-upgraded .topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.topbar-upgraded .topbar-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar-upgraded .topbar-user-name {
  font-size: 11px;
  font-weight: 600;
  color: #17315c;
}

.topbar-upgraded .topbar-user-sub {
  font-size: 11px;
  color: #7f90aa;
}

.topbar-fallback-notice {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff7e7;
  border: 1px solid #f0deaa;
  color: #8b6b17;
  font-size: 11px;
}

@media (max-width: 1100px) {
  .topbar.topbar-upgraded {
    align-items: flex-start;
  }

  .topbar-upgraded .topbar-left,
  .topbar-upgraded .topbar-right {
    width: 100%;
  }

  .topbar-upgraded .topbar-right {
    margin-left: 0;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .topbar.topbar-upgraded {
    padding: 10px 12px;
  }

  .topbar-context-card {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .topbar-upgraded .topbar-left {
    width: 100%;
  }

  .topbar-scope {
    width: 100%;
  }

  .topbar-scope-field {
    flex: 1 1 180px;
  }
}
/* ===== TOPBAR BUTTONS BLUE ===== */
.topbar-v2-btn,
.topbar-v2-btn-secondary,
#usersBtn,
#logoutBtn {
  background: linear-gradient(180deg, #4e93ff 0%, #2f80ed 100%);
  color: #fff;
  border: none;
  box-shadow: 0 6px 16px rgba(47, 128, 237, 0.22);
}

.topbar-v2-btn:hover,
#usersBtn:hover,
#logoutBtn:hover {
  background: linear-gradient(180deg, #3f86f5 0%, #276fd1 100%);
  transform: translateY(-1px);
}
/* ===== TOPBAR AVATAR FORCE BLUE ===== */
.topbar.topbar-v2 #topbarUserAvatar,
.topbar-v2-avatar,
.topbar .topbar-v2-avatar,
.topbar .user-avatar.small#topbarUserAvatar {
  width: 40px;
  height: 34px;
  min-width: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #4e93ff 0%, #2f80ed 100%) !important;
  color: #ffffff !important;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(47, 128, 237, 0.25);
  border: none !important;
}
/* ===== TOPBAR ACTION BUTTONS = same as filter button ===== */
.topbar-action-btn,
.topbar.topbar-v2 #usersBtn,
.topbar.topbar-v2 #logoutBtn {
  min-height: 34px;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
  border: none;
}

/* compact unified theme */
.topbar-upgraded { box-shadow: 0 1px 0 rgba(16,36,68,.05); }
.topbar-left{display:flex;align-items:center;gap:10px;min-width:0;}
.topbar-context-card{display:flex;flex-direction:column;justify-content:center;min-width:196px;max-width:240px;padding:8px 12px;border:1px solid var(--border);border-radius:14px;background:rgba(255,255,255,.9);box-shadow:var(--shadow-xs);}
.topbar-context-label,.topbar-scope-label{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:#7f8da5;}
.topbar-context-value{margin-top:2px;font-size:12px;font-weight:700;color:#17346f;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.topbar-icon-btn{width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:12px;border:1px solid var(--border);background:linear-gradient(180deg,#5da0ff 0%,#3d81f0 100%);box-shadow:0 8px 18px rgba(47,128,237,.18);color:#fff;text-decoration:none;}
.topbar-icon-btn svg{width:18px;height:18px;stroke:currentColor;stroke-width:1.8;}
.topbar-scope{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.topbar-scope-field{display:flex;flex-direction:column;gap:4px;min-width:0;}
.topbar-select,.topbar-badge,.topbar-empty{min-width:136px;max-width:190px;height:36px;padding:0 12px;border:1px solid var(--border);border-radius:12px;background:rgba(255,255,255,.9);display:flex;align-items:center;color:#17346f;font-size:12px;}
.topbar-select{appearance:auto;}
.topbar-empty{color:var(--text-muted);}
.topbar-action-btn{min-width:110px;}
.topbar-fallback-notice{margin-top:8px;padding:8px 10px;border-top:1px solid rgba(20,40,74,.05);font-size:12px;color:#7f8da5;}
.page-head.compact-head{margin-bottom:14px;}
.table-section .subtitle,#paginationInfo.subtitle{font-size:12px;color:var(--text-muted);}
@media (max-width: 1280px){ .stats-row{grid-template-columns:repeat(2,minmax(0,1fr));} .toolbar-grid{grid-template-columns:repeat(2,minmax(0,1fr));} }
@media (max-width: 980px){ .app-shell{grid-template-columns:78px minmax(0,1fr);} .sidebar{padding:0 8px 8px;} .brand{justify-content:center;padding:10px 0;} .brand img{width:46px;} .brand::before,.brand::after,.sidebar-group-title,.nav-subtitle,.user-meta,.user-caret{display:none;} .sidebar-link{justify-content:center;padding:10px 8px;} .nav-text-wrap{display:none;} .topbar{flex-direction:column;align-items:stretch;} .topbar-right{justify-content:space-between;} .toolbar-grid,.stats-row,.form-grid{grid-template-columns:1fr;} }

/* =========================================
   CHAT CONVERSATIONS — TARGETED FIX
   под текущий chat-conversations.html
   ========================================= */

body[data-page="chat-conversations"] {
  overflow: hidden;
}

body[data-page="chat-conversations"] .main-content {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* страница под topbar */
body[data-page="chat-conversations"] .page {
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100vh - 86px);
  max-height: calc(100vh - 86px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 18px;
  box-sizing: border-box;
}

/* верх страницы */
body[data-page="chat-conversations"] .page-head {
  flex: 0 0 auto;
  margin: 0 0 10px;
}

body[data-page="chat-conversations"] .page-head .title {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.15;
}

body[data-page="chat-conversations"] .page-head .subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
}

/* фильтры */
body[data-page="chat-conversations"] .toolbar {
  flex: 0 0 auto;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 18px;
}

/* главная рабочая область */
body[data-page="chat-conversations"] .inbox-layout {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

/* левая колонка */
body[data-page="chat-conversations"] .inbox-sidebar {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
}

body[data-page="chat-conversations"] .inbox-sidebar-head {
  flex: 0 0 auto;
  padding: 16px 16px 10px;
}

body[data-page="chat-conversations"] #conversationsLoading,
body[data-page="chat-conversations"] #conversationsError,
body[data-page="chat-conversations"] #conversationsEmpty {
  flex: 0 0 auto;
  margin: 0 16px 10px;
}

body[data-page="chat-conversations"] .conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px 12px;
}

/* правая колонка */
body[data-page="chat-conversations"] .inbox-thread {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
}

body[data-page="chat-conversations"] .inbox-thread-head {
  flex: 0 0 auto;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #e8eef7;
}

body[data-page="chat-conversations"] #threadLoading,
body[data-page="chat-conversations"] #threadError,
body[data-page="chat-conversations"] #threadEmpty {
  flex: 0 0 auto;
  margin: 10px 18px 0;
}

/* область сообщений */
body[data-page="chat-conversations"] .thread-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* форма ответа как мессенджер */
body[data-page="chat-conversations"] .chat-reply-form {
  flex: 0 0 auto;
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid #e8eef7;
  background: #fff;
}

body[data-page="chat-conversations"] .chat-reply-form .field {
  margin: 0 !important;
}

body[data-page="chat-conversations"] .chat-reply-form .field-label {
  display: none;
}

body[data-page="chat-conversations"] .chat-reply-textarea {
  width: 100%;
  min-height: 46px;
  height: 46px;
  max-height: 120px;
  resize: none;
  padding: 12px 16px;
  border-radius: 22px;
  border: 1px solid #d8e3f2;
  background: #f7faff;
  font-size: 13px;
  line-height: 1.35;
  box-sizing: border-box;
}

/* нижняя строка */
body[data-page="chat-conversations"] .chat-reply-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body[data-page="chat-conversations"] #replyStatus {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.2;
  color: #6f7f9e;
}

body[data-page="chat-conversations"] #sendReplyBtn {
  height: 42px;
  padding: 0 18px;
  border-radius: 21px;
  flex: 0 0 auto;
}

/* элементы списка диалогов компактнее */
body[data-page="chat-conversations"] .conversation-list .conversation-item,
body[data-page="chat-conversations"] .conversation-list > div {
  min-height: auto;
}

/* если у карточек диалога нет отдельного класса */
body[data-page="chat-conversations"] .conversation-list > * {
  margin-bottom: 10px;
}

/* компактнее общий вид карточек/сообщений */
body[data-page="chat-conversations"] .card-title {
  font-size: 16px;
  line-height: 1.2;
  margin: 0;
}

body[data-page="chat-conversations"] .card-subtitle {
  font-size: 12px;
  line-height: 1.35;
  margin: 4px 0 0;
}

/* аккуратный внутренний скролл */
body[data-page="chat-conversations"] .conversation-list::-webkit-scrollbar,
body[data-page="chat-conversations"] .thread-messages::-webkit-scrollbar {
  width: 8px;
}

body[data-page="chat-conversations"] .conversation-list::-webkit-scrollbar-thumb,
body[data-page="chat-conversations"] .thread-messages::-webkit-scrollbar-thumb {
  background: rgba(102, 130, 186, 0.28);
  border-radius: 999px;
}

/* на более узких экранах */
@media (max-width: 1280px) {
  body[data-page="chat-conversations"] .inbox-layout {
    grid-template-columns: 330px minmax(0, 1fr);
  }
}

@media (max-width: 1024px) {
  body[data-page="chat-conversations"] {
    overflow: auto;
  }

  body[data-page="chat-conversations"] .main-content,
  body[data-page="chat-conversations"] .page {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  body[data-page="chat-conversations"] .inbox-layout {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  body[data-page="chat-conversations"] .inbox-sidebar,
  body[data-page="chat-conversations"] .inbox-thread {
    height: 420px;
  }
}
/* =========================================
   CHAT CONVERSATIONS — FINAL MESSAGE LAYOUT
   ========================================= */

body[data-page="chat-conversations"] .thread-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body[data-page="chat-conversations"] .thread-message-row {
  display: flex;
  width: 100%;
  margin: 0;
}

body[data-page="chat-conversations"] .thread-message-row.incoming {
  justify-content: flex-start;
}

body[data-page="chat-conversations"] .thread-message-row.outgoing {
  justify-content: flex-end;
}

body[data-page="chat-conversations"] .thread-message-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(520px, 78%);
  min-width: 0;
}

body[data-page="chat-conversations"] .thread-message-row.incoming .thread-message-stack {
  align-items: flex-start;
}

body[data-page="chat-conversations"] .thread-message-row.outgoing .thread-message-stack {
  align-items: flex-end;
}

body[data-page="chat-conversations"] .thread-message-meta {
  margin: 0 2px;
  font-size: 11px;
  line-height: 1.15;
  color: #4b82d6;
}

body[data-page="chat-conversations"] .thread-message-bubble {
  display: inline-flex;
  align-items: flex-end;
  gap: 6px;
  width: auto;
  max-width: 100%;
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 12px;
  box-sizing: border-box;
}

body[data-page="chat-conversations"] .thread-message-row.incoming .thread-message-bubble {
  background: #ffffff;
  border: 1px solid #dfe7f3;
}

body[data-page="chat-conversations"] .thread-message-row.outgoing .thread-message-bubble {
  background: #eaf3ff;
  border: 1px solid #d5e4fb;
}

body[data-page="chat-conversations"] .thread-message-text {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: #17315c;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

body[data-page="chat-conversations"] .thread-message-time {
  flex: 0 0 auto;
  margin: 0;
  font-size: 10px;
  line-height: 1;
  color: #7b8cab;
  opacity: 0.9;
  white-space: nowrap;
  align-self: flex-end;
}

body[data-page="chat-conversations"] .thread-message-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
  background: #edf3ff;
  color: #5b78b6;
}

body[data-page="chat-conversations"] .thread-message-badge.danger {
  background: #fff1f1;
  color: #d14b4b;
}
/* =========================================
   SETTINGS — UNIFIED BRAND STYLE
   ========================================= */

body[data-page="settings"] .settings-sidebar .is-active,
body[data-page="settings"] .settings-sidebar .active,
body[data-page="settings"] .settings-nav .is-active,
body[data-page="settings"] .settings-nav .active,
body[data-page="settings"] .settings-sections .is-active,
body[data-page="settings"] .settings-sections .active,
body[data-page="settings"] .settings-tab.active,
body[data-page="settings"] .settings-pill.active,
body[data-page="settings"] .settings-section-btn.active,
body[data-page="settings"] .settings-section-btn.is-active {
  background: linear-gradient(135deg, #4d8df7 0%, #2d6cdf 100%) !important;
  color: #fff !important;
  border-color: #2d6cdf !important;
  box-shadow: 0 10px 24px rgba(52, 114, 234, 0.20) !important;
}

body[data-page="settings"] .settings-sidebar button,
body[data-page="settings"] .settings-nav button,
body[data-page="settings"] .settings-section-btn,
body[data-page="settings"] .settings-tab,
body[data-page="settings"] .settings-pill {
  border: 1px solid #dbe4f0;
  background: #fff;
  color: #122b57;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

body[data-page="settings"] .settings-sidebar button:hover,
body[data-page="settings"] .settings-nav button:hover,
body[data-page="settings"] .settings-section-btn:hover,
body[data-page="settings"] .settings-tab:hover,
body[data-page="settings"] .settings-pill:hover {
  background: #f4f8ff;
  border-color: #bfd3f7;
  color: #17346f;
}

/* карточки/кнопки выбора точки */
body[data-page="settings"] .branch-tab.active,
body[data-page="settings"] .branch-pill.active,
body[data-page="settings"] .branch-card.active,
body[data-page="settings"] .branch-item.active,
body[data-page="settings"] .settings-branch.active,
body[data-page="settings"] .settings-branch.is-active {
  background: linear-gradient(135deg, #4d8df7 0%, #2d6cdf 100%) !important;
  border-color: #2d6cdf !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(52, 114, 234, 0.20) !important;
}

body[data-page="settings"] .branch-tab.active *,
body[data-page="settings"] .branch-pill.active *,
body[data-page="settings"] .branch-card.active *,
body[data-page="settings"] .branch-item.active *,
body[data-page="settings"] .settings-branch.active *,
body[data-page="settings"] .settings-branch.is-active * {
  color: #fff !important;
}

/* статусные плашки в карточке точки */
body[data-page="settings"] .status-chip,
body[data-page="settings"] .settings-badge,
body[data-page="settings"] .settings-status {
  border: 1px solid #dbe4f0;
  background: #f8fbff;
  color: #17346f;
}

body[data-page="settings"] .status-chip.is-active,
body[data-page="settings"] .status-chip.success,
body[data-page="settings"] .settings-badge.success,
body[data-page="settings"] .settings-status.success {
  background: #eaf2ff;
  color: #2d6cdf;
  border-color: #cfe0fb;
}

/* если где-то остались тёмные forced-кнопки */
body[data-page="settings"] button[style*="background: #111"],
body[data-page="settings"] button[style*="background:#111"],
body[data-page="settings"] button[style*="background: black"],
body[data-page="settings"] button[style*="background:black"],
body[data-page="settings"] [style*="background: #0"],
body[data-page="settings"] [style*="background:#0"] {
  background: linear-gradient(135deg, #4d8df7 0%, #2d6cdf 100%) !important;
  color: #fff !important;
  border-color: #2d6cdf !important;
}

/* чуть мягче общий вид карточек в настройках */
body[data-page="settings"] .card,
body[data-page="settings"] .settings-card,
body[data-page="settings"] .settings-panel,
body[data-page="settings"] .settings-sidebar,
body[data-page="settings"] .settings-content {
  border-color: #e7edf5;
  box-shadow: 0 8px 24px rgba(15, 36, 77, 0.04);
}
/* =========================================
   SIDEBAR — USER AVATAR (UNIFY WITH TOPBAR)
   ========================================= */

.sidebar .user-block .avatar,
.sidebar .user-profile .avatar,
.sidebar .user .avatar,
.sidebar .user-info .avatar,
.sidebar [class*="user"] [class*="avatar"] {
  background: linear-gradient(135deg, #4d8df7 0%, #2d6cdf 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 6px 14px rgba(52, 114, 234, 0.25);
}

/* если там круглый контейнер */
.sidebar [class*="avatar"] {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}