:root {
    color-scheme: light;
    --bg: #eef1f7;
    --surface: #ffffff;
    --surface-subtle: #f7f8fb;
    --surface-elevated: #ffffff;
    --surface-hover: #f2f5fb;
    --border: #e2e6ef;
    --border-strong: #d3d9e6;
    --text: #101828;
    --text-soft: #344054;
    --muted: #667085;
    --muted-light: #98a2b3;
    --primary: #1769e0;
    --primary-strong: #0d54c2;
    --primary-soft: #eaf2ff;
    --primary-glow: rgba(23, 105, 224, 0.18);
    --success: #12b76a;
    --success-soft: #eafbf3;
    --warning: #f79009;
    --warning-soft: #fff7e6;
    --danger: #d92d20;
    --danger-soft: #fff0ee;
    --rail: #0b1020;
    --rail-soft: #151c32;
    --chat-bg: #f3f5f9;
    --incoming: #ffffff;
    --outgoing: #1769e0;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 4px 14px rgba(16, 24, 40, 0.07);
    --shadow-md: 0 12px 32px rgba(16, 24, 40, 0.12);
    --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.16);
    --rail-width: 72px;
    --sidebar-width: 342px;
    --details-width: 306px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #080d19;
    --surface: #111827;
    --surface-subtle: #151e2f;
    --surface-elevated: #182235;
    --surface-hover: #1b263a;
    --border: #263247;
    --border-strong: #344158;
    --text: #f2f4f7;
    --text-soft: #d0d5dd;
    --muted: #98a2b3;
    --muted-light: #667085;
    --primary: #4c8dff;
    --primary-strong: #6aa0ff;
    --primary-soft: rgba(76, 141, 255, 0.14);
    --primary-glow: rgba(76, 141, 255, 0.22);
    --success-soft: rgba(18, 183, 106, 0.12);
    --warning-soft: rgba(247, 144, 9, 0.12);
    --danger-soft: rgba(217, 45, 32, 0.13);
    --rail: #050811;
    --rail-soft: #12192a;
    --chat-bg: #0c1321;
    --incoming: #182235;
    --outgoing: #2f73e8;
    --shadow-sm: 0 5px 18px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 14px 38px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid var(--primary-glow);
    outline-offset: 2px;
}

svg {
    display: block;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Authentication screens */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 14% 16%, rgba(23, 105, 224, 0.18), transparent 32%),
        radial-gradient(circle at 88% 82%, rgba(113, 75, 228, 0.16), transparent 34%),
        var(--bg);
}

.auth-card {
    width: min(100%, 540px);
    padding: 42px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 28px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: var(--shadow-lg);
    text-align: center;
    backdrop-filter: blur(14px);
}

.auth-card h1 {
    margin: 18px 0 10px;
    font-size: clamp(29px, 5vw, 42px);
    letter-spacing: -0.045em;
    line-height: 1.08;
}

.brand-mark {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin: 0 auto;
    border-radius: 20px;
    color: #fff;
    background: linear-gradient(145deg, #1769e0, #7259e8);
    box-shadow: 0 14px 30px rgba(23, 105, 224, 0.28);
    font-size: 28px;
    font-weight: 850;
}

.eyebrow {
    margin: 0;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.muted,
.security-note {
    color: var(--muted);
    line-height: 1.65;
}

.security-note {
    margin: 18px 0 0;
    font-size: 12px;
}

.facebook-button,
.primary-button {
    width: 100%;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    padding: 12px 22px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #4a79ee);
    box-shadow: 0 10px 24px var(--primary-glow);
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.facebook-button:hover,
.primary-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow: 0 14px 28px var(--primary-glow);
}

.page-selection-form {
    margin-top: 24px;
}

.page-options {
    display: grid;
    gap: 10px;
    text-align: left;
}

.page-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-subtle);
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.page-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.page-option span {
    display: grid;
    gap: 3px;
}

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

/* Dashboard shell */
.dashboard-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.support-app {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr) var(--details-width);
    overflow: hidden;
    background: var(--surface);
}

.support-app.details-collapsed {
    grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr) 0;
}

/* Navigation rail */
.app-rail {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 12px;
    background:
        radial-gradient(circle at 50% 0%, rgba(77, 111, 255, 0.22), transparent 35%),
        var(--rail);
    color: #fff;
    z-index: 30;
}

