/* Arti CRM — clean light redesign based on Figma reference
   Single source of truth for UI styles. No legacy inline overrides. */

:root {
  --crm-bg: #f3f3f3;
  --crm-bg-soft: #f7f7f7;
  --crm-panel: #ffffff;
  --crm-panel-soft: #fafafa;
  --crm-panel-muted: #f0f0f0;
  --crm-line: #e3e3e3;
  --crm-line-strong: #d7d7d7;
  --crm-text: #222222;
  --crm-text-soft: #454545;
  --crm-muted: #777777;
  --crm-muted-2: #a0a0a0;
  --crm-active: #e7e7e7;
  --crm-hover: #f1f1f1;
  --crm-primary: #111111;
  --crm-primary-soft: #ededed;
  --crm-blue: #dfeaf9;
  --crm-blue-text: #2d577d;
  --crm-green: #e5f2df;
  --crm-green-text: #3b6a31;
  --crm-red: #f9e5e3;
  --crm-red-text: #9b4a42;
  --crm-orange: #f8eadc;
  --crm-orange-text: #8a5731;
  --crm-purple: #f0e2fb;
  --crm-purple-text: #73508b;
  --crm-yellow: #fbf0cd;
  --crm-yellow-text: #80601a;
  --crm-shadow-xs: 0 1px 2px rgba(0, 0, 0, .04);
  --crm-shadow-sm: 0 4px 14px rgba(0, 0, 0, .05);
  --crm-shadow-md: 0 14px 34px rgba(0, 0, 0, .08);
  --crm-radius-xs: 5px;
  --crm-radius-sm: 7px;
  --crm-radius-md: 10px;
  --crm-radius-lg: 14px;
  --crm-sidebar: 214px;
  --crm-chat-list: 404px;
  --crm-focus: 0 0 0 3px rgba(120, 120, 120, .16);
  color: var(--crm-text);
  font-family: "Onest", "Segoe UI", Roboto, Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--crm-bg);
  color: var(--crm-text);
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--crm-muted); }
.soft-counter { color: var(--crm-muted); font-weight: 500; }

button,
.button-like {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--crm-radius-sm);
  background: var(--crm-text);
  border: 1px solid var(--crm-text);
  color: #fff;
  box-shadow: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .15s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
button.secondary,
button.ghost,
button.crm-light-btn,
button.user-light-btn,
button.refresh-btn,
button.small.secondary,
button.small.ghost {
  background: #fff;
  border: 1px solid var(--crm-line);
  color: var(--crm-text);
}
button.secondary:hover,
button.ghost:hover,
button.crm-light-btn:hover,
button.user-light-btn:hover,
button.refresh-btn:hover { background: var(--crm-hover); border-color: var(--crm-line-strong); }
button.link-btn {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--crm-text-soft);
  text-decoration: none;
}
button.link-btn:hover { color: var(--crm-text); text-decoration: underline; transform: none; }
button.small { min-height: 28px; padding: 5px 9px; font-size: 12px; border-radius: 6px; }
button.icon-btn:not(#extraMenuBtn),
.mobile-back-btn,
.reply-templates-close,
.reply-template-add-icon,
.knowledge-modal-close,
.knowledge-modal-nav,
.message-actions-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--crm-radius-sm);
  background: #fff;
  border: 1px solid var(--crm-line);
  color: var(--crm-text-soft);
  box-shadow: none;
}
button.icon-btn:not(#extraMenuBtn):hover,
.mobile-back-btn:hover,
.reply-templates-close:hover,
.reply-template-add-icon:hover,
.knowledge-modal-close:hover,
.knowledge-modal-nav:hover,
.message-actions-btn:hover { background: var(--crm-hover); color: var(--crm-text); }

input, select, textarea {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  background: #fff;
  color: var(--crm-text);
  outline: 0;
  box-shadow: none;
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 72px; }
input::placeholder, textarea::placeholder { color: var(--crm-muted-2); }
input:focus, select:focus, textarea:focus, button:focus-visible { border-color: var(--crm-line-strong); box-shadow: var(--crm-focus); }
label { display: grid; gap: 6px; color: var(--crm-text-soft); font-size: 13px; }

.auth-pending #appShell,
.auth-pending #loginScreen { display: none !important; }
.auth-boot-screen,
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--crm-bg);
}
.auth-boot-card,
.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--crm-radius-lg);
  border: 1px solid var(--crm-line);
  background: #fff;
  box-shadow: var(--crm-shadow-md);
}
.login-card { display: grid; gap: 13px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; color: var(--crm-muted); }
.login-mark,
.auth-boot-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--crm-active);
  color: var(--crm-text);
  font-weight: 700;
}
.login-error { color: var(--crm-red-text); font-size: 13px; }

.app-shell {
  height: 100vh;
  width: 100vw;
  display: grid;
  grid-template-columns: var(--crm-sidebar) minmax(0, 1fr);
  overflow: hidden;
  background: var(--crm-bg);
}
.app-locked { pointer-events: none; user-select: none; }

.app-nav {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 16px 13px;
  background: #fff;
  border-right: 1px solid var(--crm-line);
  overflow: hidden;
}
.brand-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 3px;
  background: #dfdfdf;
  border: 1px solid #dddddd;
  color: #222;
  box-shadow: none;
}
.brand-mark { display: none; }
.brand-copy h1 {
  margin: 0;
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .01em;
}
.brand-copy p { display: none; }

.main-nav,
.account-nav,
.notifications-widget { display: grid; gap: 4px; }
.nav-spacer { flex: 1 1 auto; }
.nav-btn {
  width: 100%;
  min-height: 34px;
  justify-content: flex-start;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--crm-text);
  box-shadow: none;
  font-weight: 500;
}
.nav-btn:hover,
.nav-btn.active {
  background: var(--crm-active);
  border-color: var(--crm-active);
  transform: none;
}
.nav-btn .btn-icon {
  width: 18px;
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  color: var(--crm-text-soft);
}
.nav-btn svg,
.btn-icon svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-card,
.user-card {
  min-height: 33px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--crm-panel-soft);
  border: 1px solid var(--crm-line);
  color: var(--crm-muted);
  font-size: 12px;
}
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fa65f;
  flex: 0 0 auto;
}
.notification-badge {
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--crm-red);
  color: var(--crm-red-text);
  font-size: 11px;
  font-weight: 700;
}
.mobile-more-btn,
.mobile-logout-btn { display: none; }

.workspace {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  padding: 16px;
  background: var(--crm-bg);
}
.view { height: 100%; min-width: 0; }
.active-view { display: block; }
.panel-card {
  background: var(--crm-panel);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-lg);
  box-shadow: var(--crm-shadow-xs);
}
.layout {
  display: grid;
  grid-template-columns: minmax(320px, var(--crm-chat-list)) minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-height: 0;
}
.sidebar {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}
.section-title-row h2,
.tasks-toolbar h2,
.tasks-ref-toolbar h2 { margin: 0; font-size: 18px; line-height: 1.1; }
.section-title-row p,
.tasks-toolbar p { margin: 4px 0 0; color: var(--crm-muted); }
.filters,
.review-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.filters button,
.filters select,
.filters input,
.review-filters button,
.review-filters select,
.review-filters input { min-width: 0; }
.check-filter { display: flex; align-items: center; gap: 7px; }
.check-filter input { width: auto; min-height: auto; }
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--crm-muted);
  font-size: 12px;
}
.stats span,
.stats div {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--crm-panel-soft);
  border: 1px solid var(--crm-line);
}
.chat-list,
.reviews-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-auto-rows: 100px;
  gap: 8px;
  padding: 1px 2px 6px;
}
.chat-item,
.review-item,
.empty-card,
.empty-chat-item {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border-radius: var(--crm-radius-md);
  background: #fff;
  border: 1px solid var(--crm-line);
  box-shadow: var(--crm-shadow-xs);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.chat-item:hover,
.review-item:hover { background: #fbfbfb; border-color: var(--crm-line-strong); }
.chat-item.active,
.review-item.active { background: var(--crm-panel-soft); border-color: var(--crm-line-strong); box-shadow: var(--crm-shadow-sm); }
.chat-item-topline,
.chat-item-title,
.review-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.chat-item-title { width: 100%; }
.chat-item-title strong,
.review-item strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.chat-time { color: var(--crm-muted-2); font-size: 11px; white-space: nowrap; }
.preview,
.review-item p { margin: 0; color: var(--crm-text-soft); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-item-footer,
.chat-badges,
.review-stars { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }

.badge,
.marketplace-pill,
.status-badge,
.review-status,
.sla-badge,
.assignee-chip,
.rating-badge,
.tasks-ref-pill,
.task-card-pill,
.notification-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 11px;
  line-height: 1.1;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ozon,
.marketplace-pill.ozon,
.badge.OZON { background: var(--crm-blue); color: var(--crm-blue-text); }
.badge.wb,
.marketplace-pill.wb,
.badge.WB,
.badge.wildberries,
.marketplace-pill.wildberries { background: var(--crm-purple); color: var(--crm-purple-text); }
.badge.yandex,
.marketplace-pill.yandex,
.badge.ym,
.marketplace-pill.ym { background: var(--crm-red); color: var(--crm-red-text); }
.status-badge,
.review-status,
.assignee-chip { background: var(--crm-blue); color: var(--crm-blue-text); }
.status-new,
.review-status-new,
.tasks-ref-status-pill-open { background: var(--crm-green); color: var(--crm-green-text); }
.status-waiting,
.status-color-orange,
.sla-badge { background: var(--crm-red); color: var(--crm-red-text); }
.status-in_progress,
.status-in-progress,
.status-color-blue,
.review-status-answered { background: var(--crm-blue); color: var(--crm-blue-text); }
.status-closed,
.status-archived,
.review-status-processed,
.tasks-ref-status-pill-archive { background: var(--crm-panel-muted); color: var(--crm-text-soft); }
.status-color-green { background: var(--crm-green); color: var(--crm-green-text); }
.status-color-red { background: var(--crm-red); color: var(--crm-red-text); }
.status-color-purple { background: var(--crm-purple); color: var(--crm-purple-text); }
.status-color-gray { background: var(--crm-panel-muted); color: var(--crm-text-soft); }
.rating-badge { background: var(--crm-yellow); color: var(--crm-yellow-text); }

.conversation {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.empty-state {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--crm-muted);
  text-align: center;
}
.chat-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--crm-line);
  background: #fff;
  z-index: 8;
}
.chat-heading-row { display: flex; align-items: center; gap: 10px; min-width: 0; position: relative; }
.customer-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--crm-active);
  color: var(--crm-text);
  font-weight: 700;
  text-align: center;
  align-content: center;
}
.chat-title-stack { min-width: 0; }
.chat-title-inline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-title-inline h2 { margin: 0; font-size: 16px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chatSubtitle { margin: 3px 0 0; color: var(--crm-muted); font-size: 12px; }
.chat-controls { display: flex; gap: 8px; align-items: center; }
.chat-controls select { width: auto; min-width: 138px; }
.mobile-back-btn { display: none; }
.extra-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 210px;
  padding: 6px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: #fff;
  box-shadow: var(--crm-shadow-md);
}
.extra-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 32px;
  padding: 7px 9px;
  background: transparent;
  border: 0;
  color: var(--crm-text);
}
.extra-menu button:hover { background: var(--crm-hover); transform: none; }
.extra-panel {
  position: absolute;
  top: var(--chat-extra-panel-top, 78px);
  right: 14px;
  z-index: 35;
  width: min(324px, calc(100% - 28px));
  max-height: min(620px, calc(100% - var(--chat-extra-panel-top, 78px) - 14px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border-radius: var(--crm-radius-lg);
  border: 1px solid var(--crm-line);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--crm-shadow-md);
  backdrop-filter: blur(14px);
}
.extra-section { display: grid; gap: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-head h3 { margin: 0; font-size: 14px; }
.task-list { display: grid; gap: 8px; }
.task-form,
.note-form,
.customer-form,
.task-create-form-v2 { display: grid; gap: 8px; }
.task-form textarea,
.note-form textarea { min-height: 72px; }
.task-create-actions { display: flex; justify-content: flex-end; }

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  background: #fff;
}
.message {
  max-width: min(640px, 76%);
  display: grid;
  gap: 4px;
  align-self: flex-start;
}
.message.outbound { align-self: flex-end; }
.message.internal { align-self: center; max-width: min(420px, 86%); }
.message-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  color: var(--crm-muted-2);
  font-size: 10px;
  min-height: 16px;
}
.message-text {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f2f2f2;
  color: var(--crm-text);
  box-shadow: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.outbound .message-text { background: #f3f3f3; }
.message.internal .message-text {
  background: #fff;
  border: 1px solid var(--crm-line);
  box-shadow: var(--crm-shadow-xs);
}
.message.ai-selected-message .message-text { outline: 2px solid #cddff6; }
.message-actions-menu-wrap { position: relative; margin-left: 5px; }
.message-actions-menu {
  position: absolute;
  right: 0;
  top: 24px;
  z-index: 45;
  min-width: 126px;
  padding: 5px;
  border-radius: var(--crm-radius-sm);
  background: #fff;
  border: 1px solid var(--crm-line);
  box-shadow: var(--crm-shadow-md);
}
.message-actions-menu button { width: 100%; justify-content: flex-start; background: transparent; border: 0; color: var(--crm-text); min-height: 28px; }
.internal-note-actions { display: flex; gap: 8px; justify-content: flex-end; }
.internal-note-action { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--crm-muted); font-size: 11px; }
.internal-note-delete { color: var(--crm-red-text); }
.internal-note-editor { display: grid; gap: 7px; }
.message-images,
.review-media { display: flex; flex-wrap: wrap; gap: 8px; }
.image-card {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-panel-soft);
  color: var(--crm-muted);
  text-decoration: none;
}
.image-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-fallback { font-size: 12px; text-align: center; padding: 8px; }
.message-receipt { justify-self: end; color: var(--crm-muted-2); font-size: 10px; }
.message-receipt.is-read { color: var(--crm-blue-text); }
.chat-loading-card { align-self: center; }

.ai-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--crm-line);
  background: var(--crm-panel-soft);
}
.ai-selection-bar strong { display: block; font-size: 12px; }
.ai-selection-bar span { color: var(--crm-muted); font-size: 12px; }
.ai-selection-actions { display: flex; gap: 8px; }
.composer {
  flex: 0 0 auto;
  position: relative;
  padding: 14px 18px;
  border-top: 1px solid var(--crm-line);
  background: #fff;
}
.composer-main-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px 42px;
  gap: 8px;
  align-items: center;
}
.composer-attach-btn,
.composer-template-btn,
.composer-send-btn {
  min-width: 0;
  width: 34px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--crm-radius-sm);
  background: #fff;
  color: var(--crm-text-soft);
  border: 1px solid transparent;
}
.composer-attach-btn:hover,
.composer-template-btn:hover { background: var(--crm-hover); border-color: var(--crm-line); }
.composer-send-btn { width: 42px; background: #fff; border-color: transparent; color: var(--crm-text); }
#messageText { min-height: 36px; max-height: 160px; resize: none; padding-top: 8px; }
#messageText.ai-filled { box-shadow: 0 0 0 3px rgba(223, 234, 249, .8); }
.composer-attachments { margin-bottom: 9px; display: flex; gap: 8px; flex-wrap: wrap; }
.reply-templates-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(380px, calc(100% - 36px));
  max-height: 430px;
  overflow: auto;
  padding: 12px;
  border-radius: var(--crm-radius-lg);
  border: 1px solid var(--crm-line);
  background: #fff;
  box-shadow: var(--crm-shadow-md);
  z-index: 34;
}
.reply-templates-head,
.reply-templates-head-actions,
.reply-template-create-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reply-templates-title { font-weight: 700; }
.reply-templates-subtitle { color: var(--crm-muted); font-size: 12px; margin-top: 2px; }
.reply-template-create { display: grid; gap: 8px; margin-top: 10px; }
.reply-templates-list { display: grid; gap: 7px; margin-top: 10px; overflow-x: hidden; }
.reply-template-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 5px;
  align-items: stretch;
}
.reply-template-item {
  width: 100%;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 10px 11px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: var(--crm-panel-soft);
  cursor: pointer;
  text-align: left;
}
.reply-template-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding-top: 2px;
}
button.reply-template-action,
html[data-theme="dark"] button.reply-template-action {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 7px;
  background: transparent !important;
  color: var(--crm-muted) !important;
  box-shadow: none !important;
}
button.reply-template-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
button.reply-template-action:hover,
button.reply-template-action:focus-visible,
html[data-theme="dark"] button.reply-template-action:hover,
html[data-theme="dark"] button.reply-template-action:focus-visible {
  background: var(--crm-hover) !important;
  color: var(--crm-text) !important;
  border: 0 !important;
  transform: none;
}
button.reply-template-delete-action:hover,
button.reply-template-delete-action:focus-visible,
html[data-theme="dark"] button.reply-template-delete-action:hover,
html[data-theme="dark"] button.reply-template-delete-action:focus-visible {
  color: var(--crm-red-text) !important;
}
.reply-template-item-title {
  display: block;
  overflow: hidden;
  color: var(--crm-text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-template-item-preview {
  color: var(--crm-muted);
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  text-align: left;
  white-space: break-spaces;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.notification-toast-stack {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 10000;
  width: min(360px, calc(100vw - 44px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}
.notification-toast-stack.has-items { pointer-events: auto; }
.notification-toast {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 11px 36px 11px 12px;
  border: 1px solid rgba(127, 145, 170, .16);
  border-radius: 12px;
  background: rgba(248, 251, 255, .88);
  box-shadow: 0 6px 18px rgba(25, 39, 66, .08);
  color: var(--crm-text);
  cursor: pointer;
}
.notification-close-btn,
#extraMenuBtn {
  border: 0;
  box-shadow: none;
}
.notification-close-btn {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  background: transparent;
  color: var(--crm-muted);
  font-size: 18px;
  line-height: 1;
}
.notification-close-btn:focus-visible,
#extraMenuBtn:hover,
#extraMenuBtn:focus-visible {
  border: 0;
  box-shadow: none;
}
.notification-close-btn:focus-visible { background: rgba(112, 130, 157, .10); color: var(--crm-text); transform: none; }
#extraMenuBtn { background: transparent; color: var(--crm-text); }
#extraMenuBtn:hover,
#extraMenuBtn:focus-visible { background: var(--crm-hover); }
.notification-toast-topline { display: flex; gap: 8px; align-items: flex-start; }
.notification-toast-icon { width: 22px; height: 22px; min-height: 22px; padding: 0; background: rgba(255,255,255,.70); color: var(--crm-blue-text); }
.notification-toast-title { display: block; font-size: 14px; line-height: 1.35; font-weight: 650; }
.notification-toast-subtitle { color: var(--crm-muted); font-size: 13px; line-height: 1.35; }
.notification-body { color: var(--crm-text-soft); font-size: 14px; line-height: 1.4; }

html[data-theme="dark"] .notification-toast {
  background: rgba(22, 31, 47, .90) !important;
  border-color: rgba(148, 163, 184, .14) !important;
  color: var(--crm-text) !important;
  box-shadow: 0 7px 20px rgba(0, 0, 0, .18) !important;
}
html[data-theme="dark"] .notification-toast-icon {
  background: rgba(37, 52, 77, .82) !important;
}
html[data-theme="dark"] .notification-close-btn,
html[data-theme="dark"] #extraMenuBtn {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
html[data-theme="dark"] html[data-theme="dark"] .notification-close-btn:focus-visible,
html[data-theme="dark"] #extraMenuBtn:hover,
html[data-theme="dark"] #extraMenuBtn:focus-visible {
  background: rgba(148, 163, 184, .10) !important;
  border: 0 !important;
}

.reviews-page {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}
.reviews-list-panel,
.review-detail-panel { min-height: 0; overflow: hidden; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.review-detail-panel { overflow: auto; }
.review-panel { display: grid; gap: 14px; }
.review-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.review-header h2 { margin: 0; font-size: 18px; }
.review-header p { margin: 4px 0 0; color: var(--crm-muted); }
.review-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.review-fact,
.review-body-card,
.review-reply-card,
.existing-reply {
  padding: 13px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: #fff;
}
.review-fact span { display: block; color: var(--crm-muted); font-size: 12px; margin-bottom: 4px; }
.review-fact strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-body-card h3,
.review-reply-card h3 { margin: 0 0 8px; font-size: 14px; }
.review-body-card p { margin: 0; white-space: pre-wrap; }
.review-reply-form { display: grid; gap: 10px; }
.review-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.tasks-page,
.knowledge-page,
.analytics-page { height: 100%; overflow: auto; }
.tasks-toolbar,
.analytics-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.tasks-toolbar h2,
.analytics-toolbar h2 { margin: 0; font-size: 18px; }
.analytics-toolbar-actions,
.knowledge-search-row { display: flex; align-items: center; gap: 8px; }
.analytics-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.analytics-note { padding: 12px 14px; margin-bottom: 14px; color: var(--crm-muted); }
.analytics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.analytics-card { padding: 14px; display: grid; gap: 5px; }
.analytics-card span { color: var(--crm-muted); font-size: 12px; }
.analytics-card strong { font-size: 24px; }
.analytics-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.analytics-panel { padding: 14px; }
.analytics-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.analytics-panel h3 { margin: 0; font-size: 15px; }
.analytics-table { overflow: auto; }
.analytics-table table,
.analytics-table-grid { width: 100%; border-collapse: collapse; }
.analytics-table th,
.analytics-table td { padding: 9px 8px; border-bottom: 1px solid var(--crm-line); text-align: left; font-size: 13px; }
.analytics-marketplace-breakdown,
.analytics-drilldown-summary { display: grid; gap: 8px; }
.analytics-excluded-details { margin-top: 12px; color: var(--crm-muted); }

.tasks-redesign-page { padding: 0; }
#tasksView { font-size: 15px; }
#tasksView input,
#tasksView select,
#tasksView textarea,
#tasksView button,
#tasksView .tasks-ref-field-title,
#tasksView .tasks-ref-field-value,
#tasksView .tasks-ref-pill,
#tasksView .task-card-pill,
#tasksView .tasks-ref-status-option,
#tasksView .tasks-ref-empty,
#tasksView .tasks-standalone-form,
#tasksView .tasks-ref-card {
  font-size: 15px;
}
.tasks-ref-toolbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) minmax(140px, 180px) minmax(130px, 160px) minmax(150px, 190px) 44px;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-lg);
  box-shadow: var(--crm-shadow-xs);
}
.tasks-ref-search {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  background: #fff;
}
.tasks-ref-search svg,
.tasks-ref-date svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tasks-ref-search input { border: 0; padding-left: 0; box-shadow: none; min-height: 32px; }
.tasks-ref-select { min-height: 34px; }
.tasks-ref-date {
  width: 44px;
  position: relative;
}
.tasks-ref-date > .date-range-filter-btn {
  width: 44px;
  height: 36px;
  min-width: 44px;
  min-height: 36px;
}
.tasks-ref-list { display: grid; gap: 10px; }
.tasks-ref-card {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(130px, 1fr) minmax(120px, .8fr) minmax(220px, 2fr) auto;
  align-items: stretch;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-lg);
  box-shadow: var(--crm-shadow-xs);
}
.tasks-ref-field-title { display: block; margin-bottom: 5px; color: var(--crm-muted); font-size: 12px; }
.tasks-ref-field-value { color: var(--crm-text); overflow-wrap: anywhere; }
.tasks-ref-side { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; gap: 10px; }
.tasks-ref-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tasks-ref-type { background: #fff; color: var(--crm-text-soft); border-color: var(--crm-line); }
.tasks-ref-status-wrap { position: relative; }
.tasks-ref-status-pill { min-height: 22px; border: 0; box-shadow: none; }
.tasks-ref-status-pill-in_progress { background: var(--crm-blue); color: var(--crm-blue-text); }
.tasks-ref-status-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 25;
  width: 150px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow-md);
}
.tasks-ref-status-option { width: 100%; justify-content: flex-start; background: transparent; border: 0; color: var(--crm-text); min-height: 30px; }
.tasks-ref-status-option.active,
.tasks-ref-status-option:hover { background: var(--crm-hover); transform: none; }
.tasks-ref-empty { padding: 16px; border: 1px solid var(--crm-line); border-radius: var(--crm-radius-lg); background: #fff; color: var(--crm-muted); }

.task-card,
.task-chat-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: var(--crm-panel-soft);
}
.task-card-main,
.task-card-header,
.task-card-meta,
.task-card-actions,
.task-edit-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-card-actions { justify-content: flex-end; }
.task-chat-edit-panel { display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--crm-line); }
.task-chat-edit-panel textarea { min-height: 66px; }

