/* ==========================================================================
   Casa Mas · CMS v2
   Tokens visuals extrets dels mockups (verd Casa Mas, xips d'estat, avatars)
   ========================================================================== */

:root {
    --cm-bg: #f6f7f5;
    --cm-surface: #ffffff;
    --cm-surface-2: #f3f5f2;
    --cm-sidebar: #fafbf9;
    --cm-border: #e6e9e4;
    --cm-border-strong: #d7dcd4;
    --cm-text: #1c211d;
    --cm-text-muted: #6b736c;
    --cm-text-faint: #9aa29b;

    --cm-green: #237a3b;
    --cm-green-hover: #1c6630;
    --cm-green-soft: #e7f4ea;
    --cm-green-softer: #f1f9f2;
    --cm-green-text: #1f6f35;

    --cm-amber-soft: #fff3d6;
    --cm-amber-text: #b26b00;
    --cm-red-soft: #fde7e7;
    --cm-red-text: #c0392b;
    --cm-blue-soft: #e8f0fe;
    --cm-blue-text: #2a5bb8;
    --cm-violet-soft: #efeafd;
    --cm-violet-text: #6544b8;
    --cm-gray-soft: #eef0ee;
    --cm-gray-text: #5b625c;
    --cm-note-bg: #fff6df;
    --cm-note-border: #f3dca6;
    --cm-note-text: #9a6200;

    --cm-radius-sm: 10px;
    --cm-radius: 14px;
    --cm-radius-lg: 18px;
    --cm-shadow: 0 1px 2px rgba(20, 30, 20, .04), 0 4px 14px rgba(20, 30, 20, .04);

    --cm-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --cm-font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;

    --bs-body-font-family: var(--cm-font);
    --bs-body-color: var(--cm-text);
    --bs-body-bg: var(--cm-bg);
    --bs-border-color: var(--cm-border);
    --bs-link-color: var(--cm-green);
    --bs-link-color-rgb: 35, 122, 59;
    --bs-link-hover-color: var(--cm-green-hover);
}

body {
    background: var(--cm-bg);
    color: var(--cm-text);
    font-family: var(--cm-font);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--cm-green); }

.cm-display {
    font-family: var(--cm-font-display);
    font-weight: 700;
    letter-spacing: -.01em;
}

.text-muted-cm { color: var(--cm-text-muted) !important; }
.text-faint { color: var(--cm-text-faint) !important; }
.fs-13 { font-size: 13px; }
.fs-12 { font-size: 12px; }

/* ---------- Shell: sidebar + main ---------- */

.cm-shell {
    display: flex;
    min-height: 100vh;
}

.cm-sidebar {
    width: 236px;
    flex-shrink: 0;
    background: var(--cm-sidebar);
    border-right: 1px solid var(--cm-border);
    padding: 22px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.cm-sidebar__logo {
    display: block;
    width: 84px;
    margin: 0 0 26px 12px;
}

.cm-sidebar__logo img {
    width: 100%;
    border-radius: 6px;
}

.cm-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cm-nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 12px;
    color: var(--cm-text);
    text-decoration: none;
    font-size: 15px;
}

.cm-nav__link svg { width: 20px; height: 20px; color: var(--cm-text-muted); flex-shrink: 0; }

.cm-nav__link:hover { background: var(--cm-surface-2); color: var(--cm-text); }

.cm-nav__link.is-active {
    background: var(--cm-green-soft);
    color: var(--cm-green-text);
    font-weight: 500;
}

.cm-nav__link.is-active svg { color: var(--cm-green-text); }

.cm-nav__link.is-disabled {
    color: var(--cm-text-faint);
    cursor: default;
}

.cm-nav__link.is-disabled:hover { background: transparent; }
.cm-nav__link.is-disabled svg { color: var(--cm-text-faint); }

.cm-nav__badge {
    margin-left: auto;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--cm-green);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cm-nav__soon {
    margin-left: auto;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--cm-text-faint);
}

.cm-main {
    flex: 1;
    min-width: 0;
    padding: 26px 32px 40px;
}

.cm-main--flush { padding: 0; }

.cm-mobilebar {
    display: none;
}

/* ---------- Capçalera de pàgina ---------- */

.cm-page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.cm-page-header h1 {
    font-family: var(--cm-font-display);
    font-weight: 700;
    font-size: 34px;
    letter-spacing: -.015em;
    margin: 0;
}

.cm-page-header__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.cm-user {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 0;
    padding: 4px 6px;
    border-radius: 12px;
    color: var(--cm-text);
    text-align: left;
}

.cm-user:hover { background: var(--cm-surface-2); }
.cm-user__name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.cm-user__role { font-size: 12px; color: var(--cm-text-muted); }

/* ---------- Controls ---------- */

