:root {
    --crm-bg: #f8fafc;
    --crm-card: #ffffff;
    --crm-text: #1e293b;
    --crm-muted: #64748b;
    --crm-border: #e2e8f0;
    --crm-primary: #25d366;
    --crm-primary-dark: #128c7e;
    --crm-danger: #ef4444;
    --crm-warning: #f59e0b;
    --crm-success: #22c55e;
    --crm-info: #3b82f6;
}

.dark {
    --crm-bg: #020617;
    --crm-card: #0f172a;
    --crm-text: #e2e8f0;
    --crm-muted: #94a3b8;
    --crm-border: #1e293b;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 999px;
}

body {
    background: var(--crm-bg);
    color: var(--crm-text);
}

.crm-card {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

.crm-card:hover {
    box-shadow: 0 10px 30px rgb(15 23 42 / 0.08);
}

.page-kicker,
.form-label {
    display: block;
    color: var(--crm-muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.page-title {
    color: var(--crm-text);
    font-size: clamp(1.5rem, 2vw, 2rem);
    font-weight: 800;
    line-height: 1.15;
}

.section-title {
    color: var(--crm-text);
    font-size: 1rem;
    font-weight: 800;
}

.section-subtitle {
    color: var(--crm-muted);
    font-size: .875rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: var(--crm-card);
    color: var(--crm-text);
    font-size: .875rem;
    line-height: 1.4;
    padding: .68rem .8rem;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.form-textarea {
    resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgb(37 211 102 / .18);
}

.btn-primary,
.btn-secondary,
.icon-btn,
.chip {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-size: .875rem;
    font-weight: 700;
    gap: .45rem;
    justify-content: center;
    min-height: 2.5rem;
    transition: background .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease, transform .18s ease;
}

.btn-primary {
    background: var(--crm-primary);
    color: #fff;
    padding: .65rem 1rem;
}

.btn-primary:hover {
    background: var(--crm-primary-dark);
}

.btn-secondary {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    color: var(--crm-text);
    padding: .62rem .95rem;
}

.btn-secondary:hover,
.icon-btn:hover,
.chip:hover {
    background: #f1f5f9;
}

.dark .btn-secondary:hover,
.dark .icon-btn:hover,
.dark .chip:hover {
    background: #1e293b;
}

.icon-btn {
    border: 1px solid transparent;
    color: var(--crm-text);
    height: 2.5rem;
    padding: 0;
    width: 2.5rem;
}

.icon-btn.h-8,
.icon-btn.w-8 {
    height: 2rem;
    min-height: 2rem;
    width: 2rem;
}

.icon-btn.danger {
    color: #dc2626;
}

.icon-btn.danger:hover {
    background: #fee2e2;
    border-color: #fecaca;
}

.dark .icon-btn.danger:hover {
    background: rgb(127 29 29 / .32);
    border-color: rgb(248 113 113 / .24);
}

.chip {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #047857;
    min-height: 2rem;
    padding: .35rem .7rem;
}

.dark .chip {
    background: rgb(6 78 59 / .35);
    border-color: rgb(16 185 129 / .3);
    color: #86efac;
}

.btn-primary.is-loading,
.btn-secondary.is-loading {
    opacity: .72;
    pointer-events: none;
}

.btn-primary.is-loading::after,
.btn-secondary.is-loading::after {
    animation: spin .8s linear infinite;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    content: "";
    height: 1rem;
    width: 1rem;
}

.sidebar {
    transition: width .2s ease, transform .2s ease;
}

.sidebar-link {
    align-items: center;
    border-radius: 8px;
    color: #cbd5e1;
    display: flex;
    gap: .75rem;
    min-height: 2.75rem;
    padding: .7rem .75rem;
    transition: background .18s ease, color .18s ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    background: rgb(255 255 255 / .08);
    color: #fff;
}

.dropdown-item {
    border-radius: 6px;
    display: block;
    font-size: .875rem;
    padding: .65rem .75rem;
}

.dropdown-item:hover {
    background: #f1f5f9;
}

.dark .dropdown-item:hover {
    background: #1e293b;
}

.toolbar {
    align-items: center;
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    padding: .75rem;
}

.toolbar .form-input,
.toolbar .form-select {
    width: auto;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1;
    padding: .35rem .55rem;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-muted { background: #f1f5f9; color: #475569; }

.dark .badge-muted { background: #1e293b; color: #cbd5e1; }

.priority-alta { border-left: 4px solid var(--crm-danger); }
.priority-media { border-left: 4px solid var(--crm-warning); }
.priority-baixa { border-left: 4px solid var(--crm-success); }

.skeleton {
    animation: shimmer 1.4s infinite linear;
    background: linear-gradient(90deg, #e2e8f0 25%, #f8fafc 37%, #e2e8f0 63%);
    background-size: 400% 100%;
    border-radius: 6px;
}

.dark .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 37%, #1e293b 63%);
    background-size: 400% 100%;
}

.kanban-board {
    display: grid;
    gap: 1rem;
    grid-auto-columns: minmax(300px, 340px);
    grid-auto-flow: column;
    min-height: 640px;
    overflow-x: auto;
    padding-bottom: .5rem;
}

.kanban-column {
    background: #f1f5f9;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 220px);
    min-height: 540px;
}

.dark .kanban-column {
    background: #0b1220;
}

.kanban-column-header {
    align-items: center;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    justify-content: space-between;
    padding: .85rem;
}

.kanban-column-body {
    flex: 1;
    overflow-y: auto;
    padding: .85rem;
    transition: background .18s ease, box-shadow .18s ease;
}

.kanban-column-body.is-drop-target {
    background: rgb(37 211 102 / .12);
    box-shadow: inset 0 0 0 2px rgb(37 211 102 / .35);
}

.kanban-card {
    background: var(--crm-card);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgb(15 23 42 / .08);
    cursor: pointer;
    margin-bottom: .75rem;
    padding: .9rem;
    text-align: left;
    transition: transform .18s ease, box-shadow .18s ease;
    width: 100%;
}

.kanban-card:hover {
    box-shadow: 0 12px 24px rgb(15 23 42 / .12);
    transform: translateY(-1px);
}

.kanban-card.is-dragging {
    opacity: .58;
    transform: rotate(.5deg) scale(.99);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.tab {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    color: var(--crm-muted);
    font-size: .875rem;
    font-weight: 800;
    padding: .65rem 1rem;
}

.tab.is-active {
    background: var(--crm-primary);
    border-color: var(--crm-primary);
    color: #fff;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .5rem;
}

.calendar-weekdays {
    color: var(--crm-muted);
    font-size: .75rem;
    font-weight: 800;
    margin-bottom: .5rem;
    text-align: center;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1 / .8;
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    min-height: 92px;
    padding: .55rem;
    text-align: left;
}

.calendar-day.is-muted {
    opacity: .45;
}

.calendar-day.is-selected {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgb(37 211 102 / .18);
}

.chat-panel {
    scroll-behavior: smooth;
}

.assistant-panel {
    overscroll-behavior: contain;
    overflow-anchor: none;
    scroll-padding-bottom: 1rem;
}

#conversation-messages.chat-panel {
    --conversation-readable-width: 760px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    background-position: top left;
    background-repeat: repeat;
    background-size: auto;
    overflow-anchor: none;
    overscroll-behavior: contain;
    padding: .6rem clamp(.6rem, 1.8vw, 1rem) 4.75rem;
    scroll-behavior: auto;
    scroll-padding-bottom: 4.75rem;
}

.conversation-chat-card {
    contain: layout;
}

.conversation-composer {
    background: var(--crm-card);
    position: relative;
    z-index: 2;
}

.delicate-scroll {
    scrollbar-color: rgb(148 163 184 / .55) transparent;
}

.delicate-scroll::-webkit-scrollbar {
    width: 6px;
}

.delicate-scroll::-webkit-scrollbar-thumb {
    background: rgb(148 163 184 / .55);
    border-radius: 999px;
}

.chat-bubble {
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    max-width: min(70%, 520px);
    padding: .3rem .5rem;
    position: relative;
    white-space: pre-wrap;
    line-height: 1.18;
    font-size: .8rem;
}

#conversation-messages .chat-bubble {
    font-size: .82rem;
    line-height: 1.3;
    max-width: min(74%, 560px);
    min-width: 4rem;
    overflow: visible;
    overflow-wrap: anywhere;
    padding: 7px 22px 5px 10px;
    width: fit-content;
}

#conversation-messages .chat-bubble.has-media {
    max-width: min(78%, 560px);
    padding: 6px 22px 6px 8px;
}

#conversation-messages .chat-bubble.is-sender-change {
    margin-top: 6px;
}

.chat-date-separator {
    align-self: center;
    background: rgb(255 255 255 / .86);
    border: 1px solid rgb(226 232 240 / .85);
    border-radius: 999px;
    box-shadow: 0 1px 2px rgb(15 23 42 / .08);
    color: #64748b;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1;
    margin: .55rem auto .4rem;
    padding: .38rem .7rem;
    width: fit-content;
}

.dark .chat-date-separator {
    background: rgb(255 255 255 / .92);
    border-color: rgb(226 232 240 / .85);
    color: #475569;
}

.chat-bubble.client,
.chat-bubble.user {
    background: #fff;
    border: 1px solid var(--crm-border);
    margin-right: auto;
}

.chat-bubble.agent,
.chat-bubble.assistant {
    background: #dcf8c6;
    margin-left: auto;
}

#conversation-messages .chat-bubble.client,
#conversation-messages .chat-bubble.user {
    background: #ffffff;
    border-color: rgb(226 232 240 / .75);
    border-top-left-radius: 4px;
    margin-left: max(0px, calc((100% - var(--conversation-readable-width)) / 2));
    margin-right: auto;
}

#conversation-messages .chat-bubble.agent,
#conversation-messages .chat-bubble.assistant {
    background: #e9ffd8;
    border-top-right-radius: 4px;
    margin-left: auto;
    margin-right: max(0px, calc((100% - var(--conversation-readable-width)) / 2));
}

.dark .chat-bubble.client,
.dark .chat-bubble.user {
    background: #243449;
}

.dark .chat-bubble.agent,
.dark .chat-bubble.assistant {
    background: #176b3a;
}

.dark #conversation-messages .chat-bubble.client,
.dark #conversation-messages .chat-bubble.user {
    background: #ffffff;
    border-color: rgb(226 232 240 / .75);
    color: #1e293b;
}

.dark #conversation-messages .chat-bubble.agent,
.dark #conversation-messages .chat-bubble.assistant {
    background: #e9ffd8;
    color: #1e293b;
}