.knowledge-panel { height: 100%; padding: 14px; overflow: hidden; display: flex; flex-direction: column; }
.knowledge-toolbar { flex: 0 0 auto; padding: 0 0 12px; margin: 0 0 12px; border-bottom: 1px solid var(--crm-line); box-shadow: none; border-radius: 0; background: transparent; }
.knowledge-search-row input { min-width: 260px; }
.knowledge-layout { min-height: 0; flex: 1 1 auto; display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 14px; }
.knowledge-categories,
.knowledge-editor { min-height: 0; overflow: auto; border: 1px solid var(--crm-line); border-radius: var(--crm-radius-lg); background: #fff; padding: 12px; }
.knowledge-left-head { margin-bottom: 10px; }
.knowledge-mini-head { font-weight: 700; }
.knowledge-hint { margin: 3px 0 0; color: var(--crm-muted); font-size: 12px; }
.knowledge-tree,
.knowledge-category-list,
.knowledge-articles-list { display: grid; gap: 6px; }
.knowledge-category-item,
.knowledge-article-item {
  padding: 9px 10px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-panel-soft);
  cursor: pointer;
}
.knowledge-article-item.active { background: var(--crm-active); }
.knowledge-category-form,
.knowledge-article-form { display: grid; gap: 9px; margin-top: 12px; }
.knowledge-empty-state { height: 100%; display: grid; place-items: center; align-content: center; text-align: center; color: var(--crm-muted); }
.knowledge-empty-state h3 { color: var(--crm-text); margin: 0 0 4px; }
.knowledge-reader { display: grid; gap: 12px; }
.knowledge-reader-head,
.knowledge-form-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.knowledge-reader h3,
.knowledge-form-head h3 { margin: 0; font-size: 18px; }
.knowledge-reader-meta { color: var(--crm-muted); font-size: 12px; }
.knowledge-reader-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.knowledge-reader-tags span,
.knowledge-tag { padding: 3px 7px; border-radius: 999px; background: var(--crm-panel-muted); color: var(--crm-text-soft); font-size: 11px; }
.knowledge-reader-image { max-width: 100%; border-radius: var(--crm-radius-md); border: 1px solid var(--crm-line); }
.knowledge-reader-content { white-space: pre-wrap; line-height: 1.55; }
.knowledge-image-preview { padding: 8px; border: 1px solid var(--crm-line); border-radius: var(--crm-radius-sm); }

.tech-settings-page,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.settings-grid.one-col,
.users-settings-grid { grid-template-columns: 1fr; }
.settings-card { padding: 14px; display: grid; gap: 12px; }
.settings-card-head { display: flex; justify-content: space-between; gap: 12px; }
.settings-card h3 { margin: 0; font-size: 15px; }
.settings-card p { margin: 4px 0 0; }
.chat-status-create-form,
.task-type-create-form,
.settings-form,
.user-create-form { display: grid; gap: 9px; }
.status-settings-header,
.task-type-settings-header {
  display: grid;
  gap: 8px;
  color: var(--crm-muted);
  font-size: 12px;
  padding: 0 6px;
}
.status-settings-header { grid-template-columns: 1.4fr 1fr .7fr .7fr auto; }
.task-type-settings-header { grid-template-columns: 1.4fr 1fr 1.1fr .6fr .7fr auto; }
.status-settings-list,
.task-type-settings-list,
.users-list { display: grid; gap: 7px; }
.status-settings-row,
.task-type-settings-row,
.user-row {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: #fff;
}
.status-settings-row,
.user-row { grid-template-columns: 1.4fr 1fr .7fr .7fr auto; }
.task-type-settings-row { grid-template-columns: 1.4fr 1fr 1.1fr .6fr .7fr auto; }
.task-type-settings-row > * { min-width: 0; }
.settings-actions-bottom { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-account-actions { margin-top: 12px; }
.user-create-open-btn,
.user-light-btn-primary { background: var(--crm-text); border-color: var(--crm-text); color: #fff; }
.user-create-modal {
  position: fixed;
  inset: 0;
  z-index: 10002;
  display: grid;
  place-items: center;
  padding: 24px;
}
.user-create-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .28); }
.user-create-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--crm-radius-lg);
  background: #fff;
  border: 1px solid var(--crm-line);
  box-shadow: var(--crm-shadow-md);
}
.user-create-modal-topbar { display: flex; justify-content: space-between; gap: 12px; }
.user-create-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.user-edit-active-row { display: flex; align-items: center; gap: 8px; }
.user-edit-active-row input { width: auto; min-height: auto; }

.knowledge-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .28);
}
.knowledge-modal-dialog {
  width: min(880px, 100%);
  max-height: min(760px, 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--crm-radius-lg);
  background: #fff;
  border: 1px solid var(--crm-line);
  box-shadow: var(--crm-shadow-md);
}
.knowledge-modal-topbar { flex: 0 0 auto; display: flex; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--crm-line); }
.knowledge-modal-toolbar-actions { display: flex; gap: 8px; }
.knowledge-modal-body { overflow: auto; padding: 18px; }

.mobile-nav-backdrop,
.mobile-more-sheet { display: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5d5d5; border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #c4c4c4; border: 3px solid transparent; background-clip: padding-box; }

@media (max-width: 1280px) {
  :root { --crm-sidebar: 196px; --crm-chat-list: 350px; }
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .app-nav { padding: 12px 9px; align-items: center; }
  .brand-card { width: 44px; height: 34px; padding: 0; }
  .brand-copy h1 { font-size: 0; }
  .brand-copy h1::first-letter { font-size: 0; }
  .brand-copy h1::after { content: "A"; font-size: 14px; }
  .nav-btn { width: 44px; justify-content: center; padding: 0; }
  .nav-btn .btn-label,
  .sync-card,
  .account-nav .btn-label,
  .notifications-widget .btn-label,
  #refreshBtn .btn-label,
  #logoutBtn .btn-label { display: none; }
  .layout { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); }
  .tech-settings-page { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; grid-template-columns: 1fr; }
  .app-nav {
    position: sticky;
    top: 0;
    z-index: 80;
    height: auto;
    flex-direction: row;
    align-items: center;
    width: 100%;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--crm-line);
  }
  .main-nav,
  .account-nav,
  .notifications-widget { display: flex; gap: 5px; }
  .nav-spacer { display: none; }
  .workspace { height: calc(100vh - 66px); padding: 10px; }
  .layout,
  .reviews-page,
  .knowledge-layout,
  .analytics-columns { grid-template-columns: 1fr; }
  .sidebar { display: flex; }
  .conversation { min-height: 0; }
  .chat-panel.mobile-chat-open { display: flex; }
  .mobile-back-btn { display: inline-grid; }
  .chat-header { align-items: flex-start; flex-direction: column; }
  .chat-controls { width: 100%; }
  .chat-controls select { width: 100%; min-width: 0; }
  .messages { padding: 18px 12px; }
  .message { max-width: 88%; }
  .composer { padding: 10px; }
  .review-facts,
  .analytics-grid,
  .analytics-filters,
  .tasks-ref-toolbar,
  .tasks-ref-card { grid-template-columns: 1fr; }
  .tasks-ref-side { align-items: flex-start; }
  .tasks-toolbar,
  .analytics-toolbar,
  .knowledge-toolbar { align-items: stretch; flex-direction: column; }
  .knowledge-search-row,
  .analytics-toolbar-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .knowledge-search-row input { min-width: 0; }
  .status-settings-header,
  .task-type-settings-header { display: none; }
  .status-settings-row,
  .task-type-settings-row,
  .user-row { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  :root { font-size: 13px; }
  .workspace { padding: 8px; }
  .panel-card { border-radius: 12px; }
  .filters,
  .review-filters { grid-template-columns: 1fr; }
  .chat-item,
  .review-item { padding: 10px; }
  .message { max-width: 94%; }
  .extra-panel { right: 8px; width: calc(100% - 16px); }
  .composer-main-row { grid-template-columns: 32px minmax(0, 1fr) 32px  38px; gap: 6px; }
  .composer-attach-btn,
  .composer-template-btn { width: 32px; height: 34px; }
  .composer-send-btn { width: 38px; height: 38px; }
  .notification-toast-stack { right: 10px; top: 10px; width: calc(100vw - 20px); }
}

/* Figma typography/layout correction — Onest + compact chat cards */
html,
body,
button,
input,
select,
textarea {
  font-family: "Onest", "Segoe UI", Roboto, Arial, system-ui, sans-serif;
}

body {
  font-size: 13px;
  line-height: 1.32;
  font-weight: 400;
}

button,
input,
select,
textarea {
  font-size: 13px;
}

/* Chat list: closer to the Figma reference */
#chatsView.layout {
  gap: 12px;
}

#chatsView > .sidebar.panel-card {
  padding: 0;
  gap: 8px;
  background: #0b0f1700;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#chatsView > .sidebar .section-title-row,
#chatsView > .sidebar #stats {
  display: none;
}

#chatsView .filters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 0;
}

#chatsView .filters select,
#chatsView .filters input,
#chatsView .filters button {
  min-height: 30px;
  height: 30px;
  padding: 5px 11px;
  border: 0;
  border-radius: 4px;
  background: #253448;
  color: #ededed;
  font-size: 12px;
  font-weight: 400;
  box-shadow: none;
}

#chatsView .chat-list {
  flex: 1 1 auto;
  min-height: 0;
  grid-auto-rows: minmax(125px, max-content);
  align-content: start;
  gap: 8px;
  padding: 0 0 8px;
}

#chatsView .chat-list-load-state {
  flex: none;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 3px 0 0;
  color: var(--crm-muted);
  font-size: 12px;
}

#chatsView .chat-list-load-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--crm-line);
  border-top-color: var(--crm-muted);
  border-radius: 50%;
  animation: chat-list-load-spin .75s linear infinite;
}

@keyframes chat-list-load-spin {
  to { transform: rotate(360deg); }
}

#chatsView .chat-item,
#chatsView .empty-chat-item {
  position: relative;
  min-height: 125px;
  gap: 5px;
  padding: 10px 66px 10px 12px;
  border: 0;
  border-left: 0;
  border-radius: 8px;
  background: #20354a;
  box-shadow: none;
}

#chatsView .chat-item:hover {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
}

#chatsView .chat-item.active {
  background: #ffffff;
  border: 0;
  box-shadow: 0 7px 18px rgba(0, 0, 0, .16);
}

#chatsView .chat-item.needs-response {
  border-left: 0;
  box-shadow: none;
}

#chatsView .chat-item.needs-response:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
}

#chatsView .chat-item.needs-response.active {
  box-shadow: 0 7px 18px rgba(0, 0, 0, .16);
}

#chatsView .chat-item-topline,
#chatsView .chat-item-title {
  display: block;
  min-width: 0;
}

#chatsView .chat-item-title strong,
#chatsView .review-item strong {
  display: block;
  max-width: 100%;
  color: #f1f1f1;
  font-size: 15px;
  line-height: 1.18;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#chatsView .preview {
  margin: 6px 0 0;
  color: #d0d0d0;
  font-size: 15px;
  line-height: 20px;
  min-height: 20px;
  font-weight: 400;
}

#chatsView .chat-time {
  color: #777777;
  font-size: 10px;
  line-height: 1;
  font-weight: 400;
  white-space: nowrap;
}

#chatsView .chat-item-actions {
  position: absolute;
  top: 8px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#chatsView .chat-item-actions > .badge {
  position: static;
  min-height: 19px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1;
  font-weight: 400;
  text-transform: none;
}

#chatsView .chat-pin-control {
  width: 24px;
  height: 24px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #aeb8c6;
  cursor: pointer;
  opacity: 0;
  transition: opacity .14s ease, color .14s ease;
}

#chatsView .chat-pin-control svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

#chatsView .chat-pin-control:hover,
#chatsView .chat-pin-control:focus-visible {
  border: 0;
  background: transparent;
  color: #718096;
  outline: none;
}

#chatsView .chat-item.is-pinned .chat-pin-control {
  color: #ff8a1f;
  opacity: 1;
}

@media (hover: hover) {
  #chatsView .chat-item:hover .chat-pin-control,
  #chatsView .chat-item:focus-within .chat-pin-control { opacity: 1; }
}
@media (hover: none) {
  #chatsView .chat-pin-control { opacity: 1; }
}

#chatsView .chat-item-footer,
#chatsView .chat-badges {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

#chatsView .chat-badges {
  padding-right: 0;
}
#chatsView .chat-item-title {
  padding-right: 126px;
}

#chatsView .chat-item-footer {
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}

#chatsView .chat-badges {
  flex: 1 1 auto;
}

#chatsView .chat-item-read-meta {
  flex: none;
  display: inline-flex;
  align-items: center;
  align-self: flex-end;
  gap: 4px;
  min-height: 18px;
  margin-left: auto;
}

#chatsView .chat-read-state-control {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

