* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #172033;
  background: #f4f6fa;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 24px;
  background: #fff;
  border-bottom: 1px solid #e4e8ef;
}

.brand-logo {
  display: block;
  flex: 0 1 210px;
  width: 210px;
  height: 60px;
  object-fit: contain;
  object-position: left center;
}

h1 {
  margin: 0;
  font-size: 23px;
}

h2 {
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid #edf0f5;
  font-size: 16px;
}

button {
  padding: 10px 15px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #263b80;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover:not(:disabled) {
  color: #fff !important;
  background: #1e306d;
  box-shadow: 0 3px 8px rgba(38, 59, 128, 0.22);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  box-shadow: none;
  transform: translateY(0);
}

button:focus-visible {
  outline: 3px solid rgba(38, 59, 128, 0.35);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

main {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 1400px;
  height: calc(100vh - 74px);
  margin: auto;
  padding: 16px;
}

aside,
.chat {
  min-width: 0;
  min-height: 0;
  border: 1px solid #e4e8ef;
  border-radius: 12px;
  background: #fff;
}

aside {
  overflow: auto;
}

.conversation-search {
  padding: 12px 16px 16px;
  border-bottom: 1px solid #edf0f5;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  background: #fff;
}

.search-box svg {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: #6c7485;
  stroke-width: 2;
  stroke-linecap: round;
}

.search-box input {
  width: 100%;
  min-width: 0;
  padding: 10px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
}

.search-box:focus-within {
  border-color: #5265a8;
  box-shadow: 0 0 0 2px rgba(82, 101, 168, 0.14);
}

.conversation-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #edf0f5;
}

.conversation-filters label {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #50596b;
  font-size: 13px;
  font-weight: 600;
}

/* Agents don't need the inbox-wide filter controls; admins keep them. */
.agent-view .conversation-filters {
  display: none !important;
}

/* Agents use the standard reply composer; hide admin/shortcut message tools. */
.agent-view .composer-tools {
  display: none !important;
}

.agent-view .assignee-edit,
.agent-view #profile-panel {
  display: none !important;
}

.conversation-filters select,
.conversation-controls select,
.conversation-controls input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  color: #172033;
  background: #fff;
  font: inherit;
  font-size: 13px;
}

.conversation-filters select:focus,
.conversation-controls select:focus,
.conversation-controls input:focus {
  border-color: #5265a8;
  outline: 2px solid rgba(82, 101, 168, 0.14);
}

.conversation-controls select:disabled,
.conversation-controls input:disabled {
  color: #7b8494;
  background: #f4f6fa;
}

.item {
  padding: 13px 15px;
  border-bottom: 1px solid #edf0f5;
  cursor: pointer;
}

.item:hover,
.item.active {
  background: #eef2ff;
}

.item strong {
  display: block;
  color: #30343b;
  font-weight: 500;
}

.item.unread strong {
  color: #d93025;
  font-weight: 700;
}
.item small {
  color: #6c7485;
}

.preview {
  overflow: hidden;
  color: #50596b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.conversation-labels span {
  padding: 2px 7px;
  border-radius: 999px;
  color: #344985;
  background: #eef2ff;
  font-size: 11px;
}

.chat {
  display: flex;
  flex-direction: column;
}

.chat-title {
  padding: 16px;
  border-bottom: 1px solid #edf0f5;
  font-weight: 700;
}

.conversation-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid #edf0f5;
}

.conversation-controls label {
  display: grid;
  flex: 0 1 150px;
  gap: 4px;
  min-width: 0;
  color: #50596b;
  font-size: 12px;
  font-weight: 600;
}

.conversation-controls .labels-edit {
  flex: 1 1 220px;
}

.conversation-controls button {
  flex: 0 0 auto;
}

.messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 20px 5%;
  background: #efeae2;
}

.bubble {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-self: flex-start;
  justify-content: flex-start;
  gap: 4px;
  width: fit-content;
  max-width: min(75%, 620px);
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 8px 10px 6px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
  color: #111b21;
  font-size: 14px;
  line-height: 1.45;
}

.bubble.outbound {
  align-self: flex-end;
  background: #d9fdd3;
}

.message-text {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  color: #667781;
  font-size: 11px;
  line-height: 1.2;
}

.date-separator {
  display: flex;
  flex: 0 0 auto;
  align-self: stretch;
  justify-content: center;
  margin: 8px 0;
}

.date-separator span {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 8px;
  color: #54656f;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
  font-size: 12px;
}.empty {
  color: #6c7485;
}

#reply-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #edf0f5;
}

#reply {
  flex: 1;
  min-width: 0;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  font: inherit;
  line-height: 1.4;
  resize: none;
}

.note {
  margin: 0;
  padding: 0 14px 12px;
  color: #6c7485;
  font-size: 12px;
}