.message-meta {
    align-items: center;
    display: flex;
    font-size: 10px;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 2px;
}

.message-time {
    opacity: .62;
}

.message-link {
    color: #0f766e;
    font-weight: 700;
    overflow-wrap: anywhere;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dark .message-link {
    color: #7dd3fc;
}

.dark #conversation-messages .message-link {
    color: #0f766e;
}

.message-status {
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1;
}

.message-status.lido,
#conversation-messages .message-status.lido {
    color: #0ea5e9 !important;
    opacity: 1;
}

.message-status.erro {
    color: #dc2626;
    opacity: 1;
}

.message-body {
    min-width: 0;
    white-space: pre-wrap;
}

.message-body strong {
    font-weight: 800;
}

.mensagem-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
    position: relative;
    width: 100%;
}

.message-bubble-line {
    align-items: center;
    display: flex;
    gap: 6px;
    max-width: min(86%, 620px);
    width: fit-content;
}

#conversation-messages .mensagem-wrapper.mensagem-cliente .message-bubble-line {
    align-self: flex-start;
    justify-content: flex-start;
    margin-left: max(0px, calc((100% - var(--conversation-readable-width)) / 2));
    margin-right: 0;
}

#conversation-messages .mensagem-wrapper.mensagem-agente .message-bubble-line {
    align-self: flex-end;
    justify-content: flex-end;
    margin-left: 0;
    margin-right: max(0px, calc((100% - var(--conversation-readable-width)) / 2));
}