.cm-select,
.cm-input {
    border: 1px solid var(--cm-border);
    background: var(--cm-surface);
    border-radius: var(--cm-radius-sm);
    height: 44px;
    padding: 0 14px;
    font-size: 15px;
    color: var(--cm-text);
}

.cm-select {
    appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231c211d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.cm-select:focus,
.cm-input:focus,
.cm-search input:focus {
    outline: 2px solid rgba(35, 122, 59, .25);
    outline-offset: 1px;
    border-color: var(--cm-green);
}

.cm-select-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.cm-select-icon > svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    pointer-events: none;
    color: var(--cm-text-muted);
}

.cm-select-icon > .cm-select { padding-left: 42px; max-width: 240px; }

.cm-search {
    position: relative;
    flex: 1;
}

.cm-search svg {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--cm-text-muted);
}

.cm-search input {
    width: 100%;
    height: 52px;
    border: 1px solid transparent;
    background: #eef1ec;
    border-radius: var(--cm-radius);
    padding: 0 18px 0 52px;
    font-size: 15px;
    color: var(--cm-text);
}

.cm-search input::placeholder { color: var(--cm-text-faint); }

.btn-cm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border-radius: var(--cm-radius-sm);
    border: 1px solid var(--cm-border);
    background: var(--cm-surface);
    color: var(--cm-green-text);
    font-weight: 500;
    font-size: 15px;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-cm svg { width: 20px; height: 20px; }
.btn-cm:hover { background: var(--cm-green-softer); border-color: var(--cm-border-strong); color: var(--cm-green-text); }

.btn-cm--primary {
    background: var(--cm-green);
    border-color: var(--cm-green);
    color: #fff;
}

.btn-cm--primary:hover { background: var(--cm-green-hover); border-color: var(--cm-green-hover); color: #fff; }

.btn-cm--icon {
    width: 44px;
    padding: 0;
    color: var(--cm-text);
}

.btn-cm--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--cm-text);
}

.btn-cm--round {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 999px;
}

.btn-cm:disabled,
.btn-cm.disabled {
    opacity: .5;
    pointer-events: none;
}

/* ---------- Pestanyes amb comptador ---------- */

.cm-tabs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.cm-tab {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    height: 50px;
    padding: 0 22px 0 26px;
    border-radius: var(--cm-radius);
    border: 1px solid var(--cm-border);
    background: var(--cm-surface);
    color: var(--cm-text);
    text-decoration: none;
    font-size: 15px;
    min-width: 130px;
    justify-content: space-between;
}

.cm-tab:hover { border-color: var(--cm-border-strong); color: var(--cm-text); }

.cm-tab__count {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--cm-gray-soft);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cm-tab.is-active {
    background: var(--cm-green-soft);
    border-color: var(--cm-green-soft);
    color: var(--cm-green-text);
    font-weight: 500;
}

.cm-tab.is-active .cm-tab__count { background: var(--cm-green); color: #fff; }

/* ---------- Targetes i taules ---------- */

.cm-card {
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-lg);
    box-shadow: var(--cm-shadow);
}

.cm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.cm-table-wrap { overflow-x: auto; }

.cm-table th {
    font-weight: 500;
    font-size: 14px;
    color: var(--cm-text-muted);
    padding: 16px 10px;
    border-bottom: 1px solid var(--cm-border);
    white-space: nowrap;
}

.cm-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--cm-border);
    vertical-align: middle;
}

.cm-table tbody tr:last-child td { border-bottom: 0; }
.cm-table th:first-child,
.cm-table td:first-child { padding-left: 22px; }
.cm-table th:last-child,
.cm-table td:last-child { padding-right: 18px; }

.cm-table tbody tr { transition: background-color .15s ease; }
.cm-table tbody tr:hover { background: #fafcf9; }
.cm-table tbody tr.is-highlight { background: var(--cm-green-softer); }

.cm-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--cm-text-muted);
}

/* ---------- Avatars ---------- */

.cm-avatar {
    --size: 52px;
    width: var(--size);
    height: var(--size);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: calc(var(--size) * .36);
    flex-shrink: 0;
    letter-spacing: .02em;
}

.cm-avatar--sm { --size: 36px; }
.cm-avatar--xs { --size: 28px; }
.cm-avatar--lg { --size: 64px; }

