/* QChat R67.1 theme and notification surfaces */
:root {
  color-scheme: light;
  --q67-bg: #f3f6fc;
  --q67-surface: #ffffff;
  --q67-surface-2: #f8faff;
  --q67-ink: #1d2941;
  --q67-muted: #65738b;
  --q67-line: #dbe3ef;
  --q67-shadow: 0 14px 36px rgba(27, 43, 73, .10);
  --q67-accent: #6653c7;
  --q67-accent-soft: #eeeaff;
  --q67-input: #ffffff;
}
html[data-theme="dark"] {
  color-scheme: dark;
}
body {
  --bg: var(--q67-bg);
  --surface: var(--q67-surface);
  --panel: var(--q67-surface);
  --surface-2: var(--q67-surface-2);
  --ink: var(--q67-ink);
  --text: var(--q67-ink);
  --muted: var(--q67-muted);
  --line: var(--q67-line);
  --pale: var(--q67-surface-2);
  --shadow: var(--q67-shadow);
  --input: var(--q67-input);
  background: var(--q67-bg) !important;
  color: var(--q67-ink) !important;
}
body.dark {
  color-scheme: dark;
  --q67-bg: #090e1c;
  --q67-surface: #151d31;
  --q67-surface-2: #1b2540;
  --q67-ink: #edf1ff;
  --q67-muted: #aab5ce;
  --q67-line: #303b59;
  --q67-shadow: 0 16px 40px rgba(0, 0, 0, .34);
  --q67-accent: #9b87ff;
  --q67-accent-soft: #30285a;
  --q67-input: #10182b;
  --bg: var(--q67-bg);
  --surface: var(--q67-surface);
  --panel: var(--q67-surface);
  --surface-2: var(--q67-surface-2);
  --ink: var(--q67-ink);
  --text: var(--q67-ink);
  --muted: var(--q67-muted);
  --line: var(--q67-line);
  --pale: var(--q67-surface-2);
  --shadow: var(--q67-shadow);
  --input: var(--q67-input);
  background: var(--q67-bg) !important;
  color: var(--q67-ink) !important;
}