#conversation-messages .message-bubble-line .chat-bubble {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: calc(100% - 30px);
}

#conversation-messages .message-bubble-line .chat-bubble.has-media {
    max-width: calc(100% - 30px);
}

.message-reaction-control {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    opacity: .42;
    position: relative;
    transition: opacity .14s ease, transform .14s ease;
    z-index: 25;
}

.mensagem-wrapper:hover .message-reaction-control,
.message-reaction-control:focus-within {
    opacity: 1;
}

.message-reaction-trigger {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgb(226 232 240 / .85);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgb(15 23 42 / .14);
    color: #1e293b;
    cursor: pointer;
    display: inline-flex;
    font-size: 16px;
    font-weight: 800;
    height: 24px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 24px;
}

.message-reaction-trigger:hover,
.message-reaction-trigger:focus-visible {
    background: #f8fafc;
    border-color: rgb(37 211 102 / .5);
    outline: none;
}

.message-reaction-picker {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgb(226 232 240 / .85);
    border-radius: 24px;
    box-shadow: 0 4px 16px rgb(15 23 42 / .16);
    display: none;
    gap: 2px;
    padding: 4px 8px;
    position: absolute;
    bottom: calc(100% + 6px);
    z-index: 90;
}

.message-reaction-picker.visivel {
    animation: fadeInUp .15s ease;
    display: flex;
}

.mensagem-agente .message-reaction-picker {
    right: 0;
}

.mensagem-cliente .message-reaction-picker {
    left: 0;
}

.message-reaction-btn {
    background: transparent;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 4px 6px;
    transition: transform .1s ease, background .1s ease;
}

.message-reaction-btn:hover,
.message-reaction-btn:focus-visible {
    background: #f1f5f9;
    outline: none;
    transform: scale(1.3);
}

.message-reaction-btn.selecionado {
    background: rgb(37 211 102 / .2);
}

.reacoes-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: -7px;
    max-width: min(74%, 560px);
    padding: 0 8px;
    position: relative;
    z-index: 3;
}

.reacoes-container:empty {
    display: none;
}

