:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #edf2f7;
  --surface-raised: #ffffff;
  --line: #d8e0ea;
  --text: #15202b;
  --muted: #657386;
  --blue: #2563eb;
  --green: #16a34a;
  --violet: #7c3aed;
  --red: #dc2626;
  --amber: #b45309;
  --shadow: 0 18px 45px rgba(34, 47, 62, 0.12);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #162033;
  --surface-soft: #22304a;
  --surface-raised: #1b2740;
  --line: #334155;
  --text: #e5edf8;
  --muted: #9fb0c7;
  --blue: #60a5fa;
  --green: #34d399;
  --violet: #a78bfa;
  --red: #f87171;
  --amber: #fbbf24;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.08), transparent 34%),
    linear-gradient(230deg, rgba(22, 163, 74, 0.09), transparent 38%),
    var(--bg);
  color: var(--text);
}

html[data-theme="dark"] body {
  background:
    linear-gradient(120deg, rgba(96, 165, 250, 0.13), transparent 34%),
    linear-gradient(230deg, rgba(52, 211, 153, 0.09), transparent 38%),
    var(--bg);
}

html[data-theme="dark"] .sidebar {
  background: color-mix(in srgb, var(--bg) 86%, #020617);
}

body:not(.is-authenticated) .app-shell {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(245, 247, 250, 0.76);
  backdrop-filter: blur(14px);
}

html[data-theme="dark"] .auth-screen {
  background: rgba(15, 23, 42, 0.78);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 32, 43, 0.28);
  backdrop-filter: blur(12px);
}

.auth-screen.is-hidden,
.is-hidden {
  display: none !important;
}