/* Common application surfaces */
body .rail,
body .header,
body .topbar,
body .main,
body #view,
body .panel,
body .card,
body .stat,
body .chat-list,
body .chat,
body .chat-header,
body .messages,
body .composer,
body .list-top,
body .toolbar,
body .table-wrap,
body .modal,
body dialog,
body .empty,
body .notice,
body .q65-pane,
body .q65-card,
body .q65-thread,
body .q65-org,
body .q65-ticket-detail,
body .qw64-profile,
body .qw64-card,
body .qw64-categories,
body .qw64-filterchips {
  color: var(--q67-ink);
  border-color: var(--q67-line);
}
body .panel,
body .card,
body .stat,
body .chat-list,
body .chat,
body .chat-header,
body .messages,
body .composer,
body .list-top,
body .table-wrap,
body .empty,
body .notice,
body .q65-pane,
body .q65-card,
body .q65-thread,
body .q65-org,
body .q65-ticket-detail,
body .qw64-profile,
body .qw64-card {
  background-color: var(--q67-surface);
}
body .rail,
body .header,
body .topbar {
  background-color: var(--q67-surface) !important;
  color: var(--q67-ink) !important;
  border-color: var(--q67-line) !important;
}
body .main {
  background-color: var(--q67-bg) !important;
  color: var(--q67-ink) !important;
}
body .chat-header,
body .list-top,
body .composer {
  background-color: var(--q67-surface-2) !important;
}
body .messages {
  background-color: var(--q67-bg) !important;
}
body .conversation-row {
  background-color: transparent;
  color: var(--q67-ink);
}
body .conversation-row.active {
  background-color: var(--q67-accent-soft) !important;
  border-color: var(--q67-accent) !important;
}
body .rail button,
body .rail a,
body .header-side button {
  color: var(--q67-ink);
}
body .rail button.selected,
body .rail a.selected {
  background: var(--q67-accent-soft) !important;
  color: var(--q67-accent) !important;
}
body .meta,
body .help,
body .muted,
body .q65-muted,
body .qw64-muted,
body .q65-thread small,
body .q65-org-bubble small,
body .qchat-notifications67 small {
  color: var(--q67-muted) !important;
}
body input,
body select,
body textarea,
body .composer textarea,
body .search input {
  color: var(--q67-ink);
  background-color: var(--q67-input);
  border-color: var(--q67-line);
}
body input::placeholder,
body textarea::placeholder {
  color: var(--q67-muted);
  opacity: .8;
}
body table,
body th,
body td {
  border-color: var(--q67-line);
}
body th {
  background: var(--q67-surface-2);
  color: var(--q67-ink);
}
body button:not(.primary):not(.active):not(.selected) {
  border-color: var(--q67-line);
}
body .conversation-row,
body .q65-thread,
body .q65-app-tabs button,
body .q65-kind-tabs button,
body .qw64-tabs button,
body .qw64-categories button,
body .qw64-filterchips button {
  color: var(--q67-ink);
  border-color: var(--q67-line);
}
body .conversation-row:hover,
body .q65-thread:hover,
body .qw64-tabs button:hover,
body .qw64-categories button:hover,
body .qw64-filterchips button:hover {
  background: var(--q67-surface-2);
}
body .conversation-row.active,
body .q65-thread.active,
body .qw64-tabs button.active,
body .qw64-categories button.active,
body .qw64-filterchips button.active {
  background: var(--q67-accent-soft);
  border-color: var(--q67-accent);
}
body .bubble {
  background: var(--q67-surface-2);
  color: var(--q67-ink);
  border-color: var(--q67-line);
}
body .bubble.out {
  background: var(--q67-accent-soft);
  color: var(--q67-ink);
}
body .bubble.note {
  background: var(--q67-surface);
  border-color: var(--q67-accent);
}
body .pill {
  border-color: var(--q67-line);
}
body .qchat-offline-banner60 {
  background: color-mix(in srgb, #d97706 10%, var(--q67-surface)) !important;
  color: var(--q67-ink) !important;
  border-color: #d97706 !important;
}
body .native-manager51 {
  --bg: var(--q67-bg) !important;
  --panel: var(--q67-surface) !important;
  --line: var(--q67-line) !important;
  --text: var(--q67-ink) !important;
  --muted: var(--q67-muted) !important;
  color: var(--q67-ink) !important;
  background: var(--q67-bg) !important;
}
body .native-manager51 .card,
body .native-manager51 .account-card,
body .native-manager51 .manager-card,
body .native-manager51 .panel {
  background: var(--q67-surface) !important;
  color: var(--q67-ink) !important;
  border-color: var(--q67-line) !important;
}

/* Light mode is applied to every custom workspace, not only the legacy shell. */
body:not(.dark) .q65-workspace,
body:not(.dark) .q65-pane,
body:not(.dark) .q65-profile,
body:not(.dark) .q65-chat-pane,
body:not(.dark) .q65-list-pane,
body:not(.dark) .q65-org,
body:not(.dark) .q65-ticket-page,
body:not(.dark) .q65-publish,
body:not(.dark) .qw64-profile,
body:not(.dark) .qw64-card {
  color: var(--q67-ink) !important;
  background-color: var(--q67-surface) !important;
}
body:not(.dark) .q65-pane-head,
body:not(.dark) .q65-thread,
body:not(.dark) .q65-org-bubble,
body:not(.dark) .q65-ticket-admin-controls,
body:not(.dark) .qw64-tabs,
body:not(.dark) .qw64-fields > div {
  color: var(--q67-ink) !important;
  background-color: var(--q67-surface-2) !important;
  border-color: var(--q67-line) !important;
}
body:not(.dark) .q65-notification-modal,
body:not(.dark) .q65-form-modal {
  color: var(--q67-ink) !important;
  background: var(--q67-surface) !important;
}

/* Theme control */
#themeButton {
  min-width: 38px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--q67-ink);
  background: var(--q67-surface-2);
  border: 1px solid var(--q67-line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 17px;
}