.cm-avatar--blue { background: #e6eefb; color: #24467f; }
.cm-avatar--violet { background: #ecebfa; color: #3d3a85; }
.cm-avatar--slate { background: #e9ecf0; color: #2f3a48; }
.cm-avatar--teal { background: #e3f1ee; color: #1f5c50; }
.cm-avatar--agent { background: var(--cm-green); color: #fff; }

.cm-client {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.cm-client__name { font-weight: 600; font-size: 16px; color: var(--cm-text); }
.cm-client__name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cm-client__msg {
    color: var(--cm-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.cm-client__time { color: var(--cm-text-faint); font-size: 13px; }

.cm-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--cm-green);
    margin-left: 6px;
    vertical-align: middle;
}

.cm-agent {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--cm-text-muted);
    white-space: nowrap;
}

/* ---------- Xips d'estat ---------- */

.cm-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border: 0;
}

.cm-chip svg { width: 18px; height: 18px; }
.cm-chip--sm { height: 28px; padding: 0 12px; font-size: 13px; }
/* Xip amb text llarg (noms de botiga): permet saltar de línia dins l'ample disponible */
.cm-chip--wrap { height: auto; min-height: 34px; max-width: 100%; padding: 6px 16px; border-radius: 17px; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }

.cm-chip--green { background: var(--cm-green-soft); color: var(--cm-green-text); }
.cm-chip--amber { background: var(--cm-amber-soft); color: var(--cm-amber-text); }
.cm-chip--red { background: var(--cm-red-soft); color: var(--cm-red-text); }
.cm-chip--blue { background: var(--cm-blue-soft); color: var(--cm-blue-text); }
.cm-chip--purple { background: var(--cm-violet-soft); color: var(--cm-violet-text); }
.cm-chip--gray { background: var(--cm-gray-soft); color: var(--cm-gray-text); }
.cm-chip--outline { background: var(--cm-surface); color: var(--cm-text); border: 1px solid var(--cm-border); }

.cm-chip--status-open { background: var(--cm-green-soft); color: var(--cm-green-text); }
.cm-chip--status-pending { background: var(--cm-amber-soft); color: var(--cm-amber-text); }
.cm-chip--status-resolved { background: var(--cm-gray-soft); color: var(--cm-gray-text); }

button.cm-chip { cursor: pointer; }
button.cm-chip:hover { filter: brightness(.97); }

.cm-wait {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    white-space: nowrap;
}

.cm-wait__time {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--cm-text-muted);
}

.cm-wait__time svg { width: 20px; height: 20px; }
.cm-wait.is-late .cm-wait__time svg { color: var(--cm-amber-text); }
.cm-wait__late { color: #e2830c; font-size: 13px; padding-left: 28px; }

/* ---------- Dropdowns ---------- */

.dropdown-menu {
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    box-shadow: 0 12px 32px rgba(20, 30, 20, .12);
    padding: 8px;
    font-size: 15px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    padding: 9px 12px;
}

.dropdown-item svg { width: 18px; height: 18px; color: var(--cm-text-muted); }
.dropdown-item:active { background: var(--cm-green-soft); color: var(--cm-green-text); }
.dropdown-item.is-current { font-weight: 600; color: var(--cm-green-text); }
.dropdown-header { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Conversa ---------- */

.cm-convo {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    height: 100vh;
}

.cm-convo__main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100vh;
    border-right: 1px solid var(--cm-border);
    background: var(--cm-surface);
}

.cm-convo__header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 28px;
    border-bottom: 1px solid var(--cm-border);
}

.cm-convo__header h1 {
    font-family: var(--cm-font-display);
    font-weight: 700;
    font-size: 26px;
    margin: 0;
}

.cm-convo__contact {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 28px 10px;
}

.cm-convo__contact-name {
    font-family: var(--cm-font-display);
    font-weight: 700;
    font-size: 24px;
    line-height: 1.2;
}

.cm-convo__contact-phone { color: var(--cm-text-muted); font-size: 16px; }

.cm-window {
    margin: 4px 28px 8px;
    padding: 11px 18px;
    border-radius: var(--cm-radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    font-size: 15px;
}

.cm-window svg { width: 20px; height: 20px; }
.cm-window--open { background: var(--cm-green-soft); color: var(--cm-green-text); }
.cm-window--closed { background: var(--cm-amber-soft); color: var(--cm-amber-text); }

.cm-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 28px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cm-day {
    align-self: center;
    font-size: 12px;
    color: var(--cm-text-muted);
    background: var(--cm-surface-2);
    padding: 4px 12px;
    border-radius: 999px;
    margin: 10px 0 4px;
}

.cm-msg {
    max-width: min(560px, 78%);
    display: flex;
    flex-direction: column;
    margin-top: 6px;
}

.cm-msg--in { align-self: flex-start; }
.cm-msg--out { align-self: flex-end; align-items: flex-end; }

.cm-bubble {
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cm-msg--in .cm-bubble { background: #f0f2ef; border-bottom-left-radius: 6px; }
.cm-msg--out .cm-bubble { background: var(--cm-green-soft); border-bottom-right-radius: 6px; }

.cm-bubble__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--cm-green-text);
    margin-bottom: 4px;
    white-space: normal;
}

.cm-bubble__label svg { width: 14px; height: 14px; }

.cm-msg__meta {
    font-size: 13px;
    color: var(--cm-text-muted);
    margin-top: 4px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cm-msg__meta svg { width: 16px; height: 16px; }
.cm-msg__meta .is-read { color: #3b82f6; }

/* Submenú d'accions d'un missatge rebut (p. ex. generar comanda amb IA) */
.cm-msg__more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 22px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--cm-text-muted);
    opacity: 0;
    transition: opacity .15s ease, background .15s ease;
}

.cm-msg:hover .cm-msg__more,
.cm-msg__more:focus-visible,
.cm-msg__more[aria-expanded="true"] { opacity: 1; }
.cm-msg__more:hover { background: var(--cm-green-softer); color: var(--cm-green-text); }
@media (hover: none) { .cm-msg__more { opacity: 1; } }

/* Modal "Generar comanda amb IA" */
.cm-ai-order .modal-dialog { max-width: 440px; }
.cm-ai-order .modal-content {
    border: 0;
    border-radius: var(--cm-radius-lg);
    background: var(--cm-surface);
    box-shadow: 0 20px 60px rgba(20, 30, 20, .18);
}
.cm-ai-order__loading,
.cm-ai-order__result { padding: 32px 28px 24px; text-align: center; }
.cm-ai-order__title { margin: 0 0 6px; font-family: var(--cm-font-display); font-size: 21px; font-weight: 600; line-height: 1.3; }
.cm-ai-order__hint { margin: 0; color: var(--cm-text-muted); font-size: 14px; }

.cm-ai-order__orb {
    position: relative;
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: var(--cm-violet-soft);
    color: var(--cm-violet-text);
    animation: cm-ai-pulse 1.8s ease-in-out infinite;
}
.cm-ai-order__orb::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--cm-violet-text);
    border-right-color: var(--cm-violet-text);
    animation: cm-ai-spin 1.1s linear infinite;
}
.cm-ai-order__orb svg { width: 30px; height: 30px; animation: cm-ai-twinkle 1.8s ease-in-out infinite; }

.cm-ai-order__step { min-height: 22px; margin: 4px 0 16px; color: var(--cm-text); font-size: 15px; }
.cm-ai-order__step.is-in { animation: cm-ai-step .35s ease-out; }

.cm-ai-order__bar { position: relative; height: 4px; margin: 0 auto 14px; max-width: 240px; border-radius: 2px; background: var(--cm-violet-soft); overflow: hidden; }
.cm-ai-order__bar span { position: absolute; inset: 0 auto 0 0; width: 40%; border-radius: 2px; background: var(--cm-violet-text); animation: cm-ai-bar 1.4s ease-in-out infinite; }

.cm-ai-order__result > * { animation: cm-ai-step .3s ease-out both; }
.cm-ai-order__badge { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; }
.cm-ai-order__badge svg { width: 28px; height: 28px; }
.cm-ai-order__badge--ok { background: var(--cm-green-soft); color: var(--cm-green-text); }
.cm-ai-order__badge--error { background: var(--cm-red-soft); color: var(--cm-red-text); }

.cm-ai-order__lines { margin: 18px 0 0; padding: 0; list-style: none; text-align: left; border: 1px solid var(--cm-border); border-radius: var(--cm-radius); max-height: 260px; overflow-y: auto; }
.cm-ai-order__lines li { display: flex; gap: 12px; align-items: baseline; padding: 10px 14px; font-size: 14px; }
.cm-ai-order__lines li + li { border-top: 1px solid var(--cm-border); }
.cm-ai-order__qty { flex: 0 0 auto; min-width: 34px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--cm-green-text); text-align: right; }
.cm-ai-order__qty::after { content: ' ×'; font-weight: 400; color: var(--cm-text-faint); }

.cm-ai-order__warn { margin-top: 14px; padding: 12px 14px; border-radius: var(--cm-radius); background: var(--cm-amber-soft); color: var(--cm-amber-text); font-size: 14px; text-align: left; }
.cm-ai-order__warn strong { display: flex; align-items: center; gap: 6px; }
.cm-ai-order__warn ul { margin: 6px 0; padding-left: 20px; color: var(--cm-text); }

.cm-ai-order__actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }
.cm-ai-order__actions .btn-cm { flex: 1 1 0; justify-content: center; }

