@media (min-width: 901px) {
    body { overflow: hidden; }
    .customer-main { display: flex; flex-direction: column; height: 100vh; padding-bottom: 24px; overflow: hidden; }
    .customer-main > header { flex: none; margin-bottom: 16px; }
    .channel-connections { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; flex: none; margin-bottom: 12px; }
    .channel-connections .connect-card,
    .channel-connections .channel-bar { min-width: 0; margin: 0; padding: 10px 13px; gap: 10px; border-radius: 12px; }
    .channel-connections .connect-card .connect-copy > p:last-child { display: none; }
    .channel-connections .connect-copy .eyebrow { margin-bottom: 1px; font-size: 9px; }
    .channel-connections .connect-card h2 { margin: 0; font-size: 14px; }
    .channel-connections .connect-card form { min-width: 0; gap: 7px; }
    .channel-connections .connect-card input { width: min(190px, 18vw); height: 36px; padding: 8px 10px; }
    .channel-connections .connect-card button,
    .channel-connections .channel-bar button { padding: 9px 11px; }
    .channel-connections .telegram-icon,
    .channel-connections .whatsapp-icon { width: 36px; height: 36px; border-radius: 10px; font-size: 17px; }
    .channel-connections .whatsapp-icon svg { width: 19px; height: 22px; }
    .channel-connections .channel-bar b,
    .channel-connections .channel-bar small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .channel-connections .channel-bar b { font-size: 12px; }
    .channel-connections .channel-bar small { margin-top: 1px; font-size: 9px; }
    .inbox { flex: 1; min-height: 0; }
    .inbox > aside,
    .chat { min-height: 0; }
    .inbox > aside:first-child,
    .details { overflow-y: auto; }
    .messages { min-height: 0; max-height: none; }
}

