/* /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);
}

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

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

    min-height: 56px; /* фикс высоты как у CRM */
}

/* =========================================================
   Защита от глобальных стилей 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:12px;
    flex: 0 0 auto;
    min-width: 260px; /* чтобы центр визуально держался */
}

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

.crm-context__id{
    font-size:30px;
    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:12px;
    color:var(--crm-muted);
}

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



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



/* =========================================================
   SEARCH (делаем компактнее, чтобы не раздувало высоту)
   ========================================================= */
.crm-search{
  /*  flex: 1 1 auto; */


    position: relative;
    display:flex;
    align-items:center;
    gap: 8px;

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

    padding: 6px 10px;     /* было 8px 10px */
    height: 38px;          /* фикс высоты */
    box-sizing: border-box;
}
.crm-search:focus-within{
    background:#fff;
    border-color: rgba(13,110,253,.35);

}

.crm-search__ico{
    width:18px;
    height:18px;
    display:inline-flex;
    color: var(--crm-muted);
}
.crm-search__ico svg{
    width:18px; height:18px;
    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:14px;
    color: var(--crm-text);
    padding: 0;           /* важно */
    margin: 0;            /* важно */
    line-height: 1.2;
}

.crm-search__hint{
    flex:0 0 auto;
    font-size:12px;
    color: var(--crm-muted);
    background: rgba(0,0,0,.06);
    border-radius: 8px;
    padding: 3px 8px;
    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: 2px 6px;
    border-radius: 10px;
}
.crm-clock__time{ font-size:14px; font-weight:700; }
.crm-clock__date{ font-size:12px; 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: 10px;
    padding: 8px;
    color: var(--crm-text);
    line-height: 1;
}
.crm-iconbtn:hover{ background: var(--crm-soft); }

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

/* notif dot */
#crmBtnNotif{ position:relative; }
.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:6px;
}

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

.crm-avatar{
    width:32px; height:32px;
    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:14px;
    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__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; }

/* 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); }


/* ===== Layout: поиск справа (одна строка) ===== */
.crm-topbar__inner{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;
}

/* слева фикс */
.crm-topbar__left{ flex:0 0 auto; }

/* центр теперь НЕ колонка, а просто контейнер под поиск */
.crm-topbar__center{
    flex: 1 1 auto;
    min-width: 240px;
    display:flex;
    justify-content:flex-end;   /* <-- ключ: прижимаем поиск вправо */
    align-items:center;
}

/* поиск не огромный, нормальная ширина */
.crm-search{
    width: min(520px, 100%);   /* регулируй: 420/520/600 */
    max-width: 520px;
    min-width: 240px;
}

/* справа фикс */
.crm-topbar__right{ flex:0 0 auto; }


/* ===== Layout: поиск справа, НЕ наезжает на right ===== */
.crm-topbar__left{ flex:0 0 auto; min-width: 0; }
.crm-topbar__right{ flex:0 0 auto; min-width: 0; }

.crm-topbar__center{
    flex: 1 1 auto;
    min-width: 0;                 /* важно: чтобы flex мог сжиматься */
    display:flex;
    justify-content:flex-end;
    align-items:center;
    padding-right: 10px;          /* небольшой зазор до часов/иконок */
}

/* компактный поиск */
.crm-search{
    width: 320px;                 /* фикс компакт */
    max-width: 320px;
    min-width: 180px;
    height: 36px;                 /* чуть ниже */
    padding: 5px 10px;
}

/* чтобы placeholder не раздувал */
.crm-search__input{
    font-size: 13px;
}

/* подсказку можно сделать меньше */
.crm-search__hint{
    font-size: 11px;
    padding: 2px 6px;
}





/* вкладки */
.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-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-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 = new button (изоляция от crm-стилей) */
.nb-neworder{
    all: unset;              /* КЛЮЧ: сносит любые наследованные button-стили */
    box-sizing: border-box;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    height: 32px;
    padding: 0 10px;

    border-radius: 999px;

    background: rgba(0,122,255,.10);
    color: #007AFF;

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

    cursor: pointer;
    user-select: none;
}

.nb-neworder__ico{
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nb-neworder__ico img{
    width: 16px;
    height: 16px;
    display: block;
    object-fit: contain;
}

.nb-neworder:hover{
    background: rgba(0,122,255,.14);
}

.nb-neworder:active{
    transform: translateY(1px);
    background: rgba(0,122,255,.18);
}

.nb-neworder:focus-visible{
    box-shadow: 0 0 0 3px rgba(0,122,255,.25);
}

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













/* если места мало — прячем 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; }
}



/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 1100px){
    .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; }
}