#chatsView .chat-read-state-checks {
  position: relative;
  width: 14px;
  height: 10px;
  color: #91a0b5;
}
#chatsView .chat-read-state-checks::before,
#chatsView .chat-read-state-checks::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 4px;
  height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(38deg);
}
#chatsView .chat-read-state-checks::before { left: 3px; }
#chatsView .chat-read-state-checks::after { left: 7px; }
#chatsView .chat-item.is-unread .chat-read-state-checks::after { opacity: 0; }
#chatsView .chat-item:not(.is-unread) .chat-read-state-checks { color: var(--crm-blue-text); }

#chatsView .chat-item:not(.is-unread) .chat-read-state-control:hover,
#chatsView .chat-item:not(.is-unread) .chat-read-state-control:focus-visible {
  border: 0;
  outline: none;
}

#chatsView .chat-item.is-unread .chat-item-title strong {
  font-weight: 650;
}

#chatsView .chat-item.is-unread .preview {
  font-weight: 500;
}

#chatsView .status-badge,
#chatsView .sla-badge,
#chatsView .assignee-chip {
  min-height: 19px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  line-height: 1;
  font-weight: 400;
}

#chatsView .chat-badges .assignee-chip {
  position: absolute;
  top: 31px;
  right: 12px;
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chatsView .badge.ozon,
#chatsView .badge.OZON,
#chatsView .marketplace-pill.ozon {
  background: #dfeafa;
  color: #1d3550;
}

#chatsView .badge.wb,
#chatsView .badge.WB,
#chatsView .badge.wildberries,
#chatsView .marketplace-pill.wb,
#chatsView .marketplace-pill.wildberries {
  background: #f0dcfb;
  color: #5a3d6b;
}

#chatsView .badge.yandex,
#chatsView .marketplace-pill.yandex,
#chatsView .badge.ym,
#chatsView .marketplace-pill.ym {
  background: #fde4e2;
  color: #5b3130;
}

#chatsView .status-new {
  background: #e5f3df;
  color: #375a2d;
}

#chatsView .status-in_progress,
#chatsView .status-in-progress,
#chatsView .assignee-chip {
  background: #dfeafa;
  color: #1d4b73;
}

#chatsView .status-waiting,
#chatsView .sla-badge {
  background: #f9e3e1;
  color: #7f413a;
}

/* Keep the same clean Onest typography across the rest of CRM */
.panel-card,
.nav-btn,
.chat-header,
.messages,
.composer,
.extra-panel,
.review-item,
.review-panel,
.tasks-ref-card,
.task-card,
.task-chat-card,
.knowledge-panel,
.settings-card,
.analytics-card,
.analytics-panel,
.notification-toast {
  font-family: "Onest", "Segoe UI", Roboto, Arial, system-ui, sans-serif;
}



/* Chat list width and preview readability fix */
@media (min-width: 901px) {
  :root {
    --crm-chat-list: 404px;
  }
}

#chatsView .chat-item,
#chatsView .empty-chat-item {
  padding-right: 12px;
  overflow: hidden;
}

#chatsView .chat-item-title,
#chatsView .preview,
#chatsView .chat-item-footer,
#chatsView .chat-badges {
  max-width: 100%;
  min-width: 0;
}

#chatsView .preview {
  position: relative;
  z-index: 1;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#chatsView .chat-item-topline > .badge {
  z-index: 2;
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chatsView .chat-badges .assignee-chip {
  z-index: 2;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chatsView .chat-time {
  z-index: 2;
}

#chatsView { --crm-chat-radius: 16px; }
#chatsView .chat-item,
#chatsView .empty-chat-item,
#chatsView .conversation,
#chatsView .chat-header,
#chatsView .composer,
#chatsView .extra-panel,
#chatsView .extra-menu,
#chatsView .message-text,
#chatsView .image-card {
  border-radius: var(--crm-chat-radius);
}
#chatsView .filters select,
#chatsView .filters input,
#chatsView .filters button,
#chatsView .chat-search-toggle,
#chatsView .chat-search-box,
#chatsView .date-range-filter-popover,
#chatsView .date-range-filter-popover input,
#chatsView #chatStatus,
#chatsView #assignedUserSelect,
#chatsView #messageText,
#chatsView .composer-attach-btn,
#chatsView .composer-template-btn,
#chatsView .composer-send-btn {
  border-radius: 8px;
}
#chatsView .filters select,
#chatsView .filters input,
#chatsView .filters button,
#chatsView .chat-search-box input,
#chatsView .date-range-filter-popover input,
#chatsView #chatStatus,
#chatsView #assignedUserSelect,
#chatsView #messageText,
#chatsView .message-text,
#chatsView .chat-title-inline h2 {
  font-size: 15px;
}

@media (max-width: 900px) {
  #chatsView .chat-item,
  #chatsView .empty-chat-item {
    padding-right: 12px;
  }
}


/* =========================================================
   Arti CRM — targeted UI patch v11
   Clean build from original styles.css.

   Mobile chat behavior is integrated into app.js; no extra JS file is needed.
   ========================================================= */


/* ---------- Analytics: prevent page-wide horizontal overflow ---------- */
.analytics-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

.analytics-page *,
.analytics-page *::before,
.analytics-page *::after {
  box-sizing: border-box;
  min-width: 0;
}

.analytics-page :is(
  .analytics-toolbar,
  .analytics-toolbar-actions,
  .analytics-filters,
  .analytics-grid,
  .analytics-columns,
  .analytics-card,
  .analytics-panel,
  .analytics-panel-head,
  .analytics-table,
  .analytics-table-grid,
  .analytics-marketplace-breakdown,
  .analytics-drilldown-summary
) {
  max-width: 100%;
}

.analytics-page .analytics-panel {
  overflow: hidden;
}

.analytics-page .analytics-table {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.analytics-page .analytics-table table {
  width: max-content;
  min-width: 100%;
}


/* ---------- Analytics: peak hours as horizontal thin-bar chart ---------- */
.analytics-page .analytics-panel:has(> .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25)))),
.analytics-page #peakHoursPanel,
.analytics-page .peak-hours-panel,
.analytics-page .analytics-peak-hours {
  min-height: 0 !important;
  overflow: hidden !important;
}

.analytics-page .analytics-panel:has(> .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25)))) > .analytics-panel-head,
.analytics-page #peakHoursPanel .analytics-panel-head,
.analytics-page .peak-hours-panel .analytics-panel-head,
.analytics-page .analytics-peak-hours .analytics-panel-head {
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.analytics-page .analytics-panel:has(> .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25)))) > .analytics-panel-head p,
.analytics-page #peakHoursPanel .analytics-panel-head p,
.analytics-page .peak-hours-panel .analytics-panel-head p,
.analytics-page .analytics-peak-hours .analytics-panel-head p {
  max-width: 470px;
  margin: 0;
  color: var(--crm-muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 0 !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 6px !important;
  padding: 2px 0 4px !important;
  overflow: visible !important;
  background: transparent !important;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *,
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *,
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *,
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * {
  --peak-percent: 20;
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: 24px !important;
  min-height: 24px !important;
  display: grid !important;
  grid-template-columns: minmax(70px, 92px) minmax(0, 1fr) minmax(24px, 36px) !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--crm-text-soft) !important;
  font-size: 11px !important;
  line-height: 1 !important;
  font-weight: 500 !important;
  text-align: left !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  transform: none !important;
  cursor: default !important;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *::after,
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *::after,
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *::after,
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *::after {
  content: "";
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: #eeeeee;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *::before,
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *::before,
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *::before,
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *::before {
  content: "";
  grid-column: 2;
  grid-row: 1;
  z-index: 1;
  width: max(6px, calc(var(--peak-percent) * 1%));
  height: 4px;
  border-radius: 999px;
  background: #1f1f1f;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > * > *,
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > *,
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > *,
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > * > :first-child,
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > :first-child,
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > :first-child,
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > :first-child {
  grid-column: 1;
  grid-row: 1;
  color: var(--crm-text-soft);
  font-weight: 500;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > * > :last-child:not(:first-child),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > :last-child:not(:first-child),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > :last-child:not(:first-child),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * > :last-child:not(:first-child) {
  grid-column: 3;
  grid-row: 1;
  color: var(--crm-muted);
  text-align: right;
  font-weight: 600;
}

.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(1),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(1),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(1),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(1) { --peak-percent: 22; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(2),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(2),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(2),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(2) { --peak-percent: 19; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(3),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(3),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(3),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(3) { --peak-percent: 4; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(4),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(4),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(4),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(4) { --peak-percent: 11; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(5),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(5),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(5),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(5) { --peak-percent: 4; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(6),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(6),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(6),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(6) { --peak-percent: 19; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(7),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(7),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(7),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(7) { --peak-percent: 7; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(8),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(8),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(8),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(8) { --peak-percent: 30; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(9),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(9),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(9),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(9) { --peak-percent: 37; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(10),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(10),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(10),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(10) { --peak-percent: 48; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(11),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(11),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(11),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(11) { --peak-percent: 85; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(12),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(12),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(12),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(12) { --peak-percent: 59; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(13),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(13),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(13),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(13) { --peak-percent: 78; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(14),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(14),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(14),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(14) { --peak-percent: 100; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(15),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(15),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(15),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(15) { --peak-percent: 74; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(16),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(16),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(16),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(16) { --peak-percent: 85; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(17),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(17),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(17),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(17) { --peak-percent: 85; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(18),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(18),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(18),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(18) { --peak-percent: 78; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(19),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(19),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(19),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(19) { --peak-percent: 48; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(20),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(20),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(20),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(20) { --peak-percent: 70; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(21),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(21),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(21),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(21) { --peak-percent: 41; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(22),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(22),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(22),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(22) { --peak-percent: 56; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(23),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(23),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(23),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(23) { --peak-percent: 59; }
.analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *:nth-child(24),
.analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(24),
.analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(24),
.analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *:nth-child(24) { --peak-percent: 22; }


/* ---------- Technical settings: compact controls ---------- */
.tech-settings-page,
.settings-grid {
  align-items: start;
  gap: 12px;
}

.tech-settings-page .settings-card {
  padding: 12px;
  gap: 10px;
}

.tech-settings-page .task-type-settings-card {
  grid-column: 1 / -1;
}

.tech-settings-page .settings-card h3 {
  font-size: 14px;
}

.tech-settings-page .settings-card p {
  margin: 2px 0 0;
  color: var(--crm-muted);
  font-size: 12px;
  line-height: 1.35;
}

.tech-settings-page .chat-status-create-form,
.tech-settings-page .task-type-create-form,
.tech-settings-page .settings-form {
  max-width: 360px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.tech-settings-page .status-settings-header {
  grid-template-columns: minmax(124px, 1fr) 56px 34px auto;
  gap: 8px;
  padding: 0 4px;
  font-size: 11px;
}

.tech-settings-page .task-type-settings-header {
  grid-template-columns: minmax(150px, 1.35fr) minmax(130px, 1fr) minmax(160px, 1.15fr) 72px 88px auto;
  gap: 8px;
  padding: 0 4px;
  font-size: 11px;
}

.tech-settings-page .status-settings-row {
  grid-template-columns: minmax(124px, 1fr) 56px 34px auto;
  gap: 8px;
  padding: 8px;
  align-items: center;
}

.tech-settings-page .task-type-settings-row {
  grid-template-columns: minmax(150px, 1.35fr) minmax(130px, 1fr) minmax(160px, 1.15fr) 72px 88px auto;
  gap: 8px;
  padding: 8px;
  align-items: center;
}

.tech-settings-page .status-settings-row input,
.tech-settings-page .task-type-settings-row input,
.tech-settings-page .status-settings-row select,
.tech-settings-page .task-type-settings-row select {
  min-height: 30px;
  padding: 6px 8px;
}

.tech-settings-page .status-settings-row select {
  padding-right: 22px;
  font-size: 0;
}

.tech-settings-page .task-type-settings-row select {
  padding-right: 28px;
  font-size: 13px;
}

.tech-settings-page .status-settings-row select option,
.tech-settings-page .task-type-settings-row select option {
  font-size: 13px;
}

.tech-settings-page .status-settings-row input[type="checkbox"],
.tech-settings-page .task-type-settings-row input[type="checkbox"],
.tech-settings-page .user-edit-active-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  padding: 0;
  margin: 0;
  accent-color: #6f6f6f;
}

.tech-settings-page .status-settings-row button,
.tech-settings-page .task-type-settings-row button {
  min-height: 30px;
  padding: 6px 8px;
}


/* ---------- Mobile: fullscreen chat controlled by mobile_chat_fix_v10.js ---------- */
@media (max-width: 900px) {
  html,
  body,
  .app-shell,
  .workspace {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  .app-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 120;
    height: calc(60px + env(safe-area-inset-bottom));
    min-height: calc(60px + env(safe-area-inset-bottom));
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--crm-line);
    border-bottom: 0;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, .08);
    backdrop-filter: blur(16px);
  }

  .app-nav .brand-card,
  .app-nav .sync-card,
  .app-nav .user-card,
  .app-nav .nav-spacer {
    display: none !important;
  }

  .main-nav,
  .account-nav,
  .notifications-widget {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: max-content;
    flex-wrap: nowrap;
  }

  .nav-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 12px;
    background: transparent;
  }

  .workspace {
    height: 100vh;
    padding: 8px;
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .view,
  .layout,
  .sidebar,
  .conversation,
  .panel-card {
    max-width: 100%;
    min-width: 0;
  }

  /* Do not show empty right panel on mobile list screen. */
  #chatsView:not(.mobile-chat-mode) > .conversation {
    display: none !important;
  }

  #chatsView.mobile-chat-mode > .sidebar {
    display: none !important;
  }

  #chatsView.mobile-chat-mode > .conversation,
  #chatsView > .conversation.mobile-chat-open {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10000 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }

  body.mobile-chat-open .app-nav {
    transform: translateY(120%) !important;
    pointer-events: none !important;
  }

  body.mobile-chat-open .workspace {
    padding: 0 !important;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-panel,
  #chatsView > .conversation.mobile-chat-open .chat-panel {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }

  #chatsView.mobile-chat-mode > .conversation .empty-state {
    display: none !important;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-header,
  #chatsView > .conversation.mobile-chat-open .chat-header {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px 14px;
    background: #fff;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-heading-row,
  #chatsView > .conversation.mobile-chat-open .chat-heading-row {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
  }

  #chatsView.mobile-chat-mode > .conversation .mobile-back-btn,
  #chatsView > .conversation.mobile-chat-open .mobile-back-btn {
    position: static !important;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    margin: 0;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-title-stack,
  #chatsView > .conversation.mobile-chat-open .chat-title-stack {
    min-width: 0;
  }

  /* Three dots button stays on the right; the dropdown opens from the right. */
  #chatsView.mobile-chat-mode > .conversation .chat-heading-row > button.icon-btn:last-child:not(.mobile-back-btn),
  #chatsView > .conversation.mobile-chat-open .chat-heading-row > button.icon-btn:last-child:not(.mobile-back-btn) {
    position: static !important;
    justify-self: end;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    z-index: 6;
  }

  #chatsView.mobile-chat-mode > .conversation .extra-menu,
  #chatsView > .conversation.mobile-chat-open .extra-menu {
    left: auto !important;
    right: 0 !important;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-controls,
  #chatsView > .conversation.mobile-chat-open .chat-controls {
    width: 100%;
    gap: 8px;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-controls select,
  #chatsView > .conversation.mobile-chat-open .chat-controls select {
    width: 100%;
    min-width: 0;
  }

  #chatsView.mobile-chat-mode > .conversation .messages,
  #chatsView > .conversation.mobile-chat-open .messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px 12px;
    -webkit-overflow-scrolling: touch;
  }

  #chatsView.mobile-chat-mode > .conversation .composer,
  #chatsView > .conversation.mobile-chat-open .composer {
    flex: 0 0 auto;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: #fff;
  }

  #chatsView.mobile-chat-mode > .conversation .message,
  #chatsView > .conversation.mobile-chat-open .message {
    max-width: 94%;
  }

  .analytics-page .analytics-panel > .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25))) > *,
  .analytics-page #peakHoursPanel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *,
  .analytics-page .peak-hours-panel :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > *,
  .analytics-page .analytics-peak-hours :is(.analytics-drilldown-summary, .analytics-table-grid, .peak-hours-grid, .peak-hours-list) > * {
    grid-template-columns: minmax(58px, 74px) minmax(0, 1fr) minmax(22px, 30px) !important;
    gap: 8px !important;
  }
}

@media (max-width: 560px) {
  .analytics-page .analytics-panel:has(> .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25)))) > .analytics-panel-head,
  .analytics-page #peakHoursPanel .analytics-panel-head,
  .analytics-page .peak-hours-panel .analytics-panel-head,
  .analytics-page .analytics-peak-hours .analytics-panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .analytics-page .analytics-panel:has(> .analytics-panel-head + *:has(> :nth-child(24)):not(:has(> :nth-child(25)))) > .analytics-panel-head p,
  .analytics-page #peakHoursPanel .analytics-panel-head p,
  .analytics-page .peak-hours-panel .analytics-panel-head p,
  .analytics-page .analytics-peak-hours .analytics-panel-head p {
    max-width: none;
    text-align: left;
  }

  .tech-settings-page,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}


/* Arti CRM — v16 stable runtime states */
@media (max-width: 900px) {
  html.mobile-chat-lock,
  body.mobile-chat-lock {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
  }
}

.composer-send-btn:disabled,
#messageForm button[type="submit"]:disabled {
  opacity: .45;
  cursor: wait;
  transform: none;
}


/* Arti CRM — v17 mobile performance state */
.chat-loading-card {
  justify-self: center;
  align-self: center;
  cursor: default;
}

@media (max-width: 900px) {
  #chatsView.mobile-chat-mode > .conversation .chat-loading-card {
    width: calc(100% - 24px);
    min-height: 52px;
    display: grid;
    place-items: center;
    margin: 12px auto;
    color: var(--crm-muted);
  }
}


/* Arti CRM — v18 chat menu responsiveness */
#extraMenuBtn,
.extra-menu button,
[data-extra] {
  touch-action: manipulation;
}

@media (max-width: 900px) {
  #chatsView.mobile-chat-mode > .conversation .extra-menu {
    z-index: 10020 !important;
    will-change: transform, opacity;
  }

  #chatsView.mobile-chat-mode > .conversation .extra-panel {
    z-index: 10015 !important;
    will-change: transform, opacity;
  }
}


/* Arti CRM — v19 desktop/mobile live message refresh */
@media (min-width: 901px) {
  .messages {
    overflow-anchor: auto;
  }
}


/* Arti CRM — v22 safe mobile interaction fix
   Restores v20/v19 header stacking. Avoid paint containment on the header/menu:
   it clipped dropdowns and made the menu appear under the chat body on iOS Safari. */
@media (max-width: 900px) {
  #chatsView.mobile-chat-mode button,
  #chatsView.mobile-chat-mode select,
  #chatsView.mobile-chat-mode input,
  #chatsView.mobile-chat-mode textarea,
  #chatsView.mobile-chat-mode [data-extra],
  #chatsView > .conversation.mobile-chat-open button,
  #chatsView > .conversation.mobile-chat-open select,
  #chatsView > .conversation.mobile-chat-open input,
  #chatsView > .conversation.mobile-chat-open textarea,
  #chatsView > .conversation.mobile-chat-open [data-extra] {
    touch-action: manipulation;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-header,
  #chatsView > .conversation.mobile-chat-open .chat-header {
    overflow: visible !important;
    z-index: 30000 !important;
    isolation: isolate;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-heading-row,
  #chatsView > .conversation.mobile-chat-open .chat-heading-row {
    overflow: visible !important;
    z-index: 30001 !important;
  }

  #chatsView.mobile-chat-mode > .conversation .extra-menu,
  #chatsView > .conversation.mobile-chat-open .extra-menu {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    left: auto !important;
    right: 0 !important;
    z-index: 30020 !important;
    background: #fff !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  #chatsView.mobile-chat-mode > .conversation .extra-panel,
  #chatsView > .conversation.mobile-chat-open .extra-panel {
    z-index: 30010 !important;
    background: #fff !important;
  }

  #chatsView.mobile-chat-mode > .conversation .composer,
  #chatsView > .conversation.mobile-chat-open .composer {
    z-index: 60;
  }
}


/* Arti CRM — v23 native mobile select stability */
#chatStatus,
#assignedUserSelect {
  touch-action: manipulation;
}

@media (max-width: 900px) {
  #chatStatus,
  #assignedUserSelect {
    transition: none !important;
    will-change: auto !important;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-controls select {
    -webkit-tap-highlight-color: transparent;
  }
}


/* Arti CRM — v25 mobile chat-list render performance */
.chat-list-render-limit-note {
  cursor: default;
  text-align: center;
  color: var(--crm-muted);
}

@media (max-width: 900px) {
  body.mobile-chat-open #chatList {
    contain: content;
  }
}


/* Arti CRM — v27 message dialog UI */
.message {
  gap: 5px;
}

.message-bubble {
  position: relative;
  display: grid;
  gap: 8px;
}

.message.inbound .message-bubble,
.message.outbound .message-bubble {
  background: #253448;
  border-radius: 14px;
  padding: 10px 12px;
}

.message.inbound .message-bubble {
  padding-right: 36px;
}


.message.internal .message-bubble {
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--crm-shadow-xs);
}

.message-text {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--crm-text);
  box-shadow: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.outbound .message-text,
.message.internal .message-text {
  background: transparent;
}

.message-bubble-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 12px;
  margin-top: 1px;
  color: var(--crm-muted-2);
  font-size: 10px;
  line-height: 1;
}