@keyframes cm-ai-spin { to { transform: rotate(360deg); } }
@keyframes cm-ai-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(101, 68, 184, .25); } 50% { box-shadow: 0 0 0 12px rgba(101, 68, 184, 0); } }
@keyframes cm-ai-twinkle { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.12) rotate(8deg); } }
@keyframes cm-ai-bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@keyframes cm-ai-step { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .cm-ai-order__orb, .cm-ai-order__orb::before, .cm-ai-order__orb svg, .cm-ai-order__bar span { animation-duration: 3s; }
    .cm-ai-order__step.is-in, .cm-ai-order__result > * { animation: none; }
}

/* Adjunts */
.cm-media {
    display: block;
    max-width: 320px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--cm-surface-2);
}

.cm-media img,
video.cm-media { display: block; width: 100%; max-height: 360px; object-fit: cover; }

.cm-file {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 260px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: 16px;
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
    color: var(--cm-text);
    text-decoration: none;
}

.cm-file:hover { border-color: var(--cm-border-strong); color: var(--cm-text); }

.cm-file__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--cm-red-soft);
    color: var(--cm-red-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cm-file__icon svg { width: 22px; height: 22px; }
.cm-file__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cm-file__open { width: 18px; height: 18px; color: var(--cm-text-muted); }

.cm-bubble--caption { margin-top: 6px; }

.btn-cm--sm { height: 36px; padding: 0 14px; font-size: 14px; }
.btn-cm--sm svg { width: 16px; height: 16px; }

/* Àudio */
.cm-audio {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px 10px 12px;
    background: #f0f2ef;
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    min-width: 320px;
}

.cm-audio__play {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid var(--cm-border);
    background: var(--cm-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cm-text);
    flex-shrink: 0;
}

.cm-audio__play svg { width: 20px; height: 20px; fill: currentColor; }

.cm-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 34px;
    flex: 1;
}