@media (max-width: 760px) {
  header {
    gap: 10px;
    padding: 12px;
  }

  .brand-logo {
    flex-basis: 125px;
    width: 125px;
    height: 36px;
  }

  h1 {
    font-size: 17px;
  }

  header button {
    padding: 9px 11px;
  }

  main {
    grid-template-columns: 1fr;
    height: auto;
    padding: 8px;
  }

  aside {
    max-height: 420px;
  }

  .chat {
    height: 65vh;
  }

  .conversation-filters label {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .conversation-controls label {
    flex: 1 1 120px;
  }
  .conversation-controls .labels-edit {
    flex-basis: 100%;
  }
}

.date-separator {
  flex: 0 0 auto;
  align-self: center;
  margin: 8px 0;
}

.date-separator span {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 8px;
  color: #54656f;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
  font-size: 12px;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  color: #667781;
  font-size: 11px;
  line-height: 1.2;
}

.message-status {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -3px;
  padding-right: 3px;
}

.message-status.sent,
.message-status.delivered {
  color: #8696a0;
}

.message-status.read {
  color: #53bdeb;
}

.message-status.failed {
  color: #d93025;
  letter-spacing: normal;
}

/* Priority, profile fields, and staff-only internal notes */
[hidden] {
  display: none !important;
}

.priority-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #344985;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.priority-urgent {
  background: #fde8e7;
  color: #b42318;
}

.priority-high {
  background: #fff0db;
  color: #9a5700;
}

.priority-low {
  background: #edf7ef;
  color: #28723b;
}

.assignment-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5ee;
  color: #26734d;
  font-size: 11px;
}

.profile-panel {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-bottom: 1px solid #edf0f5;
}

.profile-panel summary {
  color: #344985;
  font-weight: 700;
  cursor: pointer;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 8px;
  padding-top: 10px;
}

.profile-form label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: #50596b;
  font-size: 12px;
  font-weight: 600;
}

.profile-form input,
.profile-form textarea,
.profile-form select {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
}

.profile-form textarea {
  resize: vertical;
}

.profile-notes-field {
  grid-column: span 2;
}

#profile-feedback {
  color: #28723b;
  font-size: 12px;
}

.message-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 6px 10px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid #d9deea;
  background: #fff;
}

.message-tabs button {
  padding: 7px 12px;
  border-radius: 7px 7px 0 0;
  color: #50596b;
  background: transparent;
}

.message-tabs button:hover:not(:disabled) {
  background: #263b80;
  box-shadow: none;
  transform: none;
}

.message-tabs button.active {
  color: #263b80;
  background: #eef2ff;
}

.internal-notes-panel {
  background: #fffdf5;
}

.internal-note {
  align-self: stretch;
  padding: 10px 12px;
  border: 1px solid #f0dfa6;
  border-radius: 8px;
  background: #fff8dc;
}

.internal-note p {
  margin: 0 0 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.internal-note small {
  color: #6c7485;
  font-size: 11px;
}

#internal-note-form {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #edf0f5;
  background: #fff;
}

#internal-note-input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

@media (max-width: 900px) {
  .profile-form {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .profile-notes-field {
    grid-column: span 2;
  }
}

@media (max-width: 560px) {
  .profile-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .profile-notes-field {
    grid-column: auto;
  }

  #internal-note-form {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Preserve enough room for recent messages; short screens can scroll the page. */
main {
  min-height: 840px;
}

.chat {
  min-height: 0;
  overflow: hidden;
}

.chat-title,
.conversation-controls,
.profile-panel,
.message-tabs,
#reply-form,
.note {
  flex: 0 0 auto;
}

.messages {
  flex: 1 1 0%;
  min-height: 340px;
}

#profile-panel[open] {
  max-height: min(40vh, 360px);
  overflow-y: auto;
}

#profile-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding-top: 6px;
}

#profile-form textarea {
  height: 42px;
  min-height: 42px;
}

.whatsapp-consent-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  min-width: 0;
  margin: 2px 0;
  padding: 10px;
  border: 1px solid #d9deea;
  border-radius: 8px;
}

.whatsapp-consent-fields legend,
.consent-category-heading {
  color: #344985;
  font-size: 12px;
  font-weight: 700;
}

.whatsapp-consent-fields > label,
.whatsapp-consent-fields > select,
.whatsapp-consent-fields > textarea,
.whatsapp-consent-fields > .form-help,
.consent-category-heading,
.consent-category-list,
.whatsapp-consent-history,
#whatsapp-consent-timestamp {
  grid-column: 1 / -1;
}

.whatsapp-consent-fields > select,
.whatsapp-consent-fields > textarea {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
}

.consent-category-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.consent-category-list label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: #50596b;
  font-size: 12px;
  font-weight: 400;
}

.consent-category-list input {
  width: auto;
  margin: 2px 0 0;
}

.whatsapp-consent-history ul {
  display: grid;
  gap: 6px;
  margin: 6px 0 0;
  padding-left: 18px;
}

.whatsapp-consent-history li small {
  display: block;
  color: #667085;
  font-size: 11px;
}

#reply-form {
  padding: 8px;
}

#reply {
  height: 48px;
  min-height: 48px;
  max-height: 48px;
}

.note {
  padding: 0 12px 8px;
}

@media (max-width: 900px) {
  #profile-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  main {
    min-height: 0;
    height: auto;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .chat {
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .messages {
    flex: 0 0 auto;
    height: clamp(220px, 42dvh, 420px);
    min-height: 220px;
    max-height: none;
  }

  #profile-panel[open] {
    max-height: none;
    overflow: visible;
  }

  #reply-form {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

/* Keep the full reply notice visible */
#reply-note {
  flex-shrink: 0;
  line-height: 1.5;
  padding: 0 14px 14px;
}

.chat {
  overflow: hidden;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.current-user {
  color: #50596b;
  font-size: 13px;
}

.push-notification-status {
  color: #667085;
  font-size: 12px;
  max-width: 190px;
}

.users-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 20px;
  border: 1px solid #d9deea;
  border-radius: 14px;
  color: #172033;
}