.message.inbound .message-bubble-meta {
  justify-content: flex-start;
}

.message.outbound .message-bubble-meta {
  justify-content: flex-end;
}

.message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 14px;
  padding-right: 4px;
  color: var(--crm-muted-2);
  font-size: 10px;
}

.message-time {
  line-height: 1;
  white-space: nowrap;
}

.message-crm-author {
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--crm-muted);
  font-weight: 600;
  line-height: 1;
}

.message-crm-author::after {
  content: '·';
  margin-left: 8px;
  color: var(--crm-muted-2);
  font-weight: 400;
}

.message-actions-menu-wrap {
  position: absolute;
  top: 8px;
  right: 8px;
  margin-left: 0;
  z-index: 2;
}

.message-actions-btn {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: none;
}

.message-actions-menu {
  top: 24px;
  right: 0;
}

.message-receipt {
  justify-self: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--crm-muted-2);
  font-size: 10px;
}

.message-receipt .receipt-label {
  display: none;
}

.message-images {
  margin-top: 2px;
}

.message-product-context {
  width: min(320px, 100%);
  min-width: 0;
  display: block;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--crm-line);
  color: inherit;
  text-decoration: none;
}


.message-product-context:hover .message-product-context-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-product-context:focus-visible {
  border-radius: var(--crm-radius-xs);
  outline: 0;
  box-shadow: var(--crm-focus);
}


.message-product-context-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.message-product-context-label,
.message-product-context-meta {
  color: var(--crm-muted);
  font-size: 10px;
  line-height: 1.2;
}

.message-product-context-title {
  min-width: 0;
  overflow: hidden;
  color: var(--crm-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .messages {
    padding: 18px 16px;
  }

  .message {
    max-width: 92%;
  }

  .message.inbound .message-bubble {
    padding-right: 34px;
  }

  .message-product-context {
    width: 100%;
  }
}


/* Arti CRM — v28 readable full image previews */
.message.message-has-images {
  max-width: min(520px, 88%);
}

.message.message-has-images .message-bubble {
  padding: 8px;
}

.message.inbound.message-has-images .message-bubble {
  padding-right: 36px;
}

.message.message-has-images .message-text {
  padding: 2px 4px 0;
}

.message.message-has-images .message-images {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 0;
}

.message.message-has-images .image-card {
  width: min(430px, 100%);
  height: auto;
  min-height: 120px;
  max-height: 520px;
  justify-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
}

.message.message-has-images .image-card img {
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  display: block;
  background: #fff;
}

.message.message-has-images .image-card.image-error {
  min-height: 148px;
}

@media (max-width: 900px) {
  .message.message-has-images {
    max-width: 96%;
  }

  .message.message-has-images .image-card {
    width: min(100%, calc(100vw - 64px));
    min-height: 118px;
    max-height: 460px;
  }

  .message.message-has-images .image-card img {
    max-height: 460px;
  }
}

@media (max-width: 520px) {
  .message.message-has-images {
    max-width: 98%;
  }

  .message.message-has-images .image-card {
    width: min(100%, calc(100vw - 56px));
    max-height: 420px;
  }

  .message.message-has-images .image-card img {
    max-height: 420px;
  }
}


/* Arti CRM — v29 remove image open label */
.message.message-has-images .image-fallback {
  display: none !important;
}

.message.message-has-images .image-card {
  cursor: zoom-in;
}


/* Arti CRM — v30 reliable mobile extra action taps */
@media (max-width: 900px) {
  #extraMenu [data-extra] {
    touch-action: manipulation;
    cursor: pointer;
  }
}


/* Arti CRM — v31 chat routes and marketplace deeplink */
#chatSubtitle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}

.marketplace-chat-link {
  color: var(--crm-blue-text);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.marketplace-chat-link:hover {
  text-decoration: underline;
}


/* Arti CRM — v32 clean open chat header */
#chatSubtitle.hidden {
  display: none !important;
}

#chatSubtitle {
  margin-top: 2px;
}

.marketplace-chat-link {
  font-size: 12px;
}


/* Arti CRM — v33 Ozon order links inside messages */
.ozon-order-link {
  color: var(--crm-blue-text);
  font-weight: 600;
  text-decoration: none;
}

.ozon-order-link:hover {
  text-decoration: underline;
}


/* Arti CRM — v35 desktop chat menu position fix
   The extra menu was moved into .chat-controls.
   Keep the current header layout, but make the dropdown anchor to the controls row. */
.chat-header {
  position: relative;
  overflow: visible;
  z-index: 80;
}

.chat-controls {
  position: relative;
  overflow: visible;
}

.chat-controls .extra-menu {
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
}


/* Arti CRM — v36 mobile input zoom fix
   iOS Safari zooms focused inputs when font-size is below 16px. */
@media (max-width: 900px) {
  #chatsView.mobile-chat-mode input,
  #chatsView.mobile-chat-mode select,
  #chatsView.mobile-chat-mode textarea,
  #chatsView > .conversation.mobile-chat-open input,
  #chatsView > .conversation.mobile-chat-open select,
  #chatsView > .conversation.mobile-chat-open textarea {
    font-size: 13px !important;
  }

  #messageText {
    font-size: 13px !important;
  }
}


/* Arti CRM — v38 chat message search */
#chatsView .filters {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: start;
  overflow: visible;
  position: relative;
}

#chatsView .filters.chat-search-open {
  margin-bottom: 55px;
}

.chat-filter-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 6px;
  min-width: 0;
}

.chat-search-wrap {
  position: static;
  min-width: 36px;
}

.chat-search-toggle {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  background: #fff;
  color: var(--crm-text-soft);
}

.chat-search-toggle:hover,
.chat-search-toggle.active {
  background: var(--crm-hover);
  border-color: var(--crm-line-strong);
  color: var(--crm-text);
  transform: none;
}

.chat-search-toggle svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
}

.chat-search-box {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  z-index: 60;
  width: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: #fff;
  box-shadow: var(--crm-shadow-md);
}

.chat-search-box input {
  min-height: 34px;
}

.chat-search-clear {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: var(--crm-radius-sm);
  background: transparent;
  border: 0;
  color: var(--crm-muted);
}

.chat-search-clear:hover {
  background: var(--crm-hover);
  color: var(--crm-text);
  transform: none;
}

.chat-search-match-preview {
  color: var(--crm-blue-text);
}

@media (max-width: 900px) {
  #chatsView .filters {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
  }

  #chatsView .chat-scope-select-row {
    grid-column: 1 / span 2;
  }

  #chatsView .chat-filter-actions {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: start;
    justify-self: end;
    flex-direction: column;
  }

  .chat-search-box {
    width: auto;
  }
}


/* Arti CRM — v39 mobile search input zoom fix */
#chatSearchInput::-webkit-search-cancel-button,
#chatSearchInput::-webkit-search-decoration,
#chatSearchInput::-webkit-search-results-button,
#chatSearchInput::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

#chatSearchInput {
  -webkit-appearance: textfield;
  appearance: textfield;
}

@media (max-width: 900px) {
  #chatSearchInput,
  .chat-search-box input {
    font-size: 13px !important;
    line-height: 1.35;
  }
}


/* Arti CRM — v40 mobile chat list infinite scroll */
.chat-list-render-limit-note,
.chat-list-load-more-note {
  cursor: default;
  text-align: center;
  color: var(--crm-muted);
  background: var(--crm-panel-soft);
}

.chat-list-load-more-note p {
  margin: 0;
}


/* Arti CRM — v43 real image assets for section icons */
.main-nav .nav-btn {
  position: relative;
}

.main-nav .nav-btn .nav-image-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 12px;
  overflow: visible;
  color: inherit;
}

.main-nav .nav-btn .nav-image-icon img {
  width: 38px;
  height: 38px;
  display: block;
  object-fit: contain;
  border-radius: 12px;
  filter: drop-shadow(0 7px 12px rgba(24, 38, 70, .16));
  transition: transform .15s ease, filter .15s ease;
}

.main-nav .nav-btn:hover .nav-image-icon img,
.main-nav .nav-btn.active .nav-image-icon img {
  transform: translateY(-1px);
  filter: drop-shadow(0 9px 16px rgba(24, 38, 70, .20));
}

.main-nav .nav-btn.active {
  background: linear-gradient(90deg, rgba(0,102,255,.10), rgba(0,102,255,.035));
  border-color: rgba(0,102,255,.10);
}

.main-nav .nav-btn.active::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 999px;
  background: #0066ff;
}

@media (max-width: 900px) {
  .main-nav .nav-btn .nav-image-icon,
  .main-nav .nav-btn .nav-image-icon img {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 11px;
  }

  .main-nav .nav-btn.active::before {
    left: 6px;
    right: 6px;
    top: auto;
    bottom: -1px;
    width: auto;
    height: 3px;
  }
}


/* Arti CRM — v45 PWA notification support */
.notification-toggle.notifications-enabled .btn-icon {
  color: var(--crm-green-text);
}

.notification-toggle.notifications-enabled {
  background: var(--crm-green);
  border-color: transparent;
}


/* Arti CRM — v47 real Web Push for desktop and mobile */
.notification-toggle.notifications-enabled .btn-icon {
  color: var(--crm-green-text);
}

.notification-toggle.notifications-enabled {
  background: var(--crm-green);
  border-color: transparent;
}



/* Arti CRM — v52 light/dark product redesign layer
   Safe layer: keeps existing IDs/classes and changes only visual tokens/skins. */
:root,
html[data-theme="light"] {
  --crm-bg: #ffffff0000;
  --crm-bg-soft: #eef3fb;
  --crm-panel: rgba(255, 255, 255, .92);
  --crm-panel-solid: #ffffff;
  --crm-panel-soft: #f8fafd;
  --crm-panel-muted: #eef2f8;
  --crm-nav: rgba(255, 255, 255, .64);
  --crm-card: #ffffff;
  --crm-card-hover: #fbfdff;
  --crm-card-active: #f0f6ff;
  --crm-line: rgba(130, 145, 170, .22);
  --crm-line-strong: rgba(88, 112, 148, .30);
  --crm-text: #162033;
  --crm-text-soft: #3d4b63;
  --crm-muted: #7a879b;
  --crm-muted-2: #a0aabb;
  --crm-active: rgba(57, 122, 255, .11);
  --crm-hover: rgba(57, 122, 255, .07);
  --crm-primary: #2563eb;
  --crm-primary-soft: rgba(37, 99, 235, .12);
  --crm-blue: #e7f0ff;
  --crm-blue-text: #2458c6;
  --crm-green: #e9f8ef;
  --crm-green-text: #1f7a3d;
  --crm-red: #fdecee;
  --crm-red-text: #b42336;
  --crm-orange: #fff2df;
  --crm-orange-text: #a45512;
  --crm-purple: #f2e9ff;
  --crm-purple-text: #6c3bbd;
  --crm-yellow: #fff7d9;
  --crm-yellow-text: #886500;
  --crm-shadow-xs: 0 1px 2px rgba(22, 32, 51, .045);
  --crm-shadow-sm: 0 10px 30px rgba(20, 38, 74, .075);
  --crm-shadow-md: 0 22px 60px rgba(20, 38, 74, .12);
  --crm-focus: 0 0 0 3px rgba(37, 99, 235, .16);
}

html[data-theme="dark"] {
  --crm-bg: #0b0f17;
  --crm-bg-soft: #111827;
  --crm-panel: rgb(54 64 92);
  --crm-panel-solid: #121826;
  --crm-panel-soft: #171f2e;
  --crm-panel-muted: #1e2738;
  --crm-nav: rgba(12, 18, 31, .62);
  --crm-card: rgba(18, 24, 38, .92);
  --crm-card-hover: rgba(24, 32, 48, .98);
  --crm-card-active: rgba(38, 93, 180, .18);
  --crm-line: rgba(148, 163, 184, .14);
  --crm-line-strong: rgba(148, 163, 184, .24);
  --crm-text: #edf3ff;
  --crm-text-soft: #f0f0f0;
  --crm-muted: #8b98ab;
  --crm-muted-2: #687487;
  --crm-active: rgba(66, 133, 244, .18);
  --crm-hover: rgba(148, 163, 184, .08);
  --crm-primary: #63a2ff;
  --crm-primary-soft: rgba(99, 162, 255, .16);
  --crm-blue: rgba(69, 124, 255, .18);
  --crm-blue-text: #9cc6ff;
  --crm-green: rgba(51, 202, 112, .16);
  --crm-green-text: #87e6a8;
  --crm-red: rgba(255, 96, 110, .16);
  --crm-red-text: #ff9ea8;
  --crm-orange: rgba(251, 146, 60, .16);
  --crm-orange-text: #ffc08a;
  --crm-purple: rgba(168, 85, 247, .18);
  --crm-purple-text: #d7b3ff;
  --crm-yellow: rgba(250, 204, 21, .16);
  --crm-yellow-text: #fde68a;
  --crm-shadow-xs: 0 1px 2px rgba(0, 0, 0, .22);
  --crm-shadow-sm: 0 12px 34px rgba(0, 0, 0, .30);
  --crm-shadow-md: 0 26px 70px rgba(0, 0, 0, .42);
  --crm-focus: 0 0 0 3px rgba(99, 162, 255, .22);
}

html[data-theme] body {
  background:
    radial-gradient(circle at 12% 14%, rgba(101, 158, 255, .30), transparent 34%),
    radial-gradient(circle at 88% 10%, rgba(157, 190, 255, .28), transparent 32%),
    linear-gradient(118deg, #d9e7ff 0%, #eef5ff 31%, #ffffff 54%, #edf5ff 72%, #d6e7ff 100%);
  color: var(--crm-text);
}
html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 12% 8%, rgba(53, 107, 210, .38), transparent 36%),
    radial-gradient(circle at 88% 10%, rgba(86, 72, 180, .30), transparent 34%),
    linear-gradient(118deg, #0a0f1b 0%, #14213a 30%, #0f1728 55%, #1d2945 76%, #0a0f1b 100%);
}

html[data-theme] .app-shell,
html[data-theme] .workspace { background: transparent; }

@media (min-width: 1200px) {
  html[data-theme] .app-shell {
    width: min(1480px, calc(100vw - 48px));
    height: calc(100vh - 32px);
    margin: 16px auto;
    grid-template-columns: var(--crm-sidebar) minmax(0, 1fr);
    gap: 16px;
    overflow: visible;
  }
  html[data-theme] .workspace {
    height: 100%;
    padding: 0;
  }
}
html[data-theme] .app-nav {
  background: var(--crm-nav);
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(20, 38, 74, .07);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
}
html[data-theme="dark"] .app-nav { border-color: rgba(148, 163, 184, .16); box-shadow: 0 12px 34px rgba(0,0,0,.28); }