.rail-brand {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #2d7bf1, #7654e8);
    box-shadow: 0 11px 26px rgba(40, 104, 235, 0.34);
}

.rail-brand svg {
    width: 25px;
    height: 25px;
    fill: #fff;
}

.rail-brand .rail-brand-cut {
    fill: #2f72e7;
}

.rail-nav {
    width: 100%;
    display: grid;
    justify-items: center;
    gap: 10px;
    margin-top: 34px;
}

.rail-bottom {
    width: 100%;
    display: grid;
    justify-items: center;
    gap: 15px;
    margin-top: auto;
}

.rail-button {
    position: relative;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 13px;
    color: #8791aa;
    background: transparent;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.rail-button svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
}

.rail-button svg path[stroke],
.rail-button .theme-icon-sun {
    fill: none;
}

.rail-button:hover:not(:disabled),
.rail-button.active {
    color: #fff;
    background: var(--rail-soft);
    transform: translateY(-1px);
}

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

.rail-active-indicator {
    position: absolute;
    left: -12px;
    width: 3px;
    height: 22px;
    border-radius: 0 4px 4px 0;
    background: #5c91ff;
    box-shadow: 0 0 12px rgba(92, 145, 255, 0.7);
}

.theme-icon-sun {
    display: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
}

html[data-theme="dark"] .theme-icon-moon {
    display: none;
}

html[data-theme="dark"] .theme-icon-sun {
    display: block;
}

.rail-agent {
    position: relative;
    width: 39px;
    height: 39px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.14);
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(145deg, #344054, #20283a);
    font-weight: 800;
}

.rail-agent::after {
    content: "";
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--rail);
    border-radius: 50%;
    background: var(--success);
}

/* Inbox sidebar */
.inbox-sidebar {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
    z-index: 20;
}

.inbox-header {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 10px;
}

.page-identity {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.page-avatar,
.contact-avatar,
.details-avatar,
.agent-avatar-small {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(145deg, #2675e8, #7058df);
    font-weight: 850;
    box-shadow: var(--shadow-xs);
}

.page-avatar {
    width: 43px;
    height: 43px;
    border-radius: 14px;
}

.page-copy {
    min-width: 0;
}

.page-label {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.page-copy h1 {
    max-width: 220px;
    margin: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button,
.mini-icon-button,
.header-action,
.copy-mini-button,
.search-clear {
    border: 0;
    background: transparent;
    cursor: pointer;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--muted);
    transition: color 0.18s ease, background 0.18s ease;
}

.icon-button:hover {
    color: var(--text);
    background: var(--surface-hover);
}

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

.mobile-close,
.mobile-menu-button {
    display: none;
}

.inbox-connection-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 18px 14px;
}

.connection-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    color: #067647;
    background: var(--success-soft);
    font-size: 10px;
    font-weight: 750;
}

.connection-pill span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.12);
}

.connection-pill.offline {
    color: var(--danger);
    background: var(--danger-soft);
}

.connection-pill.offline span {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.12);
}

.sync-copy {
    overflow: hidden;
    color: var(--muted-light);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-box {
    position: relative;
    margin: 0 16px 14px;
}

.search-box > svg {
    position: absolute;
    left: 13px;
    top: 50%;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: var(--muted-light);
    stroke-width: 1.9;
    stroke-linecap: round;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    height: 42px;
    padding: 0 37px 0 39px;
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: 0;
    color: var(--text);
    background: var(--surface-subtle);
    font-size: 12px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.search-box input::placeholder {
    color: var(--muted-light);
}

.search-box input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-clear {
    position: absolute;
    right: 9px;
    top: 50%;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--muted);
    transform: translateY(-50%);
}

.search-clear:hover {
    background: var(--surface-hover);
}

.inbox-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin: 0 16px 13px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-subtle);
}