.inbox-settings-dialog {
  width: min(760px, calc(100vw - 24px));
}

.inbox-settings-form {
  display: grid;
  gap: 14px;
}

.inbox-automation-section {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid #d9deea;
  border-radius: 10px;
  background: #fbfcff;
}

.inbox-settings-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
}

.inbox-settings-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #293f88;
}

.inbox-automation-section > label:not(.inbox-settings-toggle) {
  color: #50596b;
  font-size: 13px;
}

.inbox-automation-section textarea,
.inbox-automation-section > input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  font: inherit;
}

.inbox-automation-section .form-help {
  margin: 0;
}

.business-hours-days {
  display: grid;
  gap: 7px;
  margin-top: 4px;
}

.business-hours-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(105px, 1fr) auto minmax(105px, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid #e5e8ef;
  border-radius: 8px;
  background: #fff;
}

.business-hours-row label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.business-hours-row input[type="checkbox"] {
  accent-color: #293f88;
}

.business-hours-row input[type="time"] {
  min-width: 0;
  padding: 7px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
}

.inbox-settings-actions {
  display: flex;
  justify-content: flex-end;
}

.business-hours-notice {
  margin: 0 0 10px;
  padding: 9px 12px;
  border: 1px solid #f0d39a;
  border-radius: 8px;
  background: #fff8e8;
  color: #815500;
  font-size: 13px;
}

@media (max-width: 560px) {
  .business-hours-row {
    grid-template-columns: minmax(80px, 1fr) minmax(95px, 1fr) auto minmax(95px, 1fr);
    gap: 5px;
    padding: 7px 5px;
    font-size: 12px;
  }

  .business-hours-row input[type="time"] {
    padding: 6px 3px;
    font-size: 12px;
  }
}

/* Keep the whole composer inside the viewport on compact laptop screens. */
body {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

header {
  flex: 0 0 auto;
}

.push-notification-status {
  display: none !important;
}

main {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.chat {
  min-height: 0;
}

.messages {
  flex: 1 1 0%;
  min-height: 0;
}

#reply-form {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  min-width: 0;
}

#reply-form > *,
.reply-input-row,
.reply-input-wrap {
  min-width: 0;
  max-width: 100%;
}

#reply-note {
  max-width: 100%;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  main {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
  }

  .chat {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .messages {
    flex: 0 0 auto;
    height: clamp(200px, 38dvh, 380px);
    min-height: 200px;
  }

  #reply-form {
    box-sizing: border-box;
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .reply-input-row {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .reply-input-row {
    grid-template-columns: minmax(0, 1fr) 46px;
  }

  .reply-input-wrap,
  #reply {
    width: 100%;
    min-width: 0;
  }

  #send.send-button {
    align-self: stretch;
  }
}

/* Final viewport-fit overrides: keep the composer from being clipped by the chat. */
body {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

main {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.chat {
  min-height: 0;
}

.messages {
  min-height: 0;
}

#reply-form {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
}

.reply-input-row,
.reply-input-wrap,
#reply {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 760px) {
  main {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
  }

  .chat {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .messages {
    flex: 0 0 auto;
    height: clamp(200px, 38dvh, 380px);
    min-height: 200px;
  }

  #reply-form {
    box-sizing: border-box;
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

.users-dialog::backdrop {
  background: rgba(23, 32, 51, 0.42);
}

.reset-agent-password-dialog {
  width: min(480px, calc(100vw - 24px));
}

.reset-agent-password-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.reset-agent-password-form label {
  display: grid;
  gap: 5px;
  color: #50596b;
  font-size: 13px;
}

.reset-agent-password-form input {
  width: 100%;
  min-width: 0;
  padding: 11px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  font: inherit;
}

.reset-agent-password-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#reset-agent-password-feedback:not(:empty) {
  margin: 0;
  font-size: 13px;
}

.users-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.users-dialog-heading h2 {
  padding: 0;
  border: 0;
}

.contacts-dialog {
  width: min(620px, calc(100vw - 24px));
}

.contacts-heading-actions,
.saved-contact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.saved-contact-form {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #d9deea;
  border-radius: 10px;
  background: #f8f9fc;
}

.saved-contact-form h3 {
  margin: 0;
}

.saved-contact-form > div:last-child {
  display: flex;
  gap: 8px;
}

.contacts-search-label {
  display: block;
  margin: 14px 0 6px;
  color: #50596b;
  font-size: 13px;
}

#saved-contact-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  font: inherit;
}

.saved-contacts-list {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 480px);
  overflow: auto;
  margin-top: 12px;
}

.saved-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e4e8ef;
  border-radius: 9px;
}

.saved-contact-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.saved-contact-row > div span {
  color: #667085;
  font-size: 12px;
}

.saved-contact-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 520px) {
  .contacts-heading-actions {
    align-items: flex-end;
    flex-direction: column-reverse;
  }

  .saved-contact-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .saved-contact-actions {
    justify-content: flex-start;
  }
}

.template-required-note {
  margin: 8px 14px;
  color: #795400;
  font-size: 12px;
}

.template-send-button {
  margin: 0;
}

.composer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 8px;
}

.composer-tools > button {
  width: 150px;
  height: 44px;
  margin: 0;
}

.quick-replies-dialog {
  width: min(680px, calc(100vw - 24px));
}

.interactive-message-dialog {
  width: min(560px, calc(100vw - 28px));
}