@media (max-width: 900px) {
    .channel-connections { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
    .channel-connections .connect-card,
    .channel-connections .channel-bar { margin-bottom: 0; }
}

.chat > header { flex-wrap: wrap; gap: 10px; height: auto; min-height: 78px; flex-shrink: 0; }
.facebook-page-options { display: grid; gap: 8px; margin: 14px 0 4px; }
.facebook-page-options label { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.facebook-page-options label:has(input:checked) { border-color: #1877f2; background: #f2f7ff; box-shadow: 0 0 0 2px #1877f21a; }
.facebook-page-options input { width: auto; margin: 0; }
.facebook-page-mark { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px; color: #fff; background: #1877f2; font-weight: 800; }
.facebook-page-options b,.facebook-page-options small { display: block; }
.facebook-page-options small { margin-top: 2px; color: var(--chat-muted, #748096); font-size: 10px; }
.facebook-page-dialog .whatsapp-dialog-actions a { display: inline-grid; place-items: center; padding: 10px 15px; border-radius: 9px; text-decoration: none; }
.chat > header > div:first-child { flex: 1; min-width: 120px; }

/* Ownership status and latest message time in every conversation row. */
.conversation { padding: 16px 15px; gap: 12px; align-items: flex-start; }
.conversation > div:nth-child(2) > b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.5; }
.conversation p { margin: 4px 0 9px; line-height: 1.5; }
.conversation-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 9px; }
.conversation-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.conversation-status.is-ai { color: #26715b; background: #eaf6ef; }
.conversation-status.is-human { color: #8c611b; background: #fff3dc; }
.status-dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.conversation-time { color: #7a879b; font-size: 10px; line-height: 1.5; white-space: nowrap; }
.conversation > i { flex-shrink: 0; font-style: normal; margin-top: 2px; }

/* Keep the destructive action away from the reply controls. */
.conversation-delete-form { margin: 20px 20px 0; padding-top: 16px; border-top: 1px solid #e6eaf0; }
.conversation-delete-form .delete-conversation { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 10px 12px; border: 1px solid #dce1e8; border-radius: 9px; color: #707b8d !important; background: #f3f5f7 !important; box-shadow: none !important; font-size: 12px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s; }
.conversation-delete-form .delete-conversation:hover { background: #e9edf2 !important; border-color: #c8d0dc; }
.conversation-delete-form .delete-conversation:focus-visible { outline: 2px solid #7b8da8; outline-offset: 3px; }
.conversation-delete-form svg { flex: none; }

/* The profile used to disappear on smaller screens; keep deletion accessible. */
@media (min-width: 901px) and (max-width: 1250px) {
    .inbox { overflow-y: auto; }
    .inbox > .customer-insights { display: block; grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
    .inbox > .chat { min-height: 540px; }
    .inbox > .chat .messages { max-height: 440px; }
}
@media (max-width: 900px) {
    .inbox > .customer-insights { display: block; border-left: 0; border-top: 1px solid var(--line); }
}

.customer-header-tools { display: flex; align-items: center; gap: 12px; }
.customer-live-status { color: #698177; font-size: 11px; }
.customer-live-status::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #35a47c; }
.customer-live-status.is-error { color: #986626; }
.customer-live-status.is-error::before { background: #c89443; }
.customer-system-alert { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 7px 8px 7px 14px; border: 1px solid #efb7bc; border-radius: 10px; background: #fff1f2; color: #8f2732; font-size: 11px; }
.customer-system-alert > a { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: inherit; text-decoration: none; }
.customer-system-alert strong { flex: none; font-size: 12px; }
.customer-system-alert span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-system-alert em { flex: none; margin-left: auto; color: #a23b45; font-style: normal; font-weight: 600; }
.customer-system-alert > button { flex: none; width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: #a75b63; box-shadow: none; font-size: 20px; line-height: 1; }
@media (max-width: 600px) { .customer-system-alert > a { align-items: flex-start; flex-wrap: wrap; } .customer-system-alert span { width: 100%; white-space: normal; } .customer-system-alert em { margin-left: 0; } }
.notification-settings { flex: none; margin-bottom: 12px; border: 1px solid #e0e7ef; background: #fff; border-radius: 11px; }
.notification-settings summary { display: flex; align-items: center; gap: 10px; padding: 11px 15px; cursor: pointer; font-size: 12px; font-weight: 600; list-style: none; }
.notification-settings summary::-webkit-details-marker { display: none; }
.notification-settings summary small { padding: 2px 7px; background: #f0f4f8; color: #6e8198; border-radius: 5px; font-size: 10px; }
.notification-settings-edit { margin-left: auto; font-weight: 400; color: #577aaa; }
.notification-settings form { padding: 0 15px 14px; }
.notification-phone { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.notification-phone label { display: grid; gap: 5px; font-size: 11px; color: #77849a; }
.notification-phone input { width: 210px; height: 38px; }
.notification-phone label:first-child input { width: 85px; }
.notification-phone button { width: auto; height: 38px; padding: 0 16px; }
.notification-phone .notification-disable { background: #fff; color: #64748b; border: 1px solid #d9e1eb; box-shadow: none; }
.notification-settings p { color: #8591a2; font-size: 11px; margin: 7px 0 0; }
.notification-settings .notification-warning { color: #a66b21; }
.customer-new-messages { align-self: center; font-size: 11px; padding: 6px 14px; margin: 5px; background: #edf4ff; color: #3476c1; border: 1px solid #d8e6fa; border-radius: 20px; box-shadow: none; }
.customer-new-messages[hidden] { display: none; }

.telegram-dialog .whatsapp-dialog-brand small { color: #229ed9; }

/* Customer service workspace */
.customer-dashboard {
    --customer-panel: #faf9ff;
    --customer-tint: #efeaff;
    --customer-line: #ded7f1;
    --customer-text: #1b1c3c;
    --customer-muted: #575d80;
    --customer-accent: #7138ed;
    --customer-primary: linear-gradient(155deg,#9b69f5,#6130eb);
    --customer-incoming: #eaf4ef;
    padding: 18px clamp(14px,2vw,26px) 20px;
    color: var(--customer-text);
    background: radial-gradient(ellipse at 84% 0%,#d7caf8,transparent 45%),linear-gradient(140deg,#f0edfc,#e9e8fa);
}
html[data-theme="dark"] .customer-dashboard {
    --customer-panel: #232339;
    --customer-tint: #302a48;
    --customer-line: #494162;
    --customer-text: #eee9ff;
    --customer-muted: #c2bad8;
    --customer-accent: #c2a7ff;
    --customer-incoming: #223c3a;
    background: radial-gradient(ellipse at 86% 0%,#463361,transparent 52%),#191a2d;
}
.customer-dashboard > .customer-hero {
    position: relative; isolation: isolate; display: grid; gap: 12px;
    margin: 0 0 14px; padding: 1px 8px; max-width: none;
}
.customer-hero-art {
    position: absolute; z-index: -1; right: 0; top: -18px; width: min(64%,760px); height: 100%;
    pointer-events: none; opacity: .92; mask-image: linear-gradient(to bottom,#000 75%,transparent);
}
.customer-dashboard .customer-hero .eyebrow { color: var(--customer-accent); margin: 0 0 4px; }
.customer-dashboard .customer-hero h1 {
    margin: 0; padding-left: 12px; border-inline-start: 5px solid #a97ef6;
    font-size: clamp(28px,3.25vw,46px); line-height: 1.08; color: var(--customer-text);
}
.customer-dashboard .customer-hero .subhead {
    margin: 5px 0 0; max-width: 68ch; font-size: 13px; color: var(--customer-muted);
}
.customer-hero-bottom { display: flex; align-items: center; gap: 12px; }
.customer-feature-strip { flex: 1; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.customer-feature {
    min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 9px;
    border-radius: 13px; background: var(--customer-panel); box-shadow: 0 5px 15px #6241a016;
}
.customer-feature-icon,.customer-chat-avatar {
    display: grid; place-items: center; width: 33px; height: 33px; flex: none;
    border-radius: 10px; color: var(--customer-accent); background: var(--customer-tint);
}
.customer-feature-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.customer-feature :is(b,small) { display: block; overflow-wrap: anywhere; }
.customer-feature b { font-size: 13px; }
.customer-feature small { color: var(--customer-muted); font-size: 10px; line-height: 1.35; }
.customer-dashboard .customer-header-tools { flex: none; flex-wrap: wrap; gap: 6px; }
.customer-dashboard .customer-header-tools button,.customer-dashboard .chat > header button:not(.secondary),.customer-dashboard .composer button {
    width: auto; background: var(--customer-primary); color: #fff; border-color: transparent;
    box-shadow: 0 3px 10px #7144d72e;
}
.customer-dashboard .customer-header-tools button {
    padding: 9px 12px; white-space: nowrap;
    background: var(--customer-primary) !important; color: #fff !important;
}
.customer-dashboard .customer-header-tools button::after { content: ' →'; }
.customer-dashboard .channel-connections { gap: 9px; margin-bottom: 12px; }
.customer-dashboard .channel-connections :is(.channel-bar,.connect-card) {
    min-width: 0; padding: 8px 10px; border: 1px solid var(--customer-line);
    border-radius: 15px; background: var(--customer-panel); box-shadow: 0 5px 12px #6241a01a;
}
.customer-dashboard .channel-bar :is(b,small) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-dashboard .channel-bar small { color: var(--customer-muted); }
.customer-connected { flex: none; padding: 3px 7px; border-radius: 999px; color: #126532; background: #d9f4e2; font-size: 10px; white-space: nowrap; }
.customer-channel-menu { position: relative; flex: none; }
.customer-channel-menu summary {
    display: grid; place-items: center; width: 24px; height: 28px; cursor: pointer;
    list-style: none; color: var(--customer-muted); font-weight: 800; font-size: 17px;
}
.customer-channel-menu summary::-webkit-details-marker { display: none; }
.customer-dashboard .customer-channel-menu form {
    position: absolute; z-index: 4; top: 100%; right: 0; width: max-content; padding: 5px;
    border-radius: 10px; background: var(--customer-panel); border: 1px solid var(--customer-line); box-shadow: 0 5px 12px #6241a030;
}
.customer-dashboard .customer-channel-menu button { color: var(--customer-text); background: var(--customer-tint); border-color: var(--customer-line); }
.customer-dashboard .inbox { gap: 9px; background: none; border: 0; border-radius: 0; box-shadow: none; }
.customer-dashboard .inbox > :is(aside,.chat) {
    min-width: 0; border: 1px solid var(--customer-line); border-radius: 16px; background: var(--customer-panel); color: var(--customer-text);
}
.customer-dashboard .inbox > aside:first-child > h2 {
    position: sticky; top: 0; z-index: 2; padding: 13px 12px; color: var(--customer-text);
    background: var(--customer-panel); border-bottom: 1px solid var(--customer-line);
}
.customer-dashboard .conversation {
    margin: 3px 5px; padding: 9px 7px; border-inline-start: 3px solid transparent; border-radius: 10px;
}
.customer-dashboard .conversation:is(:hover,.selected) { background: var(--customer-tint); }
.customer-dashboard .conversation.selected { border-inline-start-color: var(--customer-accent); }
.customer-dashboard .conversation :is(b,p,time) { color: var(--customer-text); }
.customer-dashboard .conversation .avatar { border-radius: 50%; }
.customer-dashboard .conversation-status { border-radius: 999px; }
.customer-dashboard .conversation-status.is-ai { background: var(--customer-tint); color: var(--customer-accent); }
.customer-dashboard .chat > header { min-height: 60px; padding: 8px 12px; border-color: var(--customer-line); }
.customer-dashboard .customer-chat-identity { display: flex; align-items: center; gap: 8px; }
.customer-chat-identity > div { min-width: 0; overflow-wrap: anywhere; }
.customer-chat-avatar { border-radius: 50%; color: #fff; background: #159ad4; }
.customer-chat-avatar[data-provider="whatsapp"] { background: #1cb95b; }
.customer-chat-avatar[data-provider="facebook"] { background: linear-gradient(150deg,#a543ea,#167afa); }
.customer-chat-avatar svg { width: 17px; height: 19px; }
.customer-dashboard .chat > header small { color: var(--customer-muted); }
.customer-dashboard .messages { background: linear-gradient(155deg,var(--customer-panel),var(--customer-tint)); }
.customer-dashboard .messages .message-body { color: var(--customer-text); border-color: var(--customer-line); }
.customer-dashboard .messages .incoming .message-body { background: var(--customer-incoming); }
.customer-dashboard .messages .outgoing .message-body { background: var(--customer-tint); }
.customer-dashboard .messages .outgoing[data-sender="ai"] {
    position: relative; margin-left: 32px; max-width: calc(100% - 32px); padding: 7px;
    background: var(--customer-panel); border: 1px solid var(--customer-line); border-radius: 13px;
}
.customer-dashboard .messages .outgoing[data-sender="ai"]::before {
    content: "✦" / ""; position: absolute; top: 0; left: -33px;
    display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
    background: var(--customer-primary); color: #fff;
}
.customer-dashboard .messages .outgoing[data-sender="ai"] .message-body {
    margin-left: 0; background: var(--customer-tint); border-radius: 10px;
}
.customer-dashboard .messages .outgoing[data-sender="ai"] small { text-align: left; font-weight: 700; }
.customer-dashboard .messages .message :is(time,small) { color: var(--customer-muted); }
.customer-dashboard .composer { margin: 7px; padding: 7px; border: 1px solid var(--customer-line); border-radius: 13px; background: var(--customer-panel); }
.customer-dashboard .composer textarea { min-width: 0; }
.customer-dashboard .customer-insights .details-head { padding: 12px; }
.customer-dashboard .details-head .eyebrow { color: var(--customer-accent); }
.customer-dashboard .customer-insights :is(.profile-card,.intent-card,.memory-card,.knowledge-record-card) {
    border-color: var(--customer-line); background: var(--customer-panel);
}
.customer-dashboard .intent-track > span { background: var(--customer-primary); }
.customer-dashboard :is(a,button,summary):focus-visible { outline: 2px solid var(--customer-accent); outline-offset: 2px; }
@media (min-width: 1180px) {
    .customer-dashboard .inbox { grid-template-columns: minmax(185px,.8fr) minmax(0,1.45fr) minmax(230px,1.02fr); overflow: hidden; }
    .customer-dashboard .inbox > .customer-insights { display: block; grid-column: auto; overflow-y: auto; }
    .customer-dashboard .inbox > .chat { min-height: 0; }
    .customer-dashboard .inbox > .chat .messages { max-height: none; }
}
@media (min-width: 901px) and (max-width: 1179px) {
    .customer-dashboard .inbox { grid-template-columns: minmax(175px,.6fr) minmax(0,1.4fr); }
}
@media (max-width: 900px) {
    .customer-dashboard .inbox { display: grid; grid-template-columns: minmax(0,1fr); }
    .customer-dashboard .channel-connections { grid-template-columns: repeat(auto-fit,minmax(min(100%,195px),1fr)); }
    .customer-hero-bottom { align-items: stretch; flex-direction: column; }
    .customer-dashboard .customer-header-tools { align-self: flex-end; margin: 0; }
}
@media (max-width: 650px) {
    .customer-hero-art { opacity: .35; }
    .customer-feature-strip { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .customer-dashboard .channel-connections :is(.channel-bar,.connect-card) { flex-direction: row; align-items: center; }
    .customer-dashboard .channel-connections .connect-card form { width: auto; margin: 0; }
}