.inbox-tab {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 7px;
    border: 0;
    border-radius: 9px;
    color: var(--muted);
    background: transparent;
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.inbox-tab span {
    min-width: 18px;
    padding: 2px 5px;
    border-radius: 999px;
    background: var(--border);
    font-size: 9px;
}

.inbox-tab.active {
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.inbox-tab.active span {
    color: var(--primary);
    background: var(--primary-soft);
}

.conversation-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.mini-icon-button {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--muted);
}

.mini-icon-button:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.mini-icon-button.loading svg,
.header-action.loading svg {
    animation: spin 0.75s linear infinite;
}

.mini-icon-button svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.conversation-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 9px 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.conversation-item {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: 45px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 3px;
    padding: 11px 10px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--text);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.conversation-item:hover {
    background: var(--surface-hover);
}

.conversation-item.active {
    border-color: color-mix(in srgb, var(--primary) 23%, var(--border));
    background: var(--primary-soft);
}

.conversation-item.active::before {
    content: "";
    position: absolute;
    left: -4px;
    width: 3px;
    height: 31px;
    border-radius: 999px;
    background: var(--primary);
}

.conversation-avatar {
    position: relative;
    width: 45px;
    height: 45px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: var(--avatar-gradient, linear-gradient(145deg, #3379e7, #6b5adf));
    font-size: 14px;
    font-weight: 850;
    box-shadow: var(--shadow-xs);
}

.conversation-avatar .channel-dot {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 15px;
    height: 15px;
    display: grid;
    place-items: center;
    border: 2px solid var(--surface);
    border-radius: 50%;
    color: #fff;
    background: #1683ff;
    font-size: 8px;
    font-weight: 900;
}

.conversation-copy {
    min-width: 0;
}

.conversation-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin-bottom: 4px;
}

.conversation-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    font-size: 12.5px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.needs-reply-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.conversation-preview {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item.needs-reply .conversation-preview {
    color: var(--text-soft);
    font-weight: 600;
}

.conversation-side {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 7px;
    padding: 2px 0;
}

.conversation-time {
    color: var(--muted-light);
    font-size: 9.5px;
    white-space: nowrap;
}

.reply-state-mini {
    padding: 3px 6px;
    border-radius: 999px;
    color: #067647;
    background: var(--success-soft);
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
}

.conversation-item.needs-reply .reply-state-mini {
    color: #b54708;
    background: var(--warning-soft);
}

.conversation-skeleton {
    display: grid;
    grid-template-columns: 45px minmax(0, 1fr) 28px;
    gap: 10px;
    align-items: center;
    padding: 11px 10px;
}

.conversation-skeleton > span,
.conversation-skeleton i,
.conversation-skeleton em {
    display: block;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--surface-subtle), var(--border), var(--surface-subtle));
    background-size: 200% 100%;
    animation: shimmer 1.35s infinite;
}

.conversation-skeleton > span {
    width: 45px;
    height: 45px;
    border-radius: 14px;
}

.conversation-skeleton div {
    display: grid;
    gap: 8px;
}

.conversation-skeleton i:first-child {
    width: 60%;
    height: 10px;
}

.conversation-skeleton i:last-child {
    width: 88%;
    height: 8px;
}

.conversation-skeleton em {
    width: 27px;
    height: 8px;
}

.no-conversations {
    display: grid;
    place-items: center;
    padding: 44px 22px;
    color: var(--muted);
    text-align: center;
    line-height: 1.55;
}

.no-conversations svg {
    width: 34px;
    height: 34px;
    margin-bottom: 10px;
    fill: none;
    stroke: var(--muted-light);
    stroke-width: 1.5;
}

.inbox-footer {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.agent-mini-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.agent-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 12px;
}

.agent-avatar-small span,
.contact-avatar span,
.details-avatar span {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--success);
}

