:root { color-scheme: light; font: 16px system-ui, sans-serif; color: #182b28; background: #edf3f1; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; }
header { background: #123e37; color: white; padding: 18px 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.header-actions { display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.header-actions button { font-size: .875rem; white-space: nowrap; color: #123e37; }
.header-actions button:hover { background: #e4f3ee; }
header strong { font-size: 1.22rem; }
header span { font-size: .875rem; text-align: right; color: #dcf3ea; }
.sound-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; font-size: .875rem; }
.sound-controls input { width: 84px; margin: 0; padding: 0; accent-color: #b6ebd8; }
.sound-controls span { min-width: 4ch; font-variant-numeric: tabular-nums; }
#notice { margin: 0; padding: 10px 26px; background: #fff2ce; }
main { display: grid; grid-template-columns: minmax(245px, 330px) minmax(0, 1fr); flex: 1; min-height: 0; }
aside { background: white; padding: 22px 16px; border-right: 1px solid #d8e4e0; max-height: calc(100dvh - 75px); overflow: auto; }
h1, h2 { margin: 0 0 13px; font-size: 1.3rem; }
input, select, button { font: inherit; }
input, select { border: 1px solid #a8bdb6; border-radius: 8px; padding: 10px; width: 100%; min-width: 0; background: white; color: inherit; }
aside select { margin: 9px 0 15px; }
button { cursor: pointer; border: 1px solid #a8bdb6; color: inherit; background: white; padding: 8px 12px; border-radius: 8px; }
button:disabled { opacity: .6; cursor: wait; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #18736b; outline-offset: 2px; }
.chat-card { width: 100%; display: grid; text-align: left; padding: 12px; gap: 7px; margin-bottom: 5px; border-color: transparent; }
.chat-card:hover, .chat-card[aria-pressed=true] { background: #e4f3ee; }
.chat-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-weight: 680; }
small, .snippet { color: #4b655e; font-size: .875rem; font-weight: 400; }
.snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags, #labels { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 9px; font-size: .875rem; border-radius: 100px; border: 1px solid transparent; }
button.chip[aria-pressed=false] { background: white; border-color: currentColor; }
button.chip[aria-pressed=true]::before { content: '✓ '; }
.blue { color: #174571; background: #d9eafd; }
.violet { color: #523486; background: #ece2fc; }
.amber { color: #694400; background: #ffedc2; }
.green { color: #285534; background: #d9efda; }
.rose { color: #872a47; background: #fce0ea; }
.teal { color: #135851; background: #d1f0e9; }
.thread { display: grid; grid-template-rows: auto minmax(180px, 1fr) auto; height: calc(100dvh - 62px); }
.thread-head, form { background: white; padding: 16px 22px; border-bottom: 1px solid #d8e4e0; }
.conversation-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.conversation-heading h2 { margin: 0; }
.conversation-heading button { font-size: .875rem; padding: 4px 8px; }
#contact-avatar { position: relative; display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; overflow: hidden; border-radius: 50%; background: #d9efe6; color: #145f52; font-size: .85rem; font-weight: 700; }
#contact-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#messages { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.bubble { width: fit-content; max-width: min(84%, 650px); background: white; border-radius: 10px 10px 10px 2px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.own { align-self: flex-end; background: #d9efe6; border-radius: 10px 10px 2px 10px; }
.bubble small { display: block; text-align: right; margin-top: 5px; }
.delivery-ticks { margin-inline-start: 6px; color: #526964; letter-spacing: -0.12em; font-weight: 700; }
.delivery-ticks[data-delivery="read"] { color: #00649b; }
.attachment-card { display: grid; gap: 6px; }
.attachment-card button { justify-self: start; font-size: .875rem; }
.attachment-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.attachment-preview img, .attachment-preview video { display: block; max-width: 100%; max-height: 26rem; border-radius: 6px; }
.attachment-preview pre { margin: 0; padding: 8px; max-height: 18rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: #f4f8f6; border-radius: 6px; }
audio { max-width: 100%; }
.compose-row { display: flex; flex-wrap: wrap; gap: 8px; }
.compose-row input { flex: 1 1 200px; }
#send { background: #145f52; border-color: #145f52; color: white; }
[hidden] { display: none !important; }
@media(max-width: 650px) {
  main { display: block; }
  aside { max-height: 43dvh; border-right: 0; border-bottom: 1px solid #d8e4e0; }
  .thread { height: 65dvh; }
  header, .thread-head, form, #messages { padding-left: 14px; padding-right: 14px; }
}

.assignment { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; flex-wrap: wrap; }
.assignment select { width: auto; padding: 4px 8px; }
.assignment button { padding: 3px 8px; }
.assignee { font-size: .875rem; color: #145f52; font-weight: 650; }
dialog { border: 1px solid #a8bdb6; border-radius: 12px; width: min(480px, 94vw); max-height: 90dvh; color: #182b28; }
dialog::backdrop { background: #172e28ac; }
dialog h2, dialog h3 { margin: 0; }
.dialog-title, #members li { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
#members { list-style: none; padding: 0; }
#members li { padding: 8px 0; border-bottom: 1px solid #d8e4e0; }
.team-form { display: grid; gap: 10px; padding: 0; border: 0; }
.team-form label { display: grid; gap: 4px; }
.team-form [type=submit] { justify-self: start; background: #145f52; color: white; }
.login-intro, .login-help, .login-support { margin: 0; line-height: 1.5; }
.login-intro { font-weight: 600; }
.login-help, .login-support { color: #50635e; font-size: .875rem; }
.login-support { border-top: 1px solid #d8e4e0; padding-top: 12px; }
.login-support a { color: #145f52; }

.password-field { display: grid; gap: 4px; }
.password-input { position: relative; }
.password-input input { padding-right: 49px; }
.password-input button { position: absolute; right: 4px; top: 4px; bottom: 4px; display: grid; place-items: center; border: 0; padding: 0 9px; }
.password-input button:hover { background: #e4f3ee; }
.password-input button[aria-pressed="false"] .eye-slash { display: none; }
.member-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.member-actions button { font-size: .875rem; padding: 5px 8px; }

#staff-chat { width: min(790px, 96vw); margin: 82px max(2vw, 12px) auto auto; }
.staff-layout { display: grid; grid-template-columns: minmax(155px, 1fr) minmax(0, 2.4fr); gap: 14px; margin-top: 14px; }
.staff-sidebar { border-right: 1px solid #d8e4e0; padding-right: 12px; overflow: auto; max-height: 60vh; }
.staff-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#staff-threads { display: grid; gap: 4px; margin-top: 8px; }
#staff-threads button { text-align: left; overflow-wrap: anywhere; }
#staff-threads button[aria-pressed=true] { background: #d9efe6; }
#staff-people { display: grid; gap: 7px; max-height: 38vh; overflow: auto; }
#staff-people label { display: flex; align-items: center; }
#staff-people input { width: auto; }
#staff-messages { display: flex; flex-direction: column; gap: 8px; height: min(43dvh, 390px); overflow: auto; background: #edf3f1; border-radius: 8px; padding: 9px; margin: 8px 0; }
#staff-send { padding: 0; border: 0; }
#staff-text { flex: 1; }
#staff-status { color: #872a47; margin-bottom: 0; }
@media (max-width: 540px) {
  #staff-chat { margin: 8px auto auto; }
  .staff-layout { grid-template-columns: minmax(0, 1fr); }
  .staff-sidebar { max-height: 21dvh; border: 0; padding: 0; }
}

.inbox-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.unread-badge { display: inline-block; justify-self: start; border-radius: 999px; background: #e8efec; color: #28463d; padding: 3px 8px; font-size: .8rem; font-weight: 700; }
.unread-badge.has-unread { background: #145f52; color: white; }

#whatsapp-unread { border: 1px solid transparent; }
#whatsapp-unread:hover { border-color: currentColor; }
#whatsapp-unread[aria-pressed=true] { box-shadow: inset 0 0 0 1px currentColor; }
#whatsapp-unread[aria-pressed=true]::before { content: '✓ '; }

main.has-notes { grid-template-columns: minmax(210px, 300px) minmax(0, 1fr) minmax(220px, 300px); }
#conversation-notes { border-left: 1px solid #d8e4e0; border-right: 0; min-width: 0; }
#notes-form { display: grid; gap: 7px; padding: 0 0 14px; }
#notes-form textarea { resize: vertical; width: 100%; padding: 8px; font: inherit; color: inherit; border: 1px solid #a8bdb6; border-radius: 8px; }
#notes-form input[type=file] { padding: 6px; font-size: .85rem; }
#notes-form button { justify-self: start; background: #145f52; color: white; }
#notes-status { font-size: .875rem; color: #28463d; }
.note-card { border-bottom: 1px solid #d8e4e0; padding: 10px 0; }
.note-card p { margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-images { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.note-images img { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: 6px; }
#notes-more { margin-top: 8px; }
@media (min-width: 651px) and (max-width: 820px) {
  main.has-notes { grid-template-columns: 175px minmax(0, 1fr) 190px; }
}
@media (max-width: 650px) {
  #conversation-notes { border-left: 0; max-height: none; }
}

.header-brand { display: flex; align-items: center; gap: 12px; }
#main-menu-toggle { color: #123e37; white-space: nowrap; font-size: .875rem; }
.desk-layout { display: flex; flex: 1; min-height: 0; position: relative; }
.desk-layout > main { min-width: 0; }
#main-menu {
  flex: 0 0 140px;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #f7fbf9;
  border-right: 1px solid #d8e4e0;
}
#main-menu button { text-align: left; border-color: transparent; background: transparent; }
#main-menu button:hover { background: #e4f3ee; }
#main-menu button[aria-pressed=true] { background: #ccece0; font-weight: 650; }
#sign-out { margin-top: 8px; }
@media (max-width: 820px) {
  #main-menu { position: absolute; z-index: 2; top: 0; left: 0; width: 165px; box-shadow: 0 6px 18px #123e3726; }
}
@media (max-width: 540px) {
  header { flex-wrap: wrap; gap: 8px; }
}
main.customers-view { grid-template-columns: minmax(0, 1fr); }
main.customers-view.has-notes { grid-template-columns: minmax(0, 1fr) minmax(230px, 32%); }
#customers-panel { min-width: 0; overflow: auto; padding: 22px; max-height: calc(100dvh - 75px); }
#customers-search { max-width: 480px; }
.customers-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 12px; }
.customers-heading button { font-size: .875rem; }
#customers-list { margin-top: 14px; max-width: 850px; }
.customer-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #d8e4e0; padding: 6px 0; }
.customer-row > button { flex: 1; min-width: 0; text-align: left; overflow-wrap: anywhere; }
.customer-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.customer-actions button { font-size: .875rem; white-space: nowrap; }
.customer-row button[aria-pressed=true] { background: #e4f3ee; border-color: #18736b; }
.customer-row small { display: block; margin-top: 4px; }
#customers-more { margin-top: 12px; }
@media (max-width: 650px) { #customers-panel { padding: 14px; max-height: 55dvh; } }

.compose-row textarea { flex: 1 1 200px; min-width: 0; min-height: 42px; resize: vertical; font: inherit; color: inherit; background: white; border: 1px solid #a8bdb6; border-radius: 8px; padding: 9px 10px; }
.compose-row textarea:focus-visible { outline: 3px solid #18736b; outline-offset: 2px; }
#quick-replies-picker { max-height: 205px; overflow: auto; background: white; border: 1px solid #a8bdb6; border-radius: 8px; margin-bottom: 8px; padding: 4px; }
#quick-replies-picker button { display: flex; flex-direction: column; gap: 3px; text-align: left; width: 100%; border: 0; }
#quick-replies-picker button.active, #quick-replies-picker button:hover { background: #e0f1ec; }
#quick-replies-picker button span { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#quick-replies-picker p { padding: 4px 8px; margin: 0; }

#quick-replies-list { max-height: 240px; overflow-y: auto; }
.saved-quick-reply { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid #d8e4df; }
.saved-quick-reply p { grid-column: 1 / -1; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
#quick-replies-body { font: inherit; resize: vertical; }

.saved-quick-reply-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