html[data-theme] .brand-card {
  justify-content: flex-start;
  min-height: 50px;
  padding: 9px 10px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--crm-panel-solid), var(--crm-panel-soft));
  border-color: var(--crm-line);
  color: var(--crm-text);
  box-shadow: var(--crm-shadow-xs);
}
html[data-theme="dark"] .brand-card {
  background: linear-gradient(135deg, rgba(31, 41, 61, .98), rgba(18, 24, 38, .92));
}
html[data-theme] .brand-mark {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  margin-right: 9px;
  border-radius: 10px;
  background: linear-gradient(135deg, #63a2ff, #7c5cff);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(68, 118, 255, .24);
}
html[data-theme] .brand-copy h1 { font-size: 15px; letter-spacing: -.01em; }
html[data-theme] .brand-copy p { display: block; margin: 3px 0 0; color: var(--crm-muted); font-size: 11px; }

html[data-theme] .nav-btn {
  min-height: 40px;
  border-radius: 13px;
  color: var(--crm-text-soft);
  font-size: 15px;
}
html[data-theme] .nav-btn:hover {
  background: var(--crm-hover);
  border-color: transparent;
  color: var(--crm-text);
}
html[data-theme] .nav-btn.active,
html[data-theme] .main-nav .nav-btn.active {
  background: linear-gradient(90deg, rgba(52, 112, 255, .16), rgba(52, 112, 255, .06));
  border-color: rgba(52, 112, 255, .12);
  color: var(--crm-text);
  box-shadow: inset 0 0 0 1px rgba(52, 112, 255, .06);
}
html[data-theme] .main-nav .nav-btn.active::before { background: var(--crm-primary); }
html[data-theme] .sync-card,
html[data-theme] .user-card {
  border-color: var(--crm-line);
  background: var(--crm-panel);
  color: var(--crm-muted);
  border-radius: 14px;
}
html[data-theme] .refresh-btn,
html[data-theme] button.secondary,
html[data-theme] button.ghost,
html[data-theme] button.crm-light-btn,
html[data-theme] button.user-light-btn {
  background: var(--crm-panel);
  border-color: var(--crm-line);
  color: var(--crm-text);
}
html[data-theme] .refresh-btn:hover,
html[data-theme] button.secondary:hover,
html[data-theme] button.ghost:hover,
html[data-theme] button.crm-light-btn:hover,
html[data-theme] button.user-light-btn:hover {
  background: var(--crm-hover);
  border-color: var(--crm-line-strong);
}

html[data-theme] .panel-card,
html[data-theme] .sidebar,
html[data-theme] .conversation,
html[data-theme] .reviews-page,
html[data-theme] .knowledge-card,
html[data-theme] .analytics-card,
html[data-theme] .tasks-ref-card,
html[data-theme] .task-card,
html[data-theme] .settings-card,
html[data-theme] .profile-card,
html[data-theme] .user-card-panel {
  background: var(--crm-panel);
  border-color: var(--crm-line);
  box-shadow: var(--crm-shadow-sm);
  backdrop-filter: blur(18px);
}
html[data-theme] .chat-item,
html[data-theme] .review-item,
html[data-theme] .empty-card,
html[data-theme] .empty-chat-item,
html[data-theme] .mobile-more-card,
html[data-theme] .task-item,
html[data-theme] .knowledge-item,
html[data-theme] .question-card,
html[data-theme] .review-detail-card {
  background: var(--crm-card);
  border-color: var(--crm-line);
  box-shadow: var(--crm-shadow-xs);
}
html[data-theme] .chat-item:hover,
html[data-theme] .review-item:hover,
html[data-theme] .task-item:hover,
html[data-theme] .knowledge-item:hover {
  background: var(--crm-card-hover);
  border-color: var(--crm-line-strong);
}
html[data-theme] .chat-item.active,
html[data-theme] .review-item.active {
  background: var(--crm-card-active);
  border-color: rgba(72, 132, 255, .32);
  box-shadow: var(--crm-shadow-sm);
}

html[data-theme] .chat-header,
html[data-theme] .composer,
html[data-theme] .extra-menu,
html[data-theme] .extra-panel,
html[data-theme] .notifications-panel,
html[data-theme] .reply-template-menu,
html[data-theme] .modal-card,
html[data-theme] .toast,
html[data-theme] .image-lightbox-card {
  background: var(--crm-panel);
  border-color: var(--crm-line);
  color: var(--crm-text);
  box-shadow: var(--crm-shadow-md);
}
html[data-theme] .messages,
html[data-theme] .chat-body,
html[data-theme] .empty-state {
  background: transparent;
}
html[data-theme] .customer-avatar,
html[data-theme] .empty-illustration,
html[data-theme] .login-mark,
html[data-theme] .auth-boot-mark {
  background: linear-gradient(135deg, rgba(99, 162, 255, .20), rgba(124, 92, 255, .16));
  color: var(--crm-primary);
}

html[data-theme] input,
html[data-theme] select,
html[data-theme] textarea,
html[data-theme] .chat-search-box,
html[data-theme] .composer-input,
html[data-theme] .message-editor {
  background: var(--crm-panel-solid);
  border-color: var(--crm-line);
  color: var(--crm-text);
}
html[data-theme] input::placeholder,
html[data-theme] textarea::placeholder { color: var(--crm-muted-2); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .chat-search-box,
html[data-theme="dark"] .composer-input,
html[data-theme="dark"] .message-editor {
  background: rgb(40 52 70);
}


html[data-theme] .message { color: var(--crm-text); }
html[data-theme] .message.internal { background: var(--crm-yellow); color: var(--crm-yellow-text); }

html[data-theme] .preview,
html[data-theme] .review-item p,
html[data-theme] #chatSubtitle,
html[data-theme] .empty-state p,
html[data-theme] .sync-status,
html[data-theme] .chat-time { color: var(--crm-muted); }
html[data-theme] .chat-item-title strong,
html[data-theme] .section-title-row h2,
html[data-theme] .chat-title-inline h2 { color: var(--crm-text); }

html[data-theme] .badge,
html[data-theme] .marketplace-pill,
html[data-theme] .status-badge,
html[data-theme] .review-status,
html[data-theme] .sla-badge,
html[data-theme] .assignee-chip,
html[data-theme] .rating-badge {
  border-color: rgba(255,255,255,.04);
}

html[data-theme] .theme-toggle-icon .theme-sun,
html[data-theme] .theme-toggle-icon .theme-core { transition: opacity .15s ease, transform .15s ease; }
html[data-theme="dark"] .theme-toggle-icon .theme-sun { opacity: 0; transform: scale(.5); }
html[data-theme="dark"] .theme-toggle-icon .theme-core { transform: translateX(2px) scale(1.08); }
html[data-theme] .theme-toggle-btn { order: 8; }

html[data-theme] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme] ::-webkit-scrollbar-thumb { background: rgba(130, 145, 170, .30); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .26); border: 3px solid transparent; background-clip: content-box; }

@media (max-width: 900px) {
  html[data-theme] .app-nav {
    background: var(--crm-nav);
    backdrop-filter: blur(18px);
  }
  html[data-theme] .brand-card { min-width: 132px; }
  html[data-theme] .nav-btn { min-height: 38px; }
}

/* Arti CRM — v54-chat-theme-direction-fix-20260701
   Final theme-scoped chat/list correction.
   Light theme returns chat list and messages to the original light UI.
   Dark theme keeps chat list and dialog dark; hover/active become lighter. */

/* Light theme fallback: applies when html has data-theme="light" OR no theme attribute yet. */
html:not([data-theme="dark"]) #chatsView > .sidebar.panel-card,
html[data-theme="light"] #chatsView > .sidebar.panel-card {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html:not([data-theme="dark"]) #chatsView .filters select,
html:not([data-theme="dark"]) #chatsView .filters input,
html:not([data-theme="dark"]) #chatsView .filters button,
html[data-theme="light"] #chatsView .filters select,
html[data-theme="light"] #chatsView .filters input,
html[data-theme="light"] #chatsView .filters button {
  background: #ffffff !important;
  color: #172033 !important;
  border: 1px solid #e1e6ef !important;
  box-shadow: none !important;
}

html:not([data-theme="dark"]) #chatsView .filters select:hover,
html:not([data-theme="dark"]) #chatsView .filters input:hover,
html:not([data-theme="dark"]) #chatsView .filters button:hover,
html[data-theme="light"] #chatsView .filters select:hover,
html[data-theme="light"] #chatsView .filters input:hover,
html[data-theme="light"] #chatsView .filters button:hover {
  background: #eef2f7 !important;
  border-color: #d4dbe8 !important;
}

html:not([data-theme="dark"]) #chatsView .chat-item,
html:not([data-theme="dark"]) #chatsView .empty-chat-item,
html[data-theme="light"] #chatsView .chat-item,
html[data-theme="light"] #chatsView .empty-chat-item {
  background: #ffffff !important;
  color: #172033 !important;
  border: 1px solid #e5e9f1 !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04) !important;
}

html:not([data-theme="dark"]) #chatsView .chat-item:hover,
html:not([data-theme="dark"]) #chatsView .chat-item.needs-response:hover,
html[data-theme="light"] #chatsView .chat-item:hover,
html[data-theme="light"] #chatsView .chat-item.needs-response:hover {
  background: #f1f4f8 !important;
  border-color: #d8dfeb !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .06) !important;
}

html:not([data-theme="dark"]) #chatsView .chat-item.active,
html:not([data-theme="dark"]) #chatsView .chat-item.needs-response.active,
html[data-theme="light"] #chatsView .chat-item.active,
html[data-theme="light"] #chatsView .chat-item.needs-response.active {
  background: #edf3fb !important;
  border-color: #cfd9ea !important;
  box-shadow: 0 7px 18px rgba(15, 23, 42, .10) !important;
}

html:not([data-theme="dark"]) #chatsView .chat-item-title strong,
html:not([data-theme="dark"]) #chatsView .review-item strong,
html[data-theme="light"] #chatsView .chat-item-title strong,
html[data-theme="light"] #chatsView .review-item strong {
  color: #172033 !important;
}

html:not([data-theme="dark"]) #chatsView .preview,
html[data-theme="light"] #chatsView .preview {
  color: #3e4858 !important;
}

html:not([data-theme="dark"]) #chatsView .chat-time,
html[data-theme="light"] #chatsView .chat-time {
  color: #758196 !important;
}

html:not([data-theme="dark"]) .conversation,
html[data-theme="light"] .conversation,
html:not([data-theme="dark"]) .chat-panel,
html[data-theme="light"] .chat-panel,
html:not([data-theme="dark"]) .chat-header,
html[data-theme="light"] .chat-header,
html:not([data-theme="dark"]) .composer,
html[data-theme="light"] .composer {
  background: #ffffff !important;
  color: #172033 !important;
  border-color: #e5e9f1 !important;
}

html:not([data-theme="dark"]) .messages,
html:not([data-theme="dark"]) .chat-body,
html[data-theme="light"] .messages,
html[data-theme="light"] .chat-body {
  background: #ffffff !important;
}

html:not([data-theme="dark"]) .message.inbound .message-bubble,
html:not([data-theme="dark"]) .message.outbound .message-bubble,
html[data-theme="light"] .message.inbound .message-bubble,
html[data-theme="light"] .message.outbound .message-bubble {
  background: #f3f4f6 !important;
  color: #172033 !important;
}

html:not([data-theme="dark"]) .message.outbound .message-bubble,
html[data-theme="light"] .message.outbound .message-bubble {
  background: #f1f3f5 !important;
}

html:not([data-theme="dark"]) .message.internal .message-bubble,
html[data-theme="light"] .message.internal .message-bubble {
  background: #ffffff !important;
  color: #172033 !important;
  border-color: #e5e9f1 !important;
}

html:not([data-theme="dark"]) .message-text,
html:not([data-theme="dark"]) .message-bubble .message-text,
html[data-theme="light"] .message-text,
html[data-theme="light"] .message-bubble .message-text {
  color: #172033 !important;
}

html:not([data-theme="dark"]) .message-footer,
html:not([data-theme="dark"]) .message-bubble-meta,
html:not([data-theme="dark"]) .message-time,
html[data-theme="light"] .message-footer,
html[data-theme="light"] .message-bubble-meta,
html[data-theme="light"] .message-time {
  color: #8490a3 !important;
}

html:not([data-theme="dark"]) .message-crm-author,
html[data-theme="light"] .message-crm-author {
  color: #66758a !important;
}

html:not([data-theme="dark"]) .message-actions-btn,
html[data-theme="light"] .message-actions-btn {
  background: rgba(255, 255, 255, .92) !important;
  border-color: #e1e6ef !important;
  color: #526073 !important;
}

html:not([data-theme="dark"]) .message-actions-btn:hover,
html[data-theme="light"] .message-actions-btn:hover {
  background: #eef2f7 !important;
  color: #172033 !important;
}

/* Dark theme: dark base, hover/active slightly lighter. */
html[data-theme="dark"] #chatsView > .sidebar.panel-card {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] #chatsView .filters select,
html[data-theme="dark"] #chatsView .filters input,
html[data-theme="dark"] #chatsView .filters button {
  background: #253448 !important;
  color: #edf3ff !important;
  border: 1px solid rgba(255,255,255,.06) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] #chatsView .filters select:hover,
html[data-theme="dark"] #chatsView .filters input:hover,
html[data-theme="dark"] #chatsView .filters button:hover {
  background: #30455f !important;
  border-color: rgba(255,255,255,.10) !important;
}

html[data-theme="dark"] #chatsView .chat-item,
html[data-theme="dark"] #chatsView .empty-chat-item {
  background: #20354a !important;
  color: #edf3ff !important;
  border: 1px solid rgba(255,255,255,.05) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] #chatsView .chat-item:hover,
html[data-theme="dark"] #chatsView .chat-item.needs-response:hover {
  background: #2a435d !important;
  border-color: rgba(255,255,255,.10) !important;
  box-shadow: 0 6px 16px rgba(0,0,0,.18) !important;
}

html[data-theme="dark"] #chatsView .chat-item.active,
html[data-theme="dark"] #chatsView .chat-item.needs-response.active {
  background: #314c69 !important;
  border-color: rgba(114, 166, 255, .26) !important;
  box-shadow: 0 10px 24px rgba(0,0,0,.24) !important;
}

html[data-theme="dark"] #chatsView .chat-item-title strong,
html[data-theme="dark"] #chatsView .review-item strong {
  color: #f4f7fb !important;
}

html[data-theme="dark"] #chatsView .preview {
  color: #cad4e2 !important;
}

html[data-theme="dark"] #chatsView .chat-time {
  color: #a8b3c2 !important;
}

html[data-theme="dark"] .conversation,
html[data-theme="dark"] .chat-panel,
html[data-theme="dark"] .chat-header,
html[data-theme="dark"] .composer {
  background: rgba(17, 24, 39, .94) !important;
  color: #edf3ff !important;
  border-color: rgba(148, 163, 184, .14) !important;
}

html[data-theme="dark"] .messages,
html[data-theme="dark"] .chat-body {
  background: rgba(10, 15, 23, .78) !important;
}

html[data-theme="dark"] .message.inbound .message-bubble,
html[data-theme="dark"] .message.outbound .message-bubble {
  background: #253448 !important;
  color: #edf3ff !important;
}

html[data-theme="dark"] .message.outbound .message-bubble {
  background: #2c405b !important;
}

html[data-theme="dark"] .message.internal .message-bubble {
  background: #1b2738 !important;
  color: #edf3ff !important;
  border-color: rgba(148, 163, 184, .16) !important;
}

html[data-theme="dark"] .message-text,
html[data-theme="dark"] .message-bubble .message-text {
  color: #edf3ff !important;
}

html[data-theme="dark"] .message-footer,
html[data-theme="dark"] .message-bubble-meta,
html[data-theme="dark"] .message-time {
  color: #a8b3c2 !important;
}

html[data-theme="dark"] .message-crm-author {
  color: #c3cfdf !important;
}

html[data-theme="dark"] .message-actions-btn {
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.10) !important;
  color: #edf3ff !important;
}

html[data-theme="dark"] .message-actions-btn:hover {
  background: rgba(255,255,255,.16) !important;
}


/* Arti CRM — v55 global dark theme hardening
   Goal: in dark theme there must be no white/light UI surfaces anywhere
   except text/icons. This is intentionally appended at the end so it wins over
   older local section rules such as background:#fff in reviews/questions/tasks. */

html[data-theme="dark"] {
  --crm-bg: #0b0f17;
  --crm-bg-soft: #0f1624;
  --crm-panel: #121a29;
  --crm-panel-solid: #111827;
  --crm-panel-soft: #162033;
  --crm-panel-muted: #1d2a3f;
  --crm-nav: rgba(12, 18, 31, .62);
  --crm-card: #121a29;
  --crm-card-hover: #1a263a;
  --crm-card-active: #223553;
  --crm-line: rgba(126, 148, 178, .22);
  --crm-line-strong: rgba(145, 169, 204, .34);
  --crm-text: #eef4ff;
  --crm-text-soft: #d8e2f1;
  --crm-muted: #9ba8ba;
  --crm-muted-2: #738198;
  --crm-active: #18243a;
  --crm-hover: #1a263a;
  --crm-primary-soft: rgba(99, 162, 255, .16);
  --crm-shadow-xs: 0 1px 2px rgba(0, 0, 0, .28);
  --crm-shadow-sm: 0 10px 30px rgba(0, 0, 0, .32);
  --crm-shadow-md: 0 24px 70px rgba(0, 0, 0, .46);
}

html[data-theme="dark"] {
  background: #0b0f17 !important;
  color: var(--crm-text) !important;
}
html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .workspace,
html[data-theme="dark"] .view,
html[data-theme="dark"] .layout {
  background: transparent !important;
  color: var(--crm-text) !important;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 12% 8%, rgba(53, 107, 210, .38), transparent 36%),
    radial-gradient(circle at 88% 10%, rgba(86, 72, 180, .30), transparent 34%),
    linear-gradient(118deg, #0a0f1b 0%, #14213a 30%, #0f1728 55%, #1d2945 76%, #0a0f1b 100%) !important;
}

/* Main dark surfaces across all sections */
html[data-theme="dark"] :is(
  .app-nav,
  .brand-card,
  .panel-card,
  .sidebar,
  .conversation,
  .chat-panel,
  .chat-header,
  .messages,
  .composer,
  .extra-menu,
  .extra-panel,
  .reply-templates-panel,
  .notifications-panel,
  .reviews-list-panel,
  .review-detail-panel,
  .review-panel,
  .review-fact,
  .review-body-card,
  .review-reply-card,
  .existing-reply,
  .tasks-toolbar,
  .tasks-ref-toolbar,
  .tasks-ref-card,
  .tasks-ref-search,
  .tasks-ref-date,
  .tasks-ref-status-menu,
  .tasks-ref-empty,
  .task-card,
  .task-chat-card,
  .task-chat-edit-panel,
  .knowledge-panel,
  .knowledge-toolbar,
  .knowledge-categories,
  .knowledge-editor,
  .knowledge-modal-dialog,
  .knowledge-modal-topbar,
  .knowledge-image-preview,
  .settings-card,
  .status-settings-row,
  .task-type-settings-row,
  .user-row,
  .user-create-modal-dialog,
  .analytics-toolbar,
  .analytics-note,
  .analytics-card,
  .analytics-panel,
  .analytics-table,
  .analytics-table table,
  .analytics-table-grid,
  .empty-card,
  .empty-chat-item,
  .mobile-more-sheet,
  .mobile-more-card,
  .auth-boot-card,
  .login-card,
  .image-card,
  .message-actions-menu
) {
  background: var(--crm-panel) !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text) !important;
  box-shadow: var(--crm-shadow-xs) !important;
}

/* Slightly different nested surfaces, so sections keep depth without white. */
html[data-theme="dark"] :is(
  .review-fact,
  .review-body-card,
  .review-reply-card,
  .existing-reply,
  .task-card,
  .task-chat-card,
  .status-settings-row,
  .task-type-settings-row,
  .user-row,
  .analytics-card,
  .analytics-panel,
  .empty-card,
  .empty-chat-item,
  .image-card,
  .reply-template-item
) {
  background: var(--crm-card) !important;
}