.quick-reply-list {
  display: grid;
  gap: 8px;
  max-height: min(38vh, 340px);
  overflow: auto;
  margin: 12px 0 18px;
}

.quick-reply-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid #e4e8ef;
  border-radius: 8px;
}

.quick-reply-row > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.quick-reply-row p {
  margin: 5px 0;
  white-space: pre-wrap;
}

.quick-reply-row span,
.quick-reply-row small {
  display: block;
  color: #667085;
  font-size: 11px;
}

.quick-reply-row > div:last-child {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.quick-reply-row button,
.quick-reply-delete {
  padding: 6px 9px;
  font-size: 11px;
}

.quick-reply-delete {
  color: #a12222;
  background: #fdecec;
}

.template-variable-fields {
  display: grid;
  gap: 8px;
}

.template-variable-fields label {
  display: grid;
  gap: 5px;
  color: #50596b;
  font-size: 13px;
}

.template-variable-fields input,
#approved-template-select,
#template-header-format,
#interactive-kind {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
}

.template-header-preview {
  display: block;
  width: min(100%, 360px);
  max-height: 240px;
  object-fit: contain;
  border: 1px solid #d9deea;
  border-radius: 8px;
  background: #f8f9fc;
}

.template-preview-box {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  background: #f8f9fc;
  font-size: 13px;
}

.template-preview-box pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
}

.campaign-dialog {
  width: min(760px, calc(100vw - 24px));
}

#campaign-template,
#campaign-image,
#campaign-search {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  background: #fff;
  font: inherit;
}

.campaign-audience-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #293f88;
}

.campaign-audience-heading label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.campaign-audience-heading input,
.campaign-recipient input {
  width: 18px;
  height: 18px;
  accent-color: #293f88;
}

.campaign-audience-list {
  display: grid;
  gap: 6px;
  max-height: min(34vh, 300px);
  overflow: auto;
  padding: 2px;
}

.campaign-recipient {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  padding: 9px 10px;
  border: 1px solid #e4e8ef;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.campaign-recipient span {
  display: grid;
  gap: 2px;
}

.campaign-recipient small {
  color: #667085;
}

#campaign-feedback {
  margin: 0;
  color: #344054;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .campaign-audience-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

.interactive-message {
  display: grid;
  gap: 6px;
  min-width: 160px;
  max-width: min(330px, 65vw);
  white-space: pre-wrap;
}

.interactive-message > small {
  color: #667085;
  font-size: 10px;
}

.interactive-choices {
  display: grid;
  gap: 4px;
  margin-top: 3px;
}

.interactive-choice {
  display: block;
  padding: 5px 8px;
  border: 1px solid #dce2ef;
  border-radius: 6px;
  color: #344985;
  background: #fff;
  font-size: 11px;
}

.interactive-choice small {
  display: block;
  color: #667085;
  font-size: 10px;
}

.team-management {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #e4e8ef;
  border-radius: 10px;
}

.team-management h3,
.add-user-heading {
  margin: 0 0 10px;
  color: #263b80;
  font-size: 15px;
}

.create-team-form {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.create-team-form label {
  color: #50596b;
  font-size: 13px;
}

.create-team-form input,
#delete-reassign-to {
  min-width: 0;
  padding: 9px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
}

.create-team-form p {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
}

.team-list ul {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.team-list li {
  padding: 4px 9px;
  border-radius: 999px;
  color: #344985;
  background: #eef2ff;
  font-size: 12px;
}

.team-list .empty {
  margin: 8px 0 0;
  font-size: 12px;
}

.add-user-heading {
  margin: 18px 0 0;
}

.secondary-button {
  color: #263b80;
  background: #eef2ff;
}

.create-user-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 1fr) 140px 140px auto;
  align-items: end;
  gap: 10px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid #e4e8ef;
  border-radius: 10px;
}

.create-user-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #50596b;
  font-size: 12px;
}

.create-user-form input,
.create-user-form select {
  width: 100%;
  min-width: 0;
  padding: 9px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
}

.form-help,
#user-form-feedback {
  grid-column: 1 / -1;
  margin: 0;
  color: #667085;
  font-size: 12px;
}

#user-form-feedback:not(:empty) {
  color: #b42318;
}

.user-table-wrap {
  overflow-x: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.user-table th,
.user-table td {
  padding: 9px;
  border-bottom: 1px solid #e4e8ef;
  white-space: nowrap;
}

.user-table th {
  color: #50596b;
  font-size: 12px;
}

.user-table button {
  padding: 6px 9px;
  font-size: 12px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-table .delete-user-button {
  color: #a12222;
  background: #fdecec;
}

.user-table .delete-user-button:hover:not(:disabled) {
  background: #a12222;
}

.delete-user-dialog {
  width: min(480px, calc(100vw - 24px));
}

.delete-conversation-dialog {
  width: min(480px, calc(100vw - 28px));
}

.delete-conversation-form {
  display: grid;
  gap: 10px;
}

#delete-conversation-feedback {
  margin: 0;
  color: #b42318;
  font-size: 12px;
}

.delete-conversation-button {
  margin-top: 8px;
  padding: 5px 8px;
  color: #a12222;
  background: #fdecec;
  font-size: 11px;
}

.delete-conversation-button:hover:not(:disabled) {
  background: #a12222;
}

.delete-conversation-dialog .delete-user-button {
  color: #a12222;
  background: #fdecec;
}

#delete-user-dialog .delete-user-button {
  color: #a12222;
  background: #fdecec;
}