#conversation-messages .mensagem-wrapper.mensagem-agente .reacoes-container {
    justify-content: flex-end;
    margin-left: auto;
    margin-right: max(0px, calc((100% - var(--conversation-readable-width)) / 2));
}

#conversation-messages .mensagem-wrapper.mensagem-cliente .reacoes-container {
    justify-content: flex-start;
    margin-left: max(0px, calc((100% - var(--conversation-readable-width)) / 2));
    margin-right: auto;
}

.reacao-badge {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgb(226 232 240 / .85);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgb(15 23 42 / .14);
    color: #1e293b;
    cursor: pointer;
    display: inline-flex;
    font-size: 14px;
    gap: 3px;
    line-height: 1;
    min-height: 20px;
    padding: 2px 7px;
    transition: transform .1s ease, border-color .1s ease, background .1s ease;
}

.reacao-badge:hover,
.reacao-badge:focus-visible {
    outline: none;
    transform: scale(1.1);
}

.reacao-badge.minha {
    background: rgb(37 211 102 / .15);
    border-color: #25d366;
}

.reacao-count {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
}

.dark .message-reaction-trigger,
.dark .message-reaction-picker,
.dark .reacao-badge {
    background: #0f172a;
}

.dark #conversation-messages .message-reaction-trigger,
.dark #conversation-messages .message-reaction-picker,
.dark #conversation-messages .reacao-badge {
    background: #ffffff;
    border-color: rgb(226 232 240 / .85);
    color: #1e293b;
}

.dark #conversation-messages .message-reaction-btn {
    background: transparent;
}

.dark #conversation-messages .message-reaction-btn:hover,
.dark #conversation-messages .message-reaction-btn:focus-visible {
    background: #f1f5f9;
}

.dark #conversation-messages .message-reaction-btn.selecionado,
.dark #conversation-messages .reacao-badge.minha {
    background: rgb(37 211 102 / .15);
    border-color: #25d366;
}

.dark .reacao-count {
    color: #94a3b8;
}

.dark #conversation-messages .reacao-count {
    color: #64748b;
}

.message-action {
    position: absolute;
    top: -6px;
    z-index: 6;
}

.chat-bubble.client .message-action,
.chat-bubble.user .message-action,
.chat-bubble.agent .message-action,
.chat-bubble.assistant .message-action {
    left: auto;
    right: -6px;
}

.chat-bubble.is-menu-open .message-action {
    z-index: 60;
}

#conversation-messages.has-open-message-menu .chat-bubble:not(.is-menu-open) .message-action {
    pointer-events: none;
}

#conversation-messages.has-open-message-menu .chat-bubble:not(.is-menu-open) .message-action-button {
    opacity: 0;
}

.message-action-button {
    align-items: center;
    background: rgb(255 255 255 / .92);
    border: 1px solid rgb(226 232 240 / .9);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgb(15 23 42 / .12);
    color: #475569;
    display: inline-flex;
    height: 22px;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s ease, background .15s ease, color .15s ease;
    width: 22px;
}

.chat-bubble:hover .message-action-button,
.chat-bubble.is-menu-open .message-action-button,
.message-action-button:focus-visible {
    opacity: 1;
}

.message-action-button:hover {
    background: #f8fafc;
    color: #0f172a;
}

.message-action-menu {
    background: #f8fafc;
    border: 1px solid rgb(226 232 240 / .78);
    border-radius: 10px;
    box-shadow: 0 6px 14px rgb(15 23 42 / .12);
    min-width: 0;
    overflow: hidden;
    padding: 0;
    position: absolute;
    top: 22px;
    width: max-content;
    z-index: 70;
}

.chat-bubble.client .message-action-menu,
.chat-bubble.user .message-action-menu,
.chat-bubble.agent .message-action-menu,
.chat-bubble.assistant .message-action-menu {
    left: auto;
    right: 0;
}

.message-action-menu button {
    align-items: center;
    border-radius: 0;
    color: var(--crm-text);
    display: flex;
    font-size: .74rem;
    font-weight: 700;
    gap: .24rem;
    line-height: .9;
    margin: 0;
    min-height: 0;
    padding: 0 .35rem;
    text-align: left;
    white-space: nowrap;
    width: 100%;
}

.message-action-menu svg {
    height: .74rem;
    width: .74rem;
}

.message-action-menu button:hover {
    background: #f1f5f9;
}

.message-action-menu button.danger {
    color: #dc2626;
}

.message-action-menu.hidden {
    display: none;
}

.dark .message-action-button {
    background: rgb(255 255 255 / .92);
    border-color: rgb(226 232 240 / .9);
    color: #475569;
}

.dark .message-action-menu {
    background: #ffffff;
    border-color: rgb(226 232 240 / .78);
    color: #0f172a;
}

.dark .message-action-menu button {
    color: #0f172a;
}