.cm-wave span {
    flex: 1;
    min-width: 2px;
    border-radius: 2px;
    background: #b9c0ba;
    transition: background-color .2s linear;
}

.cm-wave span.is-played { background: var(--cm-text); }

.cm-audio__time { font-size: 14px; color: var(--cm-text-muted); font-variant-numeric: tabular-nums; }

.cm-transcript {
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    background: var(--cm-surface);
    max-width: 560px;
    margin-top: 10px;
}

.cm-transcript summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 4px;
    cursor: pointer;
    font-weight: 600;
}

.cm-transcript summary::-webkit-details-marker { display: none; }
.cm-transcript summary svg { width: 20px; height: 20px; }
.cm-transcript summary .cm-transcript__chevron { margin-left: auto; transition: transform .2s ease; }
.cm-transcript[open] summary .cm-transcript__chevron { transform: rotate(180deg); }
.cm-transcript__lang { height: 20px; padding: 0 7px; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.cm-transcript__body { padding: 2px 18px 14px 48px; color: var(--cm-text-muted); }

/* Nota interna */
.cm-note {
    align-self: flex-start;
    max-width: min(620px, 86%);
    margin-top: 10px;
    background: var(--cm-note-bg);
    border: 1px solid var(--cm-note-border);
    border-radius: var(--cm-radius);
    padding: 12px 18px;
}

.cm-note__title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--cm-note-text);
    font-weight: 600;
}

.cm-note__title svg { width: 20px; height: 20px; }
.cm-note__body { display: flex; gap: 16px; align-items: flex-end; margin-top: 2px; }
.cm-note__text { flex: 1; white-space: pre-wrap; }
.cm-note__time { font-size: 13px; color: var(--cm-text-muted); white-space: nowrap; }

/* Compositor */
.cm-composer {
    border-top: 1px solid var(--cm-border);
    padding: 14px 28px 18px;
    background: var(--cm-surface);
}

.cm-quick {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cm-quick__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}

.cm-quick__label svg { width: 20px; height: 20px; }

.cm-quick__chip {
    height: 44px;
    padding: 0 20px;
    border-radius: var(--cm-radius-sm);
    border: 1px solid var(--cm-border);
    background: var(--cm-surface);
    font-weight: 500;
    color: var(--cm-text);
}

.cm-quick__chip:disabled,
.cm-quick__chip.is-unavailable { opacity: .45; cursor: not-allowed; }

.cm-quick__chip.is-active,
.cm-quick__chip:not(:disabled):not(.is-unavailable):hover { background: var(--cm-green-soft); border-color: var(--cm-green-soft); color: var(--cm-green-text); }

.cm-quick__preview {
    flex: 1;
    min-width: 120px;
    background: var(--cm-surface-2);
    border-radius: var(--cm-radius-sm);
    padding: 10px 16px;
    color: var(--cm-text-muted);
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Avisos de les respostes ràpides: han de cridar l'atenció i llegir-se sencers */
.cm-quick__preview.is-warning,
.cm-quick__preview.is-info { white-space: normal; font-weight: 500; }
.cm-quick__preview.is-warning { background: var(--cm-amber-soft); color: var(--cm-amber-text); }
.cm-quick__preview.is-info { background: var(--cm-blue-soft); color: var(--cm-blue-text); }

.cm-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px 56px;
    padding: 2px 4px 2px 12px;
    border-radius: var(--cm-radius-sm);
    background: var(--cm-surface-2);
    font-size: 14px;
    color: var(--cm-text-muted);
}

.cm-attachment[hidden] { display: none; }
.cm-attachment svg { width: 16px; height: 16px; }
.cm-attachment .btn-cm { width: 32px; height: 32px; }

.cm-composer__row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cm-composer__input {
    flex: 1;
    min-height: 52px;
    max-height: 160px;
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    padding: 14px 18px;
    font-size: 15px;
    resize: none;
    background: var(--cm-surface);
    color: var(--cm-text);
}