#delete-user-dialog .delete-user-button:hover:not(:disabled) {
  background: #a12222;
}

.delete-user-dialog h2 {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
}

.delete-user-dialog > p {
  color: #50596b;
}

.delete-user-form {
  display: grid;
  gap: 10px;
}

.delete-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

#delete-user-feedback:not(:empty) {
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid #e4e8ef;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(23, 32, 51, 0.08);
}

.auth-card h1 {
  margin-bottom: 8px;
}

.auth-card p {
  color: #667085;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  color: #50596b;
  font-size: 13px;
}

.auth-form input {
  width: 100%;
  padding: 11px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  font: inherit;
}

.auth-error {
  min-height: 1.4em;
  color: #b42318 !important;
  font-size: 13px;
}

@media (max-width: 760px) {
  header {
    flex-wrap: wrap;
  }

  header h1 {
    flex: 1;
    text-align: center;
  }

  .header-actions {
    flex-wrap: wrap;
    margin-left: auto;
  }

  .create-user-form {
    grid-template-columns: 1fr 1fr;
  }

  .create-team-form {
    grid-template-columns: 1fr auto;
  }

  .create-team-form label {
    grid-column: 1 / -1;
  }
}

/* Emoji picker and contextual reply controls */
#reply-form {
  flex-direction: column;
  gap: 8px;
}

#reply-form.template-only {
  gap: 6px;
  padding: 8px 12px;
}

#reply-form.template-only #reply-context,
#reply-form.template-only #media-attachment-preview {
  display: none;
}

#reply-form.template-only .template-required-note {
  margin: 2px 4px;
}

#reply-form.template-only .template-send-button {
  margin: 0;
}

#reply-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-left: 3px solid #263b80;
  border-radius: 6px;
  background: #eef2ff;
  color: #344985;
  font-size: 12px;
}

#reply-context[hidden] {
  display: none;
}

#reply-context > div {
  display: grid;
  min-width: 0;
}

#reply-context-text {
  overflow: hidden;
  color: #50596b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reply-context button {
  padding: 1px 8px;
  color: #344985;
  background: transparent;
  font-size: 20px;
}

.reply-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.reply-utility-buttons {
  display: contents;
}

.attach-media-button {
  flex: 0 0 auto;
  align-self: stretch;
  padding: 8px 12px;
  color: #344985;
  background: #eef2ff;
  font-size: 20px;
}

.send-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.send-button-icon {
  display: none;
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.media-attachment-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  color: #344985;
  background: #f7f8fc;
  font-size: 12px;
}

.media-attachment-preview[hidden] {
  display: none;
}

.media-attachment-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-attachment-preview button {
  flex: 0 0 auto;
  padding: 0 6px;
  color: #344985;
  background: transparent;
  font-size: 18px;
}

.reply-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

#reply {
  display: block;
  width: 100%;
  min-width: 0;
  padding-left: 48px;
}

.emoji-picker-toggle {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 7px;
  width: 34px;
  height: 34px;
  padding: 4px;
  transform: translateY(-50%);
  color: #344985;
  background: transparent;
  font-size: 20px;
}

.emoji-picker-toggle:hover:not(:disabled) {
  background: #263b80;
  box-shadow: none;
  transform: translateY(-50%);
}

.emoji-picker {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 8px);
  left: 0;
  display: grid;
  box-sizing: border-box;
  width: min(320px, calc(100vw - 32px));
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
  padding: 8px;
  border: 1px solid #d9deea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.18);
  overflow: hidden;
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-picker button {
  display: grid;
  width: 100%;
  min-width: 0;
  place-items: center;
  padding: 5px 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 21px;
  line-height: 1.1;
}

.emoji-picker button:hover {
  background: #263b80;
  box-shadow: none;
  transform: none;
}

.reply-quote {
  display: grid;
  gap: 2px;
  max-width: 100%;
  padding: 5px 8px;
  border-left: 3px solid #5269a8;
  border-radius: 4px;
  background: rgba(38, 59, 128, 0.08);
  color: #344985;
  font-size: 11px;
}

.message-media-link {
  display: block;
  max-width: min(360px, 60vw);
}

.image-preview-button {
  display: block;
  width: fit-content;
  max-width: min(360px, 60vw);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  cursor: zoom-in;
}

.image-preview-button:hover:not(:disabled) {
  background: transparent;
  box-shadow: none;
  transform: none;
}

.message-media {
  display: block;
  width: auto;
  max-width: min(360px, 60vw);
  max-height: 320px;
  border-radius: 8px;
  object-fit: contain;
}

.video-preview {
  display: grid;
  width: min(360px, 60vw);
  min-height: 150px;
  aspect-ratio: 16 / 9;
  place-content: center;
  justify-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #344985, #172033);
  cursor: pointer;
}

.video-preview:hover:not(:disabled) {
  background: linear-gradient(135deg, #405aa2, #263b80);
  box-shadow: none;
  transform: none;
}

.video-preview-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  padding-left: 3px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  font-size: 20px;
}

.video-preview-label {
  font-size: 12px;
}

.message-video {
  width: min(360px, 60vw);
  height: auto;
  aspect-ratio: 16 / 9;
  background: #111;
}

.message-sticker {
  width: 160px;
  height: 160px;
  border-radius: 0;
}

.message-audio {
  display: block;
  width: min(300px, 60vw);
  max-width: 100%;
}

.message-document {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(360px, 60vw);
  padding: 9px 11px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  color: #263b80;
  background: #fff;
  text-decoration: none;
}

