/* Chat Agent Inbox — scoped layout (matches ERP shell) */

.page-wrapper:has(.chat-agent-page-full) {
    padding-top: 60px;
}

.chat-agent-page-full {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    min-height: 0;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
    background: var(--ns-color-bg-light, #f7f8fb);
    overflow: hidden;
}

.cai-shell {
    display: flex;
    flex: 1;
    min-height: 0;
}

.cai-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--ns-color-border-light, #e8ebed);
}

.cai-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid var(--ns-color-border-light, #e8ebed);
    flex-shrink: 0;
}

.cai-header__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cai-header__subtitle {
    margin: 2px 0 0;
    font-size: 0.875rem;
    color: var(--ns-color-gray, #637381);
}

.cai-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cai-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.cai-feed-outer {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cai-date-float {
    position: absolute;
    top: 10px;
    left: 50%;
    z-index: 6;
    transform: translateX(-50%) translateY(-6px);
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    color: #374151;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.cai-date-float.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.cai-feed {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px;
    background: #f3f4f6;
}

.cai-feed__inner {
    max-width: 45rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cai-feed__inner > .cai-card-wrap {
    will-change: opacity, transform, max-height;
}

/* ── Contact card layout ─────────────────────── */
.cai-card-wrap {
    max-height: 3000px;
    overflow: hidden;
    transition:
        opacity 0.22s ease,
        transform 0.22s ease,
        max-height 0.28s ease 0.14s,
        margin 0.28s ease 0.14s;
}

.cai-card-wrap--out {
    opacity: 0;
    transform: translateX(12px);
    max-height: 0;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    pointer-events: none;
}

.cai-card {
    background: #fff;
    border: 1px solid #e5e5e7;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.cai-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    border-color: #d4d4d8;
}

.cai-card--done {
    opacity: 0.85;
}

.cai-card--done .cai-card__name {
    color: #71717a;
}

.cai-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 10px;
}

.cai-card__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cai-card__avatar.cai-avatar--a { background: #18181b; color: #fff; }
.cai-card__avatar.cai-avatar--b { background: #6d28d9; color: #fff; }
.cai-card__avatar.cai-avatar--c { background: #0369a1; color: #fff; }
.cai-card__avatar.cai-avatar--d { background: #b45309; color: #fff; }
.cai-card__avatar.cai-avatar--e { background: #be123c; color: #fff; }

.cai-card__info {
    flex: 1;
    min-width: 0;
}

.cai-card__name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #18181b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cai-card__contact {
    font-size: 0.6875rem;
    color: #71717a;
    margin-top: 1px;
}

.cai-card__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.cai-card__channel-tag {
    font-size: 0.6875rem;
    font-weight: 500;
    color: #16a34a;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 2px 6px;
    border-radius: 4px;
}

.cai-card__pending-tag {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #1e40af;
    background: #eff6ff;
    padding: 2px 7px;
    border-radius: 4px;
}

.cai-card__time {
    font-size: 0.6875rem;
    color: #a1a1aa;
}

.cai-card__sep {
    height: 1px;
    background: #f0f0f0;
}

.cai-card__stream {
    padding: 4px 0 0;
}

.cai-card__text-row {
    display: flex;
    gap: 8px;
    padding: 6px 14px;
}

.cai-card__text-time {
    font-size: 0.6875rem;
    color: #a1a1aa;
    padding-top: 2px;
    width: 34px;
    flex-shrink: 0;
}

.cai-card__text-body {
    font-size: 0.8125rem;
    color: #3f3f46;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.cai-card__attach-pair {
    margin: 0 14px 12px 56px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cai-card__attach-gallery {
    margin: 0 14px 12px 56px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cai-card__thumb-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.cai-card__thumb {
    width: 100px;
    height: 66px;
    background: #f4f4f5;
    border: 1px solid #e5e5e7;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    padding: 0;
    transition: border-color 0.12s ease;
}

.cai-card__thumb:hover {
    border-color: #2563eb;
}

.cai-card__thumb img,
.cai-card__thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cai-card__thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 0.5625rem;
    padding: 2px 5px;
    text-align: center;
}

.cai-card__thumb-icon {
    font-size: 1.125rem;
    color: #71717a;
}

.cai-card__upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border: 1px solid #e5e5e7;
    border-radius: 6px;
    background: #fff;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #71717a;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.12s ease;
    align-self: flex-start;
    margin-top: 2px;
}

.cai-card__upload-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

.cai-card__status-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 6px 56px;
}

.cai-card__activity {
    padding: 2px 14px 8px;
}

.cai-card__footer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px 12px;
    flex-wrap: wrap;
}

.cai-card__footer-sp {
    flex: 1;
}

.cai-card__footer-status {
    font-size: 0.75rem;
    color: #a1a1aa;
}

.cai-intelligence--compact {
    margin: 0;
    padding: 0;
    border-top: none;
    background: transparent;
}

.cai-intelligence--compact.cai-intelligence--ready {
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    background: #eff6ff;
}

.cai-intelligence--compact.cai-intelligence--failed {
    border: 1px solid #fca5a5;
    border-radius: 6px;
    background: #fef2f2;
}

.cai-intelligence--compact.cai-intelligence--done {
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    background: #f0fdf4;
}

.cai-intelligence--compact.cai-intelligence--spin {
    border: 1px solid #e5e5e7;
    border-radius: 6px;
    background: #fafafa;
}

.cai-intelligence--compact .cai-intelligence__top {
    padding: 7px 10px 4px;
    margin-bottom: 0;
}

.cai-intelligence--compact .cai-intelligence__headline {
    padding: 0 10px 2px;
    margin: 0;
    font-size: 0.8125rem;
}

.cai-intelligence--compact .cai-intelligence__sub {
    padding: 0 10px 6px;
    margin: 0;
    font-size: 0.75rem;
}

.cai-intelligence--compact .cai-intelligence__fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px 10px;
    padding: 0 10px 8px;
    margin: 0;
}

.cai-intelligence--compact .cai-intelligence__field-row {
    display: flex;
    gap: 4px;
    align-items: baseline;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.cai-intelligence--compact .cai-intelligence__field-row dt {
    font-size: 0.6875rem;
    color: #a1a1aa;
    white-space: nowrap;
}

.cai-intelligence--compact .cai-intelligence__field-row dd {
    font-size: 0.75rem;
    font-weight: 500;
    color: #3f3f46;
}

.cai-intelligence--compact .cai-intelligence__stats {
    padding: 0 10px 8px;
    margin: 0;
}

.cai-intelligence--compact .cai-intelligence__alert {
    margin: 0 10px 8px;
}

.cai-intelligence--compact .cai-intelligence__loading,
.cai-intelligence--compact .cai-intelligence__done {
    padding: 10px;
}

.cai-intelligence__foot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.5);
}

.cai-intelligence__note {
    font-size: 0.6875rem;
    color: #71717a;
    flex: 1;
}

.cai-btn--approve {
    background: #16a34a;
    color: #fff;
    padding: 4px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s ease;
    margin-left: auto;
}

.cai-btn--approve:hover:not(:disabled) {
    background: #15803d;
}

.cai-btn--approve:disabled {
    background: #f4f4f5;
    color: #a1a1aa;
    cursor: not-allowed;
}

.cai-feed__loading,
.cai-feed__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 64px 16px;
    text-align: center;
    color: var(--ns-color-gray, #637381);
}

.cai-feed__empty-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
}

.cai-date-separator {
    display: flex;
    justify-content: center;
    margin: 14px 0 10px;
}

.cai-date-separator__pill,
.cai-date-separator__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.cai-message {
    display: flex;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 8px;
}

.cai-message:hover {
    background: rgba(255, 255, 255, 0.65);
}

.cai-message__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.cai-avatar--a { background: rgba(255, 107, 0, 0.12); color: var(--ns-color-primary, #ff6b00); }
.cai-avatar--b { background: rgba(79, 93, 113, 0.12); color: #4f5d71; }
.cai-avatar--c { background: rgba(16, 185, 129, 0.12); color: #047857; }
.cai-avatar--d { background: rgba(14, 165, 233, 0.12); color: #0369a1; }
.cai-avatar--e { background: rgba(139, 92, 246, 0.12); color: #6d28d9; }

.cai-card__avatar.cai-avatar--a,
.cai-card__avatar.cai-avatar--b,
.cai-card__avatar.cai-avatar--c,
.cai-card__avatar.cai-avatar--d,
.cai-card__avatar.cai-avatar--e {
    color: #fff;
}

.cai-message__body {
    flex: 1;
    min-width: 0;
}

.cai-message__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.cai-message__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
}

.cai-message__time {
    font-size: 0.75rem;
    color: var(--ns-color-gray, #637381);
}

.cai-message__badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--ns-color-border-light, #e8ebed);
    background: #fff;
    color: var(--ns-color-gray, #637381);
}

.cai-message__badge--status,
.cai-message__badge--success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.cai-message__badge--muted {
    background: #f4f4f5;
    border-color: #e4e4e7;
    color: #71717a;
}

.cai-message__badge--review {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
    font-weight: 600;
}

.cai-message--needs-review {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 12px 10px;
}

.cai-message__contact {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: var(--ns-color-gray, #637381);
}

.cai-message__text {
    margin: 8px 0 0;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--ns-color-blue, #212b36);
}

.cai-attachment-card {
    margin-top: 10px;
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cai-attachment {
    margin-top: 8px;
    border: 1px solid var(--ns-color-border-light, #e8ebed);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.cai-attachment__preview {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    background: #111;
}

.cai-attachment__preview-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    position: relative;
}

.cai-attachment__preview-btn:hover .cai-attachment__preview {
    opacity: 0.92;
}

.cai-attachment__play-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 3rem;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.cai-attachment__preview-placeholder {
    width: 100%;
    height: 140px;
    background: linear-gradient(90deg, #eceff3 25%, #f7f8fb 50%, #eceff3 75%);
    background-size: 200% 100%;
    animation: cai-shimmer 1.2s ease-in-out infinite;
}

@keyframes cai-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.cai-attachment__info {
    flex: 1;
    min-width: 0;
}

.cai-attachment__row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
}

.cai-attachment__icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ns-color-gray, #637381);
}

.cai-attachment__label {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ns-color-blue, #212b36);
}

.cai-attachment__type {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: var(--ns-color-gray, #637381);
}

.cai-message__actions,
.cai-message__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #f4f4f5;
}

.cai-sidebar {
    display: none;
    width: 320px;
    flex-shrink: 0;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid var(--ns-color-border-light, #e8ebed);
}

@media (min-width: 1024px) {
    .cai-sidebar {
        display: flex;
    }
}

.cai-sidebar__head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--ns-color-border-light, #e8ebed);
}

.cai-sidebar__title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
}

.cai-sidebar__subtitle {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: var(--ns-color-gray, #637381);
}

.cai-sidebar__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.cai-contact-card {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--ns-color-border-light, #e8ebed);
    background: #f9fafb;
}

.cai-contact-card__label {
    margin: 0;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ns-color-gray, #637381);
}

.cai-contact-card__number {
    margin: 6px 0 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
    text-align: center;
}

.cai-contact-card__whatsapp-link {
    color: #128c7e;
    text-decoration: none;
    font-weight: 600;
}

.cai-contact-card__whatsapp-link:hover {
    color: #075e54;
    text-decoration: underline;
}

.cai-contact-card__qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--ns-color-border-light, #e8ebed);
}

.cai-contact-card__qr {
    display: block;
    width: 168px;
    height: 168px;
    border-radius: 4px;
}

.cai-contact-card__qr-label {
    margin: 10px 0 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
    text-align: center;
}

.cai-contact-card__hint {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: var(--ns-color-gray, #637381);
}

.cai-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cai-steps__title {
    margin: 20px 0 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ns-color-gray, #637381);
}

.cai-step {
    display: flex;
    gap: 12px;
}

.cai-step__num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ns-color-primary, #ff6b00);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cai-step__text {
    margin: 2px 0 0;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--ns-color-blue, #212b36);
}

.cai-tip {
    margin-top: 24px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 107, 0, 0.2);
    background: rgba(255, 107, 0, 0.05);
}

.cai-tip__title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
}

.cai-tip__body {
    margin: 6px 0 0;
    font-size: 0.875rem;
    color: var(--ns-color-gray, #637381);
}

.cai-dialog-body {
    padding: 20px 24px 24px;
}

.cai-dialog-search {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.cai-booking-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 12px;
    border: 1px solid var(--ns-color-border-light, #e8ebed);
    border-radius: 8px;
    padding: 4px;
}

.cai-booking-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.cai-booking-item:hover {
    background: #f3f4f6;
}

.cai-booking-item.is-selected {
    background: rgba(255, 107, 0, 0.08);
    border: 1px solid var(--ns-color-primary, #ff6b00);
}

.cai-booking-item__no {
    font-weight: 600;
    color: var(--ns-color-blue, #212b36);
}

.cai-booking-item__meta {
    font-size: 0.75rem;
    color: var(--ns-color-gray, #637381);
    margin-top: 2px;
}

.cai-pending-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    background: #18181b;
    color: #fff;
}

/* Segmented filter control (shadcn-style) */
.cai-segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 8px;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    gap: 2px;
}

.cai-segmented__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #71717a;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.cai-segmented__item:hover {
    color: #18181b;
}

.cai-segmented__item.is-active {
    background: #fff;
    color: #18181b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.cai-segmented__dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 4px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    background: #18181b;
    color: #fff;
}

/* shadcn-inspired buttons */
.cai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 14px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.cai-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cai-btn--sm {
    height: 32px;
    padding: 0 10px;
    font-size: 0.8125rem;
    border-radius: 6px;
}

.cai-btn--block {
    width: 100%;
}

.cai-btn--icon {
    width: 36px;
    padding: 0;
}

.cai-btn--primary {
    background: #18181b;
    color: #fff;
    border-color: #18181b;
}

.cai-btn--primary:hover:not(:disabled) {
    background: #27272a;
}

.cai-btn--outline {
    background: #fff;
    color: #18181b;
    border-color: #e4e4e7;
}

.cai-btn--outline:hover:not(:disabled) {
    background: #f4f4f5;
}

.cai-btn--ghost {
    background: transparent;
    color: #18181b;
}

.cai-btn--ghost:hover:not(:disabled) {
    background: #f4f4f5;
}

.cai-btn--muted {
    color: #71717a;
}

.cai-btn--destructive {
    color: #dc2626;
    border-color: #fecaca;
}

.cai-btn--destructive:hover:not(:disabled) {
    background: #fef2f2;
    border-color: #fca5a5;
}

.cai-btn__spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cai-spin 0.7s linear infinite;
}

@keyframes cai-spin {
    to { transform: rotate(360deg); }
}

.cai-preview-dialog-shell .rz-dialog-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
}

.cai-preview-dialog {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: #0f1115;
}

.cai-preview-dialog__loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cai-preview-dialog__media {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-height: calc(92vh - 88px);
    object-fit: contain;
    background: #0f1115;
}

.cai-preview-dialog__fallback {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    color: #e5e7eb;
    text-align: center;
}

.cai-preview-dialog__filename {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.cai-preview-dialog__hint {
    margin: 0;
    font-size: 0.875rem;
    color: #9ca3af;
}

.cai-preview-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--ns-color-border-light, #e8ebed);
}

.cai-intelligence {
    margin: 0;
    padding: 14px 16px;
    border-top: 1px solid #f4f4f5;
    background: #fafafa;
}

.cai-intelligence--ready {
    background: linear-gradient(to bottom, #f0f9ff, #fafafa);
    border-top-color: #bae6fd;
}

.cai-intelligence--failed {
    background: linear-gradient(to bottom, #fef2f2, #fafafa);
    border-top-color: #fecaca;
}

.cai-intelligence--done {
    background: linear-gradient(to bottom, #f0fdf4, #fafafa);
    border-top-color: #bbf7d0;
}

.cai-intelligence--muted {
    background: #fafafa;
    border-top-color: #e4e4e7;
}

.cai-intelligence__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.cai-intelligence__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #71717a;
}

.cai-intelligence__badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f4f4f5;
    color: #52525b;
    border: 1px solid #e4e4e7;
}

.cai-intelligence__badge--high {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.cai-intelligence__badge--med {
    background: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}

.cai-intelligence__headline {
    margin: 0 0 6px;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
    color: #18181b;
}

.cai-intelligence__sub {
    margin: 0 0 10px;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #52525b;
}

.cai-intelligence__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.cai-intelligence__stat {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e4e4e7;
    color: #52525b;
}

.cai-intelligence__stat--ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.cai-intelligence__stat--warn {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.cai-intelligence__alert {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.cai-intelligence__alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.cai-intelligence__alert--warn {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.cai-intelligence__footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.cai-intelligence__secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cai-intelligence__context {
    margin: 0 0 12px;
    font-size: 0.8125rem;
    color: #52525b;
}

.cai-intelligence__context summary {
    cursor: pointer;
    font-weight: 600;
    color: #3f3f46;
    margin-bottom: 6px;
}

.cai-intelligence__context ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.cai-intelligence__context li {
    padding: 6px 0;
    border-top: 1px solid #f4f4f5;
}

.cai-intelligence__context-time {
    display: inline-block;
    min-width: 52px;
    margin-right: 8px;
    color: #a1a1aa;
    font-size: 0.75rem;
}

.cai-intelligence__fields {
    margin: 0 0 12px;
    display: grid;
    gap: 6px;
}

.cai-intelligence__field-row {
    display: grid;
    grid-template-columns: minmax(90px, 38%) 1fr;
    gap: 8px;
    font-size: 0.8125rem;
    padding: 6px 8px;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid #f4f4f5;
}

.cai-intelligence__field-row dt {
    margin: 0;
    color: #71717a;
    font-weight: 500;
}

.cai-intelligence__field-row dd {
    margin: 0;
    color: #18181b;
    word-break: break-word;
}

.cai-intelligence__loading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.cai-intelligence__loading-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #18181b;
}

.cai-intelligence__loading-hint {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: #71717a;
}

.cai-intelligence__spinner {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    border: 2px solid #e4e4e7;
    border-top-color: #18181b;
    border-radius: 50%;
    animation: cai-spin 0.7s linear infinite;
}

.cai-intelligence__done {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.cai-intelligence__done-icon {
    color: #16a34a;
    font-size: 1.25rem !important;
    flex-shrink: 0;
}

.cai-intelligence__done-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #166534;
}

.cai-intelligence__done-sub {
    margin: 4px 0 0;
    font-size: 0.8125rem;
    color: #52525b;
}

.cai-intelligence__header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.cai-intelligence__confidence {
    font-size: 0.75rem;
    color: #64748b;
}

.cai-intelligence__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.cai-timeline-details {
    margin-top: 10px;
}

.cai-timeline-details__summary {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #71717a;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.cai-timeline-details__summary::-webkit-details-marker {
    display: none;
}

.cai-timeline-details__summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s;
}

.cai-timeline-details[open] .cai-timeline-details__summary::before {
    transform: rotate(90deg);
}

.cai-timeline {
    margin-top: 10px;
    padding-left: 8px;
    border-left: 2px solid #e2e8f0;
}

.cai-timeline__item {
    position: relative;
    padding: 0 0 12px 14px;
}

.cai-timeline__dot {
    position: absolute;
    left: -5px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
}

.cai-timeline__title { font-weight: 600; font-size: 0.85rem; }
.cai-timeline__meta { font-size: 0.75rem; color: #64748b; }
.cai-timeline__detail { font-size: 0.8rem; margin: 4px 0 0; color: #475569; }
.cai-timeline__empty { font-size: 0.8rem; color: #94a3b8; margin: 0; }

/* Sidebar menu — unread-style pending count */
.sidebar .sidebar-menu > ul > li > a.team-inbox-menu-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.team-inbox-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #25d366;
}

.team-inbox-menu-icon svg {
    display: block;
    width: 18px;
    height: 18px;
    filter: none !important;
}

.sidebar .sidebar-menu > ul > li > a.team-inbox-menu-link:hover .team-inbox-menu-icon,
.sidebar .sidebar-menu > ul > li > a.team-inbox-menu-link.active .team-inbox-menu-icon {
    color: #128c7e;
}

.sidebar .sidebar-menu > ul > li > a.team-inbox-menu-link .team-inbox-menu-link__label {
    font-size: 15px;
    font-weight: 500;
    color: var(--ns-color-gray, #637381);
}

.sidebar .sidebar-menu > ul > li > a.team-inbox-menu-link:hover .team-inbox-menu-link__label,
.sidebar .sidebar-menu > ul > li.active > a.team-inbox-menu-link .team-inbox-menu-link__label {
    color: var(--ns-color-primary, #ff6b00);
}

.sidebar .sidebar-menu > ul > li > a.team-inbox-menu-link .team-inbox-menu-badge {
    margin-left: auto;
    flex-shrink: 0;
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 6px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff !important;
    font-size: 0.625rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    letter-spacing: 0;
}

/* Thread context (Phase 1) */
.cai-thread-details {
    margin-top: 10px;
    border-top: 1px solid #e5e7eb;
    padding-top: 8px;
}

.cai-thread-details__summary {
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #4b5563;
    list-style: none;
    user-select: none;
}

.cai-thread-details__summary::-webkit-details-marker {
    display: none;
}

.cai-thread-details__summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s ease;
}

.cai-thread-details[open] .cai-thread-details__summary::before {
    transform: rotate(90deg);
}

.cai-thread__messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.cai-thread__bubble {
    max-width: 92%;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.cai-thread__bubble--inbound {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.cai-thread__bubble--outbound {
    align-self: flex-end;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
}

.cai-thread__sender {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #6366f1;
    margin-bottom: 2px;
}

.cai-thread__text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.cai-thread__time {
    display: block;
    margin-top: 4px;
    font-size: 0.6875rem;
    color: #9ca3af;
    text-align: right;
}

.cai-thread__empty {
    margin: 8px 0 0;
    font-size: 0.8125rem;
    color: #9ca3af;
}

/* Reply-to chip (Phase 1.5) */
.cai-reply-to {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #f3f4f6;
    border-left: 3px solid #6366f1;
    font-size: 0.8125rem;
    color: #4b5563;
    max-width: 100%;
}

.cai-reply-to__label {
    font-weight: 600;
    color: #6366f1;
    flex-shrink: 0;
}

.cai-reply-to__preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Contact thread header — static sender divider */
.cai-contact-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 8px;
    padding: 6px 0;
    border-bottom: 1px solid #e5e7eb;
}

.cai-contact-header__main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.cai-contact-header__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.cai-contact-header__contact {
    font-size: 0.8125rem;
    color: #6b7280;
}

.cai-contact-header__channel {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
}

.cai-contact-header__count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6366f1;
    background: #eef2ff;
    padding: 3px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.cai-message__meta--compact {
    margin-bottom: 4px;
}

/* Unified action footer */
.cai-message__footer--unified {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.cai-message__footer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cai-message__footer-busy {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: #6b7280;
}

.cai-message__footer--recovery {
    background: #fafafa;
}

.cai-message__recovery-hint {
    margin: 0;
    font-size: 0.8125rem;
    color: #6b7280;
}

.cai-btn--block {
    width: 100%;
    justify-content: center;
}

/* Header filter chip */
.cai-header__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cai-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.cai-filter-chip:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.cai-filter-chip.is-active {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #4338ca;
}

/* Merged conversation panel */
.cai-conversation-details {
    margin-top: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
}

.cai-conversation-details__summary {
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.cai-conversation-details__summary::-webkit-details-marker {
    display: none;
}

.cai-conversation-details__summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s;
}

.cai-conversation-details[open] .cai-conversation-details__summary::before {
    transform: rotate(90deg);
}

.cai-conversation {
    padding: 0 12px 12px;
}

.cai-conversation__section {
    margin-top: 10px;
}

.cai-conversation__section:first-child {
    margin-top: 0;
}

.cai-conversation__section-label {
    margin: 0 0 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9ca3af;
}

.cai-conversation__empty {
    margin: 0;
    padding: 8px 0;
    font-size: 0.8125rem;
    color: #9ca3af;
}

.cai-timeline--embedded {
    margin: 0;
    padding: 0;
}
