:root {
  color-scheme: light;
  --brand-bar-height: 68px;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --line: #d9e1dd;
  --text: #17211d;
  --muted: #62726a;
  --brand: #177245;
  --brand-dark: #0d5934;
  --accent: #0f766e;
  --danger: #a43b3b;
  --incoming: #ffffff;
  --outgoing: #dff5e7;
  --chat-bg: #efeae2;
  --chat-pattern: url("data:image/svg+xml,%3Csvg width='180' height='180' viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23a6b7ad' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' opacity='.28'%3E%3Cpath d='M25 30c8-9 22-5 24 7 2 14-12 22-24 13l-10 3 3-10c-4-5-3-10 7-13Z'/%3E%3Cpath d='M42 39h10M32 39h4M37 34v10'/%3E%3Cpath d='M118 19h28v23h-28zM124 47h16M151 26l8-6M151 34l9 4'/%3E%3Cpath d='M78 79c0-9 7-16 16-16s16 7 16 16-7 16-16 16-16-7-16-16Z'/%3E%3Cpath d='M86 78h16M94 70v16'/%3E%3Cpath d='M21 117h34v25H21zM25 121l13 10 13-10'/%3E%3Cpath d='M128 123c9 0 16 7 16 16v12h-32v-12c0-9 7-16 16-16ZM121 116c0-4 3-7 7-7s7 3 7 7-3 7-7 7-7-3-7-7Z'/%3E%3Cpath d='M73 145l18-16 18 16M83 146v15h20v-15'/%3E%3Cpath d='M151 80c0 8-7 15-15 15h-11l-10 8 3-10c-5-3-8-8-8-13 0-8 7-15 15-15h11c8 0 15 7 15 15Z'/%3E%3Cpath d='M35 73l10 7-10 7M50 87h12'/%3E%3Cpath d='M154 158l8 8M162 158l-8 8'/%3E%3C/g%3E%3C/svg%3E");
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary,
.filter {
  background: #e9efec;
  color: var(--text);
}

.secondary:hover,
.filter:hover,
.filter.active {
  background: #cfe0d8;
}

.archived-conversations {
  width: calc(100% - 24px);
  min-height: 42px;
  margin: 0 12px 10px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 10px;
  background: #f5f7f6;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.archived-conversations:hover,
.archived-conversations.active { background: #e4f1ea; color: var(--brand-dark); }
.archived-conversations svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.archived-count { margin-left: auto; color: var(--muted); }

.hidden {
  display: none !important;
}

.brand-bar {
  height: var(--brand-bar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 10px rgba(20, 39, 54, 0.06);
}

.brand-mark {
  min-width: 0;
  display: flex;
  align-items: center;
}

.brand-mark img {
  display: block;
  width: auto;
  height: 52px;
  max-width: 220px;
  object-fit: contain;
}

.provider-badge {
  min-width: 0;
  margin-left: 10px;
  padding: 8px 12px;
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #dbe5df;
  border-radius: 12px;
  background: #f7faf8;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.provider-badge[data-provider="evolution"] {
  position: relative;
  padding-left: 34px;
}

.provider-badge[data-provider="evolution"]::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.14);
  transform: translateY(-50%);
}

.provider-badge[data-connection="connected"]::before {
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.14);
}

.provider-badge[data-connection="connecting"]::before,
.provider-badge[data-connection="checking"]::before {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.provider-badge[data-connection="disconnected"]::before,
.provider-badge[data-connection="error"]::before,
.provider-badge[data-connection="unconfigured"]::before {
  background: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.14);
}

.provider-badge-icon {
  width: 28px;
  height: 28px;
  display: block;
  flex: 0 0 auto;
}

.provider-badge-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.provider-badge-label,
.provider-badge-value {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.provider-badge-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.provider-badge-value {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-session {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.brand-user {
  max-width: min(520px, 44vw);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.brand-logout {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: #eef5f1;
  color: var(--brand-dark);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-logout:hover {
  background: #d9eee3;
  color: var(--brand-dark);
}

.brand-logout svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #eef5f1;
  color: var(--brand-dark);
  font-weight: 800;
}

.theme-toggle:hover { background: #d9eee3; color: var(--brand-dark); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-moon { display: none; }
.theme-dark .theme-toggle .theme-sun { display: none; }
.theme-dark .theme-toggle .theme-moon { display: block; }

.theme-dark {
  --bg: #09110f;
  --panel: #111b18;
  --line: #2a3934;
  --text: #edf5f1;
  --muted: #9aada5;
  --incoming: #182521;
  --outgoing: #104632;
  background: var(--bg);
  color: var(--text);
}

.theme-dark .brand-bar,
.theme-dark .sidebar,
.theme-dark .sidebar-header,
.theme-dark .conversation-pane,
.theme-dark .topbar,
.theme-dark .details-panel,
.theme-dark .composer,
.theme-dark .modal-panel,
.theme-dark .call-panel,
.theme-dark .attachment-menu,
.theme-dark .emoji-picker {
  background-color: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.theme-dark .messages { background-color: #0b1512; }
.theme-dark input,
.theme-dark textarea,
.theme-dark select { background-color: #15211e; color: var(--text); border-color: var(--line); }
.theme-dark input::placeholder,
.theme-dark textarea::placeholder { color: #74877f; }
.theme-dark .conversation-select:hover,
.theme-dark .conversation-item.active,
.theme-dark .filter,
.theme-dark .queue-tab,
.theme-dark .icon-button,
.theme-dark .composer-icon,
.theme-dark .theme-toggle,
.theme-dark .brand-logout { background: #1a2925; color: #c8d9d2; }
.theme-dark .conversation-item,
.theme-dark .team-member,
.theme-dark .details-card { border-color: var(--line); }
.theme-dark .provider-badge { background: #12211c; border-color: #2a3a34; box-shadow: none; }

.login-view {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(400px, 480px);
  justify-content: center;
  align-items: center;
  gap: clamp(48px, 6vw, 88px);
  padding: 32px;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 78% 18%, rgba(20, 184, 166, 0.18), transparent 28%),
    radial-gradient(circle at 8% 84%, rgba(23, 114, 69, 0.24), transparent 30%),
    linear-gradient(135deg, #071b19 0%, #0b2924 48%, #0d3830 100%);
}

.brand-flj .login-view {
  background:
    radial-gradient(circle at 18% 15%, rgba(0, 214, 190, .18), transparent 34%),
    radial-gradient(circle at 82% 85%, rgba(20, 111, 224, .18), transparent 30%),
    linear-gradient(135deg, #061d35 0%, #073f66 50%, #075b83 100%);
}

.login-view::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to right, #000, transparent 80%);
}

.login-ambient { position: absolute; inset: 0; pointer-events: none; }
.login-copy, .login-panel { position: relative; z-index: 2; }

.login-copy { max-width: 620px; color: #fff; }
.login-kicker { display: flex; align-items: center; gap: 10px; color: #77e2c0; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.login-kicker span { width: 28px; height: 2px; background: currentColor; }
.login-copy h2 { margin: 24px 0 20px; font-size: clamp(42px, 5vw, 72px); line-height: 1.04; letter-spacing: -.045em; font-weight: 500; }
.login-copy h2 strong { color: #76e1bd; font-weight: 800; }
.login-copy > p:last-child { max-width: 540px; color: #b6cbc4; font-size: 18px; line-height: 1.7; }

.login-ambient span { position: absolute; border: 1px solid rgba(118,225,189,.16); border-radius: 50%; }
.login-ambient span:nth-child(1) { width: 520px; height: 520px; left: -250px; top: -180px; }
.login-ambient span:nth-child(2) { width: 720px; height: 720px; left: -350px; top: -280px; }
.login-ambient span:nth-child(3) { width: 360px; height: 360px; right: -180px; bottom: -170px; }

.login-panel {
  width: 100%;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 24px;
  padding: clamp(28px, 4vw, 48px);
  display: grid;
  gap: 20px;
  box-shadow: 0 36px 100px rgba(0,0,0,.35);
  backdrop-filter: blur(18px);
}

.login-brand { min-height: 72px; display: flex; align-items: center; margin-bottom: 2px; }
.login-brand img { display: block; width: min(100%, 270px); height: auto; object-fit: contain; }
.brand-flj .login-brand { min-height: 112px; }
.brand-flj .login-brand img { width: 180px; max-height: 180px; }
.brand-flj .brand-mark img {
  height: 62px;
  max-width: 180px;
  transform: scale(1.28);
  transform-origin: left center;
}
.login-heading h1 { font-size: 34px; letter-spacing: -.035em; }
.login-heading > p:last-child { margin: 8px 0 0; color: var(--muted); }
.login-field > span:first-child { color: #33463e; font-weight: 700; }
.login-input-wrap { position: relative; display: block; }
.login-input-wrap svg { position: absolute; left: 15px; top: 50%; width: 19px; transform: translateY(-50%); fill: none; stroke: #81938b; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.login-input-wrap input { min-height: 52px; padding-left: 46px; border-radius: 12px; background: #f8faf9; }
.login-submit { min-height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 800; box-shadow: 0 10px 24px rgba(23,114,69,.22); }
.login-submit span { font-size: 20px; transition: transform .2s ease; }
.login-submit:hover span { transform: translateX(4px); }
.login-panel .form-error:empty { display: none; }
.password-help-button { min-height: auto; padding: 4px; background: transparent; color: var(--brand); font-size: 14px; font-weight: 800; box-shadow: none; }
.password-help-button:hover { background: transparent; color: var(--brand-dark); text-decoration: underline; }

.forgot-password-panel { width: min(500px, 100%); grid-template-rows: auto auto auto; border-radius: 18px; }
.forgot-password-body { padding: 24px; display: grid; gap: 18px; }
.forgot-password-body > p:first-child { margin: 0; color: var(--muted); line-height: 1.6; }
.forgot-password-body .form-error,
.forgot-password-body .form-success { margin: 0; }
.forgot-password-actions { padding: 16px 24px 22px; display: flex; justify-content: flex-end; gap: 10px; }
.forgot-password-actions button { min-width: 130px; }

.app-toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 100;
  width: min(390px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.app-toast {
  padding: 15px 18px 15px 48px;
  border: 1px solid #b8ddcc;
  border-radius: 12px;
  position: relative;
  background: #ffffff;
  color: #174c35;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
  box-shadow: 0 18px 50px rgba(8, 57, 42, 0.2);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .22s ease, transform .22s ease;
}

.app-toast::before {
  content: "✓";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  background: #177245;
  color: #fff;
  font-size: 13px;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.force-password-modal { z-index: 90; background: rgba(3, 32, 27, .78); backdrop-filter: blur(7px); }
.force-password-panel { width: min(500px, 100%); grid-template-rows: auto auto auto; border-radius: 18px; }
.force-password-body { padding: 24px; display: grid; gap: 18px; }
.force-password-body > p:first-child { margin: 0; color: var(--muted); line-height: 1.6; }
.force-password-body .form-error { margin: 0; }
.force-password-actions { padding: 0 24px 24px; }
.force-password-actions button { width: 100%; min-height: 50px; border-radius: 12px; font-weight: 800; }
.password-input-wrap { position: relative; display: block; }
.password-input-wrap input { min-height: 52px; padding-right: 52px; border-radius: 12px; background: #f8faf9; }
.password-visibility { position: absolute; top: 50%; right: 8px; width: 38px; min-height: 38px; padding: 0; transform: translateY(-50%); display: grid; place-items: center; border-radius: 9px; background: transparent; color: #71827a; }
.password-visibility:hover { background: #e8f1ed; color: var(--brand-dark); }
.password-visibility svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-visibility.visible { color: var(--brand); background: #e8f6ef; }

@media (max-width: 1180px) {
  .login-view { grid-template-columns: minmax(0, 1fr); padding: 28px; }
  .login-copy { display: none; }
  .login-panel { max-width: 480px; justify-self: center; }
}

@media (max-width: 520px) {
  .login-view { min-height: 100dvh; padding: 14px; align-items: center; }
  .login-panel { padding: 24px 20px; border-radius: 20px; gap: 15px; }
  .login-brand { min-height: 60px; justify-content: center; }
  .login-brand img { width: min(100%, 240px); }
  .login-heading { text-align: center; }
  .login-heading .eyebrow { text-align: center; }
  .login-heading h1 { font-size: 30px; }
  .forgot-password-actions { flex-direction: column-reverse; }
  .forgot-password-actions button { width: 100%; }
}

@media (max-height: 680px) and (max-width: 1180px) {
  .login-view { align-items: start; }
  .login-panel { margin: 10px 0; }
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin: 0 0 4px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 36px;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  font-size: 15px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 40px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.form-error {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
}

.desk-view {
  height: calc(100dvh - var(--brand-bar-height));
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr) 280px;
  overflow: hidden;
}

.desk-view.no-details {
  grid-template-columns: 390px minmax(0, 1fr);
}

.desk-view.no-details .details {
  display: none;
}

.sidebar,
.details {
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
}

.details {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 18px 12px 18px 18px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.sidebar-header,
.topbar {
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  gap: 12px;
}

.icon-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eef5f1;
  color: var(--brand-dark);
}

.icon-button:hover {
  background: #d9eee3;
  color: var(--brand-dark);
}

.icon-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conversation-search {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: var(--panel);
}

.conversation-search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conversation-search input {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: #eef3f0;
  padding: 8px 10px;
}

.conversation-search input:focus {
  box-shadow: none;
  background: #fff;
}

.filters {
  padding: 10px 12px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter {
  min-height: 28px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 11px;
  background: #f0f4f2;
  color: #52645b;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter:hover {
  background: #e1ebe6;
  color: var(--brand-dark);
}

.filter.active {
  border-color: #b7d8c9;
  background: #dff3e9;
  color: var(--brand-dark);
}

.queue-tabs {
  padding: 0 12px 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.queue-tab {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.queue-tab:hover {
  background: #eef5f1;
  color: var(--brand-dark);
}

.queue-tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(23, 114, 69, 0.18);
}

.conversation-list {
  min-height: 0;
  height: auto;
  overflow: auto;
  scrollbar-gutter: stable;
}

.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 0;
  position: relative;
  text-align: left;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.conversation-select {
  min-width: 0;
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  text-align: left;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 14px 54px 14px 12px;
}

.conversation-select:hover {
  background: transparent;
  color: var(--text);
}

.conversation-summary {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  align-self: start;
  color: var(--avatar-fg);
  background: var(--avatar-bg);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  user-select: none;
  overflow: hidden;
}

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

.header-avatar {
  width: 46px;
  height: 46px;
  align-self: center;
  font-size: 16px;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eef5f1;
}

.conversation-item.unread {
  background: #f0faf5;
  border-left: 4px solid var(--brand);
}

.conversation-item.unread .conversation-select {
  padding-left: 8px;
}

.conversation-item.unread .contact-name,
.conversation-item.unread .preview {
  font-weight: 800;
  color: var(--text);
}

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

.conversation-flags {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.conversation-menu-wrap {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18px;
  padding-right: 8px;
  position: relative;
}

.conversation-menu-toggle {
  width: 28px;
  min-height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: transparent;
  color: #52645b;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.conversation-item:hover .conversation-menu-toggle,
.conversation-menu-toggle[aria-expanded="true"] {
  opacity: 1;
  pointer-events: auto;
  background: #e0ebe6;
}

.conversation-menu-toggle:hover {
  background: #d4e4dc;
  color: var(--brand-dark);
}

.conversation-menu-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conversation-menu {
  position: absolute;
  top: 48px;
  right: 8px;
  z-index: 8;
  width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(23, 33, 29, 0.16);
}

.conversation-menu-item {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 400;
}

.conversation-menu-item:hover {
  background: #eef5f1;
  color: var(--brand-dark);
}

.conversation-menu-item.danger {
  color: var(--danger);
}

.conversation-menu-item.danger:hover {
  background: #f5eeee;
  color: var(--danger);
}

.conversation-menu-empty {
  display: block;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.unread-count {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 3px rgba(23, 114, 69, 0.13);
}

.contact-name {
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.contact-company {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.badge {
  border-radius: 999px;
  color: var(--brand-dark);
  background: #d9eee3;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-summary > .muted {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-pane {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.conversation-pane.idle {
  grid-template-rows: 1fr;
}

.conversation-pane.idle .topbar,
.conversation-pane.idle .composer {
  display: none;
}

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

.mobile-back-button {
  display: none;
}

.topbar-action {
  min-height: 32px;
  border-radius: 999px;
  padding: 0 13px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.assign-action {
  background: #dff3e9;
  color: var(--brand-dark);
}

.assign-action:hover {
  background: #cfeadc;
  color: var(--brand-dark);
}

.close-action {
  background: var(--brand);
  color: #fff;
}

.close-action:hover {
  background: var(--brand-dark);
}

.voice-action {
  background: #edf8f2;
  color: var(--brand-dark);
  border-color: #cce8d9;
}

.voice-action:hover {
  background: #d9eee3;
  color: var(--brand-dark);
}

.call-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
}

.call-card {
  width: min(360px, calc(100vw - 44px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 16px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(23, 33, 29, 0.22);
}

.call-card h2 {
  margin-bottom: 4px;
}

.call-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call-actions button {
  flex: 1;
}

.call-accept {
  background: var(--brand);
}

.call-end {
  background: var(--danger);
}

.call-end:hover {
  background: #842f2f;
}

#conversationTitle {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.conversation-heading {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.conversation-heading h2,
.conversation-heading p {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.messages {
  min-height: 0;
  padding: 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--chat-bg);
  background-image: var(--chat-pattern);
  background-size: 180px 180px;
  background-repeat: repeat;
}

.empty-state {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.message {
  position: relative;
  max-width: min(620px, 78%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 8px;
  background: var(--incoming);
  box-shadow: 0 4px 14px rgba(23, 33, 29, 0.05);
}

.message.has-media {
  max-width: min(500px, 82%);
}

.message.visual-media {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.message.out {
  align-self: flex-end;
  background: var(--outgoing);
}

.message.system {
  align-self: center;
  max-width: min(620px, 86%);
  border-style: dashed;
  background: #f5f8f6;
  color: var(--muted);
  box-shadow: none;
}

.message.system .message-text {
  color: var(--text);
}

.internal-note {
  display: grid;
  gap: 4px;
}

.internal-note-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.internal-note-text {
  font-size: 14px;
  font-weight: 700;
}

.message-actions {
  position: absolute;
  top: 8px;
  z-index: 7;
  display: grid;
  justify-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  transform: translateY(2px);
}

.message.in .message-actions {
  right: -10px;
}

.message.out .message-actions {
  left: -10px;
}

.message:hover .message-actions,
.message:focus-within .message-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.message-actions.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.message-actions-toggle {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  background: var(--panel);
  color: #52645b;
  box-shadow: 0 4px 14px rgba(23, 33, 29, 0.16);
  opacity: 0;
  pointer-events: none;
}

.message:hover .message-actions-toggle,
.message:focus-within .message-actions-toggle,
.message-actions.open .message-actions-toggle,
.message-actions-toggle[aria-expanded="true"] {
  opacity: 1;
  pointer-events: auto;
}

.message-actions-toggle:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: #fff;
}

.message-actions-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-actions-menu {
  position: absolute;
  top: calc(100% + 6px);
  min-width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(23, 33, 29, 0.18);
  display: grid;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.message.in .message-actions-menu {
  left: 0;
  right: auto;
  transform-origin: top left;
}

.message.out .message-actions-menu {
  right: 0;
  left: auto;
  transform-origin: top right;
}

.message-actions.open .message-actions-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.message-actions-menu::before {
  content: "";
  position: absolute;
  top: 10px;
  width: 10px;
  height: 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  transform: rotate(45deg);
}

.message.in .message-actions-menu::before {
  left: -5px;
}

.message.out .message-actions-menu::before {
  right: -5px;
}

.message-menu-item {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  font-size: 13px;
  font-weight: 400;
}

.message-menu-item:hover {
  background: #eef5f1;
  color: var(--brand-dark);
}

.conversation-menu .conversation-menu-item,
.message-actions-menu .message-menu-item,
.message-actions-menu .message-menu-item span {
  font-weight: 400;
}

.message-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reaction-bar {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 6px);
  z-index: 5;
  width: min(340px, calc(100vw - 32px));
  max-height: 292px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(23, 33, 29, 0.18);
  display: grid;
  gap: 8px;
}

.message.out .reaction-bar {
  right: 8px;
  left: auto;
}

.message.in .reaction-bar {
  right: auto;
}

.message.reaction-below .reaction-bar {
  top: calc(100% + 6px);
  bottom: auto;
}

.reaction-favorites {
  display: grid;
  grid-template-columns: repeat(6, 34px);
  justify-content: center;
  gap: 4px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.reaction-grid {
  max-height: 216px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 2px;
  padding-right: 2px;
  overscroll-behavior: contain;
}

.reaction-option {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

.reaction-option.favorite {
  font-size: 21px;
}

.reaction-option:hover {
  background: #eef5f1;
  transform: translateY(-1px);
}

.message-reaction {
  position: absolute;
  left: 10px;
  bottom: -12px;
  z-index: 2;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  border: 1px solid rgba(23, 33, 29, 0.08);
  box-shadow: 0 2px 8px rgba(23, 33, 29, 0.16);
  font-size: 16px;
  line-height: 1;
}

.message.out .message-reaction,
.message.out .image-group .message-reaction {
  left: auto;
  right: 10px;
}

.message.out.visual-media {
  background: transparent;
  justify-items: end;
}

.message.in {
  align-self: flex-start;
}

.reply-quote {
  min-width: 0;
  margin: 0 0 6px;
  padding: 7px 9px;
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  display: grid;
  gap: 2px;
  background: rgba(255, 255, 255, 0.72);
}

.message.out .reply-quote {
  background: rgba(255, 255, 255, 0.58);
}

.reply-quote strong,
.reply-quote span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-quote strong {
  color: var(--brand-dark);
  font-size: 13px;
}

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

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.group-message .message-text {
  display: grid;
  gap: 4px;
}

.group-message-author {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.image-group .group-message-author {
  padding: 2px 6px 0;
}

.call-message-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.call-message-text::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.72);
}

.message.has-media .message-text {
  white-space: normal;
}

.shared-contact-message {
  display: grid;
  gap: 12px;
}

.shared-contact-text {
  display: grid;
  gap: 2px;
  white-space: normal;
}

.message.shared-contact {
  padding-bottom: 9px;
}

.message.shared-contact .message-text {
  white-space: normal;
}

.message.shared-contact .message-meta {
  margin-top: 7px;
}

.shared-contact-add {
  justify-self: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 18px;
  border: 1px solid #b8ddcc;
  background: #e8f6ef;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.shared-contact-add:hover {
  background: #d8eee4;
  color: var(--brand-dark);
}

.shared-contact-add:disabled {
  opacity: 0.8;
  cursor: default;
}

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

.transfer-body {
  padding: 22px 24px 18px;
  display: grid;
  gap: 16px;
}

.transfer-body > p:first-child {
  margin: 0;
  line-height: 1.6;
}

.transfer-field {
  gap: 8px;
}

.transfer-field select {
  min-height: 44px;
  border-radius: 8px;
}

.transfer-preview {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.transfer-actions {
  padding: 0 24px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.transfer-actions button {
  min-width: 120px;
}

.message-media {
  margin: 0;
  display: grid;
}

.message.out .message-media {
  justify-items: end;
}

.message.out .media-preview {
  margin-left: auto;
  background: var(--outgoing);
}

.media-preview {
  min-height: 0;
  padding: 4px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--incoming);
  cursor: pointer;
  position: relative;
  display: block;
  width: min(420px, 100%);
  box-shadow: 0 1px 2px rgba(23, 33, 29, 0.2);
}

.media-preview:hover {
  background: var(--incoming);
  filter: brightness(0.96);
}

.media-preview img,
.media-preview video {
  display: block;
  width: 100%;
  max-height: min(560px, 64vh);
  border-radius: 5px;
  object-fit: contain;
  background: #0b1511;
}

.sticker-media {
  width: 180px;
  max-width: min(48vw, 220px);
}

.sticker-preview {
  width: 100%;
  min-height: 124px;
  padding: 8px;
  background: transparent;
  box-shadow: none;
}

.message.out .sticker-preview,
.sticker-preview:hover {
  background: transparent;
}

.sticker-preview img {
  max-height: 180px;
  background: transparent;
  object-fit: contain;
}

.image-group-message {
  max-width: min(430px, 82%);
}

.image-group {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: var(--outgoing);
  box-shadow: 0 1px 2px rgba(23, 33, 29, 0.18);
}

.message.in .image-group {
  background: var(--incoming);
}

.image-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}

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

.image-group-grid.count-3 .image-group-tile:first-child {
  grid-row: span 2;
}

.image-group-tile {
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  border-radius: 5px;
  box-shadow: none;
}

.image-group-tile img {
  height: 100%;
  max-height: none;
  border-radius: 5px;
  object-fit: cover;
}

.image-group-more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(9, 20, 15, 0.62);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
}

.image-group-download {
  justify-self: start;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.image-group-download:hover {
  background: #fff;
  color: var(--brand-dark);
}

.image-group-download svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.image-group-meta {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  padding: 0 4px 2px;
}

.message-caption {
  padding: 8px 10px 9px;
}

.visual-media .message-caption {
  margin-top: -1px;
  border-radius: 0 0 8px 8px;
  background: var(--incoming);
}

.audio-message {
  --audio-progress: 0%;
  width: min(340px, 76vw);
  min-height: 62px;
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  background: var(--incoming);
}

.message.out .audio-message {
  background: var(--outgoing);
}

.audio-play {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #111c17;
  background: transparent;
}

.audio-play:hover {
  background: rgba(23, 33, 29, 0.08);
}

.audio-play svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.audio-pause-icon,
.audio-message.playing .audio-play-icon {
  display: none;
}

.audio-message.playing .audio-pause-icon {
  display: block;
}

.audio-track {
  min-width: 0;
  position: relative;
  display: grid;
  gap: 4px;
  padding-left: 17px;
}

.audio-waveform {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 2px;
  color: #b9c8c0;
  overflow: hidden;
}

.audio-waveform span {
  width: 3px;
  min-width: 3px;
  border-radius: 999px;
  background: currentColor;
}

.audio-waveform::before {
  display: none;
}

.audio-track::before {
  content: "";
  position: absolute;
  top: 6px;
  left: clamp(0px, var(--audio-progress), calc(100% - 12px));
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #4fc3f7;
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.16);
  pointer-events: none;
  z-index: 2;
}

.audio-range {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.audio-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.audio-sent-at {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.audio-message audio {
  display: none;
}

.document-media {
  min-width: min(340px, 76vw);
  border: 0;
  border-radius: 7px;
  padding: 10px 12px;
  background: rgba(223, 245, 231, 0.84);
  color: var(--text);
  text-decoration: none;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
}

.pending-media {
  min-width: min(300px, 76vw);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  background: #f4f8f6;
}

.pending-media span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

.pending-media strong {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.retry-media-download {
  min-height: 32px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.message.in .document-media {
  background: #f4f8f6;
}

.document-icon {
  width: 32px;
  height: 38px;
  border-radius: 5px;
  display: grid;
  place-items: end center;
  padding-bottom: 6px;
  background: #3f73d8;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  position: relative;
}

.document-icon::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-top: 9px solid rgba(255, 255, 255, 0.76);
  border-left: 9px solid rgba(19, 45, 96, 0.24);
}

.document-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 500;
}

.document-download {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(13, 89, 52, 0.34);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: rgba(13, 89, 52, 0.54);
}

.document-download svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.play-indicator {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  pointer-events: none;
}

.play-indicator svg {
  width: 54px;
  height: 54px;
  padding: 12px;
  border-radius: 999px;
  background: rgba(15, 23, 20, 0.72);
  fill: currentColor;
}

.media-meta-overlay {
  position: absolute;
  right: 9px;
  bottom: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 18px);
  border-radius: 999px;
  padding: 3px 7px;
  color: #fff;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.36), rgba(0, 0, 0, 0.58));
  font-size: 12px;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.message-checks {
  color: #7b8d84;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -3px;
  margin-left: 4px;
}

.message-checks.read {
  color: #34b7f1;
}

.message-checks.failed {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  letter-spacing: 0;
}

.message-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
  background: var(--panel);
  align-items: center;
}

.reply-preview {
  grid-column: 1 / -1;
  min-height: 54px;
  padding: 8px 10px 8px 12px;
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: #eef5f1;
}

.reply-preview-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.reply-preview-body strong,
.reply-preview-body span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview-body strong {
  color: var(--brand-dark);
  font-size: 13px;
}

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

.reply-preview-close {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}

.reply-preview-close:hover {
  background: #d9eee3;
  color: var(--text);
}

.reply-preview-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-preview {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
  background: #f4f8f6;
  border: 1px solid var(--line);
}

.attachment-preview-items {
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.attachment-preview-item {
  min-width: 140px;
  max-width: 220px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.attachment-preview-item img,
.attachment-preview-file {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  object-fit: cover;
  background: #d9eee3;
}

.attachment-preview-file {
  display: grid;
  place-items: center;
  color: var(--brand-dark);
}

.attachment-preview-item span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-clear {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}

.attachment-preview-clear:hover {
  background: #d9eee3;
  color: var(--text);
}

.attachment-preview-clear svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #eef5f1;
  color: var(--brand-dark);
}

.composer-icon:hover {
  background: #d9eee3;
  color: var(--brand-dark);
}

.template-button,
.file-request-button {
  min-height: 36px;
  width: auto;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0 12px;
  background: #eef5f1;
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 13px;
}

.template-button:disabled,
.template-button:disabled:hover,
.file-request-button:disabled,
.file-request-button:disabled:hover {
  background: #eef5f1;
  color: var(--brand-dark);
}

.template-button:not(:disabled):hover,
.file-request-button:not(:disabled):hover {
  background: #d9eee3;
}

.composer-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#sendButton {
  display: inline-grid;
  place-items: center;
}

#sendButton svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#sendButton.audio-mode {
  background: #eef5f1;
  color: #0c271b;
}

#sendButton.recording {
  background: #b64242;
  color: #fff;
}

#sendButton.recording:hover {
  background: #963737;
}

.attachment-menu {
  position: absolute;
  left: 12px;
  bottom: 62px;
  width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 2px;
  box-shadow: 0 14px 38px rgba(23, 33, 29, 0.16);
}

.attachment-menu button {
  min-height: 44px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  text-align: left;
  font-weight: 500;
}

.attachment-menu button:hover {
  background: #f3f7f5;
  color: var(--text);
}

.attachment-menu-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
}

.attachment-menu-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-menu-icon.document {
  background: #6d5dfc;
}

.attachment-menu-icon.media {
  background: #1683f3;
}

.attachment-menu-icon.camera {
  background: #ff3c7d;
}

.attachment-menu-icon.contact {
  background: #0797d5;
}

.emoji-picker {
  position: absolute;
  left: 60px;
  bottom: 62px;
  width: min(430px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 120px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  box-shadow: 0 14px 38px rgba(23, 33, 29, 0.16);
  overflow: hidden;
}

.emoji-search-row {
  display: flex;
}

.emoji-search-input {
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf8;
  color: var(--text);
  outline: none;
}

.emoji-search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 114, 69, 0.12);
}

.emoji-category-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 2px 8px 0;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.emoji-category-nav::-webkit-scrollbar {
  height: 8px;
}

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

.emoji-category-nav::-webkit-scrollbar-thumb {
  background: rgba(123, 138, 131, 0.42);
  border-radius: 999px;
}

.emoji-category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7faf8;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.emoji-category-chip.active,
.emoji-category-chip:hover {
  background: #eef7f1;
  border-color: rgba(23, 114, 69, 0.28);
}

.emoji-sections {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  padding-right: 10px;
  scrollbar-gutter: stable;
}

.emoji-sections::-webkit-scrollbar {
  width: 10px;
}

.emoji-sections::-webkit-scrollbar-track {
  background: transparent;
}

.emoji-sections::-webkit-scrollbar-thumb {
  background: rgba(123, 138, 131, 0.36);
  border-radius: 999px;
}

.emoji-section {
  display: grid;
  gap: 8px;
}

.emoji-section-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  background: linear-gradient(180deg, #fff 75%, rgba(255, 255, 255, 0));
}

.emoji-section-icon {
  font-size: 18px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.emoji-option {
  min-height: 34px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 20px;
}

.emoji-option:hover {
  background: #eef5f1;
}

.emoji-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  color: var(--muted);
  text-align: center;
}

.agent-box,
.team-member {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 4px;
  background: #fbfcfb;
}

.team-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}

.team-member {
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.team-member-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.team-member-body strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-dot {
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 999px;
  background: #7b8a83;
  box-shadow: 0 0 0 4px rgba(123, 138, 131, 0.2);
}

.team-member.online .presence-dot {
  background: #00a63e;
  box-shadow: 0 0 0 4px rgba(0, 166, 62, 0.2), 0 0 0 8px rgba(0, 166, 62, 0.08);
}

.presence-text {
  color: var(--muted);
  font-size: 12px;
}

.team-member.online .presence-text {
  color: var(--brand-dark);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: 24px;
  background: rgba(23, 33, 29, 0.42);
  display: grid;
  place-items: center;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: min(720px, calc(100dvh - 48px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(23, 33, 29, 0.18);
}

.group-members-panel {
  width: min(520px, 100%);
  max-height: min(700px, calc(100dvh - 48px));
  grid-template-rows: auto auto minmax(0, 1fr);
}

.group-members-body {
  padding: 16px 18px 20px;
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow: auto;
}

.group-members-count {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.group-members-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.group-member-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.group-member-item strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.group-member-subtitle {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-all;
}

.new-conversation-panel {
  height: min(720px, calc(100dvh - 48px));
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-height: 0;
}

.share-contact-panel {
  width: min(520px, 100%);
  height: min(680px, calc(100dvh - 48px));
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 0;
}

.conversation-history-panel {
  width: min(620px, 100%);
  max-height: min(720px, calc(100dvh - 48px));
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
}

.conversation-history-summary {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.conversation-history-count {
  margin: 0;
  padding: 16px 18px 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.conversation-history-body {
  min-height: 0;
  overflow-y: auto;
  padding: 0;
  display: block;
  background-color: var(--chat-bg);
  background-image: var(--chat-pattern);
  background-size: 180px 180px;
  background-repeat: repeat;
}

.conversation-history-list {
  display: grid;
  gap: 0;
  padding: 16px 18px 20px;
  min-height: 100%;
  align-content: start;
  background: transparent;
}

.conversation-history-thread {
  display: grid;
  gap: 12px;
}

.conversation-history-thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.conversation-history-thread-time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.conversation-history-messages {
  min-height: auto;
  overflow: visible;
  padding: 0;
  background: transparent;
  background-image: none;
  background-size: auto;
  border-radius: 0;
}

.conversation-history-messages .message-actions,
.conversation-history-messages .reaction-bar,
.conversation-history-messages .message-menu {
  display: none !important;
}

.conversation-history-messages .message {
  cursor: default;
}

.conversation-history-divider {
  border-top: 1px dashed var(--line);
  margin: 18px 4px;
  padding-top: 14px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  justify-items: center;
}

.conversation-history-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  background: #edf4ef;
  color: var(--brand-dark);
}

.theme-dark .conversation-history-summary {
  background: #111b18;
  border-bottom-color: #2a3a34;
}

.theme-dark .conversation-history-body {
  background-color: #08110f;
}

.add-contact-panel {
  width: min(560px, 100%);
  grid-template-rows: auto minmax(0, 1fr);
}

.add-contact-form {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.add-contact-avatar-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  background: #fbfcfb;
}

.add-contact-avatar-preview {
  width: 82px;
  height: 82px;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #e8f1ed;
  color: var(--brand-dark);
  font-size: 22px;
  font-weight: 800;
  border: 1px solid var(--line);
}

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

.add-contact-avatar-actions {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.add-contact-avatar-actions > span {
  color: var(--text);
  font-weight: 800;
}

.add-contact-avatar-actions > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.add-contact-fields label {
  min-width: 0;
  color: var(--text);
  font-weight: 800;
}

.add-contact-fields label input {
  margin-top: 7px;
}

.add-contact-fields .field-wide {
  grid-column: 1 / -1;
}

.add-contact-form .form-error {
  margin: 0;
}

.add-contact-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.share-contact-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.share-contact-search input {
  width: 100%;
}

.share-contact-list {
  min-height: 0;
  overflow-y: auto;
  padding: 8px 12px;
}

.share-contact-option {
  min-height: 64px;
  padding: 7px 8px;
  border-radius: 9px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.share-contact-option:hover {
  background: #eef5f1;
}

.share-contact-option input {
  width: 19px;
  height: 19px;
  accent-color: var(--brand);
}

.share-contact-avatar {
  width: 44px;
  height: 44px;
  font-size: 13px;
}

.share-contact-option > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.share-contact-option strong,
.share-contact-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-contact-option small {
  color: var(--muted);
}

.share-contact-actions {
  min-height: 66px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.edit-contact-panel {
  width: min(440px, 100%);
  grid-template-rows: auto minmax(0, 1fr);
}

.template-modal-panel {
  width: min(620px, 100%);
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.camera-modal-panel {
  width: min(720px, 100%);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.camera-capture {
  min-height: 0;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.camera-capture video {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(62vh, 520px);
  border-radius: 8px;
  background: #101815;
  object-fit: contain;
}

.camera-capture .form-error {
  margin: 0;
}

.camera-actions {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fbfcfb;
}

.template-form {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #fbfcfb;
}

.template-form-body {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.template-form-footer {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  background: var(--panel);
  display: grid;
  gap: 8px;
}

.template-form-body label {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
}

.template-form-body label input,
.template-form-body label select,
.template-form-body label textarea {
  margin-top: 7px;
}

.template-preview {
  min-height: 112px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
  box-shadow: inset 0 0 0 1px rgba(23, 33, 29, 0.02);
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(9, 13, 12, 0.94);
  display: grid;
  grid-template-rows: auto 1fr;
}

.media-viewer-toolbar {
  min-height: 64px;
  padding: 12px 18px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.media-viewer-action {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.media-viewer-action:hover {
  background: rgba(255, 255, 255, 0.22);
}

.media-viewer-action svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.media-viewer-stage {
  min-height: 0;
  padding: 0 18px 24px;
  display: grid;
  place-items: center;
  position: relative;
}

.media-viewer-content {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 100px);
  object-fit: contain;
}

.media-viewer-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 42px;
  line-height: 1;
  transform: translateY(-50%);
}

.media-viewer-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.media-viewer-prev {
  left: 24px;
}

.media-viewer-next {
  right: 24px;
}

.media-viewer-count {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 2;
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.modal-header {
  border-bottom: 1px solid var(--line);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.contact-search {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.contact-mode-tabs {
  padding: 12px 12px 0;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.contact-mode-tab {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef5f1;
  color: var(--text);
  font-weight: 800;
}

.contact-mode-tab:hover,
.contact-mode-tab.active {
  background: #d9eee3;
  color: var(--brand-dark);
}

.quick-contact-form {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.quick-contact-form .form-error {
  grid-column: 1 / -1;
}

.edit-contact-form {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.edit-contact-form label {
  color: var(--text);
  font-weight: 800;
}

.edit-contact-form label input {
  margin-top: 7px;
}

.edit-contact-form .form-error {
  margin: 0;
}

.edit-contact-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.contact-picker {
  min-height: 0;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: var(--brand) #e6ece9;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.contact-picker::-webkit-scrollbar {
  width: 12px;
}

.contact-picker::-webkit-scrollbar-track {
  background: #e6ece9;
  border-radius: 999px;
}

.contact-picker::-webkit-scrollbar-thumb {
  background: var(--brand);
  border: 3px solid #e6ece9;
  border-radius: 999px;
}

.empty-contact-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
}

.contact-option {
  width: 100%;
  min-height: 56px;
  background: #fbfcfb;
  color: var(--text);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.contact-option:hover {
  background: #eef5f1;
}

.contact-option span:first-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.simulator {
  align-self: start;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

@media (max-width: 980px) {
  .desk-view {
    grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  }

  .details {
    display: none;
  }
}

@media (max-width: 860px) {
  .conversation-row {
    align-items: start;
  }

  .conversation-flags {
    max-width: 118px;
  }
}

@media (max-width: 720px) {
  :root {
    --brand-bar-height: 82px;
  }

  .brand-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "session";
    align-items: start;
    height: var(--brand-bar-height);
    padding: 6px 12px 9px;
    gap: 0;
  }

  .brand-mark img {
    height: 42px;
    max-width: 140px;
  }

  .brand-flj .brand-mark img {
    height: 46px;
    max-width: 140px;
    transform: scale(1.04);
  }

  .brand-mark {
    grid-area: brand;
    flex: 0 0 auto;
  }

  .provider-badge {
    display: none;
  }

  .provider-badge-icon {
    width: 22px;
    height: 22px;
  }

  .provider-badge-copy {
    gap: 0;
  }

  .provider-badge-label {
    display: none;
  }

  .provider-badge-value {
    display: none;
  }

  .brand-session {
    grid-area: session;
    flex: 1 0 100%;
    min-width: 0;
    margin-top: -9px;
    gap: 8px;
    justify-content: space-between;
  }

  .brand-user {
    flex: 1;
    max-width: none;
    font-size: 0.78rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
    min-width: 0;
  }

  .theme-toggle {
    min-width: 36px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .theme-toggle span {
    display: none;
  }

  .brand-logout {
    min-height: 34px;
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .brand-logout-label {
    display: none;
  }

  .contact-search,
  .quick-contact-form {
    grid-template-columns: 1fr;
  }

  .add-contact-avatar-editor,
  .add-contact-fields {
    grid-template-columns: 1fr;
  }

  .add-contact-avatar-preview {
    justify-self: center;
  }

  .add-contact-avatar-actions {
    text-align: center;
  }

  .add-contact-avatar-actions > div,
  .add-contact-actions {
    justify-content: center;
  }

  .desk-view {
    height: calc(100dvh - var(--brand-bar-height));
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .sidebar {
    height: 100%;
    min-height: 0;
  }

  .conversation-pane {
    display: none;
    height: 100%;
    min-height: 0;
  }

  .desk-view.conversation-open .sidebar {
    display: none;
  }

  .desk-view.conversation-open .conversation-pane {
    display: grid;
  }

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

  .topbar-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-actions button {
    flex: 1;
  }

  .mobile-back-button {
    min-width: 38px;
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #eef5f1;
    color: var(--brand-dark);
  }

  .mobile-back-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #conversationTitle {
    min-width: 0;
  }

  .message {
    max-width: 92%;
  }

  .composer {
    position: relative;
    grid-template-columns: 42px 42px minmax(0, 1fr) 48px;
    grid-template-areas:
      "reply reply reply reply"
      "template template file file"
      "attach emoji input send";
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(217, 225, 221, 0.9);
    background: #f7faf8;
  }

  .reply-preview {
    grid-area: reply;
    min-height: 48px;
    border-radius: 14px;
    background: #ffffff;
  }

  .composer-icon {
    width: 42px;
    min-height: 42px;
    background: #eef5f1;
  }

  #attachButton {
    grid-area: attach;
  }

  #emojiButton {
    grid-area: emoji;
  }

  .template-button {
    grid-area: template;
  }

  .file-request-button {
    grid-area: file;
  }

  .template-button,
  .file-request-button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
    line-height: 1.1;
  }

  #messageInput {
    grid-area: input;
    min-height: 42px;
    border: 0;
    border-radius: 22px;
    background: #ffffff;
    padding: 10px 14px;
    box-shadow: 0 0 0 1px rgba(217, 225, 221, 0.9);
  }

  #messageInput:focus {
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
  }

  #sendButton {
    grid-area: send;
    width: 48px;
    min-width: 48px;
    min-height: 42px;
    padding: 0;
    border-radius: 22px;
    font-size: 0;
    display: grid;
    place-items: center;
  }

  #sendButton::before {
    content: none;
  }

  .attachment-menu {
    left: 10px;
    bottom: calc(60px + env(safe-area-inset-bottom));
  }

  .emoji-picker {
    left: 10px;
    bottom: calc(60px + env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
  }
}

/* Ajustes finais de contraste para o tema escuro. Mantidos no fim para
   prevalecer sobre as cores claras específicas dos componentes. */
.theme-dark .sidebar,
.theme-dark .sidebar-header,
.theme-dark .conversation-search,
.theme-dark .filters,
.theme-dark .queue-tabs,
.theme-dark .conversation-list {
  background: #0d1b18;
}

.theme-dark .conversation-search input,
.theme-dark .conversation-search input:focus {
  background: #142622;
  color: #e8f3ef;
  box-shadow: inset 0 0 0 1px #29433c;
}

.theme-dark .archived-conversations {
  background: #132521;
  color: #bfd1ca;
  box-shadow: inset 0 0 0 1px #294039;
}

.theme-dark .archived-conversations:hover,
.theme-dark .archived-conversations.active {
  background: #19352e;
  color: #eaf6f2;
}

.theme-dark .filter,
.theme-dark .queue-tab {
  border-color: #294039;
  background: #142622;
  color: #b6c9c1;
}

.theme-dark .filter:hover,
.theme-dark .queue-tab:hover {
  background: #1a352e;
  color: #f0f8f5;
}

.theme-dark .filter.active {
  border-color: color-mix(in srgb, var(--brand) 68%, #8fded1);
  background: color-mix(in srgb, var(--brand) 32%, #142622);
  color: #f4fbf9;
}

.theme-dark .queue-tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.theme-dark .conversation-item:hover {
  background: #142923;
}

.theme-dark .conversation-item.active {
  background: #193a32;
  box-shadow: inset 4px 0 0 var(--brand);
}

.theme-dark .conversation-item.unread {
  background: #112c25;
}

.theme-dark .message.system {
  background: #15211e;
  border-color: #31423c;
}

.theme-dark .transfer-preview {
  background: #14211e;
  border-color: #31423c;
  color: #dce7e1;
}

.theme-dark .conversation-item.active .muted,
.theme-dark .conversation-item.active .preview {
  color: #b8cdc5;
}

.theme-dark .conversation-select {
  background: #101b25;
  border-color: #233142;
  color: #f1f7fb;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.theme-dark .conversation-select:hover {
  background: #13202c;
}

.theme-dark .conversation-item.active .conversation-select {
  background: #173042;
  border-color: #3b82f6;
  box-shadow: inset 4px 0 0 #60a5fa, 0 12px 26px rgba(37, 99, 235, 0.16);
}

.theme-dark .conversation-item.unread .conversation-select {
  background: #112622;
  border-color: #25433d;
}

.theme-dark .contact-name,
.theme-dark .conversation-time,
.theme-dark .conversation-owner {
  color: #eef5fb;
}

.theme-dark .conversation-time,
.theme-dark .conversation-owner,
.theme-dark .contact-company,
.theme-dark .conversation-assignee {
  color: #b7c6d6;
}

.theme-dark .badge {
  background: #162733;
  color: #dbeafe;
  border: 1px solid #2d4661;
}

.theme-dark .unread-count {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}

.theme-dark .conversation-status {
  background: #162733;
  color: #dbeafe;
  border-color: #2d4661;
}

.theme-dark .messages {
  background-color: #08110f;
}

.theme-dark .message {
  color: #111827;
}

.theme-dark .message.in,
.theme-dark .message.out,
.theme-dark .message.system {
  color: #111827;
}

.theme-dark .message-text,
.theme-dark .message-meta,
.theme-dark .reply-quote strong,
.theme-dark .reply-quote span,
.theme-dark .shared-contact-text,
.theme-dark .call-message-text {
  color: #111827;
}

.theme-dark .message-meta {
  color: #64748b;
}

.theme-dark .reply-quote {
  background: rgba(255, 255, 255, 0.82);
  border-left-color: #60a5fa;
}

.theme-dark .reply-quote strong {
  color: #1d4ed8;
}

.theme-dark .reply-quote span {
  color: #475569;
}

.theme-dark .message-checks {
  color: #64748b;
}

.theme-dark .message-checks.read {
  color: #38bdf8;
}

.theme-dark .message.system .message-text {
  color: #e2e8f0;
}

.theme-dark .message-actions-toggle {
  background: #1a2925;
  color: #c8d9d2;
  border-color: #2a3a34;
}

.theme-dark .message-actions-toggle:hover {
  background: #20312b;
  color: #f0f8f5;
}

.theme-dark .message-actions-menu {
  background: #111b18;
  border-color: #2a3934;
}

.theme-dark .message-actions-menu::before {
  background: #111b18;
  border-color: #2a3934;
}

.theme-dark .message-menu-item:hover {
  background: #1a352e;
  color: #f0f8f5;
}

.theme-dark .conversation-menu,
.theme-dark .reaction-bar,
.theme-dark .document-card,
.theme-dark .shared-contact-card {
  background: #162723;
  color: var(--text);
  border-color: var(--line);
}

.theme-dark .app-toast {
  background: #142622;
  color: #dff6ed;
  border-color: #2b6653;
}

/* Modais: superfícies e controles precisam permanecer no mesmo plano de
   contraste. Alguns componentes usam cores claras fixas no tema padrão. */
.theme-dark .modal {
  background: rgba(2, 10, 8, 0.74);
  backdrop-filter: blur(3px);
}

.theme-dark .modal-panel {
  background: #101d19;
  border-color: #30443d;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.theme-dark .modal-header,
.theme-dark .contact-search,
.theme-dark .quick-contact-form,
.theme-dark .add-contact-actions,
.theme-dark .edit-contact-actions,
.theme-dark .template-form-footer,
.theme-dark .camera-actions {
  background: #101d19;
  border-color: #30443d;
}

.theme-dark .template-form,
.theme-dark .template-form-body,
.theme-dark .contact-picker,
.theme-dark .add-contact-form,
.theme-dark .edit-contact-form,
.theme-dark .camera-capture {
  background: #0d1815;
}

.theme-dark .add-contact-avatar-editor {
  background: #162722;
  border-color: #30483f;
}

.theme-dark .add-contact-avatar-preview {
  background: #20382f;
  color: #c9f2e3;
  border-color: #385047;
}

.theme-dark .modal input,
.theme-dark .modal textarea,
.theme-dark .modal select {
  background: #162722;
  color: #edf5f1;
  border-color: #385047;
}

.theme-dark .modal input:focus,
.theme-dark .modal textarea:focus,
.theme-dark .modal select:focus {
  border-color: color-mix(in srgb, var(--brand) 70%, #9ee3cd);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
  outline: none;
}

.theme-dark .modal input::placeholder,
.theme-dark .modal textarea::placeholder {
  color: #8da29a;
}

.theme-dark .modal .secondary,
.theme-dark .modal .icon-button {
  background: #1c302a;
  color: #e1eee9;
  border-color: #385047;
}

.theme-dark .modal .secondary:hover,
.theme-dark .modal .icon-button:hover {
  background: #29433a;
  color: #fff;
}

.theme-dark .contact-option {
  background: #162722;
  color: #edf5f1;
  border-color: #30483f;
}

.theme-dark .contact-option:hover {
  background: #1c352d;
  border-color: #3f6255;
}

.theme-dark .share-contact-search,
.theme-dark .share-contact-actions {
  border-color: #30443d;
}

.theme-dark .share-contact-option:hover {
  background: #193029;
}

.theme-dark .contact-option .muted,
.theme-dark .modal .muted {
  color: #9fb3ab;
}

.theme-dark .contact-option .badge {
  background: #20483b;
  color: #c9f2e3;
}

.theme-dark .contact-picker {
  scrollbar-color: #397c65 #16231f;
}

.theme-dark .contact-picker::-webkit-scrollbar-track {
  background: #16231f;
}

.theme-dark .contact-picker::-webkit-scrollbar-thumb {
  background: #397c65;
  border-color: #16231f;
}

.theme-dark .template-form-body label,
.theme-dark .template-preview {
  background: #162722;
  color: #edf5f1;
  border-color: #30483f;
}

/* Cartões da equipe exibidos no painel lateral. */
.theme-dark .agent-box,
.theme-dark .team-member {
  background: #162722;
  color: #edf5f1;
  border-color: #30483f;
}

.theme-dark .team-member:hover {
  background: #1b302a;
  border-color: #3a594e;
}

.theme-dark .team-member-body strong {
  color: #edf5f1;
}

.theme-dark .presence-text {
  color: #91a69e;
}

.theme-dark .team-member.online .presence-text {
  color: #73d9ad;
}

/* Modern layout override */
:root {
  --brand-bar-height: 60px;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --line: #e2e8f0;
  --text: #1f2937;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --accent: #2563eb;
  --danger: #dc2626;
  --incoming: #ffffff;
  --outgoing: #dcfce7;
  --chat-bg: #f8fafc;
}

body {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 24%),
    linear-gradient(180deg, #f6f7fb 0%, #eef2f7 100%);
}

.brand-bar {
  height: var(--brand-bar-height);
  margin: 12px 12px 0;
  padding: 0 18px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.brand-mark img {
  height: 36px;
  max-width: 160px;
}

.provider-badge {
  padding: 6px 10px;
  border-radius: 999px;
  border-color: rgba(226, 232, 240, 0.95);
  background: #f8fafc;
}

.provider-badge-icon {
  width: 24px;
  height: 24px;
}

.brand-session {
  gap: 10px;
}

.brand-user {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.brand-logout,
.theme-toggle {
  min-height: 34px;
  padding: 0 14px;
}

.desk-view {
  height: calc(100dvh - var(--brand-bar-height) - 24px);
  margin: 12px;
  gap: 12px;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr) minmax(280px, 320px);
}

.sidebar,
.conversation-pane,
.details {
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.sidebar {
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
}

.details {
  border-left: 1px solid rgba(226, 232, 240, 0.95);
  padding: 14px 10px 14px 14px;
  gap: 12px;
  scrollbar-gutter: stable;
}

.sidebar-header,
.topbar,
.details-header {
  min-height: 68px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.sidebar-header h2,
.details-header h2 {
  font-size: 22px;
  letter-spacing: -0.03em;
}

.sidebar-actions,
.topbar-actions {
  gap: 8px;
}

.icon-button,
.topbar-action,
.conversation-chip,
.conversation-status,
.filter,
.queue-tab,
.composer-icon,
.template-button,
.file-request-button,
.brand-logout,
.theme-toggle {
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: none;
}

.team-action {
  display: none;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-weight: 800;
}

.conversation-search {
  padding: 12px 14px 10px;
  border-bottom: 0;
  background: transparent;
}

.conversation-search input {
  min-height: 44px;
  border-radius: 14px;
  background: #f8fafc;
}

.filters {
  padding: 2px 12px 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.filter {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eff4f9;
  color: #334155;
}

.filter.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.queue-tabs {
  padding: 0 12px 12px;
  gap: 8px;
  border-bottom: 0;
}

.queue-tab {
  min-height: 34px;
  border-radius: 12px;
  background: #f8fafc;
  color: #475569;
}

.queue-tab.active {
  background: #e0efff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  box-shadow: none;
}

.conversation-list {
  padding: 0 8px 6px;
}

.conversation-item {
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  border-bottom: 0;
  padding: 3px 8px;
  background: transparent;
}

.conversation-item.menu-open {
  z-index: 8;
}

.conversation-item.active,
.conversation-item.unread {
  background: transparent;
}

.conversation-select {
  min-height: 72px;
  padding: 9px 50px 9px 12px;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  align-items: flex-start;
}

.conversation-select:hover {
  background: #f8fbff;
}

.conversation-item.active .conversation-select {
  background: #eff6ff;
  border-color: #bfdbfe;
  box-shadow: inset 3px 0 0 #2563eb, 0 10px 24px rgba(37, 99, 235, 0.12);
}

.conversation-item.unread .conversation-select {
  background: #f8fbff;
  border-color: #dbeafe;
}

.conversation-item.unread .conversation-select {
  padding-left: 12px;
}

.conversation-menu-wrap {
  position: absolute;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  z-index: 2;
}

.conversation-item.menu-open .conversation-menu-wrap {
  z-index: 9;
}

.conversation-menu-toggle {
  width: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
  transition: opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.conversation-item:hover .conversation-menu-toggle,
.conversation-menu-toggle[aria-expanded="true"] {
  opacity: 1;
  pointer-events: auto;
  background: #dbeafe;
  border-color: #93c5fd;
}

.conversation-menu-toggle:hover {
  background: #bfdbfe;
  color: #1d4ed8;
}

.conversation-item .preview,
.conversation-item .muted,
.conversation-item .conversation-flags {
  display: none;
}

.conversation-summary {
  gap: 4px;
}

.conversation-row {
  gap: 12px;
}

.conversation-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.contact-company {
  display: block;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.conversation-preview {
  display: -webkit-box;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
}

.conversation-meta,
.conversation-extra {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.conversation-status {
  padding: 3px 9px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.conversation-status.is-waiting {
  background: #f1f5f9;
  color: #64748b;
}

.conversation-status.is-assigned {
  background: #dcfce7;
  color: #15803d;
}

.conversation-status.is-closed {
  background: #e2e8f0;
  color: #475569;
}

.conversation-owner {
  color: var(--muted);
  font-size: 12px;
}

.conversation-assignee {
  min-width: 0;
  max-width: 142px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-unread {
  position: absolute;
  top: 14px;
  right: 44px;
  min-width: 22px;
  height: 22px;
  margin: 0;
  padding: 0 6px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  display: inline-grid;
  place-items: center;
  align-self: start;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  box-shadow: none;
}

.conversation-pane {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.conversation-pane.idle .topbar,
.conversation-pane.idle .composer {
  display: none;
}

.topbar {
  padding: 16px 18px;
  align-items: flex-start;
  gap: 12px;
}

#conversationTitle {
  align-items: flex-start;
  gap: 14px;
}

.conversation-heading {
  gap: 6px;
}

.conversation-heading h2 {
  font-size: 21px;
  line-height: 1.1;
}

.conversation-heading .muted {
  color: var(--muted);
  font-size: 13px;
}

.conversation-live-status {
  color: var(--brand-dark);
  font-weight: 600;
}

.conversation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.conversation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
}

.conversation-chip strong {
  color: #1f2937;
  font-weight: 800;
}

.conversation-chip-provider {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #047857;
}

.conversation-chip-status {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.topbar-actions button {
  min-height: 34px;
}

.messages {
  padding: 24px;
  background-color: #f8fafc;
  background-size: 180px 180px;
}

.message {
  max-width: min(540px, 78%);
  padding: 12px 14px 10px;
  border-radius: 16px;
  border-color: #e2e8f0;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

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

.message.out {
  background: #dcfce7;
  border-color: #bbf7d0;
  align-self: flex-end;
}

.message.system {
  background: #f8fafc;
}

.message-meta {
  color: var(--muted);
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 14px 16px 16px;
  gap: 10px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -16px 30px rgba(15, 23, 42, 0.04);
}

.composer-icon,
.template-button,
.file-request-button {
  background: #f8fafc;
  color: #334155;
}

#messageInput {
  min-height: 46px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

#sendButton {
  min-width: 52px;
  min-height: 46px;
  border-radius: 16px;
  background: #22c55e;
  color: #fff;
  box-shadow: 0 12px 22px rgba(34, 197, 94, 0.24);
}

#sendButton:hover {
  background: #16a34a;
}

.details-header {
  display: grid;
  gap: 8px;
}

.details-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.details-close-button {
  display: none;
}

.team-search {
  min-height: 44px;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  color: #94a3b8;
}

.team-search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.team-search input {
  min-height: 40px;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.team-list {
  padding-right: 12px;
  scrollbar-gutter: stable;
}

.team-groups {
  display: grid;
  gap: 12px;
}

.team-section {
  display: grid;
  gap: 10px;
}

.team-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #1f2937;
  font-size: 13px;
  font-weight: 800;
}

.team-section-header span {
  color: #64748b;
  font-size: 12px;
}

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

.team-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.team-avatar {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.team-card-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.team-card-body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-card-status,
.team-section-empty,
.team-empty {
  color: #64748b;
  font-size: 12px;
}

.team-card.online .team-card-status {
  color: #15803d;
}

.team-card .presence-dot {
  margin-top: 0;
  justify-self: end;
}

.team-card.online .presence-dot {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16), 0 0 0 8px rgba(34, 197, 94, 0.08);
}

@media (max-width: 1180px) {
  .desk-view {
    grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  }

  .details {
    position: fixed;
    top: calc(var(--brand-bar-height) + 24px);
    right: 12px;
    bottom: 12px;
    width: min(360px, calc(100vw - 24px));
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transform: translateX(calc(100% + 24px));
    transition: transform 0.22s ease, opacity 0.22s ease;
  }

  .desk-view.team-open .details {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .team-action {
    display: inline-flex;
  }

  .details-close-button {
    display: grid;
  }
}

@media (max-width: 900px) {
  .desk-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
  }

  .conversation-pane {
    display: none;
  }

  .desk-view.conversation-open .sidebar {
    display: none;
  }

  .desk-view.conversation-open .conversation-pane {
    display: grid;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topbar-actions button {
    flex: 1 0 auto;
  }

  .mobile-back-button {
    min-width: 40px;
    width: 40px;
    height: 40px;
    min-height: 40px;
    display: inline-grid;
    place-items: center;
  }

  .details {
    left: 12px;
    right: 12px;
    top: calc(var(--brand-bar-height) + 12px);
    bottom: 12px;
    width: auto;
  }

  .team-action {
    display: inline-flex;
  }
}

@media (max-width: 560px) {
  :root {
    --brand-bar-height: 78px;
  }

  .brand-bar {
    margin: 8px 8px 0;
    padding: 4px 14px 8px;
    border-radius: 16px;
  }

  .brand-mark img {
    height: 56px;
    max-width: 170px;
  }

  .brand-flj .brand-mark img {
    height: 60px;
    max-width: 170px;
    transform: scale(1.02);
  }

  .brand-session {
    margin-top: -22px;
    align-items: center;
  }

  .brand-user {
    font-size: 0.8rem;
  }

  .desk-view {
    margin: 8px;
    height: calc(100dvh - var(--brand-bar-height) - 16px);
  }

  .sidebar-header,
  .topbar,
  .details-header {
    padding: 12px 14px;
  }

  .conversation-select {
    min-height: 72px;
  }

  .conversation-heading h2 {
    font-size: 18px;
  }

  .conversation-chips {
    gap: 6px;
  }

  .conversation-chip {
    padding: 6px 10px;
  }

  .messages {
    padding: 18px 14px;
  }

  .composer {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .details {
    border-radius: 18px;
  }
}

@media (hover: none), (pointer: coarse) {
  .conversation-menu-toggle,
  .message-actions-toggle {
    display: none;
  }

  .conversation-menu-wrap {
    pointer-events: none;
  }

  .conversation-item.menu-open .conversation-menu-wrap {
    pointer-events: auto;
  }

  .message-actions {
    pointer-events: none;
  }

  .message-actions.open {
    pointer-events: auto;
  }
}

.brand-user-menu {
  position: relative;
  flex: 0 0 auto;
}

.brand-user {
  min-height: 46px;
  max-width: min(260px, 42vw);
  padding: 7px 12px 7px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #eef5f1;
  color: var(--brand-dark);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 18px rgba(13, 89, 52, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  text-align: left;
}

.brand-user:hover,
.brand-user-menu.open .brand-user {
  background: #d9eee3;
  color: var(--brand-dark);
}

.brand-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: #d9eee3;
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.brand-user-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
  line-height: 1;
}

.brand-user-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-user-name {
  min-width: 0;
  max-width: 150px;
  color: var(--brand-dark);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-user-chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.82;
  transition: transform 0.16s ease;
}

.brand-user-menu.open .brand-user-chevron {
  transform: rotate(180deg);
}

.brand-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: #fff;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 4px;
  overflow: hidden;
}

.brand-user-dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--line);
}

.brand-user-dropdown .theme-toggle,
.brand-user-dropdown .brand-logout {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  font-weight: 400;
}

.brand-user-dropdown .theme-toggle:hover,
.brand-user-dropdown .brand-logout:hover {
  background: #eef5f1;
  color: var(--brand-dark);
}

.brand-user-dropdown .theme-toggle svg,
.brand-user-dropdown .brand-logout svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.brand-user-dropdown .theme-toggle span,
.brand-user-dropdown .brand-logout-label {
  display: inline;
}

.brand-user-dropdown .brand-logout {
  color: #17211d;
}

.theme-dark .brand-user {
  background: #1a2925;
  border-color: #2a3934;
  color: #c8d9d2;
}

.theme-dark .brand-user:hover,
.theme-dark .brand-user-menu.open .brand-user {
  background: #20342f;
  color: #f0f8f5;
}

.theme-dark .brand-user-avatar {
  background: #20342f;
  color: #f0f8f5;
}

.theme-dark .brand-user-name {
  color: #f0f8f5;
}

.theme-dark .brand-user-dropdown {
  background: #101a23;
  border-color: #233142;
}

.theme-dark .brand-user-dropdown .theme-toggle,
.theme-dark .brand-user-dropdown .brand-logout {
  background: transparent;
  color: #e7eef5;
}

.theme-dark .brand-user-dropdown .theme-toggle:hover,
.theme-dark .brand-user-dropdown .brand-logout:hover {
  background: #1a352e;
  color: #f0f8f5;
}

@media (max-width: 560px) {
  .brand-session {
    justify-content: flex-end;
  }

  .brand-user {
    max-width: min(180px, 56vw);
    min-height: 42px;
    padding: 6px 10px 6px 7px;
    border-radius: 13px;
  }

  .brand-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 13px;
  }

  .brand-user-name {
    max-width: 96px;
    font-size: 13px;
  }

  .brand-user-dropdown {
    right: 0;
    width: 160px;
  }
}

.theme-dark {
  --bg: #0a1016;
  --panel: #101a23;
  --line: #233142;
  --text: #e7eef5;
  --muted: #94a3b8;
  --brand: #60a5fa;
  --brand-dark: #3b82f6;
  --accent: #60a5fa;
  --danger: #f87171;
  --incoming: #111c27;
  --outgoing: #12331f;
  --chat-bg: #0c131b;
}

.theme-dark body {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 24%),
    linear-gradient(180deg, #0a1016 0%, #091116 100%);
}

.theme-dark .brand-bar,
.theme-dark .sidebar,
.theme-dark .conversation-pane,
.theme-dark .details,
.theme-dark .composer {
  background: #101a23;
  border-color: #233142;
}

.theme-dark .conversation-select,
.theme-dark .team-card,
.theme-dark .conversation-chip,
.theme-dark .team-search,
.theme-dark .conversation-search input,
.theme-dark #messageInput,
.theme-dark .composer-icon,
.theme-dark .template-button,
.theme-dark .file-request-button,
.theme-dark .team-action {
  background: #0f1720;
  border-color: #233142;
  color: #e7eef5;
}

.theme-dark .conversation-item.active .conversation-select {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(96, 165, 250, 0.35);
}

.theme-dark .conversation-status.is-waiting {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
}

.theme-dark .conversation-status.is-assigned {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.theme-dark .conversation-status.is-closed {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.theme-dark .conversation-chip-provider {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.22);
  color: #86efac;
}

.theme-dark .conversation-chip-status {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.22);
  color: #bfdbfe;
}

.theme-dark .conversation-chip {
  color: #dbe7f3;
}

.theme-dark .contact-company,
.theme-dark .conversation-assignee {
  color: #b7c6d6;
}

.theme-dark .conversation-chip strong {
  color: #f8fbff;
}

.conversation-subtitle {
  margin: 0;
  color: #667781;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
}

.conversation-subtitle.presence-online {
  color: #0a7c5b;
}

.conversation-subtitle.presence-offline {
  color: #667781;
}