.message-document span {
  overflow-wrap: anywhere;
}

.location-card,
.contact-card {
  display: grid;
  gap: 5px;
  max-width: min(320px, 60vw);
  padding: 10px 12px;
  border: 1px solid #d9deea;
  border-radius: 9px;
  color: #172033;
  background: #fff;
  text-decoration: none;
}

a.location-card:hover {
  background: #f7f8fc;
}

.location-pin {
  font-size: 24px;
}

.location-card small,
.contact-card a {
  color: #52649a;
  overflow-wrap: anywhere;
}

.save-shared-contact {
  justify-self: start;
  padding: 5px 9px;
  color: #263b80;
  background: #eef2ff;
  font-size: 12px;
}

.save-shared-contact:hover:not(:disabled) {
  background: #263b80;
  box-shadow: none;
  transform: none;
}

.save-shared-contact.is-saved {
  color: #28723b;
  background: #edf7ef;
}

.location-map-link {
  color: #263b80;
  font-size: 12px;
  font-weight: 700;
}

.contact-cards {
  display: grid;
  gap: 6px;
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.message-reactions span {
  min-width: 28px;
  padding: 2px 6px;
  border: 1px solid #d9deea;
  border-radius: 999px;
  background: #fff;
  text-align: center;
}

.structured-message-form {
  display: grid;
  gap: 10px;
}

.structured-message-form label {
  display: grid;
  gap: 5px;
  color: #50596b;
  font-size: 13px;
}

.structured-message-form input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
}

.structured-message-form textarea {
  width: 100%;
  min-width: 0;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #d9deea;
  border-radius: 7px;
  font: inherit;
}

.reaction-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reaction-options button {
  min-width: 44px;
  min-height: 42px;
  padding: 6px;
  font-size: 21px;
}

.reaction-options .remove-reaction {
  width: 100%;
  font-size: 13px;
}

.bubble.outbound .reply-quote {
  border-left-color: #25805b;
  color: #25634d;
}

.reply-quote span:last-child {
  overflow: hidden;
  color: #50596b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-to-message {
  margin-right: auto;
  padding: 0 4px;
  color: #52649a;
  background: transparent;
  font-size: 10px;
  font-weight: 500;
}

.reply-to-message:hover:not(:disabled) {
  background: #263b80;
  box-shadow: none;
  transform: none;
}

.message-action-menu {
  position: relative;
  order: 99;
  flex: 0 0 auto;
  margin-right: 0;
  color: #344985;
}

.message-action-menu > summary {
  display: grid;
  width: 22px;
  height: 20px;
  place-items: center;
  border-radius: 5px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  list-style: none;
}

.message-action-menu > summary::-webkit-details-marker {
  display: none;
}

.message-action-menu > summary:hover {
  background: #263b80;
}

.message-action-menu-items {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  display: grid;
  min-width: 180px;
  max-height: 70vh;
  overflow-y: auto;
  visibility: hidden;
  padding: 5px;
  border: 1px solid #d9deea;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.2);
}

.message-action-dialog-heading form {
  margin: 0;
}

.image-preview-dialog {
  width: min(1000px, calc(100vw - 28px));
  max-width: 1000px;
  max-height: calc(100vh - 28px);
  padding: 12px;
  border: 1px solid #d9deea;
  border-radius: 12px;
  background: #fff;
}

.image-preview-dialog::backdrop {
  background: rgba(23, 32, 51, 0.72);
}

#image-preview-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 110px);
  margin: 0 auto;
  object-fit: contain;
}

.message-action-menu-items button {
  width: 100%;
  padding: 7px 10px;
  border-radius: 5px;
  color: #172033;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.message-action-menu-items button:hover:not(:disabled) {
  background: #263b80;
  box-shadow: none;
  transform: none;
}

.message-action-menu-items .message-delete-action:hover:not(:disabled) {
  background: #a12222;
}

.message-action-menu-items .message-delete-action {
  margin-top: 4px;
  border-top: 1px solid #edf0f5;
  color: #b42318;
}

.message-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: #52649a;
  font-size: 10px;
}

.message-action-dialog {
  width: min(440px, calc(100vw - 28px));
  max-width: 440px;
  padding: 16px;
  border: 1px solid #d9deea;
  border-radius: 12px;
  color: #172033;
}

.message-action-dialog::backdrop {
  background: rgba(23, 32, 51, 0.35);
}

.message-action-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.message-action-dialog-heading h2 {
  padding: 0;
  border: 0;
}

#message-info-details {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
  font-size: 13px;
}

#message-info-details dt {
  color: #52649a;
  font-weight: 600;
}

#message-info-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

#forward-message-form {
  display: grid;
  gap: 10px;
}

#forward-message-form .form-help,
#forward-feedback {
  margin: 0;
  font-size: 12px;
}

@media (max-width: 760px) {
  #reply-form {
    padding: 8px;
  }
}

@media (max-width: 600px) {
  .reply-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 7px;
  }

  .reply-utility-buttons {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 1;
    gap: 7px;
  }

  .reply-utility-buttons .attach-media-button {
    width: 42px;
    height: 42px;
    padding: 6px;
  }

  .reply-input-wrap {
    grid-column: 1;
    grid-row: 2;
  }

  #send.send-button {
    grid-column: 2;
    grid-row: 2;
    width: 46px;
    min-width: 46px;
    height: 48px;
    padding: 0;
    border-radius: 11px;
  }

  .send-button-label {
    display: none;
  }

  .send-button-icon {
    display: block;
  }

  #reply {
    padding-left: 42px;
  }
}