/* Header notification bell and live notification panel */
.header-side {
  position: relative;
}
#q65-bell,
.q65-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 36px;
  min-width: 38px;
  padding: 7px;
  color: var(--q67-ink);
  background: var(--q67-surface-2);
  border: 1px solid var(--q67-line);
  border-radius: 10px;
  cursor: pointer;
}
#q65-bell svg,
.q65-bell svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#q65-bell-count,
.q65-bell i {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: #e34d61;
  color: #fff;
  font: 700 10px/1 system-ui, sans-serif;
  border: 2px solid var(--q67-surface);
}
#q65-bell-count[hidden],
.q65-bell i[hidden] {
  display: none !important;
}
.qchat-notifications67[hidden] {
  display: none !important;
}
.qchat-notifications67 {
  position: absolute;
  z-index: 10050;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  width: min(390px, calc(100vw - 24px));
  max-height: min(72vh, 620px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--q67-ink);
  background: var(--q67-surface);
  border: 1px solid var(--q67-line);
  border-radius: 15px;
  box-shadow: var(--q67-shadow);
  text-align: start;
  direction: inherit;
}
.qchat-notifications-head67 {
  min-height: 48px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--q67-surface-2);
  border-bottom: 1px solid var(--q67-line);
}
.qchat-notifications-head67 b {
  font-size: 13px;
}
.qchat-notifications-head67 button {
  width: 30px;
  height: 30px;
  color: var(--q67-ink);
  background: var(--q67-surface);
  border: 1px solid var(--q67-line);
  border-radius: 8px;
  cursor: pointer;
}
.qchat-notifications-list67 {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px;
}
.qchat-notification-item67 {
  width: 100%;
  display: block;
  margin: 0;
  padding: 11px 12px;
  color: var(--q67-ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--q67-line);
  border-radius: 0;
  text-align: start;
  cursor: pointer;
}
.qchat-notification-item67:hover,
.qchat-notification-item67:focus-visible {
  background: var(--q67-surface-2);
  outline: none;
}
.qchat-notification-item67:last-child {
  border-bottom: 0;
}
.qchat-notification-item67 b {
  display: block;
  margin: 3px 0 4px;
  font-size: 13px;
  line-height: 1.6;
}
.qchat-notification-item67 p {
  margin: 0 0 5px;
  color: var(--q67-muted);
  font-size: 12px;
  line-height: 1.7;
  white-space: normal;
  overflow-wrap: anywhere;
}
.qchat-notification-item67 small,
.qchat-notification-type67 {
  color: var(--q67-muted);
  font-size: 10px;
}
.qchat-notification-type67 {
  display: block;
  color: var(--q67-accent);
}
.qchat-notifications-empty67 {
  padding: 22px 12px;
  color: var(--q67-muted);
  text-align: center;
  font-size: 12px;
}

/* Incremental history loader */
.qchat-history-more67 {
  position: sticky;
  top: 4px;
  z-index: 4;
  display: block;
  width: max-content;
  max-width: 90%;
  margin: 6px auto 12px;
  padding: 6px 12px;
  color: var(--q67-ink);
  background: var(--q67-surface);
  border: 1px solid var(--q67-line);
  border-radius: 20px;
  box-shadow: var(--q67-shadow);
  font-size: 11px;
  cursor: pointer;
}
.qchat-history-more67:disabled {
  opacity: .65;
  cursor: wait;
}