.agent-mini-card > div:last-child {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.agent-mini-card strong,
.agent-mini-card small {
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-mini-card strong {
    font-size: 11px;
}

.agent-mini-card small {
    color: var(--muted);
    font-size: 9.5px;
}

.logout-form {
    margin: 0;
}

.logout-button:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

/* Main workspace */
.chat-workspace {
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: var(--chat-bg);
}

.empty-state {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    overflow: hidden;
}

.empty-state::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.4;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: radial-gradient(circle at center, black 0, transparent 68%);
    pointer-events: none;
}

.empty-visual {
    position: relative;
    width: 190px;
    height: 190px;
    display: grid;
    place-items: center;
    margin-bottom: 15px;
}

.empty-orbit {
    position: absolute;
    border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
    border-radius: 50%;
}

.orbit-one {
    width: 154px;
    height: 154px;
    animation: slow-spin 18s linear infinite;
}

.orbit-one::after,
.orbit-two::after {
    content: "";
    position: absolute;
    top: 12px;
    left: 18px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 18px var(--primary);
}

.orbit-two {
    width: 112px;
    height: 112px;
    border-style: dashed;
    animation: slow-spin 12s linear infinite reverse;
}

.orbit-two::after {
    top: auto;
    left: auto;
    right: 7px;
    bottom: 18px;
    width: 6px;
    height: 6px;
    background: #7857e7;
}

.empty-message-icon {
    position: relative;
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
    border-radius: 24px;
    color: var(--primary);
    background: var(--surface);
    box-shadow: 0 18px 46px var(--primary-glow);
    z-index: 2;
}

.empty-message-icon svg {
    width: 38px;
    height: 38px;
    fill: currentColor;
}

.empty-message-icon .empty-bolt {
    fill: var(--surface);
}

.empty-kicker {
    position: relative;
    color: var(--primary);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.empty-state h2 {
    position: relative;
    margin: 8px 0 8px;
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -0.045em;
}

.empty-state > p {
    position: relative;
    max-width: 480px;
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.empty-features {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
    margin-top: 23px;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
}

.empty-features span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.empty-features i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-soft);
}

.active-chat {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: 76px minmax(0, 1fr);
}

.chat-header {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(14px);
    z-index: 5;
}

.chat-contact {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.contact-avatar {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 15px;
}

.contact-copy {
    min-width: 0;
}

.contact-title-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.contact-title-row h2 {
    max-width: 260px;
    margin: 0;
    overflow: hidden;
    font-size: 16px;
    font-weight: 850;
    letter-spacing: -0.025em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-status {
    padding: 3px 6px;
    border-radius: 999px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 8px;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.contact-copy p {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.active-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-action {
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--muted);
    background: var(--surface);
    font-size: 10px;
    font-weight: 750;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.header-action:hover,
.header-action.active {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    color: var(--primary);
    background: var(--primary-soft);
    transform: translateY(-1px);
}

.header-action svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.conversation-stage {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
}

.message-area {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.message-area::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.42;
    background-image:
        radial-gradient(circle at 20% 15%, var(--primary-glow), transparent 22%),
        radial-gradient(circle at 84% 76%, rgba(115, 87, 231, 0.08), transparent 24%),
        linear-gradient(color-mix(in srgb, var(--border) 62%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--border) 62%, transparent) 1px, transparent 1px);
    background-size: auto, auto, 38px 38px, 38px 38px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.7), rgba(0,0,0,.28));
    pointer-events: none;
}

.message-list {
    position: relative;
    height: 100%;
    overflow-y: auto;
    padding: 25px clamp(20px, 4.3vw, 60px) 30px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    z-index: 1;
}

.message-loading {
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.message-loading span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.message-loading i {
    width: 15px;
    height: 15px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.day-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 17px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.day-separator::before,
.day-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: color-mix(in srgb, var(--border) 72%, transparent);
}

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 4px 0;
    animation: message-in 0.18s ease-out both;
}

.message-row.agent {
    justify-content: flex-end;
}

.message-row.group-start {
    margin-top: 14px;
}

.message-avatar-mini {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    margin-bottom: 3px;
    border-radius: 9px;
    color: #fff;
    background: linear-gradient(145deg, #3379e7, #6b5adf);
    font-size: 8px;
    font-weight: 850;
    visibility: hidden;
}

.message-row.group-end .message-avatar-mini {
    visibility: visible;
}

.message-stack {
    max-width: min(72%, 680px);
}

.message-row.agent .message-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-bubble {
    position: relative;
    padding: 10px 13px;
    border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    border-radius: 16px 16px 16px 5px;
    color: var(--text);
    background: var(--incoming);
    box-shadow: var(--shadow-xs);
    line-height: 1.48;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-row.agent .message-bubble {
    border-color: transparent;
    border-radius: 16px 16px 5px 16px;
    color: #fff;
    background: linear-gradient(145deg, var(--outgoing), #2c73eb);
    box-shadow: 0 6px 18px var(--primary-glow);
}

.message-row:not(.group-start):not(.agent) .message-bubble {
    border-top-left-radius: 7px;
}

.message-row.agent:not(.group-start) .message-bubble {
    border-top-right-radius: 7px;
}

.message-text {
    font-size: 12.5px;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 0 4px;
    color: var(--muted-light);
    font-size: 8.5px;
}

.message-row.agent .message-meta {
    justify-content: flex-end;
}

.message-status {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    text-transform: capitalize;
}

.message-status svg {
    width: 11px;
    height: 11px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.message-status.failed {
    color: var(--danger);
    font-weight: 800;
}

.scroll-bottom-button {
    position: absolute;
    right: 21px;
    bottom: 18px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 13px;
    color: var(--primary);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    z-index: 3;
}

.scroll-bottom-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.scroll-bottom-button span {
    position: absolute;
    top: -8px;
    right: -7px;
    min-width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    padding: 0 4px;
    border: 2px solid var(--chat-bg);
    border-radius: 999px;
    color: #fff;
    background: var(--danger);
    font-size: 8px;
    font-weight: 850;
}

.composer-panel {
    position: relative;
    padding: 9px 16px 11px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    z-index: 4;
}

.quick-replies {
    display: flex;
    gap: 7px;
    padding: 0 2px 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.quick-replies::-webkit-scrollbar {
    display: none;
}

.quick-replies button {
    flex: 0 0 auto;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-soft);
    background: var(--surface-subtle);
    font-size: 9.5px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.quick-replies button:hover {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    color: var(--primary);
    background: var(--primary-soft);
}

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

.composer-input-wrap {
    position: relative;
    min-height: 62px;
    border: 1px solid var(--border-strong);
    border-radius: 15px;
    background: var(--surface-subtle);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.composer-input-wrap:focus-within {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.composer textarea {
    width: 100%;
    min-height: 34px;
    max-height: 126px;
    display: block;
    resize: none;
    padding: 11px 13px 4px;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    line-height: 1.42;
    overflow-y: auto;
}

.composer textarea::placeholder {
    color: var(--muted-light);
}

.composer-tools {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 3px 12px 8px;
    color: var(--muted-light);
    font-size: 8.5px;
}

kbd {
    padding: 1px 4px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--muted);
    background: var(--surface);
    font-family: inherit;
    font-size: 8px;
}

.send-button {
    min-width: 86px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 0;
    border-radius: 15px;
    color: #fff;
    background: linear-gradient(145deg, var(--primary), #2e72e8);
    box-shadow: 0 9px 22px var(--primary-glow);
    font-size: 11px;
    font-weight: 850;
    cursor: pointer;
    transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.send-button:disabled {
    opacity: 0.52;
    cursor: not-allowed;
}

.send-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.send-button.sending svg {
    animation: send-pulse 0.8s ease-in-out infinite alternate;
}

.composer-meta {
    min-height: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 3px 0;
    color: var(--muted-light);
    font-size: 8.5px;
}

.composer-status.success {
    color: var(--success);
}

.composer-status.error {
    color: var(--danger);
}

/* Customer details */
.details-panel {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    border-left: 1px solid var(--border);
    background: var(--surface);
    transition: transform 0.22s ease, opacity 0.22s ease;
    z-index: 25;
}

.support-app.details-collapsed .details-panel {
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
}

.details-header {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.details-kicker {
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.details-header h2 {
    margin: 3px 0 0;
    font-size: 15px;
    letter-spacing: -0.02em;
}

.details-empty {
    height: calc(100% - 76px);
    display: grid;
    place-content: center;
    justify-items: center;
    padding: 30px;
    color: var(--muted);
    text-align: center;
}

.details-empty-icon {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 17px;
    color: var(--primary);
    background: var(--primary-soft);
}

.details-empty-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.details-content {
    padding: 18px 16px 24px;
}

.details-profile {
    display: grid;
    justify-items: center;
    padding: 7px 0 21px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.details-avatar {
    width: 70px;
    height: 70px;
    border-radius: 22px;
    font-size: 22px;
    box-shadow: 0 12px 30px var(--primary-glow);
}

.details-avatar span {
    width: 14px;
    height: 14px;
    border-width: 3px;
}

.details-profile h3 {
    max-width: 240px;
    margin: 12px 0 6px;
    overflow: hidden;
    font-size: 16px;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.messenger-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 9.5px;
}

.messenger-label i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #1683ff;
}

.details-section {
    padding-top: 20px;
}

.details-section h4 {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.detail-card {
    min-width: 0;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-subtle);
}

.detail-card:nth-of-type(2) {
    grid-template-columns: 34px minmax(0, 1fr);
}

.detail-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--primary);
    background: var(--primary-soft);
}

.detail-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.detail-card > div {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.detail-card small {
    color: var(--muted);
    font-size: 8.5px;
}

.detail-card strong {
    overflow: hidden;
    color: var(--text-soft);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-mini-button {
    padding: 5px 7px;
    border-radius: 7px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 8px;
    font-weight: 800;
}

.routing-card {
    padding: 4px 11px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-subtle);
}

.routing-row {
    min-height: 39px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 9.5px;
}

.routing-row:last-child {
    border-bottom: 0;
}

.routing-row strong {
    max-width: 145px;
    overflow: hidden;
    color: var(--text-soft);
    font-size: 9.5px;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-chip {
    padding: 4px 7px;
    border-radius: 999px;
    color: #b54708 !important;
    background: var(--warning-soft);
    font-size: 8px !important;
    text-transform: uppercase;
}

.status-chip.replied {
    color: #067647 !important;
    background: var(--success-soft);
}

.details-note {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 8px;
    margin-top: 20px;
    padding: 11px;
    border-radius: 13px;
    color: var(--muted);
    background: var(--primary-soft);
}

.details-note svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.details-note p {
    margin: 0;
    font-size: 9px;
    line-height: 1.5;
}

/* Toast */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(380px, calc(100vw - 40px));
    padding: 12px 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    background: #101828;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 100;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.error {
    background: #9f2219;
}

.toast.success {
    background: #067647;
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 20, 0.52);
    backdrop-filter: blur(3px);
    z-index: 40;
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slow-spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    to { background-position: -200% 0; }
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes send-pulse {
    to { transform: translate(2px, -2px); }
}

/* Responsive */
@media (max-width: 1240px) {
    :root {
        --sidebar-width: 318px;
    }

    .support-app {
        grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr);
    }

    .support-app.details-collapsed {
        grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr);
    }

    .details-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(330px, 90vw);
        box-shadow: var(--shadow-lg);
        transform: translateX(0);
    }

    .support-app.details-collapsed .details-panel {
        transform: translateX(100%);
    }
}

@media (max-width: 960px) {
    :root {
        --rail-width: 62px;
        --sidebar-width: 290px;
    }

    .header-action span {
        display: none;
    }

    .header-action {
        width: 38px;
        justify-content: center;
        padding: 0;
    }

    .contact-title-row h2 {
        max-width: 190px;
    }

    .message-stack {
        max-width: 82%;
    }
}

@media (max-width: 760px) {
    .support-app,
    .support-app.details-collapsed {
        display: block;
    }

    .app-rail {
        display: none;
    }

    .inbox-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(350px, 91vw);
        border-right: 0;
        box-shadow: var(--shadow-lg);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        z-index: 50;
    }

    .support-app.sidebar-open .inbox-sidebar {
        transform: translateX(0);
    }

    .mobile-close,
    .mobile-menu-button {
        display: grid;
    }

    .chat-workspace {
        width: 100%;
        height: 100%;
    }

    .chat-header {
        padding: 10px 12px;
    }

    .contact-avatar {
        width: 41px;
        height: 41px;
        border-radius: 13px;
    }

    .contact-title-row h2 {
        max-width: 155px;
        font-size: 14px;
    }

    .customer-status {
        display: none;
    }

    .chat-actions {
        gap: 3px;
    }

    #copy-psid-button {
        display: none;
    }

    .active-chat {
        grid-template-rows: 66px minmax(0, 1fr);
    }

    .message-list {
        padding: 19px 13px 24px;
    }

    .message-stack {
        max-width: 86%;
    }

    .composer-panel {
        padding: 8px 10px max(9px, env(safe-area-inset-bottom));
    }

    .composer-tools {
        display: none;
    }

    .composer-input-wrap {
        min-height: 48px;
    }

    .composer textarea {
        padding: 12px;
    }

    .send-button {
        min-width: 52px;
        width: 52px;
        padding: 0;
    }

    .send-button span {
        display: none;
    }

    .details-panel {
        width: min(340px, 92vw);
        z-index: 55;
    }

    .empty-state {
        padding: 24px;
    }

    .empty-visual {
        width: 150px;
        height: 150px;
    }

    .orbit-one {
        width: 130px;
        height: 130px;
    }

    .orbit-two {
        width: 96px;
        height: 96px;
    }
}

@media (max-width: 430px) {
    .chat-header {
        gap: 6px;
    }

    .contact-copy p {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-action {
        width: 34px;
        height: 34px;
    }

    .quick-replies {
        padding-bottom: 7px;
    }

    .empty-features {
        gap: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
