/* Мобильные правки, выделено из base.html (25.10). Позиция: начало <body>. */

.crm-toast{position:relative; display:flex; align-items:flex-start; gap:11px;
  background: var(--card-bg, #fff); border:1px solid var(--border, #e5e7eb);
  border-radius:14px; padding:13px 14px 13px 17px;
  box-shadow:0 8px 24px rgba(15, 23, 42, .10);
  color:var(--text, #111);
  animation:toastIn .28s cubic-bezier(.2,.9,.3,1.2);}
.crm-toast::before{content:''; position:absolute; left:0; top:0; bottom:0; width:3px; border-radius:3px 0 0 3px; opacity:.9;}
.crm-toast--success::before{background:#10b981;}
.crm-toast--error::before{background:#ef4444;}
.crm-toast--warning::before{background:#f59e0b;}
.crm-toast--info::before{background:#3b82f6;}
.crm-toast__icon{display:flex; align-items:center; justify-content:center;
  width:26px; height:26px; border-radius:50%; flex:none; color:#fff; margin-top:1px;}
.crm-toast--success .crm-toast__icon{background:#10b981;}
.crm-toast--error .crm-toast__icon{background:#ef4444;}
.crm-toast--warning .crm-toast__icon{background:#f59e0b;}
.crm-toast--info .crm-toast__icon{background:#3b82f6;}
.crm-toast__body{flex:1; min-width:0;}
.crm-toast__title{display:block; font-weight:700; font-size:14px; line-height:1.35; margin-bottom:2px;}
.crm-toast__text{display:block; font-size:13px; line-height:1.5; color:var(--text-muted, #6b7280); white-space:pre-line;}
.crm-toast__close{position:absolute; top:8px; right:8px; border:none; background:none; cursor:pointer;
  color:var(--text-muted, #9ca3af); line-height:1; padding:4px; border-radius:6px; display:flex;}
.crm-toast__close:hover{color:var(--text, #111); background:rgba(0,0,0,.05);}
@keyframes toastIn{from{opacity:0; transform:translateX(20px);} to{opacity:1; transform:none;}}
.crm-toast.toast-out{opacity:0; transform:translateX(20px); transition:all .25s ease;}
@media (max-width: 768px){ #toastStack{left:16px; right:16px; width:auto;} }

.demo-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #16181d, #22252c);
    color: #e2e8f0;
    z-index: 9998;
    padding: 8px 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    font-size: 12.5px;
    font-family: inherit;
}
.demo-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.demo-bar-badge {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.demo-bar-text {
    color: #b9cdc4;
    font-size: 12px;
    flex: 1;
    min-width: 200px;
    text-align: center;
}
.demo-bar-exit {
    color: #10b981;
    text-decoration: none;
    font-weight: 600;
    padding: 4px 12px;
    border: 1px solid rgba(16,185,129,0.4);
    border-radius: 6px;
    transition: all 0.15s;
    flex-shrink: 0;
    font-size: 12px;
}
.demo-bar-exit:hover {
    background: rgba(16,185,129,0.1);
    border-color: #10b981;
}
/* Отступ снизу для body, чтобы плашка не перекрывала контент */
body.has-demo-bar { padding-bottom: 50px; }
@media (max-width: 600px) {
    .demo-bar-text { display: none; }
    .demo-bar { padding: 6px 10px; }
}
.modal-box{background:var(--modal-bg)!important}.modal-foot{background:var(--modal-foot)!important}.tile .ic.orange{background:#fef3c7;color:#92400e}/* ic-orange-amber */::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#9adfc2;border-radius:6px}::-webkit-scrollbar-thumb:hover{background:#34d399}*{scrollbar-width:thin;scrollbar-color:#9adfc2 transparent}body.dark::-webkit-scrollbar-thumb{background:#1e3325}body.dark *{scrollbar-color:#1e3325 transparent}

.ic{width:1.05em;height:1.05em;display:inline-block;vertical-align:-0.16em;flex:none;}

/* BUG-340 (22.10): мобильная шапка — заголовок больше не прячется под иконками */
@media (max-width: 820px) {
    .topbar { gap: 4px; padding: 8px; }
    .topbar-left { min-width: 0; flex: 1 1 auto; overflow: hidden; }
    .topbar .title {
        display: block;
        font-size: 13.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .topbar .sub {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .topbar-center { display: block !important; min-width: 0; padding: 0; }
    .topbar-center-name { display: none; }
    .topbar-center .shift-badge { margin-top: 0; padding: 4px 8px; gap: 4px; font-size: 10.5px; }
    .topbar-left > div { min-width: 0; }
    .topbar-right { flex: 0 0 auto; }
    .home-btn { display: none !important; }
    .topbar-right { gap: 4px; }
    .topbar-right .theme-btn,
    .topbar-right > button,
    .topbar-right > a:not(.user-chip) {
        width: 30px !important; height: 30px !important;
        min-width: 30px !important; padding: 0 !important;
    }
    #notifBell { width: 30px !important; height: 30px !important; }
    /* Кнопки в шапках карточек переносятся на следующую строку */
    .card-head { flex-wrap: wrap; gap: 8px; }
    .card-head .btn, .card-head button, .card-head a.btn { flex-shrink: 0; }
    /* Таблицы и широкие ряды — горизонтальный скролл вместо обрезки */
    .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media (max-width: 480px) {
    .topbar .sub { display: none !important; }
}

/* BUG-341 (22.10): мобильные кнопки-действия читаемее, «?»-подсказки убраны */
@media (max-width: 820px) {
    /* На тач-экранах тултипы «?» неудобны и рисуются пустым пузырём — прячем */
    .tooltip-icon { display: none !important; }
    #js-tip-bubble { display: none !important; }
    #shiftHintBtn { display: none !important; }
    /* Подсказка про смену — на мобильном всегда видна, мягкий инфо-блок */
    #shiftHintPanel {
        display: block !important;
        position: static !important;
        right: auto !important; top: auto !important;
        width: auto !important;
        border: none !important;
        box-shadow: none !important;
        background: rgba(16,185,129,.06) !important;
        border-radius: 12px !important;
        padding: 12px 14px !important;
        margin-top: 10px;
        font-size: 12.5px !important;
        line-height: 1.55 !important;
        z-index: auto !important;
    }
    #shiftHintPanel button { display: none !important; }
    /* Вторичные кнопки-действия: они свёрстаны инлайном без классов —
       бьём по контейнеру .card-actions (покрывает все страницы) */
    .card-actions > a {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px;
        text-align: center !important;
        border: 1.5px solid #94a3b8 !important;
        color: var(--text, #1a1d26) !important;
        background: var(--card-bg, #ffffff) !important;
        font-weight: 600 !important;
        border-radius: 10px !important;
        padding: 9px 13px !important;
        font-size: 13px !important;
        line-height: 1.3;
        white-space: nowrap;
    }

    /* Вторичные кнопки: заметнее и текст строго по центру */
    .btn-bulk {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px;
        text-align: center !important;
        border: 1.5px solid #94a3b8 !important;
        color: var(--text, #1a1d26) !important;
        background: var(--card-bg, #ffffff) !important;
        font-weight: 600 !important;
        border-radius: 10px !important;
        padding: 9px 13px !important;
        font-size: 13px !important;
        line-height: 1.3;
        white-space: nowrap;
    }
}

/* BUG-343 (22.10): мобильные правки — сворачиваемая подсказка, журнал лентой, календарь на весь экран */
@media (max-width: 820px) {
    #shiftHintPanel {
        display: block !important;
        position: static !important;
        right: auto !important; top: auto !important;
        width: auto !important;
        border: none !important;
        box-shadow: none !important;
        background: rgba(16,185,129,.06) !important;
        border-radius: 12px !important;
        padding: 12px 14px !important;
        margin-top: 10px;
        font-size: 12.5px !important;
        line-height: 1.55 !important;
        z-index: auto !important;
    }
    #shiftHintPanel button { display: none !important; }
    #shiftHintPanel .hint-collapse-btn { display: inline-block !important; }
    #shiftHintPanel.hint-hidden { display: none !important; }

    .audit-row { display: flex !important; flex-direction: column; gap: 5px; padding: 12px 14px; }
    .audit-time br { display: none; }
    .audit-time { white-space: nowrap; color: #8b919e; font-size: 12px; }
    .audit-user { white-space: normal; overflow: visible; }
    .audit-ip { justify-self: start; font-size: 11px; color: #8b919e; }

    .calx-pop {
        position: fixed !important;
        left: 8px !important; right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%);
        max-width: calc(100vw - 16px) !important;
    }
    .calx-months { flex-direction: column !important; gap: 10px !important; }
    .calx-months > div { width: 100% !important; max-width: 272px; margin: 0 auto; }
}

/* BUG-346: колокольчик — перенос текста, панель не шире экрана */
#notifPanel a div { overflow-wrap: anywhere; word-break: break-word; }
#notifPanel { max-width: calc(100vw - 16px) !important; }

/* CALX2-MOBILE (22.10): календарь v2 — панель по центру экрана, месяцы в столбик */
@media (max-width: 700px) {
  .calx2-pop {
    position: fixed !important;
    left: 8px !important; right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%);
    max-width: calc(100vw - 16px) !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    padding: 14px 16px !important;
    z-index: 100000 !important;
  }
  .calx2-months { flex-direction: column !important; gap: 14px !important; }
}

/* CALX2-POLISH: аккуратный мобильный вид */
@media (max-width: 700px) {
  .calx2-pop { padding: 16px 14px 12px !important; border-radius: 18px !important; }
  .calx2-chips { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px !important; margin: 0 0 14px !important; }
  .calx2-chip { width: 100%; padding: 9px 0 !important; text-align: center; font-size: 13px !important; border-radius: 12px !important; color: #334155 !important; background: #f8fafc !important; }
  .calx2-chip:active { background: #e7f8f0 !important; border-color: #10b981 !important; }
  .calx2-mtitle { min-width: 0 !important; flex: 1; text-align: center; font-size: 14px !important; margin-bottom: 8px !important; }
  .calx2-nav { width: 26px !important; height: 26px !important; min-width: 26px; border-radius: 8px !important; font-size: 13px !important; }
  .calx2-d { height: 38px !important; font-size: 13px !important; }
  .calx2-wd { margin-bottom: 6px !important; }
  .calx2-wd span { font-size: 11px !important; color: #94a3b8; }
  .calx2-foot { position: sticky; bottom: -12px; background: #fff; margin: 12px -14px -12px !important; padding: 10px 14px 12px !important; border-top: 1px solid #f1f5f9; }
  .calx2-btn { flex: 1; padding: 11px 0 !important; border-radius: 12px !important; }
}

/* BUG-344 (22.10): мобильный календарь-диапазон по центру экрана, месяцы в столбик */
@media (max-width: 820px) {
    .dcal-popup, .dtp-popup {
        position: fixed !important;
        left: 8px !important; right: 8px !important; top: 50% !important;
        transform: translateY(-50%);
        width: auto !important; min-width: 0 !important;
        max-width: calc(100vw - 16px) !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        z-index: 100000 !important;
    }
    .dcal-popup > div, .dtp-popup > div { max-width: 100% !important; }
    .dcal-popup [style*="display:flex"], .dcal-popup [style*="display: flex"],
    .dtp-popup [style*="display:flex"], .dtp-popup [style*="display: flex"] { flex-wrap: wrap !important; }
    .dcal-popup [style*="272px"], .dtp-popup [style*="272px"] { width: 100% !important; max-width: 272px !important; }
}

/* BUG-345 (22.10): панель колокольчика на мобильном + подстраховка календаря */
@media (max-width: 820px) {
    #notifPanel {
        position: fixed !important;
        top: 52px !important;
        left: 8px !important; right: 8px !important;
        width: auto !important;
        max-width: none !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
        z-index: 100001 !important;
    }
    .calx-pop {
        position: fixed !important;
        left: 8px !important; right: 8px !important; top: 50% !important;
        transform: translateY(-50%);
        width: auto !important;
        max-width: calc(100vw - 16px) !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
    }
    .calx-months { flex-direction: column !important; gap: 10px !important; }
    .calx-months > div { width: 100% !important; max-width: 272px; margin: 0 auto; }
}