html[data-theme="dark"] :is(
  .review-item,
  .chat-item,
  .tasks-ref-card,
  .task-card,
  .task-chat-card,
  .status-settings-row,
  .task-type-settings-row,
  .user-row
):hover {
  background: var(--crm-card-hover) !important;
  border-color: var(--crm-line-strong) !important;
}

html[data-theme="dark"] :is(
  .review-item.active,
  .chat-item.active,
  .tasks-ref-status-option.active
) {
  background: var(--crm-card-active) !important;
  border-color: rgba(99, 162, 255, .36) !important;
}

/* Form fields: no white inputs/textareas/selects in dark theme. */
html[data-theme="dark"] :is(
  input,
  select,
  textarea,
  .chat-search-box,
  .composer-input,
  .message-editor,
  #messageText,
  #reviewReplyText,
  #questionAnswerText,
  #taskTitle,
  #noteText,
  #customerNameInput,
  .tasks-ref-search input,
  .date-range-filter-popover input
) {
  background: #182234 !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] :is(input, textarea)::placeholder {
  color: #7f8da3 !important;
}

/* Buttons and icon controls: dark neutral surfaces, lighter on hover. */
html[data-theme="dark"] :is(
  button.secondary,
  button.ghost,
  button.crm-light-btn,
  button.user-light-btn,
  button.refresh-btn,
  button.icon-btn:not(#extraMenuBtn),
  button.small.secondary,
  button.small.ghost,
  .mobile-back-btn,
  .reply-templates-close,
  .reply-template-add-icon,
  .knowledge-modal-close,
  .knowledge-modal-nav,
  .message-actions-btn,
  .composer-attach-btn,
  .composer-template-btn,
  .composer-send-btn,
  .tasks-ref-status-option
) {
  background: #182234 !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text-soft) !important;
}

html[data-theme="dark"] :is(
  button.secondary,
  button.ghost,
  button.crm-light-btn,
  button.user-light-btn,
  button.refresh-btn,
  button.icon-btn:not(#extraMenuBtn),
  button.small.secondary,
  button.small.ghost,
  .mobile-back-btn,
  .reply-templates-close,
  .reply-template-add-icon,
  .knowledge-modal-close,
  .knowledge-modal-nav,
  .message-actions-btn,
  .composer-attach-btn,
  .composer-template-btn,
  .composer-send-btn,
  .tasks-ref-status-option
):hover {
  background: #22314a !important;
  border-color: var(--crm-line-strong) !important;
  color: var(--crm-text) !important;
}

html[data-theme="dark"] button:disabled,
html[data-theme="dark"] .button-like:disabled {
  background: #1b2435 !important;
  border-color: rgba(126, 148, 178, .14) !important;
  color: #6e7c91 !important;
  opacity: 1 !important;
}

/* Review/questions detail cards and generated facts in Ozon sections. */
html[data-theme="dark"] :is(
  #reviewPanel,
  #questionPanel,
  #reviewFacts > *,
  #questionFacts > *,
  #reviewText,
  #questionText,
  #reviewReplyCard,
  #questionAnswerCard,
  .review-panel > *,
  .question-panel > *,
  .review-header,
  .review-actions,
  .question-actions
) {
  background: var(--crm-card) !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text) !important;
}

html[data-theme="dark"] :is(#reviewText, #questionText) a,
html[data-theme="dark"] a {
  color: #9cc6ff;
}

/* Tables/charts: remove light table rows and headers. */
html[data-theme="dark"] :is(
  table,
  thead,
  tbody,
  tr,
  th,
  td,
  .analytics-table th,
  .analytics-table td,
  .analytics-drilldown-summary > *,
  .analytics-marketplace-breakdown > *,
  .analytics-hourly-chart > *,
  .analytics-daily-table > *
) {
  background-color: transparent !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text-soft) !important;
}

html[data-theme="dark"] .analytics-table tr:hover,
html[data-theme="dark"] .analytics-drilldown-summary > *:hover,
html[data-theme="dark"] .analytics-marketplace-breakdown > *:hover {
  background-color: var(--crm-card-hover) !important;
}

/* Message bubbles: keep dark in dark theme, slightly lighter on hover. */
html[data-theme="dark"] :is(.message-text, .message-bubble, .message.inbound .message-text, .message.outbound .message-text) {
  background: #203049 !important;
  color: var(--crm-text) !important;
}

html[data-theme="dark"] .message.outbound :is(.message-text, .message-bubble) {
  background: #263a57 !important;
}

html[data-theme="dark"] .message.internal :is(.message-text, .message-bubble) {
  background: #1b2738 !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text) !important;
}

/* Overlays: dark glass, no white modal surfaces. */
html[data-theme="dark"] :is(.knowledge-modal, .user-create-modal-backdrop) {
  background: rgba(0, 0, 0, .58) !important;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: transparent !important;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(120, 138, 165, .38) !important;
  border-color: transparent !important;
}

/* =========================================================
   Arti CRM — v56 dark theme buttons fix
   Rule: in dark theme no white button surfaces. Text/icons may stay light.
   ========================================================= */
html[data-theme="dark"] {
  --crm-button-bg: #182234;
  --crm-button-bg-hover: #22314a;
  --crm-button-bg-active: #2a3d5c;
  --crm-button-primary-bg: #233b5f;
  --crm-button-primary-hover: #2c4c79;
  --crm-button-disabled-bg: #161e2d;
  --crm-button-disabled-text: #738198;
}

/* Catch all regular buttons first, including default primary buttons that used
   var(--crm-text) as background and therefore became white in dark theme. */
html[data-theme="dark"] button,
html[data-theme="dark"] .button-like,
html[data-theme="dark"] input[type="button"],
html[data-theme="dark"] input[type="submit"],
html[data-theme="dark"] input[type="reset"] {
  background: var(--crm-button-bg) !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] button:hover,
html[data-theme="dark"] .button-like:hover,
html[data-theme="dark"] input[type="button"]:hover,
html[data-theme="dark"] input[type="submit"]:hover,
html[data-theme="dark"] input[type="reset"]:hover {
  background: var(--crm-button-bg-hover) !important;
  border-color: var(--crm-line-strong) !important;
  color: #ffffff !important;
}

html[data-theme="dark"] button:active,
html[data-theme="dark"] .button-like:active,
html[data-theme="dark"] input[type="button"]:active,
html[data-theme="dark"] input[type="submit"]:active,
html[data-theme="dark"] input[type="reset"]:active {
  background: var(--crm-button-bg-active) !important;
  border-color: rgba(148, 163, 184, .32) !important;
}

/* Primary/action buttons: still dark, but with a blue accent instead of white. */
html[data-theme="dark"] :is(
  button:not(.ghost):not(.secondary):not(.icon-btn):not(.nav-btn):not(.link-btn),
  .button-like:not(.ghost):not(.secondary),
  .user-light-btn-primary,
  .composer-send-btn,
  #sendBtn,
  #refreshBtn,
  #questionSyncBtn,
  #reviewSyncBtn,
  #taskCreateBtn,
  #saveProfileBtn,
  #saveSettingsBtn,
  #answerQuestionBtn,
  #reviewReplySubmitBtn
) {
  background: var(--crm-button-primary-bg) !important;
  border-color: rgba(99, 162, 255, .22) !important;
  color: #eef5ff !important;
}

html[data-theme="dark"] :is(
  button:not(.ghost):not(.secondary):not(.icon-btn):not(.nav-btn):not(.link-btn),
  .button-like:not(.ghost):not(.secondary),
  .user-light-btn-primary,
  .composer-send-btn,
  #sendBtn,
  #refreshBtn,
  #questionSyncBtn,
  #reviewSyncBtn,
  #taskCreateBtn,
  #saveProfileBtn,
  #saveSettingsBtn,
  #answerQuestionBtn,
  #reviewReplySubmitBtn
):hover {
  background: var(--crm-button-primary-hover) !important;
  border-color: rgba(99, 162, 255, .36) !important;
  color: #ffffff !important;
}

/* Icon/menu/utility buttons use the neutral dark surface. */
html[data-theme="dark"] :is(
  button.secondary,
  button.ghost,
  button.crm-light-btn,
  button.user-light-btn,
  button.refresh-btn,
  button.icon-btn:not(#extraMenuBtn),
  button.small,
  button.small.secondary,
  button.small.ghost,
  .mobile-back-btn,
  .reply-templates-close,
  .reply-template-add-icon,
  .knowledge-modal-close,
  .knowledge-modal-nav,
  .message-actions-btn,
  .composer-attach-btn,
  .composer-template-btn,
  .tasks-ref-status-option,
  .extra-menu button,
  .message-actions-menu button,
  .nav-btn
) {
  background: var(--crm-button-bg) !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text-soft) !important;
}

html[data-theme="dark"] :is(
  button.secondary,
  button.ghost,
  button.crm-light-btn,
  button.user-light-btn,
  button.refresh-btn,
  button.icon-btn:not(#extraMenuBtn),
  button.small,
  button.small.secondary,
  button.small.ghost,
  .mobile-back-btn,
  .reply-templates-close,
  .reply-template-add-icon,
  .knowledge-modal-close,
  .knowledge-modal-nav,
  .message-actions-btn,
  .composer-attach-btn,
  .composer-template-btn,
  .tasks-ref-status-option,
  .extra-menu button,
  .message-actions-menu button,
  .nav-btn
):hover {
  background: var(--crm-button-bg-hover) !important;
  border-color: var(--crm-line-strong) !important;
  color: #ffffff !important;
}

/* Navigation keeps its own active look, but never becomes white. */
html[data-theme="dark"] .nav-btn {
  background: transparent !important;
  border-color: transparent !important;
}

html[data-theme="dark"] .nav-btn:hover {
  background: rgba(99, 162, 255, .12) !important;
  border-color: rgba(99, 162, 255, .14) !important;
}

html[data-theme="dark"] .nav-btn.active {
  background: rgba(99, 162, 255, .18) !important;
  border-color: rgba(99, 162, 255, .22) !important;
  color: #ffffff !important;
}

/* Link buttons may stay transparent; transparent is allowed, white fill is not. */
html[data-theme="dark"] button.link-btn,
html[data-theme="dark"] .link-btn {
  background: transparent !important;
  border-color: transparent !important;
  color: #9cc6ff !important;
}

html[data-theme="dark"] button.link-btn:hover,
html[data-theme="dark"] .link-btn:hover {
  background: rgba(99, 162, 255, .10) !important;
  color: #cfe4ff !important;
}

/* Disabled states: dark muted surface, never white/ice. */
html[data-theme="dark"] button:disabled,
html[data-theme="dark"] button[disabled],
html[data-theme="dark"] .button-like:disabled,
html[data-theme="dark"] .button-like[disabled],
html[data-theme="dark"] input[type="button"]:disabled,
html[data-theme="dark"] input[type="submit"]:disabled,
html[data-theme="dark"] input[type="reset"]:disabled {
  background: var(--crm-button-disabled-bg) !important;
  border-color: rgba(126, 148, 178, .14) !important;
  color: var(--crm-button-disabled-text) !important;
  opacity: 1 !important;
  box-shadow: none !important;
  transform: none !important;
}

/* Some browser/autofill/default controls can inject light appearance. */
html[data-theme="dark"] button *,
html[data-theme="dark"] .button-like * {
  color: inherit;
}

/* Keep badge/status pills colored, not converted into generic buttons when they
   are implemented as buttons in menus. */
html[data-theme="dark"] :is(.status-badge, .review-status, .sla-badge, .assignee-chip, .rating-badge, .marketplace-pill) {
  border-color: transparent !important;
}


/* =========================================================
   Arti CRM — v57 mobile questions inline + dark analytics rows
   ========================================================= */

/* Analytics hour rows/buttons should not create extra dark cards in dark theme. */
html[data-theme="dark"] :is(.analytics-hour-row, .analytics-hour-button),
html[data-theme="dark"] .analytics-hour-row.analytics-hour-button,
html[data-theme="dark"] button.analytics-hour-button {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: var(--crm-text-soft) !important;
}

html[data-theme="dark"] :is(.analytics-hour-row, .analytics-hour-button):hover,
html[data-theme="dark"] .analytics-hour-row.analytics-hour-button:hover,
html[data-theme="dark"] button.analytics-hour-button:hover {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

html[data-theme="dark"] .analytics-hour-track {
  background: rgba(126, 148, 178, .16) !important;
}

html[data-theme="dark"] .analytics-hour-fill {
  background: rgba(134, 177, 255, .72) !important;
}

.question-inline-panel {
  display: none;
}

@media (max-width: 900px) {
  #questionsView.reviews-page {
    display: block;
    height: 100%;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #questionsView > .reviews-list-panel {
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  #questionsView > .review-detail-panel {
    display: none !important;
  }

  #questionsView .reviews-list {
    grid-auto-rows: auto;
    overflow: visible;
    min-height: 0;
  }

  #questionsView .question-list-item {
    cursor: pointer;
  }

  #questionsView .question-list-item.is-inline-open {
    cursor: default;
  }

  #questionsView .question-inline-panel {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--crm-line);
  }

  #questionsView .question-inline-facts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #questionsView .question-inline-fact,
  #questionsView .question-inline-body,
  #questionsView .question-inline-answer-form {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--crm-line);
    border-radius: var(--crm-radius-md);
    background: var(--crm-panel);
    color: var(--crm-text);
  }

  #questionsView .question-inline-fact span,
  #questionsView .question-inline-body strong {
    color: var(--crm-muted);
    font-size: 12px;
  }

  #questionsView .question-inline-fact strong {
    color: var(--crm-text);
    overflow-wrap: anywhere;
  }

  #questionsView .question-inline-body p {
    margin: 0;
    color: var(--crm-text-soft);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  #questionsView .question-inline-product-link {
    width: fit-content;
    color: var(--crm-blue-text);
    font-weight: 600;
    text-decoration: none;
  }

  #questionsView .question-inline-product-link:hover {
    text-decoration: underline;
  }

  #questionsView .question-inline-answer-form textarea {
    min-height: 104px;
    resize: vertical;
  }

  #questionsView .question-inline-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
  }

  #questionsView .question-inline-actions button {
    min-width: 118px;
  }

  #questionsView .question-inline-existing-answer {
    margin: 0;
  }

  html[data-theme="dark"] #questionsView .question-inline-fact,
  html[data-theme="dark"] #questionsView .question-inline-body,
  html[data-theme="dark"] #questionsView .question-inline-answer-form {
    background: var(--crm-card) !important;
    border-color: var(--crm-line) !important;
    color: var(--crm-text) !important;
  }

  html[data-theme="dark"] #questionsView .question-inline-body p {
    color: var(--crm-text-soft) !important;
  }

  html[data-theme="dark"] #questionsView .question-list-item.is-inline-open {
    background: var(--crm-card-active) !important;
  }
}


/* Arti CRM — v58-compact-chat-status-settings-20260701: compact chat status settings */
.tech-settings-page .chat-status-create-form {
  max-width: 420px;
  grid-template-columns: minmax(0, 1fr) 74px 74px auto;
  align-items: center;
}

.tech-settings-page .chat-status-create-form input,
.tech-settings-page .chat-status-create-form select,
.tech-settings-page .chat-status-create-form button {
  min-height: 36px;
}

.tech-settings-page .status-settings-header-compact {
  grid-template-columns: minmax(180px, 1fr) 86px 110px 86px !important;
  align-items: center;
  padding: 0 12px;
}

.tech-settings-page .status-settings-list {
  gap: 8px;
}

.tech-settings-page .status-settings-row-compact {
  grid-template-columns: 1fr !important;
  gap: 0 !important;
  min-height: 58px;
  padding: 0 !important;
  overflow: hidden;
}

.tech-settings-page .status-compact-view {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
}

.tech-settings-page .status-compact-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tech-settings-page .status-color-dot {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--crm-panel-soft);
  border: 1px solid var(--crm-line);
  font-size: 14px;
  line-height: 1;
}

.tech-settings-page .status-compact-title-wrap {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.tech-settings-page .status-compact-title {
  min-width: 0;
  color: var(--crm-text);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tech-settings-page .status-key-hint {
  color: var(--crm-muted);
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tech-settings-page .status-compact-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.tech-settings-page .status-order-chip,
.tech-settings-page .status-active-chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--crm-line);
  background: var(--crm-panel-soft);
  color: var(--crm-text-soft);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.tech-settings-page .status-order-chip {
  min-width: 34px;
  padding: 0 9px;
}

.tech-settings-page .status-active-chip {
  min-width: 74px;
  padding: 0 10px;
}

.tech-settings-page .status-active-chip.is-active {
  background: var(--crm-green);
  border-color: transparent;
  color: var(--crm-green-text);
}

.tech-settings-page .status-active-chip.is-inactive {
  background: var(--crm-panel-muted);
  color: var(--crm-muted);
}

.tech-settings-page .status-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.tech-settings-page .status-icon-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 10px;
  background: var(--crm-panel-soft);
  border: 1px solid var(--crm-line);
  color: var(--crm-text-soft);
  box-shadow: none;
}

.tech-settings-page .status-icon-btn:hover {
  background: var(--crm-hover);
  color: var(--crm-text);
  transform: none;
}

.tech-settings-page .status-icon-btn-danger:hover {
  background: var(--crm-red);
  border-color: transparent;
  color: var(--crm-red-text);
}

.tech-settings-page .status-edit-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, 150px) 92px minmax(92px, auto) auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid var(--crm-line);
  background: var(--crm-panel-soft);
}

.tech-settings-page .status-edit-panel label {
  min-width: 0;
  gap: 4px;
}

.tech-settings-page .status-edit-panel label > span {
  color: var(--crm-muted);
  font-size: 11px;
}

.tech-settings-page .status-edit-panel input,
.tech-settings-page .status-edit-panel select {
  min-height: 32px;
}

.tech-settings-page .status-edit-panel .status-active-toggle {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 2px;
}

.tech-settings-page .status-edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.tech-settings-page .settings-actions-bottom-compact {
  margin-top: 2px;
}

html[data-theme="dark"] .tech-settings-page .status-color-dot,
html[data-theme="dark"] .tech-settings-page .status-order-chip,
html[data-theme="dark"] .tech-settings-page .status-active-chip,
html[data-theme="dark"] .tech-settings-page .status-icon-btn {
  background: var(--crm-card) !important;
  border-color: var(--crm-line) !important;
  color: var(--crm-text-soft) !important;
}

html[data-theme="dark"] .tech-settings-page .status-icon-btn:hover {
  background: var(--crm-card-hover) !important;
  color: var(--crm-text) !important;
}

html[data-theme="dark"] .tech-settings-page .status-icon-btn-danger:hover {
  background: rgba(239, 68, 68, .18) !important;
  color: #ffb0b0 !important;
}