.dark .message-action-menu button.danger {
    color: #dc2626;
}

.dark .message-action-menu button:hover {
    background: #f1f5f9;
}

.dark .message-action-button:hover {
    background: #f8fafc;
    color: #0f172a;
}

.message-reply-compose {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--crm-border);
    border-left: 3px solid var(--crm-primary);
    border-radius: 8px;
    color: var(--crm-text);
    display: flex;
    gap: .75rem;
    justify-content: space-between;
    margin-bottom: .5rem;
    padding: .55rem .65rem;
}

.message-reply-compose.hidden {
    display: none;
}

.message-reply-compose strong,
.message-forward-preview strong,
.message-forward-target strong {
    display: block;
    font-size: .78rem;
    font-weight: 800;
}

.message-reply-compose span,
.message-forward-preview span,
.message-forward-target small {
    color: var(--crm-muted);
    display: block;
    font-size: .78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-forward-preview {
    background: #f8fafc;
    border: 1px solid var(--crm-border);
    border-left: 3px solid var(--crm-primary);
    border-radius: 8px;
    padding: .65rem .75rem;
}

.message-forward-list {
    display: grid;
    gap: .4rem;
    max-height: min(360px, 55vh);
    overflow: auto;
}

.message-forward-target {
    align-items: center;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    display: flex;
    gap: .65rem;
    padding: .62rem .7rem;
    text-align: left;
    transition: background .15s ease, border-color .15s ease;
    width: 100%;
}

.message-forward-target:hover {
    background: #f1f5f9;
    border-color: rgb(37 211 102 / .45);
}

.dark .message-reply-compose,
.dark .message-forward-preview {
    background: rgb(15 23 42 / .75);
}

.dark .message-forward-target:hover {
    background: #1e293b;
}

@media (hover: none) {
    .message-action-button {
        opacity: 1;
    }
}

.quoted-reply {
    background: rgb(15 23 42 / .06);
    border-left: 3px solid var(--crm-primary);
    border-radius: 6px;
    margin-bottom: 4px;
    max-width: 100%;
    overflow: hidden;
    padding: 4px 6px;
}

.quoted-reply-author {
    color: #047857;
    font-size: .68rem;
    font-weight: 800;
    line-height: 1.2;
}

.quoted-reply-text {
    color: #475569;
    font-size: .72rem;
    line-height: 1.15;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark .quoted-reply {
    background: rgb(2 6 23 / .28);
}

.dark .quoted-reply-author {
    color: #86efac;
}

.dark .quoted-reply-text {
    color: #cbd5e1;
}

.dark #conversation-messages .quoted-reply {
    background: rgb(15 23 42 / .06);
}

.dark #conversation-messages .quoted-reply-author {
    color: #047857;
}

.dark #conversation-messages .quoted-reply-text {
    color: #475569;
}

.pdf-media-preview {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgb(226 232 240 / .9);
    border-radius: 8px;
    color: #1e293b;
    display: inline-flex;
    gap: 10px;
    margin-top: .5rem;
    max-width: 100%;
    min-width: min(16rem, 100%);
    padding: 8px 10px;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.pdf-media-preview:hover,
.pdf-media-preview:focus-visible {
    background: #f8fafc;
    border-color: rgb(239 68 68 / .35);
    outline: none;
    transform: translateY(-1px);
}

.pdf-media-preview-static:hover {
    background: #ffffff;
    border-color: rgb(226 232 240 / .9);
    transform: none;
}

.pdf-media-icon {
    flex: 0 0 auto;
    height: 38px;
    width: 38px;
}

.pdf-media-name {
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.2;
    min-width: 0;
    overflow-wrap: anywhere;
}

.dark #conversation-messages .pdf-media-preview {
    background: #ffffff;
    border-color: rgb(226 232 240 / .9);
    color: #1e293b;
}

.dark #conversation-messages .pdf-media-preview:hover,
.dark #conversation-messages .pdf-media-preview:focus-visible {
    background: #f8fafc;
    border-color: rgb(239 68 68 / .35);
}

.media-transcription {
    background: rgb(255 255 255 / .62);
    border: 1px solid rgb(148 163 184 / .34);
    border-radius: 6px;
    color: #475569;
    font-size: .72rem;
    line-height: 1.22;
    margin-top: 4px;
    padding: 4px 6px;
    white-space: pre-wrap;
}

.chat-bubble.agent .media-transcription,
.chat-bubble.assistant .media-transcription {
    background: rgb(255 255 255 / .38);
    border-color: rgb(21 128 61 / .18);
    color: #334155;
}

.dark .media-transcription {
    background: rgb(15 23 42 / .42);
    border-color: rgb(148 163 184 / .22);
    color: #cbd5e1;
}