/* CRM profile tabs and evidence */
.qw64-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px;
  border-radius: 10px;
  background: var(--q67-surface-2);
}
.qw64-tabs button {
  color: var(--q67-ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
}
.qw64-tabs button.active {
  color: var(--q67-ink);
  background: var(--q67-surface);
  border-color: var(--q67-accent);
}
.qw64-evidence {
  padding: 10px 0;
  border-bottom: 1px solid var(--q67-line);
}
.qw64-evidence pre {
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  color: var(--q67-ink);
  background: var(--q67-surface-2);
  border: 1px solid var(--q67-line);
  border-radius: 9px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  direction: auto;
  text-align: start;
  font: 11px/1.7 ui-monospace, Consolas, monospace;
}
body.dark .qchat-notifications67,
body.dark .qchat-history-more67,
body.dark .qw64-evidence pre {
  color: var(--q67-ink);
  background: var(--q67-surface);
  border-color: var(--q67-line);
}

@media (max-width: 700px) {
  .qchat-notifications67 {
    position: fixed;
    top: 64px;
    inset-inline: 12px;
    width: auto;
    max-height: calc(100vh - 90px);
  }
  #q65-bell, .q65-bell { width: 35px; min-width: 35px; height: 34px; }
}

/* Remaining R66 workspace, CRM, publishing, control and site-admin surfaces */
body #view,
body .inbox,
body .q65-inbox,
body .q65-grid,
body .q65-conversations,
body .q65-list-pane,
body .q65-chat-pane,
body .q65-profile,
body .q65-profile-body,
body .q65-publish,
body .q65-publish-form,
body .q65-publish-list,
body .q65-ticket-page,
body .q65-ticket-grid,
body .q65-org-chat,
body .q65-org-messages,
body .q65-org-form,
body .q65-pager,
body .q65-search,
body .q65-timeline,
body .auth-card,
body .company-card,
body .company-form,
body .company-health,
body .company-shortcut,
body .company-desk,
body .company-path,
body .control-hero,
body .control-small,
body .control-stats,
body .crm-columns,
body .crm-info,
body .crm-item,
body .crm-profile,
body .crm-summary,
body .crm-timeline,
body .dashboard-grid,
body .hero,
body .panel-heading,
body .profile-hero,
body .live-monitor,
body .live-viewport,
body .history-progress,
body .job-progress,
body .step-row,
body .flow-node,
body .workspace-switch,
body .fleet-preview,
body .native-frame {
  color: var(--q67-ink);
  background-color: var(--q67-surface) !important;
  border-color: var(--q67-line) !important;
}
body .q65-pane-head,
body .q65-app-tabs,
body .q65-kind-tabs,
body .q65-profile-tabs,
body .q65-ticket-admin-controls,
body .q65-pager,
body .q65-search,
body .qw64-pane-head,
body .qw64-fields > div,
body .qw64-levels,
body .panel-heading,
body .company-health,
body .control-small,
body .stat,
body .stat-icon,
body .progress-track,
body .step-row {
  background-color: var(--q67-surface-2) !important;
  color: var(--q67-ink) !important;
  border-color: var(--q67-line) !important;
}
body .q65-org-bubble,
body .q65-ticket-reply,
body .q65-thread,
body .q65-card,
body .q65-empty,
body .qw64-card,
body .crm-item,
body .crm-summary,
body .crm-info {
  background-color: var(--q67-surface-2) !important;
  color: var(--q67-ink) !important;
  border-color: var(--q67-line) !important;
}
body .q65-unread,
body .q65-status,
body .qw64-state {
  color: var(--q67-accent) !important;
  border-color: var(--q67-accent) !important;
}
body .q65-muted,
body .q65-thread small,
body .q65-org-bubble small,
body .q65-ticket-page small,
body .qw64-muted,
body .crm-timeline small,
body .company-health small {
  color: var(--q67-muted) !important;
}
body .q65-notification-modal,
body .q65-form-modal,
body .image-viewer,
body .review-modal {
  color: var(--q67-ink) !important;
  background: var(--q67-surface) !important;
  border-color: var(--q67-line) !important;
}
body .auth-card input,
body .company-form input,
body .company-form select,
body .company-form textarea,
body .q65-publish-form input,
body .q65-publish-form select,
body .q65-publish-form textarea {
  color: var(--q67-ink) !important;
  background: var(--q67-input) !important;
  border-color: var(--q67-line) !important;
}

body #view { background-color: var(--q67-bg) !important; }
body #messages { background-color: var(--q67-bg) !important; color: var(--q67-ink) !important; }
body #chat { background-color: var(--q67-surface) !important; color: var(--q67-ink) !important; border-color: var(--q67-line) !important; }