html[data-theme="dark"] .tech-settings-page .status-edit-panel {
  background: var(--crm-card) !important;
  border-color: var(--crm-line) !important;
}

@media (max-width: 900px) {
  .tech-settings-page .chat-status-create-form {
    max-width: none;
    grid-template-columns: 1fr;
  }

  .tech-settings-page .status-settings-header-compact {
    display: none;
  }

  .tech-settings-page .status-compact-view {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .tech-settings-page .status-compact-meta {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-left: 38px;
  }

  .tech-settings-page .status-row-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .tech-settings-page .status-edit-panel {
    grid-template-columns: 1fr;
  }

  .tech-settings-page .status-edit-actions {
    justify-content: stretch;
  }

  .tech-settings-page .status-edit-actions button {
    width: 100%;
  }
}

/* =========================================================
   Arti CRM — v59 analytics hourly chart scale fix
   - remove legacy nth-child pseudo-bars
   - use real values from app.js .analytics-hour-fill width
   - no row/button background in dark theme
   ========================================================= */
#analyticsHourlyChart.analytics-hourly-chart {
  width: 100% !important;
  max-width: 100% !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
  padding: 2px 0 4px !important;
  overflow: visible !important;
  background: transparent !important;
}

#analyticsHourlyChart .analytics-hour-row.analytics-hour-button,
#analyticsHourlyChart button.analytics-hour-button {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  min-height: 28px !important;
  height: 28px !important;
  display: grid !important;
  grid-template-columns: minmax(58px, 80px) minmax(0, 1fr) minmax(24px, 36px) !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  color: var(--crm-text-soft) !important;
  text-align: left !important;
  cursor: pointer !important;
  transform: none !important;
  appearance: none;
  -webkit-appearance: none;
}

#analyticsHourlyChart .analytics-hour-row.analytics-hour-button::before,
#analyticsHourlyChart .analytics-hour-row.analytics-hour-button::after,
#analyticsHourlyChart button.analytics-hour-button::before,
#analyticsHourlyChart button.analytics-hour-button::after {
  content: none !important;
  display: none !important;
}

#analyticsHourlyChart .analytics-hour-row.analytics-hour-button:hover,
#analyticsHourlyChart button.analytics-hour-button:hover {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

#analyticsHourlyChart .analytics-hour-label {
  grid-column: 1 !important;
  min-width: 0 !important;
  color: var(--crm-text-soft) !important;
  font-size: 13px !important;
  font-weight: 550 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#analyticsHourlyChart .analytics-hour-track {
  grid-column: 2 !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 6px !important;
  overflow: hidden !important;
  border-radius: 999px !important;
  background: #eeeeee !important;
  box-shadow: none !important;
}

#analyticsHourlyChart .analytics-hour-fill {
  display: block !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  border-radius: inherit !important;
  background: #1f1f1f !important;
  box-shadow: none !important;
}

#analyticsHourlyChart .analytics-hour-value {
  grid-column: 3 !important;
  min-width: 0 !important;
  color: var(--crm-muted) !important;
  font-size: 13px !important;
  font-weight: 650 !important;
  line-height: 1 !important;
  text-align: right !important;
  white-space: nowrap !important;
}

html[data-theme="dark"] #analyticsHourlyChart,
html[data-theme="dark"] #analyticsHourlyChart.analytics-hourly-chart,
html[data-theme="dark"] #analyticsHourlyChart .analytics-hour-row.analytics-hour-button,
html[data-theme="dark"] #analyticsHourlyChart button.analytics-hour-button,
html[data-theme="dark"] #analyticsHourlyChart .analytics-hour-row.analytics-hour-button:hover,
html[data-theme="dark"] #analyticsHourlyChart button.analytics-hour-button:hover {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: var(--crm-text-soft) !important;
  transform: none !important;
}

html[data-theme="dark"] #analyticsHourlyChart .analytics-hour-track {
  background: rgba(126, 148, 178, .16) !important;
}

html[data-theme="dark"] #analyticsHourlyChart .analytics-hour-fill {
  background: rgba(146, 185, 255, .82) !important;
}

html[data-theme="dark"] #analyticsHourlyChart .analytics-hour-label,
html[data-theme="dark"] #analyticsHourlyChart .analytics-hour-value {
  color: var(--crm-text-soft) !important;
}


/* Arti CRM — v60 tasks page overlay + task edit/delete actions */
#tasksView,
#tasksView .tasks-page,
#tasksView .tasks-redesign-page,
#tasksView .tasks-ref-list {
  overflow: visible;
}

#tasksView .tasks-ref-card {
  position: relative;
  overflow: visible;
  z-index: 1;
}

#tasksView .tasks-ref-card.status-menu-open,
#tasksView .tasks-ref-card.task-edit-open {
  z-index: 80;
}

#tasksView .tasks-ref-status-wrap {
  position: relative;
  z-index: 4;
}

#tasksView .tasks-ref-status-menu {
  z-index: 1000;
}

#tasksView .tasks-ref-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

#tasksView .tasks-ref-icon-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--crm-text-soft);
  line-height: 1;
  box-shadow: none;
}

#tasksView .tasks-ref-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#tasksView .tasks-ref-icon-btn:hover,
#tasksView .tasks-ref-icon-btn:focus-visible {
  background: var(--crm-hover);
  color: var(--crm-text);
  transform: none;
}

#tasksView .tasks-ref-delete-btn:hover,
#tasksView .tasks-ref-delete-btn:focus-visible {
  color: var(--crm-red-text);
}

#tasksView .tasks-ref-chat-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
}

#tasksView .tasks-ref-chat-btn svg {
  width: 14px;
  height: 14px;
}

#tasksView .tasks-ref-edit-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  margin-top: 2px;
  padding: 12px;
  border-radius: var(--crm-radius-md);
  border: 1px solid var(--crm-line);
  background: var(--crm-panel-soft);
}

#tasksView .tasks-ref-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

#tasksView .tasks-ref-edit-title,
#tasksView .tasks-ref-edit-comment {
  display: grid;
  gap: 6px;
}

#tasksView .tasks-ref-edit-title textarea,
#tasksView .tasks-ref-edit-comment textarea {
  min-height: 74px;
}

#tasksView .tasks-ref-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

html[data-theme="dark"] #tasksView .tasks-ref-edit-panel {
  background: var(--crm-panel) !important;
  border-color: var(--crm-line) !important;
}

@media (max-width: 900px) {
  #tasksView .tasks-ref-list {
    overflow: visible;
  }

  #tasksView .tasks-ref-side {
    align-items: flex-start;
    gap: 10px;
  }

  #tasksView .tasks-ref-actions {
    justify-content: flex-start;
  }

  #tasksView .tasks-ref-status-menu {
    left: 0;
    right: auto;
    min-width: 180px;
  }

  #tasksView .tasks-ref-edit-grid {
    grid-template-columns: 1fr;
  }
}

/* Arti CRM — v83-knowledge-css-clean-theme-20260713
   Knowledge base CSS cleanup: one component style, theme variables, no html:not([data-theme="dark"]) conflict. */
:root,
html[data-theme="light"] {
  --knowledge-category-bg: var(--crm-card);
  --knowledge-category-bg-hover: var(--crm-card-hover);
  --knowledge-category-border: var(--crm-line);
  --knowledge-category-border-hover: var(--crm-line-strong);
  --knowledge-category-text: var(--crm-text);
  --knowledge-category-count-text: rgba(22, 32, 51, .70);
  --knowledge-category-chevron-text: rgba(22, 32, 51, .58);
  --knowledge-category-active-bg: var(--crm-card-active);
  --knowledge-category-active-bg-hover: var(--crm-card-active);
  --knowledge-category-active-border: rgba(72, 132, 255, .28);
  --knowledge-category-active-text: var(--crm-text);
  --knowledge-category-active-muted: var(--crm-muted);
  --knowledge-category-active-shadow: var(--crm-shadow-xs);
}

html[data-theme="dark"] {
  --knowledge-category-bg: var(--crm-card);
  --knowledge-category-bg-hover: var(--crm-card-hover);
  --knowledge-category-border: var(--crm-line);
  --knowledge-category-border-hover: var(--crm-line-strong);
  --knowledge-category-text: var(--crm-text);
  --knowledge-category-count-text: rgba(237, 243, 255, .68);
  --knowledge-category-chevron-text: rgba(237, 243, 255, .58);
  --knowledge-category-active-bg: #22314a;
  --knowledge-category-active-bg-hover: #2a3b58;
  --knowledge-category-active-border: rgba(99, 162, 255, .42);
  --knowledge-category-active-text: var(--crm-text);
  --knowledge-category-active-muted: rgba(237, 243, 255, .74);
  --knowledge-category-active-shadow: inset 0 0 0 1px rgba(99, 162, 255, .08), var(--crm-shadow-xs);
}

html[data-theme] .knowledge-section {
  display: grid;
  gap: 0;
}

html[data-theme] .knowledge-section + .knowledge-section {
  margin-top: 10px;
}

html[data-theme] .knowledge-category-item {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--knowledge-category-border);
  border-radius: var(--crm-radius-sm);
  background: var(--knowledge-category-bg);
  color: var(--knowledge-category-text);
  box-shadow: var(--crm-shadow-xs);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease;
}

html[data-theme] .knowledge-category-item:hover {
  background: var(--knowledge-category-bg-hover);
  border-color: var(--knowledge-category-border-hover);
}

html[data-theme] .knowledge-category-item.active {
  background: var(--knowledge-category-active-bg);
  border-color: var(--knowledge-category-active-border);
  color: var(--knowledge-category-active-text);
  box-shadow: var(--knowledge-category-active-shadow);
}

html[data-theme] .knowledge-category-item.active:hover {
  background: var(--knowledge-category-active-bg-hover);
  border-color: var(--knowledge-category-active-border);
}

html[data-theme] .knowledge-category-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-weight: 700;
}

html[data-theme] .knowledge-category-count {
  min-width: max-content;
  white-space: nowrap;
  color: var(--knowledge-category-count-text);
  font-size: 12px;
  font-weight: 500;
}

html[data-theme] .knowledge-category-item.active .knowledge-category-count {
  color: var(--knowledge-category-active-muted);
}

html[data-theme] .knowledge-category-item .knowledge-chevron {
  min-width: 18px;
  margin-left: 2px;
  text-align: right;
  color: var(--knowledge-category-chevron-text);
}

html[data-theme] .knowledge-category-item.active .knowledge-chevron {
  color: var(--knowledge-category-active-muted);
}

html[data-theme] .knowledge-nested {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

html[data-theme] .knowledge-nested.hidden {
  display: none;
}

html[data-theme] .knowledge-nested > .empty-card,
html[data-theme] .knowledge-nested > .knowledge-article-item {
  margin-top: 0;
}

html[data-theme] .knowledge-category-form {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--crm-line);
}

@media (max-width: 900px) {
  html[data-theme] .knowledge-nested {
    margin-top: 10px;
  }

  html[data-theme] .knowledge-category-form {
    margin-top: 20px;
    padding-top: 16px;
  }
}

@media (max-width: 560px) {
  html[data-theme] .knowledge-category-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
  }

  html[data-theme] .knowledge-category-count {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  html[data-theme] .knowledge-category-item .knowledge-chevron {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }
}

/* Arti CRM — v64-supply-planning-manual-formula-20260703
   Supply planning: manual marketplace warehouse forecasting. */
.supply-planning-page {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding-bottom: 24px;
}

.supply-planning-hero {
  align-items: flex-start;
}

.supply-planning-hero p,
.supply-planning-formula-card p,
.supply-planning-panel-head p {
  margin: 5px 0 0;
  color: var(--crm-muted);
  font-size: 13px;
}

.supply-planning-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.supply-planning-formula-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 14px;
  align-items: center;
}

.supply-planning-formula-card strong {
  display: block;
  margin-top: 4px;
  color: var(--crm-text);
  line-height: 1.45;
}

.supply-planning-default-target {
  display: grid;
  gap: 7px;
  color: var(--crm-muted);
  font-size: 12px;
}

.supply-planning-default-target input {
  width: 100%;
}

.supply-planning-summary.analytics-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.supply-planning-panel {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.supply-planning-rows {
  display: grid;
  gap: 12px;
}

.supply-planning-empty {
  padding: 18px;
}

.supply-planning-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-lg);
  background: var(--crm-card);
  box-shadow: var(--crm-shadow-xs);
}

.supply-planning-row-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(145px, 1fr));
  gap: 10px;
  min-width: 0;
}

.supply-planning-row-fields label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--crm-muted);
  font-size: 12px;
}

.supply-planning-row-fields input,
.supply-planning-row-fields select {
  width: 100%;
  min-width: 0;
}

.supply-planning-row-result {
  position: relative;
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: var(--crm-panel-soft);
}

.supply-planning-status {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(109, 118, 137, .12);
  color: var(--crm-text-soft);
}

.supply-planning-status-ok {
  background: rgba(33, 163, 102, .14);
  color: #168153;
}

.supply-planning-status-need {
  background: rgba(69, 91, 255, .14);
  color: #345dff;
}

.supply-planning-status-critical {
  background: rgba(226, 92, 70, .15);
  color: #c84531;
}

.supply-planning-status-no-sales {
  background: rgba(109, 118, 137, .12);
  color: var(--crm-muted);
}

.supply-planning-result-grid {
  display: grid;
  gap: 8px;
}

.supply-planning-result-grid > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--crm-line);
}

.supply-planning-result-grid > div:last-child {
  border-bottom: 0;
}

.supply-planning-result-grid span {
  color: var(--crm-muted);
  font-size: 12px;
}

.supply-planning-result-grid strong {
  color: var(--crm-text);
  font-size: 16px;
  white-space: nowrap;
}

.supply-planning-delete {
  position: absolute;
  top: 8px;
  right: 8px;
}

html[data-theme="dark"] .supply-planning-row,
html[data-theme="dark"] .supply-planning-row-result,
html[data-theme="dark"] .supply-planning-formula-card,
html[data-theme="dark"] .supply-planning-panel {
  background: var(--crm-card) !important;
  border-color: var(--crm-line) !important;
}

html[data-theme="dark"] .supply-planning-row-result {
  background: var(--crm-panel-soft) !important;
}

html[data-theme="dark"] .supply-planning-status-ok { color: #54d99a; }
html[data-theme="dark"] .supply-planning-status-need { color: #93adff; }
html[data-theme="dark"] .supply-planning-status-critical { color: #ff9a86; }

@media (max-width: 1100px) {
  .supply-planning-row {
    grid-template-columns: 1fr;
  }

  .supply-planning-row-fields {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .supply-planning-summary.analytics-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .supply-planning-formula-card {
    grid-template-columns: 1fr;
  }

  .supply-planning-row-fields,
  .supply-planning-summary.analytics-grid {
    grid-template-columns: 1fr;
  }

  .supply-planning-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Arti CRM — v65-supply-planning-api-sync-20260703
   Supply planning API import status and actions. */
.supply-planning-api-card {
  display: grid;
  gap: 8px;
  border-style: dashed;
}

.supply-planning-api-card.hidden {
  display: none !important;
}

.supply-planning-api-title {
  font-weight: 760;
  color: var(--crm-text);
}

.supply-planning-api-card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  color: var(--crm-muted);
  font-size: 13px;
}

.supply-planning-api-card-loading {
  border-color: rgba(80, 120, 255, .35);
  background: rgba(80, 120, 255, .06);
}

.supply-planning-api-card-success {
  border-color: rgba(39, 174, 96, .35);
  background: rgba(39, 174, 96, .06);
}

.supply-planning-api-card-warning {
  border-color: rgba(245, 158, 11, .38);
  background: rgba(245, 158, 11, .08);
}

.supply-planning-api-card-error {
  border-color: rgba(239, 68, 68, .38);
  background: rgba(239, 68, 68, .08);
}

html[data-theme="dark"] .supply-planning-api-card-loading,
html[data-theme="dark"] .supply-planning-api-card-success,
html[data-theme="dark"] .supply-planning-api-card-warning,
html[data-theme="dark"] .supply-planning-api-card-error {
  background: rgba(255, 255, 255, .035);
}

/* Arti CRM — v66-supply-planning-api-required-data-20260703
   Supply planning is API-first: filters + read-only marketplace stock/sales fields. */
.supply-planning-filters {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
}

.supply-planning-filters label {
  display: grid;
  gap: 7px;
  color: var(--crm-muted);
  font-size: 12px;
}

.supply-planning-filters input,
.supply-planning-filters select {
  width: 100%;
  min-width: 0;
}

.supply-planning-readonly {
  display: grid;
  gap: 5px;
  min-width: 0;
  align-content: start;
}

.supply-planning-readonly span {
  color: var(--crm-muted);
  font-size: 12px;
}

.supply-planning-readonly strong {
  min-width: 0;
  color: var(--crm-text);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supply-planning-readonly-wide {
  grid-column: span 2;
}

.supply-planning-readonly-wide strong {
  white-space: normal;
}

html[data-theme="dark"] .supply-planning-filters {
  background: var(--crm-card) !important;
  border-color: var(--crm-line) !important;
}

@media (max-width: 1100px) {
  .supply-planning-filters {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .supply-planning-readonly-wide {
    grid-column: span 1;
  }
}

@media (max-width: 760px) {
  .supply-planning-filters {
    grid-template-columns: 1fr;
  }
}



/* Arti CRM — v67-supply-planning-urgency-global-target-20260703
   Supply planning: high-level target stock days + urgency filter. */
.supply-planning-filters {
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) minmax(220px, 1fr) minmax(200px, 260px);
}

.supply-planning-formula-card .supply-planning-default-target {
  align-self: end;
}

@media (max-width: 1280px) {
  .supply-planning-filters {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .supply-planning-filters {
    grid-template-columns: 1fr;
  }
}

/* Arti CRM — v71-tasks-scroll-container-fix-20260707
   Tasks: restore real page scrolling after the status-menu overlay fix.
   v60 made #tasksView overflow: visible so dropdowns could appear over neighbour cards,
   but inside the app shell that removed the scroll container and clipped long task lists.
*/
#tasksView.tasks-page,
#tasksView.tasks-redesign-page {
  height: 100% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 28px;
}

#tasksView .tasks-ref-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
}

#tasksView .tasks-ref-list {
  overflow: visible !important;
  position: relative;
  padding-bottom: 24px;
}

#tasksView .tasks-ref-card {
  overflow: visible !important;
}

#tasksView .tasks-ref-card.status-menu-open,
#tasksView .tasks-ref-card.task-edit-open {
  z-index: 120;
}

#tasksView .tasks-ref-status-menu {
  z-index: 1500;
}

@media (max-width: 900px) {
  #tasksView.tasks-page,
  #tasksView.tasks-redesign-page {
    height: 100% !important;
    max-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  #tasksView .tasks-ref-toolbar {
    top: 0;
  }

  #tasksView .tasks-ref-list {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
}