/* Bound the conversation history so it scrolls independently of the composer. */
@media (min-width: 761px) {
  body {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  main {
    flex: 1 1 0%;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  aside,
  .chat {
    min-height: 0;
  }

  .messages {
    flex: 0 1 auto;
    height: clamp(160px, 36vh, 400px);
    height: clamp(160px, 36dvh, 400px);
    min-height: 160px;
    max-height: 40vh;
    max-height: 40dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  main {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .chat {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .messages {
    flex: 0 0 auto;
    height: clamp(180px, 36vh, 320px);
    height: clamp(180px, 36dvh, 320px);
    min-height: 180px;
    max-height: 320px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* Final sizing: cap history and reserve the lower chat area for replying. */
@media (min-width: 761px) {
  body {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  main {
    flex: 1 1 0%;
    height: 0;
    min-height: 0;
    overflow: hidden;
  }

  .chat {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .chat-title,
  .conversation-controls,
  .profile-panel,
  .message-tabs,
  #reply-form,
  #reply-note {
    flex-shrink: 0;
  }

  .messages {
    flex: 1 1 0%;
    height: 34vh;
    height: 34dvh;
    min-height: 0;
    max-height: 34vh;
    max-height: 34dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  main {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .chat {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .messages {
    flex: 0 0 auto;
    height: clamp(180px, 32vh, 280px);
    height: clamp(180px, 32dvh, 280px);
    min-height: 180px;
    max-height: 280px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #reply-form,
  #reply-note {
    flex-shrink: 0;
  }
}

/* Balanced inbox layout: keep actions and composer visible while history scrolls. */
@media (min-width: 1200px) {
  body {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  header {
    min-height: 72px;
    padding: 4px 18px;
  }

  main {
    flex: 1 1 0%;
    height: 0;
    min-height: 0;
    grid-template-columns: minmax(260px, 25%) minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    overflow: hidden;
  }

  aside,
  .chat {
    min-height: 0;
  }

  .chat {
    height: 100%;
    overflow: hidden;
  }

  .chat-title {
    padding: 12px 16px;
  }

  .conversation-controls {
    display: grid;
    grid-template-columns: minmax(90px, .8fr) minmax(90px, .8fr) minmax(130px, 1fr) minmax(150px, 1.25fr) auto auto auto;
    align-items: end;
    gap: 7px;
    padding: 8px 10px;
  }

  .conversation-controls label,
  .conversation-controls .labels-edit {
    width: auto;
    min-width: 0;
    font-size: 11px;
  }

  .conversation-controls select,
  .conversation-controls input {
    height: 38px;
    padding: 5px 8px;
  }

  .conversation-controls button {
    height: 38px;
    padding: 6px 10px;
    white-space: nowrap;
    font-size: 12px;
  }

  .message-tabs button {
    padding: 8px 12px;
  }

  .messages {
    flex: 1 1 0%;
    height: 34vh;
    height: 34dvh;
    min-height: 120px;
    max-height: 38vh;
    max-height: 38dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  #reply-form {
    flex: 0 0 auto;
    gap: 5px;
    padding: 7px 9px;
  }

  #reply-form > .business-hours-notice,
  #reply-form > .template-required-note,
  #reply-form > .form-help {
    margin: 0;
    padding-top: 5px;
    padding-bottom: 5px;
    font-size: 12px;
    line-height: 1.3;
  }

  #reply-form > .business-hours-notice {
    padding-right: 9px;
    padding-left: 9px;
  }

  .composer-tools {
    gap: 7px;
    margin: 0;
  }

  .composer-tools > button {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 13px;
  }

  .reply-input-row {
    min-height: 48px;
    gap: 7px;
  }

  .reply-input-row .attach-media-button {
    min-width: 44px;
    min-height: 48px;
    padding: 6px 9px;
  }

  #reply {
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    padding-top: 9px;
    padding-bottom: 9px;
  }

  #send.send-button {
    min-height: 48px;
    padding: 8px 16px;
  }

  #reply-note {
    flex: 0 0 auto;
    margin: 0;
    padding: 2px 10px 7px;
    font-size: 11px;
    line-height: 1.3;
  }
}

@media (min-width: 761px) and (max-width: 1199px) {
  .conversation-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
    gap: 7px;
    padding: 8px;
  }

  .conversation-controls label,
  .conversation-controls .labels-edit {
    min-width: 0;
    flex: initial;
  }

  .conversation-controls button {
    height: 38px;
    padding: 6px 9px;
    white-space: nowrap;
    font-size: 12px;
  }

  .messages {
    min-height: 120px;
  }
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  main {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .chat {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .conversation-controls {
    gap: 7px;
    padding: 8px;
  }

  .messages {
    flex: 0 0 auto;
    height: clamp(180px, 30vh, 260px);
    height: clamp(180px, 30dvh, 260px);
    min-height: 180px;
    max-height: 260px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #reply-form {
    flex: 0 0 auto;
    padding: 7px 9px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  #reply-note {
    flex: 0 0 auto;
    padding: 2px 10px 8px;
  }
}

/* Natural page scrolling: history is bounded, but the reply section is never clipped. */
html,
body {
  height: auto !important;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

body {
  display: block !important;
}

main {
  display: grid;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  align-items: start;
}

aside {
  align-self: start;
  max-height: calc(100vh - 110px);
  max-height: calc(100dvh - 110px);
  overflow-y: auto;
}

.chat {
  height: auto !important;
  max-height: none !important;
  min-height: 0;
  overflow: visible !important;
  align-self: start;
}

.messages {
  flex: 0 0 auto !important;
  height: clamp(220px, 34vh, 320px) !important;
  height: clamp(220px, 34dvh, 320px) !important;
  min-height: 220px !important;
  max-height: 320px !important;
  overflow-x: hidden;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

#reply-form {
  display: flex !important;
  flex: 0 0 auto !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0;
  overflow: visible !important;
  position: static !important;
}

#reply-form.template-only .reply-input-row {
  display: flex;
}

#reply-note {
  display: block;
  flex: 0 0 auto;
  height: auto;
  overflow: visible;
}

@media (max-width: 760px) {
  main {
    grid-template-columns: minmax(0, 1fr);
  }

  aside {
    max-height: min(38vh, 320px);
  }

  .messages {
    height: clamp(180px, 30vh, 260px) !important;
    height: clamp(180px, 30dvh, 260px) !important;
    min-height: 180px !important;
    max-height: 260px !important;
  }
}

@media (max-width: 600px) {
  .reply-input-row,
  #reply-form.template-only .reply-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
  }
}

/* Hide the informational banners while keeping all underlying rules active. */
#business-hours-notice,
#whatsapp-consent-required-note {
  display: none !important;
}

/* Keep the conversation list tall enough on small screens while preserving its own scroll. */
@media (max-width: 760px) {
  aside {
    height: min(72dvh, 620px);
    max-height: none;
    min-height: 280px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.app-footer {
  padding: 12px 16px;
  border-top: 1px solid #223675;
  color: #fff;
  background: #293f88;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 600px) {
  .app-footer {
    padding: 10px 12px;
    line-height: 1.4;
  }
}

/* Keep the brand watermark behind the transcript without changing message flow. */
#messages {
  position: relative;
  isolation: isolate;
}

#messages::before {
  content: "Ravemora Global";
  position: sticky;
  z-index: -1;
  top: 50%;
  align-self: center;
  flex: 0 0 0;
  height: 0;
  margin-bottom: 0;
  width: max-content;
  max-width: 86%;
  color: rgba(41, 63, 136, 0.16);
  font-size: clamp(22px, 3vw, 42px);
  font-style: italic;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
  pointer-events: none;
  user-select: none;
  transform: translateY(-50%) rotate(-12deg);
}

/* Keep the brand bars aligned to the inbox's maximum width. */
header,
.app-footer {
  width: min(100%, 1400px);
  margin-inline: auto;
}

/* Compact each conversation into a name/time row and a preview/details row. */
.item {
  position: relative;
  padding: 8px 10px;
}

.conversation-summary,
.conversation-name,
.conversation-details {
  display: flex;
  min-width: 0;
  align-items: center;
}

.conversation-summary {
  justify-content: space-between;
  gap: 7px;
  min-height: 20px;
}

.conversation-name {
  flex: 1 1 auto;
  gap: 4px;
  overflow: hidden;
}

.conversation-name strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-name .pin-indicator {
  flex: 0 0 auto;
  font-size: 11px;
}

.conversation-timestamp {
  flex: 0 1 auto;
  max-width: 48%;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-details {
  gap: 4px;
  min-height: 20px;
  margin-top: 2px;
  padding-right: 28px;
}

.conversation-details .preview {
  flex: 1 1 0;
  min-width: 20px;
  font-size: 12px;
}

.conversation-details .priority-badge {
  display: inline-flex;
  flex: 0 0 20px;
  width: 20px;
  height: 18px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  font-size: 10px;
}

.conversation-details .assignment-badge {
  flex: 0 1 auto;
  max-width: 38%;
  overflow: hidden;
  margin: 0;
  padding: 2px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.conversation-details .conversation-labels {
  flex: 0 1 auto;
  max-width: 20%;
  flex-wrap: nowrap;
  overflow: hidden;
  margin: 0;
}

.conversation-details .conversation-labels span {
  flex: 0 0 auto;
  overflow: hidden;
  max-width: 60px;
  padding: 1px 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
}

.item .delete-conversation-button {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  margin: 0;
  padding: 4px;
  border-radius: 6px;
  color: #a12222;
  background: #fdecec;
}

.item .delete-conversation-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

@media (max-width: 760px) {
  header,
  .app-footer {
    width: 100%;
  }

  .conversation-timestamp {
    max-width: 46%;
  }
}

.auth-logo {
  display: block;
  width: min(250px, 100%);
  height: 82px;
  margin: 0 0 14px;
  object-fit: contain;
  object-position: left center;
}

/* The composer helper is redundant; keep the composer and all media actions visible. */
#reply-note {
  display: none !important;
}

/* Keep the sidebar controls fixed; only the conversation list scrolls. */
@media (min-width: 761px) {
  main {
    align-items: stretch;
  }

  .chat {
    align-self: stretch;
  }

  aside {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: hidden;
  }

  .conversations-heading,
  .conversation-search,
  .conversation-filters {
    flex: 0 0 auto;
  }

  #conversations {
    flex: 0 0 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 760px) {
  aside {
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: hidden;
  }

  .conversations-heading,
  .conversation-search,
  .conversation-filters {
    flex: 0 0 auto;
  }

  #conversations {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