.dark .chat-bubble.agent .media-transcription,
.dark .chat-bubble.assistant .media-transcription {
    background: rgb(2 6 23 / .28);
    color: #dcfce7;
}

.dark #conversation-messages .media-transcription {
    background: rgb(255 255 255 / .62);
    border-color: rgb(148 163 184 / .34);
    color: #475569;
}

.dark #conversation-messages .chat-bubble.agent .media-transcription,
.dark #conversation-messages .chat-bubble.assistant .media-transcription {
    background: rgb(255 255 255 / .38);
    border-color: rgb(21 128 61 / .18);
    color: #334155;
}

.emoji-picker {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    box-shadow: 0 16px 36px rgb(15 23 42 / .16);
    display: grid;
    gap: .25rem;
    grid-template-columns: repeat(auto-fill, minmax(2rem, 1fr));
    height: auto;
    max-height: min(320px, 70vh);
    overflow-y: auto;
    padding: .6rem;
    position: fixed;
    z-index: 80;
}

.emoji-picker button {
    border-radius: 6px;
    font-size: 1.15rem;
    height: 2rem;
    line-height: 1;
    transition: background .15s ease, transform .15s ease;
    width: 2rem;
}

.emoji-picker button:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.dark .emoji-picker button:hover {
    background: #1e293b;
}

.dark #manual-emoji-picker.emoji-picker {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}

.dark #manual-emoji-picker.emoji-picker button {
    background: transparent;
}

.dark #manual-emoji-picker.emoji-picker button:hover {
    background: #f1f5f9;
}

#manual-message-form {
    position: relative;
}