.cm-composer__input:focus { outline: 2px solid rgba(35, 122, 59, .25); border-color: var(--cm-green); }
.cm-composer.is-note .cm-composer__input { background: var(--cm-note-bg); border-color: var(--cm-note-border); }

.cm-send {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    border: 0;
    background: var(--cm-green);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color .15s ease, transform .1s ease;
}

.cm-send:hover { background: var(--cm-green-hover); }
.cm-send:active { transform: scale(.96); }
.cm-send svg { width: 24px; height: 24px; }
.cm-composer.is-note .cm-send { background: var(--cm-note-text); }

.cm-mode {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--cm-surface-2);
    margin-left: auto;
}

.cm-mode button {
    border: 0;
    background: transparent;
    padding: 6px 12px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cm-text-muted);
}

.cm-mode button.is-active { background: var(--cm-surface); color: var(--cm-text); box-shadow: var(--cm-shadow); }

.cm-flash {
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: var(--cm-radius-sm);
    font-size: 14px;
}

.cm-flash--error { background: var(--cm-red-soft); color: var(--cm-red-text); }
.cm-flash--success { background: var(--cm-green-soft); color: var(--cm-green-text); }

/* ---------- Configuració: etiquetes ---------- */

.cm-tags { overflow: hidden; }
.cm-tags__intro { margin: 0; padding: 18px 22px 6px; font-size: 14px; }

.cm-tags__row {
    display: grid;
    grid-template-columns: 170px minmax(160px, 1fr) auto 110px auto;
    align-items: center;
    gap: 16px;
    padding: 12px 18px 12px 22px;
    border-top: 1px solid var(--cm-border);
}

.cm-tags__row--new { background: var(--cm-green-softer); }
.cm-tags__preview { min-width: 0; display: flex; color: var(--cm-text-muted); }
.cm-tags__preview .cm-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.cm-tags__name { width: 100%; min-width: 0; }
.cm-tags__usage { font-size: 13px; white-space: nowrap; }
.cm-tags__actions { display: flex; gap: 6px; justify-content: flex-end; }
.cm-tags__delete:hover { background: var(--cm-red-soft); color: var(--cm-red-text); border-color: var(--cm-red-soft); }

.cm-swatches { display: flex; gap: 6px; }
.cm-swatch__input { position: absolute; opacity: 0; pointer-events: none; }

.cm-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
    cursor: pointer;
}

.cm-swatch__input:checked + .cm-swatch { border-color: currentColor; box-shadow: inset 0 0 0 3px var(--cm-surface); }
.cm-swatch__input:focus-visible + .cm-swatch { outline: 2px solid var(--cm-green); outline-offset: 2px; }

/* Nova etiqueta des de la fitxa del client */
.cm-chip--dashed { background: transparent; color: var(--cm-text-muted); border: 1px dashed var(--cm-border-strong); cursor: pointer; list-style: none; }
.cm-chip--dashed::-webkit-details-marker { display: none; }
.cm-chip--dashed:hover { color: var(--cm-green-text); border-color: var(--cm-green-text); }
.cm-tagnew[open] > summary { color: var(--cm-green-text); border-color: var(--cm-green-text); }
.cm-tagnew__form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.cm-tagnew .cm-swatch { width: 24px; height: 24px; }

@media (max-width: 991.98px) {
    .cm-tags__row { grid-template-columns: 1fr auto; padding: 14px 16px; }
    .cm-tags__preview, .cm-tags__name { grid-column: 1 / -1; }
}

/* ---------- Fitxa del client ---------- */

.cm-profile {
    background: var(--cm-surface);
    overflow-y: auto;
    padding: 18px 26px 28px;
}

.cm-profile__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.cm-profile__header h2 {
    font-family: var(--cm-font-display);
    font-weight: 700;
    font-size: 24px;
    margin: 0;
}

.cm-section {
    padding: 18px 0;
    border-top: 1px solid var(--cm-border);
}

.cm-section__title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 12px;
}

.cm-section__title svg { width: 22px; height: 22px; color: var(--cm-text); }

.cm-section__body { padding-left: 34px; }
.cm-section__link { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--cm-green-text); text-decoration: none; }
.cm-section__link:hover { text-decoration: underline; }

.cm-orders {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cm-orders__row {
    display: grid;
    grid-template-columns: 82px 1fr auto 20px;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    margin: 0 -8px;
    border-radius: 10px;
    color: var(--cm-text);
    text-decoration: none;
}

.cm-orders__row:hover { background: var(--cm-surface-2); color: var(--cm-text); }

.cm-orders__ref { font-weight: 600; }
.cm-orders__date { color: var(--cm-text-muted); font-size: 14px; }
.cm-orders__row svg { color: var(--cm-text-muted); width: 18px; height: 18px; }

.cm-notes summary { list-style: none; cursor: pointer; margin-bottom: 0; }
.cm-notes summary::-webkit-details-marker { display: none; }
.cm-notes[open] summary { margin-bottom: 12px; }
.cm-notes summary .cm-notes__chevron { margin-left: auto; width: 18px; height: 18px; color: var(--cm-text-muted); transition: transform .2s ease; }
.cm-notes[open] summary .cm-notes__chevron { transform: rotate(180deg); }

.cm-notelist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }

.cm-notelist__row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--cm-note-border);
    border-radius: 10px;
    background: var(--cm-note-bg);
    color: var(--cm-text);
    text-align: left;
    cursor: pointer;
}

.cm-notelist__row:hover { border-color: var(--cm-note-text); }

.cm-notelist__text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
}

.cm-notelist__meta { font-size: 13px; color: var(--cm-text-muted); }

/* Nota del fil destacada en arribar-hi des de la fitxa */
.cm-note.is-highlighted { animation: cm-note-flash 1.6s ease-out; }
@keyframes cm-note-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--cm-note-text); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ---------- Seguiment de comandes ---------- */

.cm-badge-info {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: var(--cm-radius-sm);
    background: var(--cm-green-softer);
    border: 1px solid #cfe8d5;
    color: var(--cm-green-text);
    font-weight: 500;
}

.cm-badge-info svg { width: 20px; height: 20px; }

.cm-funnel {
    padding: 18px 22px 20px;
    margin-bottom: 22px;
}

.cm-funnel h2 {
    font-family: var(--cm-font-display);
    font-weight: 700;
    font-size: 22px;
    margin: 0 0 14px;
}

.cm-funnel h2::first-letter { text-transform: uppercase; }

.cm-funnel__steps {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

/* Fletxa entre passos */
.cm-funnel__step {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "icon count" "label label" "pct pct";
    align-items: center;
    column-gap: 12px;
    padding: 14px 18px;
    border-radius: var(--cm-radius);
    background: var(--cm-surface-2);
    border: 2px solid transparent;
    color: var(--cm-text);
    text-decoration: none;
}

.cm-funnel__step + .cm-funnel__step::before {
    content: '›';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cm-text-faint);
    font-size: 22px;
    line-height: 1;
}

.cm-funnel__step:hover { color: var(--cm-text); border-color: var(--cm-border-strong); }
.cm-funnel__step.is-active { border-color: var(--cm-green); background: var(--cm-green-softer); }

.cm-funnel__icon {
    grid-area: icon;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: var(--cm-green-soft);
    color: var(--cm-green-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cm-funnel__icon svg { width: 22px; height: 22px; }
.cm-funnel__count { grid-area: count; font-family: var(--cm-font-display); font-weight: 700; font-size: 32px; text-align: right; }
.cm-funnel__label { grid-area: label; margin-top: 8px; font-weight: 600; }
.cm-funnel__pct { grid-area: pct; color: var(--cm-text-muted); font-size: 13px; }

.cm-funnel__outcomes {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--cm-border);
}

.cm-funnel__outcomes .cm-chip { text-decoration: none; border: 2px solid transparent; }
.cm-funnel__outcomes .cm-chip.is-active { border-color: currentColor; }

.cm-daynav { display: flex; align-items: center; gap: 4px; }
.cm-daynav .cm-select { max-width: 200px; }

.cm-journey td { vertical-align: middle; white-space: nowrap; }
.cm-journey td:first-child { white-space: normal; min-width: 260px; }

.cm-step {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

.cm-step svg { width: 18px; height: 18px; }
.cm-step--done { color: var(--cm-green-text); font-weight: 500; }
.cm-step--inferred { opacity: .6; font-weight: 400; cursor: help; }
.cm-step--waiting { color: var(--cm-amber-text); }
.cm-step--failed { color: var(--cm-red-text); font-weight: 500; }
.cm-step--none { color: var(--cm-text-faint); }

.cm-step__extra { display: block; margin-top: 2px; color: var(--cm-text-muted); font-size: 12px; }

.cm-step__pdf {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    font-size: 13px;
    font-weight: 500;
}

.cm-step__pdf svg { width: 15px; height: 15px; }

@media (max-width: 1100px) {
    .cm-funnel__steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cm-funnel__step + .cm-funnel__step::before { content: none; }
}

/* ---------- Login ---------- */

.cm-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.cm-login__card {
    width: 100%;
    max-width: 400px;
    padding: 34px 32px;
}

.cm-login__card img { width: 88px; border-radius: 6px; margin-bottom: 18px; }
.cm-login__card h1 { font-family: var(--cm-font-display); font-weight: 700; font-size: 28px; margin-bottom: 4px; }
.cm-login__card .cm-input { width: 100%; }
.cm-login__card label { font-size: 14px; font-weight: 500; margin: 14px 0 6px; }

/* ---------- Emulador de WhatsApp ---------- */

.wa-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.wa-contacts { padding: 8px; max-height: calc(100vh - 160px); overflow-y: auto; }

.wa-contact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--cm-text);
}

