:root {
  --crm-rgb: 54, 95, 148;
  --crm-focus: #4674a7;
  --crm-action: #365f94;
  --crm-action-hover: #284a78;
  --crm-action-text: #fff;
  --bs-primary-rgb: var(--crm-rgb);
  --bs-link-color-rgb: var(--crm-rgb);
  --bs-link-hover-color-rgb: 40, 74, 120;
}

[data-bs-theme="dark"] {
  --crm-rgb: 160, 183, 207;
  --crm-focus: #91abc6;
  --crm-action: #a0b7cf;
  --crm-action-hover: #b3c8df;
  --crm-action-text: #182330;
  --bs-primary-rgb: var(--crm-rgb);
  --bs-link-color-rgb: var(--crm-rgb);
  --bs-link-hover-color-rgb: 179, 200, 223;
}

.btn-primary {
  --bs-btn-color: var(--crm-action-text);
  --bs-btn-bg: var(--crm-action);
  --bs-btn-border-color: var(--crm-action);
  --bs-btn-hover-color: var(--crm-action-text);
  --bs-btn-hover-bg: var(--crm-action-hover);
  --bs-btn-hover-border-color: var(--crm-action-hover);
  --bs-btn-active-color: var(--crm-action-text);
  --bs-btn-active-bg: var(--crm-action-hover);
  --bs-btn-active-border-color: var(--crm-action-hover);
  --bs-btn-disabled-color: var(--crm-action-text);
  --bs-btn-disabled-bg: var(--crm-action);
  --bs-btn-disabled-border-color: var(--crm-action);
  --bs-btn-focus-shadow-rgb: var(--crm-rgb);
}

.badge.bg-primary { color: var(--crm-action-text); }
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--crm-focus);
  box-shadow: 0 0 0 .2rem rgba(var(--crm-rgb), .20);
}
.form-check-input:checked {
  background-color: var(--crm-focus);
  border-color: var(--crm-focus);
}

.crm-settings {
  max-width: 740px;
}

.settings-panel {
  display: block;
  border: 1px solid var(--bs-border-color, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bs-body-bg, #fff);
}

.settings-panel-header,
.settings-admin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
}

.settings-panel-header {
  border-bottom: 1px solid var(--bs-border-color, #e5e7eb);
  background: var(--bs-tertiary-bg, #f9fafb);
}

.settings-theme { padding: 16px 18px 18px; }
.theme-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.theme-choice {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--bs-border-color, #e5e7eb);
  border-radius: 9px;
  cursor: pointer;
}

.theme-choice:hover,
.theme-choice:has(input:checked) { border-color: var(--crm-focus); }
.theme-choice:focus-within { outline: 2px solid var(--crm-focus); outline-offset: 2px; }
.theme-choice input { position: absolute; right: 16px; top: 14px; }
.theme-preview {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: 70px;
  padding: 10px 28px 10px 12px;
  border-radius: 6px;
  border-left: 12px solid var(--preview-sidebar);
  background: var(--preview-bg);
}
.theme-preview--light {
  --preview-sidebar: #203651;
  --preview-bg: #eef5ff;
  --preview-in: #fff;
  --preview-out: #dceafd;
}
.theme-preview--dark {
  --preview-sidebar: #0b1630;
  --preview-bg: #142743;
  --preview-in: #223a5b;
  --preview-out: #2e4f7b;
}
.theme-preview i { width: 58%; height: 11px; border-radius: 5px; background: var(--preview-in); }
.theme-preview i + i { width: 43%; align-self: end; background: var(--preview-out); }

.settings-admin {
  margin-top: 14px;
  color: inherit;
  text-decoration: none;
}
.settings-admin:hover { background: var(--bs-tertiary-bg, #f9fafb); }
.sidebar .nav-item[aria-current="page"] { background: #2f4c70; color: #fff; }

[data-bs-theme="dark"] {
  --bg: #0b1529;
  --sidebar: #081022;
  --crm-surface: #12213a;
  --crm-panel: #192d49;
  --crm-line: #2a4264;
  --crm-muted: #b9c9e2;
  --crm-hover: #223c5c;
}

[data-bs-theme="dark"] .board-col { background: #102039; }
[data-bs-theme="dark"] :is(.deal-card, .login-card, .chat-workspace, .chat-list, .chat-input, .message-menu, .bubble-carousel-nav button) {
  background: var(--crm-surface);
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] :is(.chat-sidebar, .chat-sidebar-heading, .chat-header, .chat-item, .chat-input, .chat-list, .chat-workspace, .chat-dialog, .forward-item, .message-selection, .message-menu, .message-menu-info, .pinned-messages, .chat-preview-banner) {
  border-color: var(--crm-line);
}
[data-bs-theme="dark"] :is(.chat-header, .bubble-carousel, .pinned-messages, .chat-preview-banner) {
  background: var(--crm-panel);
}
[data-bs-theme="dark"] :is(.chat-wallpaper, .messages-box) {
  background-color: #0e1b32;
  background-image:
    radial-gradient(circle at center, transparent 15px, rgba(139, 158, 180, .11) 15.5px,
                    rgba(139, 158, 180, .11) 16px, transparent 16.5px),
    radial-gradient(circle at center, rgba(139, 158, 180, .16) 1px, transparent 1.5px),
    linear-gradient(145deg, #152947, #0e1b32);
}
[data-bs-theme="dark"] .bubble-in { background: #1d304b; border-color: #2c4364; }
[data-bs-theme="dark"] .bubble-out { background: #27466e; border-color: #3a5c86; }
[data-bs-theme="dark"] .bubble-avatar { background: #2e466a; color: #e1ebf9; }
[data-bs-theme="dark"] .chat-item.is-pinned { background: #292c39; }
[data-bs-theme="dark"] :is(.chat-item:hover, .chat-item.is-pinned:hover, .chat-workspace .chat-item.active, .chat-workspace .chat-item.is-selected, .forward-item:hover, .message-menu button:is(:hover, :focus-visible), .act-btn:hover) {
  background: var(--crm-hover);
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] :is(.chat-preview, .bubble-meta, .act-btn, .reply-bar-text, .reply-bar-close, .reply-quote-text, .message-menu-info, .bubble-voice-time, .bubble-carousel-nav) { color: var(--crm-muted); }
[data-bs-theme="dark"] :is(.chat-sidebar-header .link-dark, .message-menu button, .chat-preview-banner) { color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] :is(.reply-bar, .reply-quote) { background: #233d64; }
[data-bs-theme="dark"] :is(.reply-bar-icon, .reply-bar-author, .reply-quote-author, .bubble-status-read, .message-pin-icon, .pinned-message-link, .chat-channel-tg) { color: #a9c3de; }
[data-bs-theme="dark"] :is(.chat-draft, .message-likes, .bubble-status-failed, .chat-channel-ig, .message-menu button:is([data-command="delete"], [data-chat-command="delete"])) { color: #efa6b2 !important; }
[data-bs-theme="dark"] .chat-snippet { color: #ddbf97; }
[data-bs-theme="dark"] .chat-dialog { background: var(--crm-surface); color: var(--bs-body-color); }
[data-bs-theme="dark"] .layout--inline-nav #crm-sidebar-toggle { color: #c0cce0; border-color: #536581; }