.panel-respostas {
    border-left: 1px solid var(--crm-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width .2s ease, border-color .2s ease, opacity .2s ease;
    width: 100%;
}

@media (min-width: 1024px) {
    .panel-respostas {
        width: 280px;
    }
}

.panel-respostas.collapsed {
    border-color: transparent;
    min-width: 0;
    overflow: hidden;
    width: 0 !important;
}

.panel-respostas.collapsed > * {
    opacity: 0;
    pointer-events: none;
}

.resposta-card {
    border-bottom: 1px solid rgb(226 232 240 / .78);
    cursor: pointer;
    padding: 10px 12px;
    transition: background .15s ease, border-color .15s ease;
}

.resposta-card:hover,
.resposta-card:focus {
    background: rgb(37 211 102 / .06);
    outline: none;
}

.dark .resposta-card {
    border-bottom-color: rgb(30 41 59 / .9);
}

.dark .resposta-card:hover,
.dark .resposta-card:focus {
    background: rgb(37 211 102 / .1);
}

.resposta-card-text {
    color: var(--crm-muted);
    display: -webkit-box;
    font-size: .75rem;
    line-height: 1.28;
    margin: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.atalho-badge {
    background: #e1f5ee;
    border-radius: 4px;
    color: #085041;
    display: inline-flex;
    flex-shrink: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    padding: 4px 6px;
}

.dark .atalho-badge {
    background: rgb(20 83 45 / .55);
    color: #bbf7d0;
}

.quick-category {
    border-radius: 999px;
    display: inline-flex;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    padding: 4px 7px;
    text-transform: uppercase;
}

.quick-category.geral,
.quick-category.outro {
    background: rgb(100 116 139 / .14);
    color: #475569;
}

.quick-category.vendas {
    background: rgb(34 197 94 / .14);
    color: #047857;
}

.quick-category.suporte {
    background: rgb(59 130 246 / .14);
    color: #1d4ed8;
}

.quick-category.financeiro {
    background: rgb(245 158 11 / .16);
    color: #b45309;
}

.dark .quick-category.geral,
.dark .quick-category.outro {
    color: #cbd5e1;
}

.dark .quick-category.vendas {
    color: #86efac;
}

.dark .quick-category.suporte {
    color: #93c5fd;
}

.dark .quick-category.financeiro {
    color: #fcd34d;
}

.sugestoes-popup {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    bottom: calc(100% + 8px);
    box-shadow: 0 -4px 16px rgb(15 23 42 / .15);
    left: 0;
    max-height: 280px;
    overflow-y: auto;
    position: absolute;
    right: 0;
    z-index: 1000;
}

.sugestao-item {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    text-align: left;
    width: 100%;
}

.sugestao-item:hover,
.sugestao-item.ativo {
    background: rgb(37 211 102 / .1);
}

.sugestao-atalho {
    color: #1d9e75;
    flex: 0 0 80px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 800;
}

.sugestao-titulo {
    color: var(--crm-text);
    flex: 0 1 auto;
    font-size: 13px;
    font-weight: 800;
    min-width: 0;
}

.sugestao-trecho {
    color: var(--crm-muted);
    flex: 1;
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark .sugestoes-popup {
    box-shadow: 0 -4px 18px rgb(0 0 0 / .38);
}

.dark .sugestao-atalho {
    color: #86efac;
}

.flow-builder {
    background:
        linear-gradient(var(--crm-border) 1px, transparent 1px),
        linear-gradient(90deg, var(--crm-border) 1px, transparent 1px),
        var(--crm-bg);
    background-size: 32px 32px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    height: min(70vh, 720px);
    min-height: 540px;
    overflow: auto;
    position: relative;
}

.flow-lines {
    height: 1400px;
    left: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
    width: 1400px;
}

.flow-line {
    fill: none;
    stroke: var(--crm-primary-dark);
    stroke-linecap: round;
    stroke-width: 2.5;
}

.flow-node {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgb(15 23 42 / .1);
    cursor: grab;
    min-height: 168px;
    padding: .85rem;
    position: absolute;
    width: 260px;
    user-select: none;
}

.flow-node.is-moving {
    cursor: grabbing;
    opacity: .92;
    z-index: 3;
}

.flow-node textarea,
.flow-node input,
.flow-node select {
    cursor: text;
    user-select: text;
}

.flow-node select {
    cursor: pointer;
}

.flow-node-header {
    align-items: center;
    display: grid;
    gap: .5rem;
    grid-template-columns: 2.5rem 1fr 2.5rem;
}

.flow-drag-handle {
    cursor: grab;
}

.flow-port {
    background: var(--crm-primary);
    border: 2px solid var(--crm-card);
    border-radius: 999px;
    box-shadow: 0 0 0 1px rgb(15 23 42 / .12);
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
    height: 28px;
    line-height: 1;
    padding: 0 .55rem;
    position: absolute;
    top: 46px;
    white-space: nowrap;
    width: auto;
}

.flow-port.input {
    left: -22px;
}

.flow-port.is-selected {
    box-shadow: 0 0 0 5px rgb(37 211 102 / .22);
}

.flow-node-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .75rem;
}

.flow-node-actions .btn-secondary {
    min-height: 2.1rem;
    padding: .45rem .65rem;
}

.flow-connect-output.is-selected {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
    box-shadow: 0 0 0 3px rgb(37 211 102 / .16);
}

.flow-preview {
    color: #111827;
}

.flow-preview-bubble {
    color: #111827;
}

.dark .flow-preview {
    background: #111827 !important;
}

.dark .flow-preview-bubble {
    background: #f8fafc;
    color: #111827;
}

.modal,
.drawer {
    position: fixed;
    inset: 0;
    z-index: 60;
}

.modal {
    align-items: center;
    background: rgb(15 23 42 / .58);
    display: flex;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden,
.drawer.hidden {
    display: none;
}

.modal-panel {
    animation: scale-in .16s ease both;
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgb(15 23 42 / .24);
    max-height: min(90vh, 920px);
    overflow: auto;
    padding: 1.25rem;
    width: 100%;
}

.link-preview-modal-panel {
    max-width: 480px;
    width: min(480px, calc(100vw - 2rem));
}

.link-preview-url {
    color: var(--crm-muted);
    font-size: .78rem;
    margin-top: .15rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-preview-frame-wrap {
    aspect-ratio: 16 / 9;
    background: #020617;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}

.link-preview-frame-wrap.is-generic {
    aspect-ratio: auto;
    background: #fff;
    border: 1px solid var(--crm-border);
    height: min(48vh, 320px);
}

.link-preview-frame {
    border: 0;
    display: block;
    height: 100%;
    width: 100%;
}

.link-preview-fallback {
    align-items: center;
    color: var(--crm-muted);
    display: flex;
    flex-wrap: wrap;
    font-size: .82rem;
    gap: .75rem;
    justify-content: space-between;
    margin-top: .75rem;
}

.image-preview-modal-panel {
    max-width: 560px;
    width: min(560px, 92vw);
}

.image-preview-body {
    align-items: center;
    background: #020617;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    min-height: 220px;
    overflow: hidden;
}

.image-preview-media {
    display: block;
    max-height: min(66vh, 520px);
    max-width: 100%;
    object-fit: contain;
}

.drawer-overlay {
    background: rgb(15 23 42 / .55);
    position: absolute;
    inset: 0;
}

.drawer-panel {
    background: var(--crm-card);
    border-left: 1px solid var(--crm-border);
    height: 100%;
    margin-left: auto;
    max-width: 460px;
    overflow: auto;
    padding: 1.25rem;
    position: relative;
    width: min(92vw, 460px);
}

.data-table {
    border-collapse: collapse;
    font-size: .875rem;
    width: 100%;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--crm-border);
    padding: .85rem 1rem;
    text-align: left;
}

.data-table th {
    color: var(--crm-muted);
    font-size: .75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.data-table tbody tr:nth-child(even) {
    background: rgb(248 250 252 / .7);
}

.dark .data-table tbody tr:nth-child(even) {
    background: rgb(15 23 42 / .55);
}

.data-table tbody tr:hover {
    background: #ecfdf5;
}

.dark .data-table tbody tr:hover {
    background: rgb(6 78 59 / .22);
}

#report-heatmap {
    grid-template-columns: repeat(24, minmax(18px, 1fr));
}

.heat-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    min-width: 18px;
}

.toast {
    animation: toast-in .18s ease both;
    background: #0f172a;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgb(15 23 42 / .24);
    color: #fff;
    font-size: .875rem;
    max-width: 340px;
    padding: .85rem 1rem;
}

.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.warning { background: #b45309; }

.notification-panel {
    animation: scale-in .12s ease both;
    transform-origin: top right;
    z-index: 60;
}

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

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

@keyframes scale-in {
    from { opacity: 0; transform: scale(.97); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 767px) {
    #conversation-messages.chat-panel {
        --conversation-readable-width: 100%;
        padding: .6rem .55rem 5.5rem;
        scroll-padding-bottom: 5.5rem;
    }

    #conversation-messages .chat-bubble {
        max-width: 82%;
    }

    #conversation-messages .chat-bubble.has-media {
        max-width: 88%;
    }

    .toolbar .form-input,
    .toolbar .form-select,
    .toolbar .btn-secondary,
    .toolbar .btn-primary {
        width: 100%;
    }

    .kanban-board {
        grid-auto-columns: minmax(280px, 88vw);
    }

    .calendar-day {
        min-height: 72px;
        padding: .4rem;
    }
}

@media print {
    body {
        background: #fff;
    }

    aside,
    header,
    footer,
    .print\:hidden {
        display: none !important;
    }

    main {
        padding: 0 !important;
    }

    .crm-card {
        box-shadow: none;
        break-inside: avoid;
    }
}

/* Atendimento WhatsApp atualizado */
.conversation-presence-line {
    margin-top: .15rem;
    min-height: 1rem;
}

.conversation-presence {
    align-items: center;
    color: #16a34a;
    display: inline-flex;
    font-size: .78rem;
    font-weight: 700;
    gap: .35rem;
    line-height: 1.2;
    max-width: 100%;
    vertical-align: middle;
}

.conversation-presence.is-compact {
    font-size: .8rem;
}

.conversation-typing-dots {
    align-items: center;
    display: inline-flex;
    gap: 3px;
    justify-content: center;
    width: 18px;
}

.conversation-typing-dots i {
    animation: conversationTypingDot 1.05s ease-in-out infinite;
    background: currentColor;
    border-radius: 999px;
    display: block;
    height: 4px;
    opacity: .35;
    width: 4px;
}

.conversation-typing-dots i:nth-child(2) {
    animation-delay: .15s;
}

.conversation-typing-dots i:nth-child(3) {
    animation-delay: .3s;
}

.conversation-presence-recording {
    color: #dc2626;
}

.conversation-recording-dot {
    animation: conversationRecordingPulse 1s ease-in-out infinite;
    background: currentColor;
    border-radius: 999px;
    display: block;
    height: 7px;
    width: 7px;
}

.dark .conversation-presence {
    color: #4ade80;
}

.dark .conversation-presence-recording {
    color: #f87171;
}

@keyframes conversationTypingDot {
    0%,
    70%,
    100% {
        opacity: .35;
        transform: translateY(0);
    }
    35% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@keyframes conversationRecordingPulse {
    0%,
    100% {
        opacity: .55;
        transform: scale(.85);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.manual-audio-recorder {
    align-items: center;
    background: #ecfdf5;
    border: 1px solid rgb(16 185 129 / .35);
    border-radius: 8px;
    color: #065f46;
    display: flex;
    gap: 12px;
    padding: 8px 10px;
}

.manual-audio-recorder-status {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    gap: 8px;
}

.manual-audio-recorder-dot {
    background: #ef4444;
    border-radius: 999px;
    height: 9px;
    width: 9px;
}

.manual-audio-recorder.is-recording .manual-audio-recorder-dot {
    animation: audioPulse 1s ease-in-out infinite;
}

.manual-audio-recorder-time {
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
    font-weight: 900;
    letter-spacing: 0;
}

.manual-audio-recorder-preview {
    flex: 1 1 auto;
    height: 36px;
    min-width: 0;
}

.manual-audio-recorder-actions {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    gap: 6px;
}

#manual-audio-button.is-recording {
    background: #fee2e2;
    border-color: rgb(239 68 68 / .45);
    color: #b91c1c;
}

@keyframes audioPulse {
    0%, 100% {
        opacity: .45;
        transform: scale(.86);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

@media (max-width: 640px) {
    .manual-audio-recorder {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .manual-audio-recorder-preview {
        flex-basis: 100%;
        width: 100%;
    }
}