.wa-contact:hover { background: var(--cm-surface-2); color: var(--cm-text); }
.wa-contact.is-active { background: var(--cm-green-soft); }
.wa-contact__name { font-weight: 600; font-size: 14px; }
.wa-contact__phone { font-size: 12px; color: var(--cm-text-muted); }

.wa-phone {
    width: 390px;
    max-width: 100%;
    height: min(780px, calc(100vh - 140px));
    margin: 0 auto;
    border-radius: 44px;
    border: 10px solid #1d1f1e;
    background: #efeae2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0, 0, 0, .18);
}

.wa-phone__bar {
    background: #075e54;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 30px 14px 10px;
}

.wa-phone__bar img { width: 36px; height: 36px; border-radius: 999px; background: #fff; object-fit: contain; }
.wa-phone__title { font-weight: 600; font-size: 15px; line-height: 1.1; }
.wa-phone__subtitle { font-size: 12px; opacity: .8; }

.wa-thread {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wa-msg {
    max-width: 82%;
    padding: 7px 10px 5px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.35;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .08);
    overflow-wrap: anywhere;
}

.wa-msg__text { white-space: pre-wrap; }

.wa-msg--me { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 2px; }
.wa-msg--them { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.wa-msg__meta { display: block; text-align: right; font-size: 11px; color: #667781; margin-top: 2px; }
.wa-msg__template { display: block; font-size: 11px; color: #667781; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.wa-msg audio { width: 220px; height: 34px; }

.wa-composer {
    background: #f0f2f5;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wa-composer__row { display: flex; gap: 6px; align-items: center; }

.wa-composer input[type=text] {
    flex: 1;
    height: 42px;
    border-radius: 999px;
    border: 0;
    padding: 0 16px;
    font-size: 14px;
    background: #fff;
}

.wa-composer button.wa-btn {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 0;
    background: #00a884;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wa-composer button.wa-btn--ghost { background: transparent; color: #54656f; }
.wa-composer button.wa-btn.is-active { background: #e9edef; color: #00a884; }
.wa-composer svg { width: 20px; height: 20px; }

.wa-attachment,
.wa-recording {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-radius: 12px;
    padding: 6px 10px;
    font-size: 12px;
    color: #54656f;
}

.wa-attachment[hidden],
.wa-recording[hidden] { display: none; }
.wa-attachment span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-attachment button { border: 0; background: transparent; color: #54656f; padding: 0; }
.wa-attachment svg { width: 16px; height: 16px; }

.wa-recording__dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #e53935;
    animation: wa-pulse 1s ease-in-out infinite;
}

@keyframes wa-pulse { 50% { opacity: .3; } }

.wa-composer button.wa-btn.is-recording { background: #e53935; }
.wa-hint { margin: 0; font-size: 12px; color: #c0392b; padding: 0 6px; }

.wa-msg__image { display: block; max-width: 100%; border-radius: 8px; margin-bottom: 2px; }
.wa-msg__file { display: inline-flex; align-items: center; gap: 6px; color: #111b21; font-weight: 500; }
.wa-msg__file svg { width: 18px; height: 18px; }

/* ---------- Responsive ---------- */

@media (max-width: 1280px) {
    .cm-convo { grid-template-columns: minmax(0, 1fr) 330px; }
    .cm-improvements { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cm-improvements h3 { grid-column: 1 / -1; border-right: 0; }
}

@media (max-width: 1100px) {
    .cm-convo { grid-template-columns: 1fr; height: auto; }
    .cm-convo__main { height: 100vh; border-right: 0; }
    .cm-profile { border-top: 1px solid var(--cm-border); }
    .cm-signal-grid { grid-template-columns: 1fr; }
    .wa-layout { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .cm-sidebar {
        position: fixed;
        z-index: 1040;
        left: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .15);
    }

    .cm-shell.is-nav-open .cm-sidebar { transform: none; }

    .cm-mobilebar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        border-bottom: 1px solid var(--cm-border);
        background: var(--cm-surface);
        position: sticky;
        top: 0;
        z-index: 1030;
    }

    .cm-mobilebar img { height: 32px; border-radius: 4px; }
    .cm-main { padding: 18px 16px 32px; }
    .cm-page-header h1 { font-size: 28px; }
    .cm-convo__header, .cm-convo__contact, .cm-thread, .cm-composer { padding-left: 16px; padding-right: 16px; }
    .cm-window { margin-left: 16px; margin-right: 16px; }
    .cm-improvements { grid-template-columns: 1fr; }
    .cm-table-wrap { overflow-x: auto; }
    .cm-table { min-width: 900px; }
    .cm-audio { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
