/* /css/topbar.css?v=3 */

:root{
    --crm-bg:#fff;
    --crm-border:#e6e6e6;
    --crm-soft:#f4f6f9;
    --crm-soft2:#eaf2ff;
    --crm-text:#1f2a37;
    --crm-muted:#607086;
    --crm-accent:#0d6efd;
    --crm-danger:#dc3545;
}

/* =========================================================
   ВАЖНО:
   У тебя в style.css ограничен body (max-width:1200 + padding).
   Эта шапка должна быть НА ВСЮ ширину экрана, а внутри — 1200.
   ========================================================= */

/* Шапка на всю ширину (вытаскиваем из "карточки" body) */
.crm-topbar{
    position: sticky;
    top: 0;
    z-index: 50;

    background: var(--crm-bg);
    border-bottom: 1px solid var(--crm-border);
    box-shadow: 0 2px 10px rgba(0,0,0,.04);

    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

/* На обычных страницах body имеет `padding: 1rem` из style.css.
   Компенсируем и этот gutter, иначе шапка визуально уезжает вправо. */
body:not(.page-manager) .crm-topbar{
    width: calc(100vw + 2rem);
    margin-left: calc(50% - 50vw - 1rem);
    margin-right: calc(50% - 50vw - 1rem);
}

/* Внутренности шапки ограничены 1200 и центрированы */
.crm-topbar__inner{
    max-width: 1200px;
    margin: 0 auto;
    padding: 5px 10px;

    position: relative;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;

    min-height: 46px; /* compact topbar */
}

/* =========================================================
   Apple-like test globalnav (second row under topbar)
   ========================================================= */
.crm-globalnav{
    position: relative;
  /*  border-top: 1px solid rgba(15, 23, 42, 0.05); */
    background: rgba(255, 255, 255, 1);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.crm-globalnav__inner{
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 10px;
}

.crm-globalnav__list{
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.crm-globalnav__item{
    position: static;
}

.crm-globalnav__trigger{
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    color: rgba(29, 29, 31, 0.84);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: background-color .18s ease, color .18s ease;
}

.crm-globalnav__item:hover .crm-globalnav__trigger,
.crm-globalnav__item:focus-within .crm-globalnav__trigger,
.crm-globalnav__item.is-active .crm-globalnav__trigger{
    background: rgba(15, 23, 42, 0.06);
    color: #111827;
}

.crm-globalnav__panel{
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 65;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(251, 251, 253, 0.96);
    box-shadow: 0 24px 44px rgba(15, 23, 42, 0.08);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
}

.crm-globalnav__item:hover .crm-globalnav__panel,
.crm-globalnav__item:focus-within .crm-globalnav__panel{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.crm-globalnav__panel-inner{
    max-width: 1040px;
    margin: 0 auto;
    padding: 26px 10px 30px;
    display: grid;
    grid-template-columns: minmax(300px, 1.45fr) repeat(2, minmax(180px, 1fr));
    gap: 28px;
}

.crm-globalnav__column{
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.crm-globalnav__eyebrow{
    color: #6e6e73;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
}

.crm-globalnav__feature-links,
.crm-globalnav__links,
.crm-globalnav__secondary-links{
    display: flex;
    flex-direction: column;
}

.crm-globalnav__feature-links{
    gap: 2px;
}

.crm-globalnav__links{
    gap: 8px;
}

.crm-globalnav__secondary-links{
    gap: 6px;
    margin-top: 4px;
}

.crm-globalnav__feature-link{
    color: #1d1d1f;
    font-size: clamp(24px, 2vw, 34px);
    font-weight: 600;
    line-height: 1.06;
    letter-spacing: -0.05em;
    padding: 2px 0;
}

.crm-globalnav__secondary-link,
.crm-globalnav__link{
    color: rgba(29, 29, 31, 0.84);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
}

.crm-globalnav__secondary-link:hover,
.crm-globalnav__link:hover,
.crm-globalnav__feature-link:hover{
    color: #111827;
}

/* =========================================================
   Breadcrumbs (under topbar)
   ========================================================= */
.crm-breadcrumbs{
    max-width: 1200px;
    margin: 0 auto;
    padding: 3px 10px 0 10px;

    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;

    font-size: 10px;
    line-height: 1.2;
}

.page-manager .crm-breadcrumbs{
    padding: 2px 8px 0 8px;
    gap: 3px;
    min-height: 24px;
}

.crm-breadcrumbs__sep{
    opacity: .5;
}

.crm-breadcrumbs__link{
    color: #0a84ff;
    text-decoration: none;
}

.crm-breadcrumbs__link:hover{
    text-decoration: underline;
}

.crm-breadcrumbs__current{
    opacity: .8;
}

.crm-breadcrumbs__tools-slot{
    margin-left: auto;
    display: flex;
    align-items: center;
    min-height: 20px;
}

.crm-breadcrumbs__tools{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

/* =========================================================
   Защита от глобальных стилей style.css (кнопки/ссылки)
   ========================================================= */
.crm-topbar a{
    text-decoration:none;
    color: var(--crm-text);
    font-weight:300;
}
.crm-topbar a:hover{ text-decoration:none; }

/* В style.css button огромный — сбрасываем строго внутри топбара */
.crm-topbar button{
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;

    padding: 0;
    margin: 0;

    font: inherit;
    color: inherit;
    line-height: 1;
}

/* =========================================================
   LEFT / CENTER / RIGHT
   ========================================================= */
.crm-topbar__left{
    display:flex;
    align-items:center;
    gap:8px;
    flex: 0 0 auto;
    min-width: 260px; /* чтобы центр визуально держался */
}

.crm-brand img{
    height:30px;
    width:auto;
    display:block;
}
.crm-context{
    display:flex;
    align-items:center;
    gap:8px;
    line-height:1.1;
}

.crm-context__id{
    font-size:24px;
    font-weight:100;
    color:color(display-p3 0.1647 0.3922 0.6);
    letter-spacing:-0.08em;
    line-height:1;
    display:flex;
    align-items:center;
    height:100%;
}

.crm-context__text{
    display:flex;
    flex-direction:column;
}

.crm-context__title{
    font-size:11px;
    color:var(--crm-muted);
}

.crm-context__subtitle{
    font-size:10px;
    font-weight:600;
    color:var(--crm-text);
    text-transform:uppercase;
}



/* RIGHT фиксируем по ширине, чтобы центр был реально по центру экрана */
.crm-topbar__right{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap:4px;
    flex: 0 0 auto;
    min-width: 360px;
}

/* Top-level action buttons in the header stay neutral on every page. */
.crm-topbar__right > #newOrderBtn,
.crm-topbar__right > #crmBtnNotif,
.crm-topbar__right > #crmBtnMessenger,
.crm-topbar__right > .crm-userbox > #crmUserMenuBtn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:36px;
    height:36px;
    padding:6px;
    border-radius:10px;
    background: transparent;
    color: var(--crm-text);
    box-shadow: none;
}

.crm-topbar__right > #newOrderBtn:hover,
.crm-topbar__right > #crmBtnNotif:hover,
.crm-topbar__right > #crmBtnMessenger:hover,
.crm-topbar__right > .crm-userbox > #crmUserMenuBtn:hover{
    background: var(--crm-soft);
    color: var(--crm-text);
    filter: none;
}

.crm-topbar__center{
    flex: 1 1 auto;
    min-width: 0;
    display:flex;
    justify-content:flex-end;
    align-items:center;
    padding-right: 6px;
}



/* =========================================================
   SEARCH (делаем компактнее, чтобы не раздувало высоту)
   ========================================================= */
.crm-search{
    position: relative;
    display:flex;
    align-items:center;
    gap: 8px;

    background: var(--crm-soft);
    border: 1px solid transparent;
    border-radius: 10px;

    padding: 4px 8px;
    width: min(420px, 100%);
    max-width: 420px;
    min-width: 180px;
    height: 32px;
    box-sizing: border-box;
}
.crm-search:focus-within{
    background:#fff;
    border-color: rgba(13,110,253,.35);

}

.crm-search__ico{
    width:16px;
    height:16px;
    display:inline-flex;
    color: var(--crm-muted);
}
.crm-search__ico svg{
    width:16px; height:16px;
    fill:none; stroke:currentColor; stroke-width:2;
    stroke-linecap:round; stroke-linejoin:round;
}

.crm-search__input{
    width:100%;
    border:0 !important;
    outline:none;
    background:transparent;
    font-size:12px;
    color: var(--crm-text);
    padding: 0;           /* важно */
    margin: 0;            /* важно */
    line-height: 1.2;
}

.crm-search__hint{
    flex:0 0 auto;
    font-size:10px;
    color: var(--crm-muted);
    background: rgba(0,0,0,.06);
    border-radius: 8px;
    padding: 2px 6px;
    line-height: 1.1;
}

/* dropdown */
.crm-search__dropdown{
    position:absolute;
    left:0; right:0;
    top: calc(100% + 8px);
    background:#fff;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0,0,0,.10);
    overflow:hidden;
    z-index: 60;
}
.crm-search__item{
    padding: 10px 12px;
    display:flex;
    justify-content:space-between;
    gap:10px;
    cursor:pointer;
}
.crm-search__item:hover{ background: var(--crm-soft); }
.crm-search__meta{ color: var(--crm-muted); font-size:12px; }

/* =========================================================
   NAV (в одну линию рядом с поиском)
   ========================================================= */
.crm-nav{
    flex: 0 0 auto;
    min-width: 0;
}
.crm-nav__list{
    list-style:none;
    margin:0;
    padding:0;
    display:flex;
    align-items:center;
    gap: 6px;
    flex-wrap: nowrap;
}
.crm-nav__item{ flex:0 0 auto; }

.crm-nav__link,
.crm-nav__morebtn{
    display:flex;
    align-items:center;
    gap: 8px;

    padding: 6px 10px;   /* компактнее */
    border-radius: 10px;

    color: var(--crm-text);
    transition: .12s ease;
    line-height: 1;
    cursor:pointer;
    user-select:none;
    white-space: nowrap;
}
.crm-nav__link:hover,
.crm-nav__morebtn:hover{ background: var(--crm-soft); }

.crm-nav__link.is-active{
    background: var(--crm-soft2);
    color: var(--crm-accent);
    font-weight:600;
}

.crm-ico{
    width:18px;
    height:18px;
    display:inline-flex;
}
.crm-ico svg{
    width:18px; height:18px;
    fill:none; stroke:currentColor; stroke-width:1;
    stroke-linecap:round; stroke-linejoin:round;
}

/* =========================================================
   CLOCK / ACTIONS / ICONS / USER
   ========================================================= */
.crm-clock{
    display:flex;
    flex-direction:column;
    align-items:flex-end;
    line-height:1.05;
    padding: 1px 4px;
    border-radius: 8px;
}
.crm-clock__time{ font-size:12px; font-weight:700; }
.crm-clock__date{ font-size:10px; color: var(--crm-muted); }

.crm-actions{
    display:flex;
    align-items:center;
    gap:8px;
}

.crm-pill{
    display:inline-flex;
    align-items:center;
    height: 36px;
    padding: 0 10px;
    border-radius: 999px;

    background: var(--crm-accent);
    color:#fff !important;
    font-weight:700;
    font-size:13px;
    line-height: 1;
}
.crm-pill:hover{ filter: brightness(.95); }

.crm-iconbtn{
    cursor:pointer;
    border-radius: 8px;
    padding: 6px;
    color: var(--crm-text);
    line-height: 1;
}
.crm-iconbtn:hover{ background: var(--crm-soft); }

.crm-iconbtn svg{
    width:16px; height:16px;
    fill:none; stroke:currentColor; stroke-width:2;
    stroke-linecap:round; stroke-linejoin:round;
}

/* notif dot */
#crmBtnNotif{ position:relative; }
#crmBtnMessenger{ position:relative; }
.crm-icon-badge{
    position: absolute;
    top: 3px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--crm-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 1px #fff;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.crm-icon-badge--notif{
    background: #dd6b20;
    box-shadow: 0 0 0 1px #fff, 0 6px 14px rgba(221, 107, 32, 0.28);
}
.crm-dot{
    position:absolute;
    top:7px;
    right:2px;

    min-width:8px;
    height:8px;
    border-radius:50%;
    background: var(--crm-danger);

    box-shadow: 0 0 0 1px #fff;
    animation: crmDotPulse 2s ease-out infinite;
}

@keyframes crmDotPulse {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.4); opacity: .6; }
    100% { transform: scale(1); opacity: 1; }
}




.crm-userbox{
    position:relative;
    display:flex;
    align-items:center;
    gap:4px;
}

.crm-user{
    display:flex;
    align-items:center;
    gap: 6px;
    height: 32px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--crm-soft);
}
.crm-user:hover{ background: var(--crm-soft2); }

.crm-avatar{
    width:28px; height:28px;
    border-radius:50%;
    overflow:hidden;
    display:grid; place-items:center;
    background: var(--crm-accent);
    color:#fff;
    font-weight:800;
}
.crm-avatar img{
    width:100%; height:100%;
    object-fit:cover;
    display:block;
}
.crm-user__name{
    max-width: 200px;
    font-size:12px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

/* User menu */
.crm-menu{
    position:absolute;
    right:0;
    top: calc(100% + 8px);
    width: 220px;
    background:#fff;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0,0,0,.12);
    overflow:hidden;
    z-index: 70;
}
.crm-menu__item{
    display:block;
    padding: 10px 12px;
    color: var(--crm-text);
}
.crm-menu__item:hover{ background: var(--crm-soft); }
.crm-menu__sep{ height:1px; background: var(--crm-border); }
.crm-menu__item--danger{ color: var(--crm-danger); font-weight:700; }

/* Popover */
.crm-popover{
    position: absolute;
    right: 12px;
    top: calc(100% + 10px);
    width: min(420px, 92vw);
    background:#fff;
    border: 1px solid var(--crm-border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0,0,0,.12);
    overflow:hidden;
    z-index: 70;
}
.crm-popover[hidden]{
    display:none !important;
}
.crm-popover--messenger:not([hidden]){
    width:min(960px, 96vw);
    height:min(78vh, calc(100vh - 96px));
    display:flex;
    flex-direction:column;
}
.crm-popover--messenger .crm-popover__head{
    flex:0 0 auto;
}
.crm-popover--messenger .crm-popover__body{
    flex:1 1 auto;
    min-height:0;
    padding:0;
}
.crm-popover__head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding: 10px 12px;
    background: var(--crm-soft);
}
.crm-popover__title{ font-weight:800; }
.crm-popover__body{ padding: 12px; }
.crm-empty{ color: var(--crm-muted); font-size:13px; }

.crm-messenger{
    padding:0;
    display:grid;
    grid-template-columns: 320px 1fr;
    min-height:0;
    height:100%;
    max-height:none;
    overflow:hidden;
}
.crm-messenger__dialogs{
    border-right:1px solid var(--crm-border);
    overflow:auto;
    padding:8px;
    background:#fbfdff;
}
.crm-messenger__dialogs-tools{
    position:sticky;
    top:0;
    z-index:2;
    padding:8px 0;
    background:#fbfdff;
}
.crm-messenger__recipient-search{
    width:100%;
    border:1px solid var(--crm-border);
    border-radius:10px;
    font-size:12px;
    padding:8px 10px;
    outline:none;
}
.crm-messenger__recipient-search:focus{
    border-color:rgba(13,110,253,.45);
    box-shadow:0 0 0 3px rgba(13,110,253,.12);
}
.crm-messenger__recipients{
    margin-top:8px;
    max-height:220px;
    overflow:auto;
    border:1px solid rgba(0,0,0,.08);
    border-radius:10px;
    background:#fff;
    padding:6px;
}
.crm-messenger__section{
    margin-top:8px;
}
.crm-messenger__section-title{
    font-size:11px;
    font-weight:700;
    color:var(--crm-muted);
    text-transform:uppercase;
    letter-spacing:.03em;
    margin:2px 2px 8px;
}
.crm-msg-dialog{
    border:1px solid rgba(0,0,0,.08);
    border-radius:10px;
    background:#fff;
    padding:8px 10px;
    cursor:pointer;
    margin-bottom:8px;
}
.crm-msg-dialog:hover{
    background:#f5f9ff;
}
.crm-msg-dialog.is-active{
    border-color:rgba(13,110,253,.38);
    background:rgba(13,110,253,.08);
}
.crm-msg-dialog__row{
    display:flex;
    align-items:flex-start;
    gap:10px;
    min-width:0;
}
.crm-msg-dialog__avatar{
    width:34px;
    height:34px;
    border-radius:50%;
    flex:0 0 34px;
    overflow:visible;
    background:#e8eef8;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
    position:relative;
}
.crm-msg-dialog__avatar.is-online::after{
    content:"";
    position:absolute;
    right:-1px;
    bottom:-1px;
    width:9px;
    height:9px;
    border-radius:50%;
    background:#22c55e;
    box-shadow:0 0 0 2px #fff;
    z-index:2;
}
.crm-msg-dialog__avatar img{
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
    border-radius:50%;
}
.crm-msg-dialog__avatar--fallback{
    font-size:13px;
    font-weight:700;
    color:#385070;
    text-transform:uppercase;
}
.crm-msg-dialog__content{
    min-width:0;
    flex:1 1 auto;
}
.crm-msg-dialog__top{
    display:flex;
    gap:8px;
    align-items:flex-start;
    justify-content:space-between;
}
.crm-msg-dialog__tools{
    display:flex;
    align-items:center;
    gap:6px;
    flex:0 0 auto;
}
.crm-msg-dialog__title{
    font-size:12px;
    font-weight:700;
    color:var(--crm-text);
    min-width:0;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.crm-msg-dialog__time{
    font-size:11px;
    color:var(--crm-muted);
    flex:0 0 auto;
}
.crm-msg-dialog__hide{
    appearance:none;
    border:1px solid rgba(148,163,184,.35);
    background:#fff;
    color:#94a3b8;
    width:20px;
    height:20px;
    border-radius:999px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:12px;
    line-height:1;
    cursor:pointer;
    flex:0 0 auto;
    transition:background .15s ease,color .15s ease,border-color .15s ease;
}
.crm-msg-dialog__hide:hover{
    color:#b91c1c;
    border-color:rgba(185,28,28,.24);
    background:#fef2f2;
}
.crm-msg-dialog__meta{
    margin-top:4px;
    font-size:11px;
    color:var(--crm-muted);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.crm-msg-dialog__badges{
    margin-top:6px;
    display:flex;
    gap:6px;
    flex-wrap:wrap;
}
.crm-msg-dialog__badge{
    font-size:10px;
    font-weight:700;
    border-radius:999px;
    padding:2px 6px;
    line-height:1.2;
}
.crm-msg-dialog__badge--need{
    color:#9a3412;
    background:#ffedd5;
}
.crm-msg-dialog__badge--new{
    color:#065f46;
    background:#d1fae5;
}

.crm-messenger__thread{
    min-width:0;
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
}
.crm-messenger__thread-head{
    display:flex;
    align-items:flex-start;
    justify-content:flex-start;
    flex-direction:column;
    gap:10px;
    padding:10px 12px;
    border-bottom:1px solid var(--crm-border);
    background:#fff;
}
.crm-messenger__thread-title{
    font-size:13px;
    font-weight:700;
    color:var(--crm-text);
    min-width:0;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.crm-messenger__thread-subtitle{
    font-size:11px;
    color:var(--crm-muted);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:100%;
}
.crm-messenger__thread-subtitle-row{
    display:flex;
    align-items:center;
    gap:8px;
    min-width:0;
    flex-wrap:wrap;
}
.crm-messenger__presence-badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:2px 8px;
    border-radius:999px;
    font-size:10px;
    font-weight:700;
    line-height:1.3;
    text-transform:lowercase;
}
.crm-messenger__presence-badge.is-online{
    background:#dcfce7;
    color:#166534;
}
.crm-messenger__presence-badge.is-offline{
    background:#e5e7eb;
    color:#4b5563;
}
.crm-messenger__thread-link{
    appearance:none;
    border:1px solid rgba(13,110,253,.25);
    background:rgba(13,110,253,.08);
    color:#0d6efd;
    border-radius:8px;
    padding:4px 8px;
    font-size:11px;
    cursor:pointer;
    flex:0 0 auto;
}
.crm-messenger__messages{
    flex:1;
    min-height:0;
    overflow:auto;
    padding:12px;
    background:#f8fbff;
}
.crm-msg-line{
    display:flex;
    margin-bottom:8px;
}
.crm-msg-line.is-reply-target .crm-msg-bubble{
    box-shadow:0 0 0 2px rgba(13,110,253,.18);
}
.crm-msg-line--mine{
    justify-content:flex-end;
}
.crm-msg-bubble{
    max-width:74%;
    border-radius:12px;
    padding:8px 10px;
    border:1px solid rgba(0,0,0,.08);
    background:#fff;
    color:#111;
}
.crm-msg-line--mine .crm-msg-bubble{
    background:rgba(0,122,255,.92);
    border-color:rgba(0,122,255,.28);
    color:#fff;
}
.crm-msg-bubble.is-deleted{
    background:#f8fafc;
    border-style:dashed;
    color:#64748b;
}
.crm-msg-line--mine .crm-msg-bubble.is-deleted{
    background:#e2e8f0;
    border-color:#cbd5e1;
    color:#475569;
}
.crm-msg-bubble__text{
    font-size:12px;
    white-space:pre-wrap;
    word-break:break-word;
}
.crm-msg-bubble__deleted{
    font-size:12px;
    font-style:italic;
    opacity:.9;
}
.crm-msg-reply{
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    gap:2px;
    width:100%;
    margin:0 0 6px;
    padding:6px 8px;
    border:none;
    border-left:3px solid rgba(13,110,253,.38);
    border-radius:8px;
    background:rgba(148,163,184,.12);
    color:inherit;
    text-align:left;
    cursor:pointer;
}
.crm-msg-reply__sender{
    font-size:10px;
    font-weight:700;
    opacity:.92;
}
.crm-msg-reply__text{
    font-size:11px;
    line-height:1.35;
    opacity:.88;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:100%;
}
.crm-msg-reply--composer{
    margin:0;
}
.crm-msg-line--mine .crm-msg-reply{
    border-left-color:rgba(255,255,255,.72);
    background:rgba(255,255,255,.16);
}
.crm-msg-bubble__attachments{
    margin-top:8px;
    display:flex;
    flex-direction:column;
    gap:6px;
}
.crm-msg-attachment-row{
    display:flex;
    align-items:center;
    gap:6px;
}
.crm-msg-attachment{
    display:flex;
    align-items:flex-start;
    gap:6px;
    text-decoration:none;
    color:inherit;
    border:1px solid rgba(15,23,42,.1);
    background:rgba(255,255,255,.92);
    border-radius:8px;
    padding:6px 8px;
    max-width:220px;
}
.crm-msg-attachment__reuse{
    appearance:none;
    border:1px solid rgba(15,23,42,.12);
    background:#fff;
    color:#334155;
    border-radius:999px;
    width:26px;
    height:26px;
    flex:0 0 26px;
    line-height:1;
    cursor:pointer;
    padding:0;
}
.crm-msg-attachment__reuse:hover{
    background:#eff6ff;
    border-color:rgba(13,110,253,.22);
    color:#0d6efd;
}
.crm-msg-attachment__icon{
    font-size:13px;
    line-height:1.2;
    flex:0 0 auto;
}
.crm-msg-attachment__file-icon{
    width:40px;
    height:40px;
    flex:0 0 40px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border-radius:10px;
    font-size:11px;
    font-weight:800;
    letter-spacing:.03em;
    color:#fff;
    background:linear-gradient(135deg, #64748b, #334155);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.18);
}
.crm-msg-attachment__file-icon.is-word{
    background:linear-gradient(135deg, #2563eb, #1d4ed8);
}
.crm-msg-attachment__file-icon.is-excel{
    background:linear-gradient(135deg, #16a34a, #15803d);
}
.crm-msg-attachment__file-icon.is-pdf{
    background:linear-gradient(135deg, #dc2626, #b91c1c);
}
.crm-msg-attachment__file-icon.is-archive{
    background:linear-gradient(135deg, #7c3aed, #6d28d9);
}
.crm-msg-attachment__file-icon.is-text{
    background:linear-gradient(135deg, #0f766e, #115e59);
}
.crm-msg-attachment__file-icon.is-file{
    background:linear-gradient(135deg, #64748b, #334155);
}
.crm-msg-attachment__preview{
    width:56px;
    height:56px;
    flex:0 0 56px;
    overflow:hidden;
    border-radius:6px;
    background:rgba(15,23,42,.08);
}
.crm-msg-attachment__preview--file-logo{
    background:#fff;
    border:1px solid rgba(15,23,42,.08);
}
.crm-msg-attachment__preview-image{
    display:block;
    width:100%;
    height:100%;
    object-fit:cover;
}
.crm-msg-attachment__preview-image--contain{
    object-fit:contain;
    padding:6px;
    box-sizing:border-box;
}
.crm-msg-attachment__body{
    display:flex;
    flex-direction:column;
    min-width:0;
}
.crm-msg-attachment__name{
    font-size:11px;
    font-weight:700;
    line-height:1.3;
    word-break:break-word;
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    overflow:hidden;
}
.crm-msg-attachment__size{
    margin-top:2px;
    font-size:10px;
    opacity:.72;
}
.crm-msg-attachment--with-preview{
    align-items:center;
}
.crm-msg-line--mine .crm-msg-attachment{
    border-color:rgba(255,255,255,.24);
    background:rgba(255,255,255,.14);
    color:#fff;
}
.crm-msg-line--mine .crm-msg-attachment__reuse{
    background:rgba(255,255,255,.14);
    border-color:rgba(255,255,255,.24);
    color:#fff;
}
.crm-msg-line--mine .crm-msg-attachment__reuse:hover{
    background:rgba(255,255,255,.22);
    border-color:rgba(255,255,255,.34);
}
.crm-msg-line--mine .crm-msg-attachment__file-icon{
    box-shadow:inset 0 1px 0 rgba(255,255,255,.24);
}
.crm-msg-bubble__actions{
    display:flex;
    justify-content:flex-end;
    margin-top:6px;
}
.crm-msg-bubble__action{
    appearance:none;
    border:1px solid rgba(15,23,42,.12);
    background:#fff;
    color:#334155;
    border-radius:999px;
    width:24px;
    height:24px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:0;
    font-size:13px;
    line-height:1;
    cursor:pointer;
}
.crm-msg-bubble__action:hover{
    background:#eff6ff;
    border-color:rgba(13,110,253,.22);
    color:#0d6efd;
}
.crm-msg-bubble__action--danger:hover{
    background:#fef2f2;
    border-color:rgba(220,38,38,.22);
    color:#b91c1c;
}
.crm-msg-line--mine .crm-msg-bubble__action{
    background:rgba(255,255,255,.14);
    border-color:rgba(255,255,255,.24);
    color:#fff;
}
.crm-msg-line--mine .crm-msg-bubble__action:hover{
    background:rgba(255,255,255,.22);
    border-color:rgba(255,255,255,.34);
}
.crm-msg-line--mine .crm-msg-bubble__action--danger:hover{
    background:rgba(248,113,113,.26);
    border-color:rgba(254,202,202,.45);
    color:#fff;
}
.crm-msg-bubble__meta{
    margin-top:4px;
    font-size:10px;
    opacity:.72;
}
.crm-msg-bubble__meta--footer{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap:8px;
    flex-wrap:wrap;
}
.crm-msg-bubble__status{
    font-weight:600;
}
.crm-msg-line--mine .crm-msg-bubble__status{
    opacity:.96;
}
.crm-messenger__composer{
    display:flex;
    flex-direction:column;
    gap:8px;
    border-top:1px solid var(--crm-border);
    padding:10px 12px;
    background:#fff;
}
.crm-messenger__composer-row{
    min-width:0;
    display:flex;
    align-items:flex-end;
    gap:8px;
}
.crm-messenger__input-shell{
    position:relative;
    flex:1 1 auto;
    min-width:0;
    display:flex;
    align-items:flex-end;
    gap:8px;
    border:1px solid var(--crm-border);
    border-radius:16px;
    padding:6px 8px 6px 6px;
    background:#fff;
}
.crm-messenger__composer-tools{
    position:relative;
    display:flex;
    align-items:center;
    gap:4px;
    flex:0 0 auto;
    align-self:flex-end;
}
.crm-messenger__toolbtn{
    appearance:none;
    border:none;
    background:#f3f4f6;
    color:#4b5563;
    border-radius:999px;
    width:34px;
    height:34px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:22px;
    line-height:1;
    cursor:pointer;
    transition:background .15s ease,color .15s ease,transform .15s ease;
}
.crm-messenger__toolbtn:hover{
    background:#e5e7eb;
    color:#111827;
}
.crm-messenger__toolbtn:active{
    transform:scale(.96);
}
.crm-messenger__menu{
    position:absolute;
    left:0;
    bottom:calc(100% + 12px);
    min-width:240px;
    display:flex;
    flex-direction:column;
    gap:0;
    padding:1px;
    border:1px solid rgba(15,23,42,.12);
    border-radius:18px;
    background:#fff;
    box-shadow:0 20px 44px rgba(15,23,42,.16);
    z-index:4;
}
.crm-messenger__menu[hidden]{
    display:none !important;
}
.crm-messenger__menu-item{
    appearance:none;
    border:none;
    background:transparent;
    color:#111827;
    display:flex;
    align-items:center;
    gap:12px;
    width:100%;
    padding:12px 18px;
    font-size:14px;
    text-align:left;
    cursor:pointer;
}
.crm-messenger__menu-item:hover{
    background:#f8fafc;
}
.crm-messenger__menu-item--primary{
    position:relative;
    margin-bottom:8px;
    padding-bottom:16px;
}
.crm-messenger__menu-item--primary::after{
    content:"";
    position:absolute;
    left:18px;
    right:18px;
    bottom:0;
    height:1px;
    background:rgba(15,23,42,.12);
}
.crm-messenger__menu-item:disabled{
    opacity:.6;
    cursor:not-allowed;
}
.crm-messenger__menu-icon{
    width:28px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    flex:0 0 28px;
    font-size:20px;
    line-height:1;
}
.crm-messenger__menu-text{
    min-width:0;
    font-size:14px;
    font-weight:500;
    line-height:1.3;
}
.crm-messenger__file-input{
    display:none;
}
.crm-messenger__composer textarea{
    resize:none;
    min-height:40px;
    max-height:120px;
    flex:1 1 auto;
    width:auto;
    border:none;
    outline:none;
    border-radius:12px;
    padding:8px 6px 8px 0;
    font-size:13px;
    background:transparent;
}
.crm-messenger__composer-meta{
    display:flex;
    flex-direction:column;
    gap:8px;
}
.crm-messenger__reply{
    display:flex;
}
.crm-messenger__reply[hidden]{
    display:none !important;
}
.crm-messenger__reply-card{
    width:100%;
    display:flex;
    align-items:flex-start;
    gap:8px;
    padding:8px 10px;
    border:1px solid rgba(13,110,253,.18);
    border-radius:12px;
    background:#eff6ff;
}
.crm-messenger__reply-cancel{
    appearance:none;
    border:none;
    background:transparent;
    color:#64748b;
    font-size:14px;
    line-height:1;
    cursor:pointer;
    padding:2px 0 0;
    flex:0 0 auto;
}
.crm-messenger__attachments{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
}
.crm-messenger__attachment-chip{
    display:inline-flex;
    align-items:center;
    gap:8px;
    max-width:100%;
    border:1px solid rgba(13,110,253,.18);
    background:#eff6ff;
    color:#1e3a5f;
    border-radius:999px;
    padding:5px 8px 5px 10px;
}
.crm-messenger__attachment-kind{
    font-size:10px;
    font-weight:700;
    text-transform:uppercase;
    color:#0d6efd;
    letter-spacing:.04em;
}
.crm-messenger__attachment-name{
    font-size:11px;
    font-weight:700;
    max-width:240px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.crm-messenger__attachment-size{
    font-size:10px;
    color:#64748b;
}
.crm-messenger__attachment-remove{
    appearance:none;
    border:none;
    background:transparent;
    color:#64748b;
    font-size:12px;
    line-height:1;
    cursor:pointer;
    padding:0;
}
.crm-messenger__emoji-panel{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    padding:8px;
    border:1px solid rgba(148,163,184,.25);
    background:#f8fafc;
    border-radius:12px;
}
.crm-messenger__emoji-panel[hidden],
.crm-messenger__attachments[hidden]{
    display:none !important;
}
.crm-messenger__emoji{
    appearance:none;
    border:none;
    background:#fff;
    border-radius:10px;
    width:34px;
    height:34px;
    font-size:18px;
    cursor:pointer;
    box-shadow: inset 0 0 0 1px rgba(148,163,184,.2);
}
.crm-messenger__emoji:hover{
    background:#eff6ff;
    box-shadow: inset 0 0 0 1px rgba(13,110,253,.22);
}
.crm-messenger__composer-row > button{
    appearance:none;
    border:1px solid rgba(13,110,253,.3);
    background:#0d6efd;
    color:#fff;
    border-radius:10px;
    padding:0 12px;
    font-size:12px;
    height:40px;
    white-space:nowrap;
    cursor:pointer;
}
.crm-messenger__composer-row > button:disabled,
.crm-messenger__composer textarea:disabled,
.crm-messenger__toolbtn:disabled{
    opacity:.6;
    cursor:not-allowed;
}

/* Burger + Drawer */
.crm-burger{
    display:none;
    cursor:pointer;
    border-radius:10px;
    padding: 8px;
    line-height: 1;
}
.crm-burger:hover{ background: var(--crm-soft); }
.crm-burger span{
    display:block;
    width:18px;
    height:2px;
    background: var(--crm-text);
    margin:3px 0;
    border-radius:2px;
}

.crm-drawer{
    position: fixed;
    inset: 0;
    display:none;
    z-index:80;
}
.crm-drawer.is-open{ display:block; }
.crm-drawer__backdrop{
    position:absolute; inset:0;
    background: rgba(0,0,0,.35);
}
.crm-drawer__panel{
    position:absolute; right:0; top:0;
    height:100%;
    width:min(380px, 88vw);
    background:#fff;
    border-left:1px solid var(--crm-border);
    padding: 14px;
    overflow:auto;
}
.crm-drawer__head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:10px;
}
.crm-drawer__title{ font-size:16px; font-weight:800; color: var(--crm-text); }
.crm-drawer__block{
    display:flex;
    flex-direction:column;
    gap: 8px;
    margin-top: 10px;
}
.crm-drawer__link{
    display:flex;
    align-items:center;
    gap: 10px;
    padding: 12px;
    border-radius: 10px;
    background: var(--crm-soft);
    color: var(--crm-text);
}
.crm-drawer__link:hover{ background: var(--crm-soft2); }
.crm-drawer__link.danger{
    background: var(--crm-danger);
    color:#fff;
}
.crm-drawer__link.danger:hover{ filter: brightness(.95); }

/* вкладки */
.crm-notif-tabs{display:flex; gap:6px; margin-bottom:10px; font-size: 12px;}
.crm-notif-tab{
    appearance:none; border:0; cursor:pointer;
    padding:6px 10px; border-radius:10px;
    font-size:12px; line-height:1;
    background:rgba(0,0,0,.05);
}
.crm-notif-tab.is-active{
    background:rgba(13,110,253,.12);
    font-weight:600;
    padding: 3px;
    border-radius: 3px;
}

/* список */
.crm-notif-list{display:flex; flex-direction:column; gap:6px;}

.crm-notif-group{
    border:1px solid rgba(0,0,0,.08);
    border-radius:10px;
    background:#fff;
    overflow:hidden;
}
.crm-notif-group__head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:8px;
    padding:6px 10px;
    background:rgba(0,0,0,.03);
    border-bottom:1px solid rgba(0,0,0,.06);
}
.crm-notif-group__name{
    font-size:12px;
    font-weight:700;
    color:var(--crm-text);
    min-width:0;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.crm-notif-group__count{
    font-size:11px;
    font-weight:700;
    min-width:22px;
    text-align:center;
    color:#334155;
    background:rgba(51,65,85,.12);
    border-radius:999px;
    padding:2px 6px;
}
.crm-notif-group__items{
    display:flex;
    flex-direction:column;
    gap:4px;
    padding:4px;
}

.crm-notif-item{
    display:flex; gap:8px; align-items:flex-start;
    padding:7px 10px;
    border-radius:10px;
    cursor:pointer;
    transition:background .15s, opacity .15s;
}

/* АКТИВНЫЕ */
.crm-notif-item.is-active{
    background:rgba(0,0,0,.04);
}
.crm-notif-item.is-active:hover{
    background:rgba(0,0,0,.08);
}

/* АРХИВ */
.crm-notif-item.is-archive{
    background:transparent;
    opacity:.55;
}
.crm-notif-item.is-archive:hover{
    background:rgba(0,0,0,.04);
    opacity:.75;
}

/* текст */
.crm-notif-main{min-width:0; flex:1;}
.crm-notif-actions{
    display:flex;
    align-items:center;
    margin-right:6px;
}
.crm-notif-act{
    appearance:none;
    border:1px solid rgba(13,110,253,.28);
    background:rgba(13,110,253,.08);
    color:#0d6efd;
    border-radius:8px;
    font-size:11px;
    line-height:1;
    padding:4px 7px;
    cursor:pointer;
}
.crm-notif-act:hover{
    background:rgba(13,110,253,.14);
}
.crm-notif-item.is-archive .crm-notif-act{
    opacity:.82;
}
.crm-notif-title{
    font-size:12px;
    font-weight:500;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.crm-notif-meta{
    font-size:11px;
    opacity:.7;
    margin-top:2px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.crm-notif-time{
    font-size:11px;
    opacity:.45;
    margin-left:auto;
}


.crm-notif-ico{
    width:16px;
    height:16px;
    margin-top:1px;
    opacity:.75;
    flex:0 0 auto;
}
.crm-notif-item.is-archive .crm-notif-ico{
    opacity:.45;
}





.crm-pillbtn{
    display:inline-flex;
    align-items:center;
    gap:8px;

    height:32px;
    padding:0 10px;

    border:0;
    border-radius:999px;

    background: rgba(0,122,255,.10); /* apple-like blue tint */
    color: #007AFF;

    font: 500 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    letter-spacing: .1px;

    cursor:pointer;
    user-select:none;

    transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.nb-neworder__ico{
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nb-neworder__ico img,
.nb-neworder__ico svg{
    width: 16px;
    height: 16px;
    display: block;
}

.nb-neworder__ico img{
    object-fit: contain;
}

/* на узких экранах можно скрывать текст */
@media (max-width: 920px){
    .nb-neworder__txt{ display:none; }
}













/* если места мало — прячем hint, а поиск остаётся */
@media (max-width: 950px){
    .crm-search__hint{ display:none; }
    .crm-search{ width: 260px; max-width:260px; }
}
@media (max-width: 750px){
    .crm-search{ width: 200px; max-width:200px; }
}
@media (max-width: 1240px){
    .crm-globalnav__panel-inner{
        grid-template-columns: minmax(260px, 1.25fr) repeat(2, minmax(160px, 1fr));
        gap: 22px;
    }

    .crm-globalnav__feature-link{
        font-size: clamp(21px, 1.9vw, 28px);
    }
}



/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 1100px){
    .crm-globalnav{
        display:none;
    }

    .crm-nav{ display:none; }
    .crm-burger{ display:inline-block; }
    .crm-user__name{ display:none; }
    .crm-context{ display:none; }
    .crm-clock{ display:none; }

    /* центр на мобиле пусть будет обычным флексом, а не абсолютом */
    .crm-topbar__center{
        position: static;
        transform: none;
        width: 100%;
        flex: 1 1 auto;
    }
    .crm-topbar__left{ min-width: auto; }
    .crm-topbar__right{ min-width: auto; }
    .crm-search{ max-width: none; }

    .crm-popover--messenger{
        width:min(96vw, 760px);
        right:2vw;
    }
    .crm-messenger{
        grid-template-columns: 1fr;
        min-height: 70vh;
        max-height: 78vh;
    }
    .crm-messenger__dialogs{
        border-right:0;
        border-bottom:1px solid var(--crm-border);
        max-height:38vh;
    }
    .crm-messenger__composer{
        align-items:stretch;
    }
    .crm-messenger__composer-row{
        flex-wrap:wrap;
        align-items:stretch;
    }
    .crm-messenger__input-shell{
        width:100%;
    }
    .crm-messenger__composer-row > button{
        width:100%;
    }
    .crm-messenger__composer textarea{
        width:100%;
        flex:1 1 100%;
    }
    .crm-messenger__attachment-name{
        max-width:180px;
    }
}