.auth-panel,
.modal-panel {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-panel {
  width: min(100%, 520px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
}

.auth-brand {
  padding-bottom: 16px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab,
.secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.auth-tab.is-active {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 16%, var(--surface));
  color: var(--blue);
}

.auth-form,
.auth-field,
.staff-row label,
.connect-form,
.connect-form label {
  display: flex;
  flex-direction: column;
}

.auth-form,
.connect-form {
  gap: 12px;
}

.auth-field,
.staff-row label,
.connect-form label {
  gap: 6px;
}

.auth-field span,
.staff-row label span,
.staff-account-access > span,
.connect-form label span {
  color: var(--muted);
  font-size: 13px;
}

.auth-field input,
.staff-row select,
.staff-row input,
.profile-field input,
.profile-field select,
.profile-field textarea,
.settings-card input,
.settings-card select,
.settings-card textarea,
.assign-control select,
.connect-form input,
.connect-form select,
.connect-form textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

html[data-theme="dark"] .auth-panel,
html[data-theme="dark"] .modal-panel,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .staff-row,
html[data-theme="dark"] .access-code-card,
html[data-theme="dark"] .conversation-list,
html[data-theme="dark"] .conversation-card,
html[data-theme="dark"] .chat-panel,
html[data-theme="dark"] .client-card,
html[data-theme="dark"] .account-card,
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .event-card,
html[data-theme="dark"] .draft-card,
html[data-theme="dark"] .template-item,
html[data-theme="dark"] .pipeline-card,
html[data-theme="dark"] .deal-card,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .filter-button,
html[data-theme="dark"] .account-row {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #7f90aa;
}

html[data-theme="dark"] .secondary-button,
html[data-theme="dark"] .auth-tab {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .auth-tab.is-active,
html[data-theme="dark"] .filter-button.is-active,
html[data-theme="dark"] .nav button.is-active {
  background: color-mix(in srgb, var(--blue) 18%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
  color: var(--blue);
}

html[data-theme="dark"] .approval-box,
html[data-theme="dark"] .followup-summary,
html[data-theme="dark"] .connect-status,
html[data-theme="dark"] .draft-preview,
html[data-theme="dark"] .message.in,
html[data-theme="dark"] .message.internal,
html[data-theme="dark"] .queue-row,
html[data-theme="dark"] .activity-row,
html[data-theme="dark"] .analytics-card,
html[data-theme="dark"] .empty-list {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .staff-row.is-pending {
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--amber) 34%, var(--line));
}

html[data-theme="dark"] .settings-board:has(.admin-grid) {
  background: color-mix(in srgb, var(--bg) 76%, var(--surface));
  border-color: transparent;
  box-shadow: none;
}

html[data-theme="dark"] .admin-grid .settings-card {
  background: color-mix(in srgb, var(--surface) 78%, #020617);
  border-color: transparent;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] .admin-grid .connect-status,
html[data-theme="dark"] .staff-row,
html[data-theme="dark"] .access-code-card,
html[data-theme="dark"] .staff-account-access,
html[data-theme="dark"] .staff-activity {
  background: color-mix(in srgb, var(--surface-raised) 72%, var(--surface));
  border-color: transparent;
}

html[data-theme="dark"] .staff-row {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 30%, transparent);
}

html[data-theme="dark"] .staff-row.is-pending {
  background: color-mix(in srgb, var(--amber) 8%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 22%, transparent);
}

html[data-theme="dark"] .approval-box {
  background: color-mix(in srgb, var(--amber) 8%, var(--surface-raised));
  border-color: transparent;
}

html[data-theme="dark"] .approval-code-row code {
  background: color-mix(in srgb, var(--amber) 12%, var(--surface-raised));
  border-color: color-mix(in srgb, var(--amber) 38%, var(--line));
  color: var(--amber);
}

html[data-theme="dark"] .action-button {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .action-button.is-active {
  background: color-mix(in srgb, var(--blue) 18%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
  color: var(--blue);
}

html[data-theme="dark"] .small-muted,
html[data-theme="dark"] .auth-hint,
html[data-theme="dark"] .name-line span,
html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .message-label {
  color: var(--muted);
}

html[data-theme="dark"] .section-title,
html[data-theme="dark"] .collapse-button {
  color: color-mix(in srgb, var(--text) 72%, var(--muted));
}

html[data-theme="dark"] .collapse-icon {
  color: var(--muted);
}

html[data-theme="dark"] .dialog-filter-panel {
  background: color-mix(in srgb, var(--surface) 92%, #000);
  border-color: var(--line);
}

html[data-theme="dark"] .quick-filter-row button,
html[data-theme="dark"] .dialog-tag-filter select,
html[data-theme="dark"] .badge,
html[data-theme="dark"] .pin-control {
  background: var(--surface-raised);
  border-color: color-mix(in srgb, var(--line) 80%, var(--text));
  color: var(--text);
}

html[data-theme="dark"] .quick-filter-row button.is-active,
html[data-theme="dark"] .conversation-item.is-active {
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  color: var(--text);
}

html[data-theme="dark"] .conversation-item {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .conversation-item.is-excluded {
  background: color-mix(in srgb, var(--surface) 72%, #000);
  opacity: 0.72;
}

html[data-theme="dark"] .conversation-item .name-line strong,
html[data-theme="dark"] .conversation-item .chat-title strong,
html[data-theme="dark"] .conversation-item .preview {
  color: var(--text);
}

html[data-theme="dark"] .conversation-item .name-line span,
html[data-theme="dark"] .conversation-item .chat-title span,
html[data-theme="dark"] .conversation-item .time {
  color: color-mix(in srgb, var(--text) 70%, var(--muted));
}

html[data-theme="dark"] .account-chip {
  color: #fff;
  box-shadow: none;
}

html[data-theme="dark"] .conversation-item .chat-title .account-chip {
  color: #fff;
}

html[data-theme="dark"] .badge.telegram {
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.38);
}

html[data-theme="dark"] .badge.whatsapp {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.38);
}

html[data-theme="dark"] .badge.viber {
  color: #c4b5fd;
  border-color: rgba(196, 181, 253, 0.38);
}

html[data-theme="dark"] .conversation-detail,
html[data-theme="dark"] .analytics-board,
html[data-theme="dark"] .clients-board,
html[data-theme="dark"] .deals-board,
html[data-theme="dark"] .pipeline-board,
html[data-theme="dark"] .task-board,
html[data-theme="dark"] .events-board,
html[data-theme="dark"] .queue-board,
html[data-theme="dark"] .accounts-board,
html[data-theme="dark"] .settings-board {
  background: color-mix(in srgb, var(--surface) 82%, #020617);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .analytics-hero,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .bulk-panel,
html[data-theme="dark"] .client-list-card,
html[data-theme="dark"] .client-list-meta span,
html[data-theme="dark"] .deal-card,
html[data-theme="dark"] .task-create-form,
html[data-theme="dark"] .task-column,
html[data-theme="dark"] .pipeline-column,
html[data-theme="dark"] .pipeline-head,
html[data-theme="dark"] .event-card,
html[data-theme="dark"] .queue-card,
html[data-theme="dark"] .account-admin-card,
html[data-theme="dark"] .account-admin-meta span,
html[data-theme="dark"] .account-access-box,
html[data-theme="dark"] .staff-account-access,
html[data-theme="dark"] .client-profile,
html[data-theme="dark"] .profile-grid div,
html[data-theme="dark"] .profile-history,
html[data-theme="dark"] .followup-status,
html[data-theme="dark"] .client-file,
html[data-theme="dark"] .delivery-log-row {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .task-card,
html[data-theme="dark"] .pipeline-card,
html[data-theme="dark"] .event-card,
html[data-theme="dark"] .queue-card,
html[data-theme="dark"] .deal-card,
html[data-theme="dark"] .client-list-card,
html[data-theme="dark"] .account-admin-card {
  background: var(--surface-raised);
}

html[data-theme="dark"] .queue-card.failed,
html[data-theme="dark"] .queue-card.skipped,
html[data-theme="dark"] .queue-card.pending,
html[data-theme="dark"] .task-card.overdue,
html[data-theme="dark"] .danger-zone {
  background: color-mix(in srgb, var(--red) 8%, var(--surface-raised));
  border-color: color-mix(in srgb, var(--red) 36%, var(--line));
}

html[data-theme="dark"] .queue-card.sent,
html[data-theme="dark"] .queue-card.delivered,
html[data-theme="dark"] .queue-card.read,
html[data-theme="dark"] .followup-status.stopped,
html[data-theme="dark"] .followup-status.done {
  background: color-mix(in srgb, var(--green) 7%, var(--surface-raised));
  border-color: color-mix(in srgb, var(--green) 32%, var(--line));
}

html[data-theme="dark"] .followup-status.ready,
html[data-theme="dark"] .event-card.medium {
  background: color-mix(in srgb, var(--amber) 8%, var(--surface-raised));
  border-color: color-mix(in srgb, var(--amber) 34%, var(--line));
}

html[data-theme="dark"] .followup-status.paused,
html[data-theme="dark"] .followup-status.blocked,
html[data-theme="dark"] .followup-status.off {
  background: color-mix(in srgb, var(--red) 7%, var(--surface-raised));
  border-color: color-mix(in srgb, var(--red) 30%, var(--line));
}

html[data-theme="dark"] .message.out {
  background: color-mix(in srgb, var(--blue) 18%, var(--surface-raised));
  color: var(--text);
}

html[data-theme="dark"] .message.internal {
  background: color-mix(in srgb, var(--amber) 10%, var(--surface-raised));
  color: var(--text);
}

html[data-theme="dark"] .settings-board:has(.admin-grid) {
  background: color-mix(in srgb, var(--bg) 76%, var(--surface));
  border-color: transparent;
  box-shadow: none;
}

html[data-theme="dark"] .admin-grid .settings-card {
  background: color-mix(in srgb, var(--surface) 78%, #020617);
  border-color: transparent;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] .admin-grid .connect-status,
html[data-theme="dark"] .staff-row,
html[data-theme="dark"] .access-code-card,
html[data-theme="dark"] .staff-account-access {
  background: color-mix(in srgb, var(--surface-raised) 72%, var(--surface));
  border-color: transparent;
}

html[data-theme="dark"] .staff-row {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 30%, transparent);
}

html[data-theme="dark"] .approval-box {
  background: color-mix(in srgb, var(--amber) 8%, var(--surface-raised));
  border-color: transparent;
}

html[data-theme="dark"] .ai-panel {
  background: color-mix(in srgb, var(--blue) 15%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 42%, var(--line));
}

html[data-theme="dark"] .ai-flow span,
html[data-theme="dark"] .ghost-button {
  background: var(--surface-raised);
  border-color: color-mix(in srgb, var(--blue) 44%, var(--line));
  color: #bfdbfe;
}

html[data-theme="dark"] .analytics-bar,
html[data-theme="dark"] .deal-progress {
  background: color-mix(in srgb, var(--surface-soft) 72%, #000);
}

html[data-theme="dark"] .analytics-bar-row > div:first-child,
html[data-theme="dark"] .pipeline-card p,
html[data-theme="dark"] .client-list-card p,
html[data-theme="dark"] .profile-history p,
html[data-theme="dark"] .task-check,
html[data-theme="dark"] .account-admin-meta strong,
html[data-theme="dark"] .client-list-meta strong {
  color: var(--text);
}

html[data-theme="dark"] .event-pill.low,
html[data-theme="dark"] .event-pill.success,
html[data-theme="dark"] .event-pill.high,
html[data-theme="dark"] .event-pill.medium,
html[data-theme="dark"] .delivery-badge.failed,
html[data-theme="dark"] .delivery-badge.skipped,
html[data-theme="dark"] .delivery-badge.pending,
html[data-theme="dark"] .delivery-badge.sent,
html[data-theme="dark"] .delivery-badge.delivered,
html[data-theme="dark"] .delivery-badge.read {
  border: 1px solid var(--line);
}

html[data-theme="dark"] .event-pill.high,
html[data-theme="dark"] .delivery-badge.failed,
html[data-theme="dark"] .delivery-badge.skipped {
  background: color-mix(in srgb, var(--red) 14%, var(--surface-raised));
  color: #fecaca;
}

html[data-theme="dark"] .event-pill.medium,
html[data-theme="dark"] .delivery-badge.pending {
  background: color-mix(in srgb, var(--amber) 14%, var(--surface-raised));
  color: #fde68a;
}

html[data-theme="dark"] .event-pill.low {
  background: var(--surface-raised);
  color: var(--text);
}

html[data-theme="dark"] .event-pill.success,
html[data-theme="dark"] .delivery-badge.sent,
html[data-theme="dark"] .delivery-badge.delivered,
html[data-theme="dark"] .delivery-badge.read {
  background: color-mix(in srgb, var(--green) 14%, var(--surface-raised));
  color: #bbf7d0;
}

html[data-theme="dark"] .mini-check-list label {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .mini-check-list input[type="checkbox"] {
  accent-color: var(--blue);
}

html[data-theme="dark"] .session-qr-card {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .qr-demo {
  border-color: #e5edf8;
  background:
    linear-gradient(90deg, #0f172a 12px, transparent 12px 20px, #0f172a 20px 32px, transparent 32px 42px, #0f172a 42px 50px, transparent 50px),
    linear-gradient(#0f172a 12px, transparent 12px 20px, #0f172a 20px 32px, transparent 32px 42px, #0f172a 42px 50px, transparent 50px),
    repeating-linear-gradient(45deg, #0f172a 0 6px, #e5edf8 6px 12px);
}

html[data-theme="dark"] .qr-demo span {
  border-color: #0f172a;
  background: #e5edf8;
}

html[data-theme="dark"] .conversation-detail {
  background: var(--surface);
  color: var(--text);
}

html[data-theme="dark"] .detail-header {
  background: color-mix(in srgb, var(--surface) 86%, #000);
  border-color: var(--line);
}

html[data-theme="dark"] .client-card .name-line h3,
html[data-theme="dark"] .client-card .name-line span {
  color: var(--text);
}

html[data-theme="dark"] .ai-panel {
  background: color-mix(in srgb, var(--blue) 10%, var(--surface-raised));
  border-color: color-mix(in srgb, var(--blue) 34%, var(--line));
}

html[data-theme="dark"] .ai-panel strong {
  color: var(--text);
}

html[data-theme="dark"] .ai-panel span {
  color: color-mix(in srgb, var(--text) 74%, var(--muted));
}

html[data-theme="dark"] .ai-flow span,
html[data-theme="dark"] .ghost-button {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--blue) 42%, var(--line));
  color: #93c5fd;
}

.connect-form textarea {
  min-height: 120px;
  padding: 10px;
  resize: vertical;
}

.template-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.template-picker select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

.integration-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.session-connect-box:empty {
  display: none;
}

.session-qr-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.qr-demo {
  width: 112px;
  aspect-ratio: 1;
  border: 8px solid #fff;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #132238 12px, transparent 12px 20px, #132238 20px 32px, transparent 32px 42px, #132238 42px 50px, transparent 50px),
    linear-gradient(#132238 12px, transparent 12px 20px, #132238 20px 32px, transparent 32px 42px, #132238 42px 50px, transparent 50px),
    repeating-linear-gradient(45deg, #132238 0 6px, #fff 6px 12px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
  position: relative;
}

.qr-demo span {
  position: absolute;
  width: 23px;
  height: 23px;
  border: 6px solid #132238;
  background: #fff;
}

.qr-demo span:nth-child(1) {
  top: 6px;
  left: 6px;
}

.qr-demo span:nth-child(2) {
  top: 6px;
  right: 6px;
}

.qr-demo span:nth-child(3) {
  left: 6px;
  bottom: 6px;
}

.qr-demo span:nth-child(4) {
  right: 14px;
  bottom: 14px;
  width: 16px;
  height: 16px;
  border-width: 4px;
}

.session-qr-card strong,
.session-qr-card p {
  display: block;
}

.session-qr-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.auth-form button[type="submit"] {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #132238;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #132238;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.connect-status {
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  background: #eef5ff;
  color: #344154;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 12px;
}

.broadcast-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recipient-list {
  min-height: 46px;
  max-height: 150px;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.auth-hint,
.auth-error {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.auth-hint {
  color: var(--muted);
}

.auth-error {
  min-height: 18px;
  color: var(--red);
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: grid-template-columns 180ms ease;
}

.app-shell.is-sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  backdrop-filter: blur(18px);
  overflow-y: auto;
  transition: opacity 160ms ease, padding 180ms ease, border-color 180ms ease;
}

.sidebar-toggle-button {
  position: absolute;
  top: 18px;
  left: 278px;
  z-index: 12;
  width: 34px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  transition: left 180ms ease, background 160ms ease, color 160ms ease;
}

.sidebar-toggle-button:hover {
  background: #132238;
  color: #fff;
}

.app-shell.is-sidebar-collapsed .sidebar {
  opacity: 0;
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right-color: transparent;
  overflow: hidden;
  pointer-events: none;
}

.app-shell.is-sidebar-collapsed .sidebar-toggle-button {
  left: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #132238;
  color: #fff;
  font-weight: 800;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand h1,
.brand p,
.toolbar h2,
.toolbar p,
.empty-state h3,
.empty-state p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.eyebrow,
.meta,
.preview,
.small-muted {
  color: var(--muted);
}

.brand p,
.eyebrow {
  font-size: 13px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar .panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  overflow: hidden;
}

.panel.is-collapsed {
  gap: 0;
}

.panel.is-collapsed .panel-body {
  display: none;
}

.panel.is-collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.current-user {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: flex-start;
  gap: 9px;
}

.current-user .name-line strong {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.current-user .name-line span {
  display: block;
  margin-top: 3px;
  line-height: 1.35;
}

.user-avatar {
  background: #132238;
}

.emoji-avatar {
  font-size: 23px;
  line-height: 1;
}

.access-panel {
  border-top: 1px solid var(--line);
}

.tag-panel {
  padding: 10px;
}

.tag-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 32px;
  gap: 8px;
}

.tag-form input[type="text"] {
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  outline: 0;
}

.tag-form input[type="color"] {
  width: 38px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 3px;
}

.service-tags,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  max-width: 100%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color) 16%, white);
  border: 1px solid color-mix(in srgb, var(--tag-color) 46%, white);
  color: color-mix(in srgb, var(--tag-color) 72%, #15202b);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tag-chip button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--tag-color) 24%, white);
  color: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.tag-chip button:hover {
  background: color-mix(in srgb, var(--tag-color) 36%, white);
}

.staff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
  padding-right: 2px;
}

.staff-row {
  display: flex;
  flex-direction: column;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 86%, var(--surface-soft));
  padding: 12px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 42%, transparent);
}

.staff-row summary {
  cursor: pointer;
  list-style: none;
}

.staff-row summary::-webkit-details-marker {
  display: none;
}

.staff-row summary::after {
  content: "Раскрыть";
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 10%, var(--surface-soft));
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
}

.staff-row[open] summary::after {
  content: "Свернуть";
}

.staff-details {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 12px;
}

.staff-row.is-pending {
  background: color-mix(in srgb, var(--amber) 9%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 22%, transparent);
}

.access-code-card {
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 76%, var(--surface));
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.staff-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.staff-summary-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.presence-badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.presence-badge.online {
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  color: var(--green);
}

.presence-badge.offline {
  background: color-mix(in srgb, var(--muted) 12%, var(--surface));
  color: var(--muted);
}

.staff-activity {
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 82%, var(--surface));
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.staff-activity-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.presence-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 13%, transparent);
}

.presence-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent);
}

.staff-activity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.staff-activity-grid span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.staff-activity-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approval-box {
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--amber) 9%, var(--surface));
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #6b4a16;
  font-size: 12px;
  line-height: 1.35;
}

.approval-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.approval-code-row code {
  min-height: 34px;
  border: 1px dashed rgba(180, 83, 9, 0.42);
  border-radius: 8px;
  background: #fffbeb;
  color: #7c2d12;
  display: flex;
  align-items: center;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.approval-code-row input {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
}

.danger-button {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.24);
}

.section-title,
.summary-row,
.conversation-head,
.chat-meta,
.toolbar,
.toolbar-actions {
  display: flex;
  align-items: center;
}

.section-title,
.toolbar {
  justify-content: space-between;
}

.section-title {
  color: #354154;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  min-height: 34px;
  gap: 8px;
}

.collapse-button {
  min-width: 0;
  min-height: 34px;
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 4px;
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  text-align: left;
}

.collapse-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collapse-icon {
  color: var(--muted);
  display: inline-block;
  transition: transform 0.18s ease;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.channel-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-button,
.account-row,
.conversation-item {
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.filter-button {
  min-height: 42px;
  border-radius: 8px;
  color: #253247;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
}

.filter-button.is-active {
  border-color: var(--blue);
  background: #e8f0ff;
  color: var(--blue);
}

.filter-button small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.account-panel {
  min-height: 0;
}

.account-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.account-row {
  width: 100%;
  min-height: 62px;
  border-radius: 8px;
  padding: 9px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  text-align: left;
}

.account-row.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.13);
}

.account-row.is-excluded {
  opacity: 0.52;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.name-line {
  min-width: 0;
}

.name-line strong,
.chat-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.name-line span,
.chat-title span,
.badge,
.time {
  font-size: 12px;
  color: var(--muted);
}

.account-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.switch {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #c9d3df;
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.account-row:not(.is-excluded) .switch {
  background: var(--green);
}

.account-row:not(.is-excluded) .switch::after {
  transform: translateX(14px);
}

.switch.is-disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.inbox {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.app-shell.is-sidebar-collapsed .inbox {
  padding-left: 76px;
}

.toolbar {
  gap: 18px;
  align-items: flex-start;
}

.toolbar h2 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0;
}

.toolbar-actions {
  min-width: 0;
  flex: 1;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view-switch {
  min-width: min(100%, 620px);
  max-width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  flex: 1 1 560px;
  flex-wrap: wrap;
  padding: 3px;
  gap: 3px;
}

.view-switch button {
  flex: 1 1 auto;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.view-switch button.is-active {
  background: #132238;
  color: #fff;
}

.view-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  font-size: 11px;
  line-height: 1;
}

.view-badge.is-empty {
  display: none;
}

.search {
  flex: 1 1 280px;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 11px;
}

.select-control {
  flex: 0 1 220px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 10px;
}

.select-control span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.select-control select {
  min-width: 128px;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: 0;
}

.search span {
  color: var(--muted);
  font-size: 13px;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
}

.toggle {
  flex: 0 1 230px;
  min-width: 190px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
  color: #344154;
  font-size: 13px;
}

.summary-row {
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 8px 11px;
  font-size: 13px;
}

.stat strong {
  margin-right: 4px;
}

.workspace {
  min-height: 0;
  max-width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  gap: 16px;
  overflow: hidden;
}

.conversation-list,
.conversation-detail,
.analytics-board,
.clients-board,
.deals-board,
.pipeline-board,
.task-board,
.events-board,
.queue-board,
.accounts-board,
.settings-board {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.clients-board,
.analytics-board,
.deals-board,
.events-board,
.queue-board,
.accounts-board,
.settings-board {
  grid-column: 1 / -1;
  padding: 14px;
  overflow: auto;
}

.clients-board,
.analytics-board,
.deals-board,
.events-board,
.queue-board,
.accounts-board {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.clients-toolbar,
.analytics-hero,
.deals-toolbar,
.events-toolbar,
.queue-toolbar,
.accounts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.clients-toolbar h3,
.analytics-hero h3,
.deals-toolbar h3,
.events-toolbar h3,
.accounts-toolbar h3 {
  margin: 0;
  font-size: 19px;
}

.analytics-hero {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.analytics-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
}

.kpi-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.kpi-card span,
.kpi-card p {
  color: var(--muted);
  font-size: 12px;
}

.kpi-card strong {
  display: block;
  margin: 6px 0;
  font-size: 24px;
}

.kpi-card p {
  margin: 0;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.analytics-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.analytics-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.analytics-bars {
  display: grid;
  gap: 10px;
}

.analytics-bar-row {
  display: grid;
  gap: 6px;
}

.analytics-bar-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #344154;
  font-size: 13px;
}

.analytics-bar {
  height: 9px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.analytics-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
}

.client-filters,
.bulk-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.deals-toolbar {
  align-items: flex-start;
}

.deal-totals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.deals-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(340px, 1fr));
  gap: 12px;
}

.deal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

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

.deal-fields label,
.deal-note {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.deal-fields span,
.deal-note span {
  color: var(--muted);
  font-size: 12px;
}

.deal-fields input,
.deal-fields select,
.deal-note textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: 0;
}

.deal-note textarea {
  resize: vertical;
}

.deal-progress {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.deal-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #16a34a;
}

.client-filters select,
.bulk-panel select,
.bulk-panel input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

.bulk-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
}

.clients-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 12px;
}

.client-list-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.client-list-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.client-list-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.client-list-meta span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-list-meta strong {
  color: #253247;
}

.client-list-card p {
  margin: 0;
  color: #344154;
  font-size: 13px;
  line-height: 1.4;
}

.event-counters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.event-pill {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.event-pill.high {
  color: #b91c1c;
  background: #fff1f2;
  border-color: rgba(220, 38, 38, 0.25);
}

.event-pill.medium {
  color: #92400e;
  background: #fffbeb;
  border-color: rgba(180, 83, 9, 0.25);
}

.event-pill.low {
  color: #475569;
  background: #f8fafc;
}

.event-pill.success {
  color: #166534;
  background: #f0fdf4;
  border-color: rgba(22, 101, 52, 0.22);
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.event-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-card.high {
  border-color: rgba(220, 38, 38, 0.28);
}

.event-card.medium {
  border-color: rgba(180, 83, 9, 0.28);
}

.event-card.low {
  background: #fbfdff;
}

.event-card-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
}

.event-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #edf2f7;
  display: grid;
  place-items: center;
}

.event-card strong {
  display: block;
  font-size: 14px;
}

.event-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

.queue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(310px, 1fr));
  gap: 12px;
}

.queue-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.queue-card.failed {
  border-color: rgba(220, 38, 38, 0.3);
  background: #fffafa;
}

.queue-card.skipped,
.queue-card.pending {
  border-color: rgba(180, 83, 9, 0.3);
  background: #fffdf6;
}

.queue-card.sent,
.queue-card.delivered,
.queue-card.read {
  border-color: rgba(22, 101, 52, 0.18);
}

.queue-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.queue-account {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.queue-account strong,
.queue-account span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-account span,
.queue-meta,
.queue-original {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.delivery-badge {
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.delivery-badge.failed,
.delivery-badge.skipped {
  color: #b91c1c;
  background: #fff1f2;
}

.delivery-badge.pending {
  color: #92400e;
  background: #fffbeb;
}

.delivery-badge.sent,
.delivery-badge.delivered,
.delivery-badge.read {
  color: #166534;
  background: #f0fdf4;
}

.queue-message {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.queue-original {
  margin: -4px 0 0;
  border-left: 3px solid var(--line);
  padding-left: 8px;
}

.queue-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(310px, 1fr));
  gap: 14px;
}

.account-admin-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-admin-card.is-excluded {
  background: #f8fafc;
}

.account-admin-card.is-backlog {
  border-color: rgba(124, 58, 237, 0.26);
}

.account-admin-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.account-admin-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.account-admin-meta span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-admin-meta strong {
  color: #253247;
}

.account-admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.account-access-box,
.staff-account-access {
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 74%, var(--surface));
  padding: 10px;
}

.account-access-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-access-box > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.account-access-box > div:first-child span {
  color: var(--muted);
  font-size: 12px;
}

.mini-check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-check-list label {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #344154;
  font-size: 12px;
  max-width: 100%;
}

.mini-check-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--blue);
}

.mini-check-list span {
  overflow-wrap: anywhere;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.settings-board:has(.admin-grid) {
  background: color-mix(in srgb, var(--surface-soft) 58%, transparent);
  border-color: transparent;
  box-shadow: none;
}

.admin-staff-card {
  min-height: 0;
}

.admin-staff-list {
  max-height: none;
  padding-right: 0;
}

.admin-grid .settings-card {
  border: 0;
  background: color-mix(in srgb, var(--surface-raised) 88%, var(--surface-soft));
  box-shadow: 0 10px 26px rgba(21, 32, 43, 0.08);
}

.admin-grid .connect-status {
  border: 0;
  background: color-mix(in srgb, var(--surface-soft) 76%, transparent);
}

.admin-grid .success-status {
  background: color-mix(in srgb, var(--green) 12%, var(--surface));
  color: color-mix(in srgb, var(--green) 55%, var(--text));
}

.admin-grid .danger-status {
  background: color-mix(in srgb, var(--red) 10%, var(--surface));
  color: color-mix(in srgb, var(--red) 62%, var(--text));
}

.admin-grid .staff-list {
  gap: 10px;
}

.pending-registration-list {
  display: grid;
  gap: 10px;
}

.pending-registration-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--amber) 8%, var(--surface-raised));
  padding: 12px;
}

.pending-registration-row strong,
.pending-registration-row span {
  display: block;
}

.pending-registration-row span {
  margin-top: 4px;
  color: var(--muted);
}

.bot-link-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.logo-upload-row {
  display: grid;
  grid-template-columns: 54px minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.logo-preview {
  width: 54px;
  height: 54px;
  font-size: 20px;
}

.logo-file-field {
  margin: 0;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-card h3 {
  margin: 0;
  font-size: 18px;
}

.account-password-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-password-box strong,
.account-password-box span {
  display: block;
}

.account-password-box span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-status {
  min-height: 18px;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.settings-status[data-state="success"] {
  color: var(--green);
}

.settings-status[data-state="error"] {
  color: var(--red);
}

.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.maintenance-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.maintenance-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.maintenance-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.settings-check {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

.settings-check span {
  font-size: 14px;
  color: #344154;
}

.profile-check {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.profile-check span {
  color: #344154;
  font-size: 13px;
  line-height: 1.3;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 42px);
  gap: 8px;
}

.avatar-choice {
  position: relative;
  width: 42px;
  height: 42px;
}

.avatar-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.avatar-choice span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  font-size: 24px;
  cursor: pointer;
}

.avatar-choice input:checked + span {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.settings-channel-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-settings {
  grid-column: 1 / -1;
}

.followup-settings {
  grid-column: 1 / -1;
}

.anti-spam-settings {
  grid-column: 1 / -1;
}

.approval-settings {
  grid-column: 1 / -1;
}

.followup-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.data-settings {
  grid-column: 1 / -1;
}

.data-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.maintenance-settings .data-export-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.limit-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.limit-grid.two {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.draft-list {
  display: grid;
  gap: 10px;
}

.draft-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draft-card.review {
  border-color: rgba(180, 83, 9, 0.28);
  background: #fffdf6;
}

.draft-card.approved,
.draft-card.sent {
  border-color: rgba(22, 101, 52, 0.22);
}

.draft-card.rejected {
  border-color: rgba(220, 38, 38, 0.24);
  background: #fffafa;
}

.draft-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.draft-head strong,
.draft-head span {
  display: block;
}

.draft-head span,
.draft-preview {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.draft-card p {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

.draft-preview {
  border-left: 3px solid var(--line);
  padding-left: 8px;
}

.template-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.6fr) auto;
  gap: 10px;
  align-items: start;
}

.template-form input,
.template-form textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  outline: 0;
}

.template-form textarea {
  grid-column: 1 / 3;
  resize: vertical;
}

.followup-form {
  grid-template-columns: 130px minmax(220px, 1fr) auto;
}

.followup-form textarea {
  grid-column: auto;
}

.template-list {
  display: grid;
  gap: 8px;
}

.template-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
}

.template-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.template-item.is-muted {
  opacity: 0.62;
}

.template-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.mini-check {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
}

.danger-zone {
  border-color: rgba(220, 38, 38, 0.28);
  background: #fffafa;
}

.task-board {
  grid-column: 1 / -1;
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.task-create-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 140px 110px 130px minmax(180px, 0.8fr) minmax(180px, 0.8fr) auto;
  gap: 8px;
}

.task-create-form input,
.task-create-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

.task-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(250px, 1fr));
  gap: 12px;
}

.task-column {
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(245, 247, 250, 0.78);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  overflow: auto;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.task-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  color: #253247;
}

.task-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 100px 120px minmax(150px, 0.7fr);
  gap: 8px;
}

.task-edit-grid input,
.task-edit-grid select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 9px;
  outline: 0;
}

.task-edit-grid input:disabled,
.task-edit-grid select:disabled {
  background: #f1f5f9;
  color: #64748b;
}

.task-card.overdue {
  border-color: rgba(220, 38, 38, 0.35);
  background: #fff5f5;
}

.task-card.done {
  opacity: 0.72;
}

.task-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.task-card-head strong {
  font-size: 14px;
  line-height: 1.35;
}

.pipeline-board {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: 12px;
  padding: 12px;
  overflow-x: auto;
}

.pipeline-column {
  min-width: 240px;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(245, 247, 250, 0.78);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pipeline-head {
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
}

.pipeline-head strong {
  font-size: 14px;
}

.pipeline-head span {
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.pipeline-cards {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.pipeline-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.pipeline-card-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.pipeline-card p {
  margin: 0;
  color: #344154;
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pipeline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pipeline-actions .secondary-button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

.pipeline-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px 10px;
  text-align: center;
  font-size: 13px;
}

.conversation-list {
  overflow-y: auto;
}

.dialog-filter-panel {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.96);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.quick-filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-filter-row button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344154;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.quick-filter-row button.is-active {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.32);
  background: #eef5ff;
}

.more-filter-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.more-filter-button span {
  display: inline-block;
  color: inherit;
  transition: transform 0.18s ease;
}

.more-filter-button[aria-expanded="true"] span {
  transform: rotate(180deg);
}

.extra-filter-row {
  padding-top: 1px;
}

.dialog-tag-filter {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.dialog-tag-filter select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 6px 8px;
}

.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 32px;
  gap: 10px;
  padding: 12px;
  border-width: 0 0 1px;
  border-radius: 0;
  text-align: left;
  align-items: center;
}

.conversation-item.is-active {
  background: #eef5ff;
}

.conversation-item.is-excluded {
  background: #f4f5f7;
}

.pin-control {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  color: #b45309;
  font-size: 16px;
  line-height: 1;
}

.conversation-head {
  gap: 8px;
  justify-content: space-between;
}

.chat-title {
  min-width: 0;
}

.chat-meta {
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.chat-title .account-chip {
  color: #fff;
}

.account-chip.telegram {
  background: #2563eb;
}

.account-chip.whatsapp {
  background: #16a34a;
}

.account-chip.viber {
  background: #7c3aed;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.badge.telegram {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.28);
}

.badge.whatsapp {
  color: var(--green);
  border-color: rgba(22, 163, 74, 0.28);
}

.badge.viber {
  color: var(--violet);
  border-color: rgba(124, 58, 237, 0.28);
}

.preview {
  margin: 5px 0 0;
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.conversation-detail {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.detail-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 12px;
}

.ai-panel {
  margin: 12px 16px 0;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  background: #eef5ff;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 12px;
}

.ai-panel strong,
.ai-panel span {
  display: block;
}

.ai-panel strong {
  font-size: 14px;
}

.ai-panel span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.ai-flow {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.ai-controls {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.ai-flow span {
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  padding: 4px 8px;
  margin: 0;
  white-space: nowrap;
}

.ghost-button {
  min-height: 32px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  padding: 0 10px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.client-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.client-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

.detail-actions {
  min-width: 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.action-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  cursor: pointer;
}

.action-button.is-active {
  border-color: var(--blue);
  background: #e8f0ff;
  color: var(--blue);
}

.assign-control {
  min-width: min(100%, 220px);
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.assign-control select {
  min-width: 0;
  max-width: 100%;
}

.assign-control span {
  color: var(--muted);
  font-size: 13px;
}

.assign-control select {
  min-height: 36px;
}

.detail-main {
  min-height: 0;
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.detail-main.has-client-card {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.chat-column {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: min(620px, 82%);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  font-size: 14px;
}

.message-note {
  margin-top: 8px;
  border-top: 1px solid rgba(21, 32, 43, 0.1);
  padding-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.delivery-status {
  margin-top: 8px;
  border-top: 1px solid rgba(21, 32, 43, 0.1);
  padding-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.delivery-status.failed,
.delivery-status.skipped {
  color: #b91c1c;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.attachment-chip {
  border: 1px solid rgba(21, 32, 43, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  padding: 7px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.attachment-chip small {
  color: var(--muted);
}

.message.in {
  background: var(--surface-soft);
  align-self: flex-start;
}

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

.message.internal {
  max-width: min(680px, 92%);
  border: 1px dashed rgba(180, 83, 9, 0.45);
  background: #fffbeb;
  align-self: center;
  color: #344154;
}

.message-label {
  display: block;
  margin-bottom: 5px;
  color: #92400e;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.client-profile {
  min-height: 0;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.profile-head h3 {
  margin: 0;
  font-size: 18px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-grid div,
.profile-history {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.profile-grid span,
.profile-field span,
.profile-section > span,
.profile-history span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.profile-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.profile-field input,
.profile-field select,
.profile-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  outline: 0;
  resize: vertical;
}

.profile-field input,
.profile-field select {
  min-height: 38px;
}

.profile-task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.profile-task-row .secondary-button {
  min-height: 38px;
  padding: 0 10px;
}

.followup-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 9px 10px;
  margin-bottom: 8px;
}

.followup-status strong {
  display: block;
  font-size: 13px;
}

.followup-status p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.followup-status.ready {
  border-color: rgba(180, 83, 9, 0.26);
  background: #fffbeb;
}

.followup-status.stopped,
.followup-status.done {
  border-color: rgba(22, 101, 52, 0.2);
  background: #f0fdf4;
}

.followup-status.paused,
.followup-status.blocked,
.followup-status.off {
  border-color: rgba(220, 38, 38, 0.2);
  background: #fff1f2;
}

.profile-history p {
  margin: 6px 0 0;
  color: #344154;
  font-size: 13px;
  line-height: 1.35;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.client-files {
  display: grid;
  gap: 8px;
}

.client-file {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 8px;
}

.client-file strong {
  display: block;
  font-size: 13px;
}

.client-file span {
  color: var(--muted);
  font-size: 12px;
}

.delivery-log {
  display: grid;
  gap: 8px;
}

.delivery-log-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 8px;
}

.delivery-log-row.failed,
.delivery-log-row.skipped {
  border-color: rgba(220, 38, 38, 0.28);
  background: #fffafa;
}

.delivery-log-row strong {
  display: block;
  font-size: 13px;
}

.delivery-log-row span,
.delivery-log-row p {
  color: var(--muted);
  font-size: 12px;
}

.delivery-log-row p {
  margin: 4px 0 0;
}

.history-head span {
  margin-bottom: 0;
}

.history-head select {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  outline: 0;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 9px;
}

.history-item strong {
  display: block;
  font-size: 13px;
}

.history-item span {
  margin-top: 4px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.composer-template {
  grid-column: 1 / -1;
}

.composer-mode {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-form {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.5fr) minmax(150px, 0.6fr);
  gap: 8px;
}

.attachment-form input,
.attachment-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

.composer-mode label {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #344154;
  font-size: 13px;
  font-weight: 700;
}

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

.composer-field span {
  color: var(--muted);
  font-size: 12px;
}

.composer textarea {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: 0;
  resize: vertical;
}

.composer button {
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #132238;
  color: #fff;
  cursor: pointer;
}

.empty-state {
  margin: auto;
  max-width: 310px;
  text-align: center;
  padding: 28px;
}

.empty-visual {
  width: 118px;
  height: 86px;
  margin: 0 auto 16px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #fff 12px, transparent 12px 20px, #fff 20px 88px, transparent 88px),
    linear-gradient(145deg, #2563eb, #16a34a 55%, #7c3aed);
  box-shadow: var(--shadow);
}

.empty-state h3 {
  font-size: 18px;
}

.empty-state p {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 8px;
}

.empty-list {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle-button {
    left: 12px;
    top: 12px;
  }

  .app-shell.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .app-shell.is-sidebar-collapsed .sidebar {
    display: none;
  }

  .app-shell.is-sidebar-collapsed .inbox {
    padding-left: 62px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

  .pipeline-board {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .pipeline-column {
    min-width: 0;
    min-height: 360px;
  }

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

  .task-create-form,
  .task-edit-grid {
    grid-template-columns: 1fr;
  }

  .clients-grid,
  .analytics-grid,
  .deals-grid,
  .events-grid,
  .queue-grid,
  .accounts-grid,
  .settings-grid,
  .admin-grid,
  .limit-grid,
  .limit-grid.two {
    grid-template-columns: 1fr;
  }

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

  .logo-upload-row {
    grid-template-columns: 54px 1fr;
  }

  .logo-upload-row .secondary-button {
    grid-column: 1 / -1;
  }

  .task-column {
    min-height: 320px;
  }

  .detail-main.has-client-card {
    grid-template-columns: 1fr;
  }

  .client-profile {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .conversation-detail {
    min-height: 520px;
  }
}

@media (max-width: 1280px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .view-switch,
  .search,
  .select-control,
  .toggle {
    flex-grow: 1;
  }

  .detail-main.has-client-card {
    grid-template-columns: 1fr;
  }

  .detail-header,
  .ai-panel {
    grid-template-columns: 1fr;
  }

  .detail-actions,
  .ai-controls,
  .ai-flow {
    justify-content: flex-start;
  }

  .client-profile {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  }

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

  .composer-template button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .sidebar,
  .inbox {
    padding: 14px;
  }

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

  .toolbar-actions,
  .search,
  .select-control,
  .view-switch {
    width: 100%;
  }

  .view-switch button {
    flex: 1;
  }

  .search input {
    width: 100%;
  }

  .channel-filters,
  .account-list {
    grid-template-columns: 1fr;
  }

  .integration-fields,
  .template-form,
  .followup-form,
  .account-admin-meta {
    grid-template-columns: 1fr;
  }

  .template-form textarea,
  .followup-form textarea {
    grid-column: auto;
  }

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

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

  .account-admin-head {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .client-list-head {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .client-list-head .badge {
    grid-column: 1 / -1;
    justify-self: flex-start;
  }

  .client-list-meta {
    grid-template-columns: 1fr;
  }

  .deal-fields {
    grid-template-columns: 1fr;
  }

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

  .account-admin-head .badge {
    grid-column: 1 / -1;
    justify-self: flex-start;
  }

  .conversation-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .message {
    max-width: 96%;
  }
}