/* Arti CRM — v73-standalone-tasks-and-supply-beta-nav-20260707
   Tasks: standalone task creation in the Tasks section + supply menu beta label placement. */
#tasksView .tasks-ref-toolbar {
  grid-template-columns: minmax(190px, auto) minmax(220px, 1fr) minmax(140px, 180px) minmax(130px, 160px) minmax(150px, 190px) 44px;
}

#tasksView .tasks-ref-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

#tasksView .tasks-ref-title-row h2 {
  margin: 0;
}

#tasksView .tasks-ref-new-btn {
  min-height: 34px;
  padding-inline: 12px;
  border-radius: 999px;
  background: var(--crm-text);
  border-color: var(--crm-text);
  color: var(--crm-panel);
  box-shadow: none;
}

#tasksView .tasks-ref-new-btn:hover {
  transform: none;
  filter: brightness(.94);
}

#tasksView .tasks-standalone-create-panel {
  display: grid;
  gap: 12px;
  margin: -2px 0 14px;
  padding: 14px;
  border-radius: var(--crm-radius-lg);
}

#tasksView .tasks-standalone-create-panel.hidden {
  display: none !important;
}

#tasksView .tasks-standalone-form {
  display: grid;
  gap: 12px;
}

#tasksView .tasks-standalone-form-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#tasksView .tasks-standalone-form-head h3 {
  margin: 0;
  font-size: 16px;
}

#tasksView .tasks-standalone-form-head p {
  margin: 4px 0 0;
  color: var(--crm-muted);
  font-size: 13px;
}

#tasksView .tasks-standalone-grid {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) minmax(180px, 240px);
  gap: 10px;
}

#tasksView .tasks-standalone-grid label,
#tasksView .tasks-standalone-title-field {
  display: grid;
  gap: 6px;
  color: var(--crm-muted);
  font-size: 12px;
}

#tasksView .tasks-standalone-title-field textarea {
  min-height: 88px;
}

#tasksView .tasks-standalone-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

#tasksView .tasks-ref-card-standalone .tasks-ref-client .tasks-ref-field-value {
  color: var(--crm-muted);
}

html[data-theme="dark"] #tasksView .tasks-ref-new-btn {
  background: var(--crm-text);
  border-color: var(--crm-text);
  color: var(--crm-panel);
}

html[data-theme="dark"] #tasksView .tasks-standalone-create-panel {
  background: var(--crm-card) !important;
  border-color: var(--crm-line) !important;
}

@media (max-width: 1100px) {
  #tasksView .tasks-ref-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  #tasksView .tasks-ref-title-row,
  #tasksView .tasks-ref-search {
    grid-column: 1 / -1;
  }

  #tasksView .tasks-standalone-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 760px) {
  #tasksView .tasks-ref-toolbar {
    grid-template-columns: 1fr;
  }

  #tasksView .tasks-ref-title-row {
    align-items: stretch;
  }

  #tasksView .tasks-ref-new-btn {
    width: 100%;
  }

  #tasksView .tasks-standalone-grid {
    grid-template-columns: 1fr;
  }

  #tasksView .tasks-standalone-actions {
    justify-content: stretch;
  }

  #tasksView .tasks-standalone-actions button {
    flex: 1 1 auto;
  }
}

/* Arti CRM — v74-analytics-peak-weekdays-20260707
   Analytics: top weekdays by requests in selected period. */
.analytics-peak-weekdays-card strong {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.analytics-peak-weekdays-card small {
  line-height: 1.35;
}

@media (max-width: 900px) {
  .analytics-peak-weekdays-card strong {
    font-size: 18px;
  }
}

/* Arti CRM — v81-mobile-ui-cleanups-20260709
   UI cleanup: internal notes, mobile analytics filters, mobile knowledge editor and supply readability. */

/* Internal notes: no yellow surface and no visible text-field border inside notes. */
html[data-theme] .message.internal {
  background: transparent !important;
  color: var(--crm-text) !important;
}

html[data-theme] .message.internal .message-bubble {
  background: var(--crm-card) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

html[data-theme] .message.internal .message-text {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

html[data-theme] .internal-note-editor,
html[data-theme] .internal-note-edit-text,
html[data-theme] #noteText {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

html[data-theme] #noteText {
  padding-inline: 0 !important;
  resize: vertical;
}

html[data-theme] #noteText:focus,
html[data-theme] .internal-note-edit-text:focus {
  outline: none !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* Mobile analytics: date filters must stay inside the card/container. */
@media (max-width: 900px) {
  #analyticsView.analytics-page {
    overflow-x: hidden !important;
  }

  #analyticsView .analytics-filters {
    width: 100% !important;
    max-width: 100% !important;
    grid-template-columns: 1fr !important;
    padding: 12px !important;
    gap: 10px !important;
    overflow: hidden !important;
  }

  #analyticsView .analytics-filters label,
  #analyticsView .analytics-filters input,
  #analyticsView .analytics-filters select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  #analyticsView :is(#analyticsDateFrom, #analyticsDateTo) {
    appearance: none;
    -webkit-appearance: none;
    display: block;
  }
}

/* Mobile knowledge base: article editor opens as one sheet, not as a second split block. */
@media (max-width: 760px) {
  #knowledgeView.knowledge-page {
    height: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  #knowledgeView .knowledge-layout {
    display: block !important;
    min-height: 0 !important;
  }

  #knowledgeView .knowledge-categories {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  #knowledgeView .knowledge-editor {
    display: none !important;
  }

  #knowledgeView[data-kb-mode="edit"] .knowledge-editor {
    position: fixed !important;
    inset: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) 10px !important;
    z-index: 130 !important;
    display: grid !important;
    align-content: start !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100dvh - 20px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 14px !important;
    border-radius: 18px !important;
    background: var(--crm-panel) !important;
    border: 1px solid var(--crm-line) !important;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .28) !important;
    -webkit-overflow-scrolling: touch;
  }

  #knowledgeView[data-kb-mode="edit"] .knowledge-editor::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgba(15, 23, 42, .34);
    pointer-events: none;
  }

  #knowledgeView[data-kb-mode="edit"] .knowledge-article-form {
    margin-top: 0 !important;
    gap: 10px !important;
  }

  #knowledgeView[data-kb-mode="edit"] .knowledge-form-head {
    position: sticky;
    top: -14px;
    z-index: 2;
    margin: -14px -14px 4px;
    padding: 14px;
    background: var(--crm-panel) !important;
    border-bottom: 1px solid var(--crm-line);
  }

  #knowledgeView[data-kb-mode="edit"] .knowledge-mobile-back.hidden {
    display: inline-flex !important;
  }

  #knowledgeView[data-kb-mode="edit"] .knowledge-form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  #knowledgeView[data-kb-mode="edit"] .knowledge-article-form :is(input, select, textarea, button) {
    max-width: 100% !important;
  }

  #knowledgeView[data-kb-mode="edit"] #knowledgeArticleContent {
    min-height: 180px;
  }
}

/* Mobile supply planning: add breathing room and make row content readable. */
@media (max-width: 760px) {
  #supplyPlanningView.supply-planning-page {
    gap: 12px !important;
    padding: 10px 8px 28px !important;
    overflow-x: hidden !important;
  }

  #supplyPlanningView :is(.supply-planning-hero, .supply-planning-formula-card, .supply-planning-panel, .supply-planning-filters, .supply-planning-row, .supply-planning-row-result, .supply-planning-api-card) {
    width: 100% !important;
    max-width: 100% !important;
    padding: 14px !important;
    box-sizing: border-box !important;
  }

  #supplyPlanningView .supply-planning-actions {
    gap: 8px !important;
  }

  #supplyPlanningView .supply-planning-actions button {
    width: 100%;
    justify-content: center;
  }

  #supplyPlanningView .supply-planning-filters,
  #supplyPlanningView .supply-planning-row-fields,
  #supplyPlanningView .supply-planning-result-grid {
    gap: 12px !important;
  }

  #supplyPlanningView .supply-planning-row {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  #supplyPlanningView .supply-planning-row-fields {
    grid-template-columns: 1fr !important;
  }

  #supplyPlanningView .supply-planning-readonly,
  #supplyPlanningView .supply-planning-row-fields label,
  #supplyPlanningView .supply-planning-filters label {
    gap: 6px !important;
    padding: 2px 0 !important;
  }

  #supplyPlanningView .supply-planning-readonly strong,
  #supplyPlanningView .supply-planning-result-grid strong {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.35 !important;
  }

  #supplyPlanningView .supply-planning-result-grid > div {
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 10px 0 !important;
  }
}

/* Arti CRM — v84-knowledge-card-style-clean-20260713
   Knowledge base: final clean card-style buttons, no primary button inheritance and readable article cards. */
#knowledgeView .knowledge-category-item {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  justify-content: initial;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--knowledge-category-border);
  border-radius: var(--crm-radius-sm);
  background: var(--knowledge-category-bg);
  color: var(--knowledge-category-text);
  box-shadow: var(--crm-shadow-xs);
  text-align: left;
  white-space: normal;
  transform: none;
}

#knowledgeView .knowledge-category-item:hover {
  background: var(--knowledge-category-bg-hover);
  border-color: var(--knowledge-category-border-hover);
  color: var(--knowledge-category-text);
  transform: none;
}

#knowledgeView .knowledge-category-item.active,
#knowledgeView .knowledge-category-item.active:hover {
  background: var(--knowledge-category-active-bg);
  border-color: var(--knowledge-category-active-border);
  color: var(--knowledge-category-active-text);
  box-shadow: var(--knowledge-category-active-shadow);
}

#knowledgeView .knowledge-category-title {
  min-width: 0;
  color: inherit;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#knowledgeView .knowledge-category-count,
#knowledgeView .knowledge-chevron {
  color: var(--knowledge-category-count-text);
}

#knowledgeView .knowledge-category-item.active .knowledge-category-count,
#knowledgeView .knowledge-category-item.active .knowledge-chevron {
  color: var(--knowledge-category-active-muted);
}

#knowledgeView .knowledge-article-item {
  width: 100%;
  min-height: 54px;
  display: grid;
  align-items: start;
  justify-content: stretch;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-card);
  color: var(--crm-text);
  box-shadow: var(--crm-shadow-xs);
  text-align: left;
  white-space: normal;
  transform: none;
}

#knowledgeView .knowledge-article-item:hover {
  background: var(--crm-card-hover);
  border-color: var(--crm-line-strong);
  color: var(--crm-text);
  transform: none;
}

#knowledgeView .knowledge-article-item.active,
#knowledgeView .knowledge-article-item.active:hover {
  background: var(--crm-card-active);
  border-color: rgba(72, 132, 255, .28);
  color: var(--crm-text);
  box-shadow: var(--crm-shadow-xs);
}

#knowledgeView .knowledge-article-item strong {
  color: var(--crm-text);
  font-weight: 700;
}

#knowledgeView .knowledge-article-item p,
#knowledgeView .knowledge-card-top,
#knowledgeView .knowledge-card-category,
#knowledgeView .knowledge-card-date {
  color: var(--crm-muted);
}

#knowledgeView .knowledge-article-item.active strong {
  color: var(--crm-text);
}

#knowledgeView .knowledge-article-item.active p,
#knowledgeView .knowledge-article-item.active .knowledge-card-top,
#knowledgeView .knowledge-article-item.active .knowledge-card-category,
#knowledgeView .knowledge-article-item.active .knowledge-card-date {
  color: var(--crm-muted);
}

#knowledgeView .knowledge-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}

#knowledgeView .knowledge-card-category,
#knowledgeView .knowledge-card-date {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#knowledgeView .knowledge-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#knowledgeView .knowledge-card-tags span {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--crm-panel-muted);
  color: var(--crm-muted);
  font-size: 12px;
}

@media (max-width: 560px) {
  #knowledgeView .knowledge-category-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
  }

  #knowledgeView .knowledge-category-count {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  #knowledgeView .knowledge-chevron {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }
}



/* Arti CRM — v95.2 shared chat/task date-range filters */
.date-range-filter-wrap {
  position: relative;
}

.date-range-filter-btn {
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-panel);
  color: var(--crm-text-soft);
}

.date-range-filter-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.date-range-filter-btn:hover,
.date-range-filter-btn.is-active {
  background: var(--crm-hover);
  border-color: var(--crm-line-strong);
  color: var(--crm-text);
  transform: none;
}

.date-range-filter-btn.is-active {
  box-shadow: inset 0 0 0 1px var(--crm-blue);
}

.date-range-filter-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  width: 300px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius-md);
  background: var(--crm-panel);
  box-shadow: var(--crm-shadow-md);
}

.date-range-filter-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.date-range-filter-popover label {
  display: grid;
  gap: 5px;
  color: var(--crm-muted);
  font-size: 12px;
}

.date-range-filter-popover input {
  width: 100%;
  min-width: 0;
}

.date-range-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.date-range-filter-actions button {
  width: auto;
}

@media (max-width: 900px) {
  .date-range-filter-popover {
    position: fixed;
    top: 118px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  .date-range-filter-fields {
    grid-template-columns: 1fr;
  }
}


/* Arti CRM — v95.2 chat/task date-range scope correction */
#tasksView .tasks-ref-due time {
  display: block;
  white-space: nowrap;
}

@media (max-width: 1250px) and (min-width: 1101px) {
  #tasksView .tasks-ref-toolbar {
    grid-template-columns: minmax(180px, auto) minmax(200px, 1fr) repeat(3, minmax(130px, 1fr)) 44px;
  }
}


/* =========================================================
   Arti CRM — v96.9 responsive chat header
   The conversation header adapts to its own available width,
   not only to the viewport width.
   ========================================================= */
#chatsView .conversation {
  min-width: 0;
  container-type: inline-size;
  container-name: chat-conversation;
}

#chatsView .chat-header {
  min-width: 0;
}

#chatsView .chat-heading {
  flex: 1 1 260px;
  min-width: 0;
}

#chatsView .chat-heading-row {
  width: 100%;
  min-width: 0;
}

#chatsView .chat-title-stack {
  flex: 1 1 auto;
  min-width: 0;
}

#chatsView .chat-controls {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(56%, 470px);
}

#chatsView .chat-controls select {
  width: clamp(112px, 13vw, 180px);
  min-width: 0;
  max-width: 100%;
}

/* Container-driven wrapping is a desktop-only behavior.
   Mobile already uses a vertical header layout; applying flex-wrap to a
   column flex container would create an off-screen second column. */
@media (min-width: 901px) {
  @container chat-conversation (max-width: 760px) {
    #chatsView .chat-header {
      flex-wrap: wrap;
      align-items: center;
      row-gap: 10px;
    }

    #chatsView .chat-heading {
      flex: 1 1 100%;
      width: 100%;
    }

    #chatsView .chat-controls {
      width: 100%;
      max-width: none;
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
      gap: 8px;
    }

    #chatsView .chat-controls select {
      width: 100%;
      min-width: 0;
    }
  }
}

@media (max-width: 900px) {
  #chatsView.mobile-chat-mode > .conversation .chat-header,
  #chatsView > .conversation.mobile-chat-open .chat-header {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-heading,
  #chatsView > .conversation.mobile-chat-open .chat-heading {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-controls,
  #chatsView > .conversation.mobile-chat-open .chat-controls {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px !important;
    align-items: center !important;
    gap: 6px !important;
  }

  #chatsView.mobile-chat-mode > .conversation .chat-controls select,
  #chatsView > .conversation.mobile-chat-open .chat-controls select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #chatsView.mobile-chat-mode > .conversation #extraMenuBtn,
  #chatsView > .conversation.mobile-chat-open #extraMenuBtn {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
  }
}

@media (max-width: 520px) {
  #chatsView.mobile-chat-mode > .conversation .chat-header,
  #chatsView > .conversation.mobile-chat-open .chat-header {
    padding-inline: 12px;
  }
}


/* Preserve the read-state icon as a transparent utility control. */
#chatsView .chat-read-state-control,
#chatsView .chat-read-state-control:hover,
#chatsView .chat-read-state-control:focus,
#chatsView .chat-read-state-control:focus-visible,
#chatsView .chat-read-state-control:active {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

/* CRM action feedback: non-blocking in-app errors for chat actions. */
.crm-action-toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 10030;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}

.crm-action-toast-stack.has-items {
  pointer-events: auto;
}

.crm-action-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border: 1px solid var(--crm-line);
  border-radius: 16px;
  background: var(--crm-panel);
  color: var(--crm-text);
  box-shadow: var(--crm-shadow-md);
}

.crm-action-toast-warning {
  border-left: 3px solid #d58b2a;
}

.crm-action-toast-copy {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 4px;
}

.crm-action-toast-copy strong {
  font-size: 15px;
  line-height: 1.25;
}

.crm-action-toast-copy span {
  color: var(--crm-text-soft);
  font-size: 14px;
  line-height: 1.4;
}

.crm-action-toast-close,
html[data-theme="dark"] .crm-action-toast-close,
html[data-theme="dark"] .crm-action-toast-close:hover,
html[data-theme="dark"] .crm-action-toast-close:active {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border: 0 !important;
  border-radius: 8px;
  background: transparent !important;
  color: var(--crm-muted) !important;
  box-shadow: none !important;
  transform: none !important;
}

.crm-action-toast-close:hover {
  background: var(--crm-hover) !important;
  color: var(--crm-text) !important;
}

html[data-theme="dark"] .crm-action-toast {
  background: rgba(21, 31, 47, .96);
  border-color: var(--crm-line);
  color: var(--crm-text);
}

@media (max-width: 700px) {
  .crm-action-toast-stack {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }
}


/* =========================================================
   Arti CRM — v96.14 adaptive in-chat extra panel geometry
   Tasks/notes/customer panels are positioned below the actual
   rendered chat header instead of relying on a fixed top offset.
   ========================================================= */
#chatsView .extra-panel {
  top: var(--chat-extra-panel-top, 78px);
  max-height: min(620px, calc(100% - var(--chat-extra-panel-top, 78px) - 14px));
  overscroll-behavior: contain;
}

@media (max-width: 900px) {
  #chatsView.mobile-chat-mode > .conversation .extra-panel,
  #chatsView > .conversation.mobile-chat-open .extra-panel {
    position: fixed !important;
    top: var(--chat-extra-panel-viewport-top, 126px) !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100vh - var(--chat-extra-panel-viewport-top, 126px) - 12px) !important;
    max-height: calc(100dvh - var(--chat-extra-panel-viewport-top, 126px) - 12px) !important;
    margin: 0 !important;
    z-index: 29990 !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

@media (max-width: 520px) {
  #chatsView.mobile-chat-mode > .conversation .extra-panel,
  #chatsView > .conversation.mobile-chat-open .extra-panel {
    left: 6px !important;
    right: 6px !important;
  }
}
