    :root{
        /* === Blueprint Precision === */
        /* поверхности */
        --bg: #E8E6E1;              /* surface-muted — фон страницы */
        --surface: #FFFFFF;         /* paper-white — карточки/инпуты */
        --surface-2: #F6F3F2;       /* surface-container-low */
        --surface-3: #F0EDED;       /* surface-container */
        --surface-4: #EAE7E7;       /* surface-container-high */
        /* бордеры */
        --border: #E5E2E1;          /* мягкий контур */
        --border-2: #DCD9D9;        /* surface-dim */
        --border-strong: #C3C6D5;   /* outline-variant */
        --outline: #737785;
        /* текст */
        --text: #1B1C1C;            /* on-surface / ink */
        --text-2: #434653;          /* on-surface-variant */
        --text-muted: #737785;      /* outline — приглушённый */
        /* синий акцент */
        --accent: #1D58C6;          /* surface-tint — основной синий */
        --accent-strong: #064DBC;   /* primary — hover/pressed */
        --accent-container: #3367D6;/* primary-container — заливка кнопок/пиллов */
        --accent-tint: #EDEFFF;     /* on-primary-container bg — светлый синий */
        --on-accent: #FFFFFF;
        /* бирюзовый вторичный */
        --secondary: #006970;       /* teal */
        --secondary-container: #7AF1FC;
        --on-secondary-container: #006E75;
        /* семантика */
        --success: #006E75;
        --success-bg: #E9F7EF;
        --danger: #BA1A1A;          /* error */
        --danger-bg: #FFDAD6;       /* error-container */
        --on-danger-container: #93000A;
        --warning: #8B3E00;         /* tertiary */
        --warning-bg: #FFECE4;
        --pay-partial: #C2410C;     /* оранжевый — частичная оплата */
        /* радиусы */
        --r-sm: 8px;
        --r-md: 12px;
        --r-lg: 16px;
        --r-pill: 999px;
        /* отступы */
        --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
        /* тени — мягкие «слоёная бумага» */
        --shadow-sm: 0 1px 3px rgba(28,27,25,0.05);
        --shadow-card: 0 4px 20px rgba(0,0,0,0.04);   /* Level 1 — карточки/инпуты */
        --shadow-pop: 0 8px 30px rgba(0,0,0,0.08);    /* Level 2 — дропдауны/поповеры */
        --shadow-md: 0 8px 24px rgba(28,27,25,0.12);
    }

    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:600;font-display:swap;src:url('../fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:700;font-display:swap;src:url('../fonts/ibm-plex-sans-latin-700-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/ibm-plex-sans-cyrillic-400-normal.woff2') format('woff2');unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/ibm-plex-sans-cyrillic-500-normal.woff2') format('woff2');unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:600;font-display:swap;src:url('../fonts/ibm-plex-sans-cyrillic-600-normal.woff2') format('woff2');unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
    @font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:700;font-display:swap;src:url('../fonts/ibm-plex-sans-cyrillic-700-normal.woff2') format('woff2');unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}

    @keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.price-animate {
    animation: fadeIn 0.5s ease-out forwards;
}
    body{ font-family:'IBM Plex Sans','Helvetica Neue',Helvetica,Arial,sans-serif; -webkit-font-smoothing:antialiased; font-variant-numeric:tabular-nums; background:var(--bg); padding:20px; color:var(--text); margin:0; }
    .container{ background:var(--surface); max-width:900px; margin:auto; padding:30px; border-radius:var(--r-lg); border:1px solid var(--border); box-shadow:var(--shadow-card); margin-bottom:20px; }
    h2, h3 { color:var(--text); margin-top:0; letter-spacing:-0.02em; font-weight:600; }
    label{ display:block; margin-top:14px; margin-bottom:2px; font-size:11px; font-weight:600; letter-spacing:0.06em; text-transform:uppercase; color:var(--text-muted); }
    select,input,textarea{ width:100%; padding:11px 12px; margin-top:5px; border:1px solid var(--border); border-radius:var(--r-sm); background:var(--surface); color:var(--text); box-sizing:border-box; font-size:15px; outline:none; transition:border-color 0.18s ease, box-shadow 0.18s ease; }
    select:focus,input:focus,textarea:focus{ border-color:var(--accent); box-shadow:0 0 0 3px rgba(29,88,198,0.15); }
    .row{ display:flex; gap:20px; }
    .col{ flex:1; }
    button{ margin-top:25px; padding:15px; width:100%; background:var(--accent-container); border:none; color:var(--on-accent); font-size:16px; letter-spacing:0.01em; border-radius:var(--r-sm); cursor:pointer; font-weight:600; box-shadow:var(--shadow-sm); transition:background 0.2s, box-shadow 0.2s, transform 0.06s ease; }
    button:hover { background:var(--accent-strong); box-shadow:var(--shadow-card); }
    button:active { transform: translateY(1px); }
    button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    /* Единые иконки (inline-SVG, currentColor): наследуют цвет и размер текста */
    .icn { width:1.1em; height:1.1em; display:inline-block; vertical-align:-0.15em; flex:0 0 auto; }
    .icn-spin { animation: icnspin .9s linear infinite; }
    @keyframes icnspin { to { transform: rotate(360deg); } }

    /* === App shell (Blueprint Precision) === */
    .app-top-bar {
        position: sticky;
        top: 0;
        z-index: 1100;
        display: flex;
        flex-direction: column;
        width: 100%;
        margin: -20px -20px 20px;
        padding: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-sizing: border-box;
        box-shadow: 0 1px 2px rgba(28, 27, 25, 0.04);
    }
    .app-brandbar {
        position: relative;
        display: flex;
        align-items: center;
        gap: 18px;
        padding: 10px 24px;
    }
    .app-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 auto; }
    .app-brand-logo {
        display: inline-flex; align-items: center; justify-content: center;
        width: 34px; height: 34px; flex: 0 0 auto;
        border-radius: var(--r-sm);
        background: var(--accent-container); color: #fff;
    }
    .app-brand-name {
        font-size: 18px; font-weight: 500; color: var(--accent-strong);
        letter-spacing: -0.01em; white-space: nowrap;
        overflow: hidden; text-overflow: ellipsis;
    }
    .app-brand-name b { font-weight: 700; }
    .app-brand-actions { display: inline-flex; align-items: center; gap: 10px; flex: 0 0 auto; margin-left: auto; }
    .nav-newquote-btn {
        display: inline-flex; align-items: center; gap: 6px;
        width: auto; height: 38px; margin: 0; padding: 0 16px;
        background: var(--accent-container); color: #fff;
        border-radius: var(--r-sm); font-size: 14px; font-weight: 600;
        box-shadow: var(--shadow-sm);
    }
    .nav-newquote-btn .icn { width: 1.05em; height: 1.05em; }
    /* Тогл мобильного меню разделов — скрыт на десктопе */
    .nav-menu-toggle {
        display: none;
        align-items: center; gap: 8px;
        width: auto; height: 38px; margin: 0; padding: 0 14px;
        background: var(--surface-2); color: var(--text);
        border: 1px solid var(--border-2); border-radius: var(--r-sm);
        font-size: 14px; font-weight: 600; box-shadow: none;
    }
    .nav-menu-toggle .icn { width: 1.15em; height: 1.15em; }
    .nav-menu-toggle:hover { background: var(--surface-3); color: var(--text); }
    .nav-menu-toggle[aria-expanded="true"] {
        background: var(--accent-container); color: #fff; border-color: var(--accent-container);
    }
    .app-user-btn {
        flex: 0 0 auto;
        width: 38px; height: 38px; min-width: 38px;
        padding: 0; margin: 0;
        border-radius: var(--r-pill);
        border: 1px solid var(--border-2);
        background: var(--surface-2);
        color: var(--text-2);
        display: inline-flex; align-items: center; justify-content: center;
        box-shadow: var(--shadow-sm);
    }
    .app-user-btn:hover { background: var(--accent-tint); color: var(--accent-strong); border-color: var(--accent); }
    .app-user-btn.is-logged-in {
        background: var(--accent-container);
        color: #fff;
        border-color: var(--accent-container);
    }
    .app-user-btn.is-logged-in:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
    .app-user-btn-icon { display: block; }

    .tabs-nav {
        display: flex;
        align-items: center;
        gap: 2px;
        margin: 0;
        padding: 0;
        min-width: 0;
        flex: 0 1 auto;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .tabs-nav::-webkit-scrollbar { display: none; }
    .nav-tab {
        display: inline-flex; align-items: center; gap: 8px;
        flex: 0 0 auto;
        width: auto; height: auto;
        margin: 0;
        padding: 8px 14px;
        background: transparent;
        border: none; border-radius: var(--r-sm);
        cursor: pointer;
        font-size: 14px; font-weight: 500; line-height: 1.2;
        color: var(--text-2);
        white-space: nowrap;
        box-shadow: none;
        transition: background 0.18s ease, color 0.18s ease;
    }
    .nav-tab .icn { width: 1.15em; height: 1.15em; opacity: 0.85; flex: 0 0 auto; }
    .nav-tab:hover { background: var(--accent-tint); color: var(--accent-strong); }
    .nav-tab.active { background: var(--accent-container); color: #fff; }
    .nav-tab.active:hover { background: var(--accent-container); color: #fff; }
    .nav-tab--stub:disabled,
    .nav-newquote-btn:disabled {
        opacity: 0.42; cursor: not-allowed; box-shadow: none;
    }
    .nav-tab--stub:disabled:hover { background: transparent; color: var(--text-2); }
    .nav-newquote-btn:disabled { background: var(--surface-3); color: var(--text-muted); }
    .nav-newquote-btn:disabled:hover { background: var(--surface-3); }

    /* === Мобильная шапка: логотип без текста + меню-дропдаун по центру === */
    @media (max-width: 768px) {
        .app-brandbar { gap: 10px; padding: 10px 16px; }
        .app-brand { flex: 1 1 0; }
        .app-brand-name { display: none; }
        .app-brand-actions { flex: 1 1 0; margin-left: 0; justify-content: flex-end; gap: 8px; }
        .nav-newquote-btn { width: 38px; padding: 0; justify-content: center; }
        .nav-newquote-btn span { display: none; }
        .nav-menu-toggle { display: inline-flex; }
        .tabs-nav {
            position: absolute;
            top: calc(100% + 6px);
            left: 50%;
            transform: translateX(-50%);
            flex-direction: column;
            align-items: stretch;
            gap: 3px;
            width: min(280px, calc(100vw - 24px));
            padding: 8px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--r-md);
            box-shadow: var(--shadow-pop);
            overflow: visible;
            display: none;
            z-index: 1200;
        }
        .tabs-nav.is-open { display: flex; }
        .tabs-nav .nav-tab { width: 100%; justify-content: flex-start; padding: 11px 14px; font-size: 15px; }
    }

    .tab-close-btn { display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; margin-left:8px; border-radius:50%; font-size:13px; line-height:1; color:inherit; opacity:0.75; }
    .tab-close-btn:hover { background:rgba(0,0,0,0.12); opacity:1; }
    /* вкладка сделки (№…) — без двойного отступа перед крестиком */
    .nav-tab--deal .tab-close-btn { margin-left: 0; }
    .nav-tab--deal.active .tab-close-btn:hover { background: rgba(255,255,255,0.25); }
    .tab-content { display: none; }
    .tab-content.active { display: block; }

    /* === Калькулятор: 2-колоночная сетка (Blueprint Precision) === */
    #calcContainer { max-width: min(1200px, 100%); }
    /* Список заказов под калькулятором — по ширине калькулятора. */
    #crm-search-container { max-width: min(1200px, 100%); }

    /* ===== Раздел «Клиенты» ===== */
    #clients-container { max-width: min(1400px, 100%); }
    .clients-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
    .clients-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--text); }
    .clients-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
    .clients-search {
        width: 240px; max-width: 100%; padding: 8px 12px; margin: 0;
        border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 14px; background: var(--surface);
    }
    .clients-btn {
        margin: 0; width: auto; padding: 8px 14px; font-size: 13px; font-weight: 600;
        border-radius: var(--r-sm); box-shadow: none; cursor: pointer; border: 1px solid transparent;
    }
    .clients-btn-add { background: var(--accent-container); color: #fff; }
    .clients-btn-add:hover { background: var(--accent-strong); }
    .clients-btn-sync { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
    .clients-btn-sync:hover { background: var(--accent-tint); color: var(--accent-strong); }
    .clients-btn-cancel { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
    .clients-btn-cancel:hover { background: var(--surface-3); }

    .clients-form { margin-bottom: 14px; padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); }
    .clients-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
    .clients-form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
    .clients-form-grid input { margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 14px; background: var(--surface); color: var(--text); font-weight: 400; }
    .clients-form-wide { grid-column: 1 / -1; }
    .clients-form-actions { display: flex; gap: 8px; margin-top: 12px; }

    .clients-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
    .clients-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); }
    .clients-table thead th {
        position: sticky; top: 0; z-index: 1; text-align: left; padding: 9px 12px;
        background: var(--surface-2); border-bottom: 1px solid var(--border);
        font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-muted); white-space: nowrap;
    }
    .clients-table tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
    .clients-table tbody tr:last-child td { border-bottom: none; }
    .clients-table tbody tr:hover { background: var(--surface-2); }
    .clients-td-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .clients-td-nowrap { white-space: nowrap; }
    .clients-td-notes { color: var(--text-muted); max-width: 260px; }
    .clients-company { font-weight: 600; color: var(--text); }
    .clients-crm-link { margin-left: 6px; color: var(--accent); text-decoration: none; font-weight: 700; }
    .clients-crm-link:hover { color: var(--accent-strong); }
    .clients-table a { color: var(--accent); text-decoration: none; }
    .clients-table a:hover { text-decoration: underline; }
    .clients-debt { color: var(--danger); font-weight: 600; }
    .clients-debt-zero { color: var(--text-muted); }
    .clients-count { margin-top: 10px; font-size: 13px; color: var(--text-muted); }
    .clients-empty { padding: 40px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }
    .clients-empty--error { color: var(--danger); }
    .calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
    .calc-form-col { min-width: 0; }
    .calc-side-col { position: sticky; top: 96px; min-width: 0; }
    .calc-form-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .calc-form-head h2 { margin: 0; }
    .calc-version-badge {
        flex: 0 0 auto; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
        color: var(--on-secondary-container); background: var(--secondary-container);
        padding: 4px 10px; border-radius: var(--r-pill);
    }

    /* Поля + интерактивное превью изделия */
    .calc-body { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 24px; align-items: stretch; }
    .calc-fields { min-width: 0; }
    .calc-preview {
        position: sticky; top: 96px;
        align-self: start;
        display: flex; flex-direction: column; align-items: center;
        gap: 6px; padding: 16px 20px 14px;
        min-height: 300px;
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        margin-top: 21px;
    }
    .calc-preview-head {
        align-self: flex-start;
        display: inline-flex; align-items: center; gap: 6px;
        color: var(--text-muted);
        font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
    }
    .calc-preview-head .icn { width: 15px; height: 15px; }
    .calc-preview-stage {
        flex: 1 1 auto; width: 100%;
        display: flex; align-items: center; justify-content: center;
        padding: 30px 30px 22px;
    }
    .calc-preview-diagram { position: relative; }
    .calc-preview-rect {
        width: 150px; height: 83px;
        background: var(--surface);
        border: 2px solid var(--accent);
        border-radius: 4px;
        box-shadow: var(--shadow-sm);
        display: flex; align-items: center; justify-content: center;
        color: var(--accent);
        transition: width 0.32s cubic-bezier(0.22,1,0.36,1), height 0.32s cubic-bezier(0.22,1,0.36,1);
    }
    .calc-preview-icon { width: 34px; height: 34px; opacity: 0.3; }
    /* размерная линия — ширина (сверху) */
    .calc-preview-dim-w { position: absolute; left: 0; right: 0; top: -20px; height: 1px; display: flex; align-items: center; justify-content: center; }
    .calc-preview-dim-w::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--accent); opacity: 0.45; }
    /* размерная линия — высота (справа) */
    .calc-preview-dim-h { position: absolute; top: 0; bottom: 0; right: -18px; width: 1px; display: flex; align-items: center; justify-content: center; }
    .calc-preview-dim-h::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--accent); opacity: 0.45; }
    .calc-preview-dim-w span, .calc-preview-dim-h span {
        position: relative; z-index: 1;
        background: var(--surface-2);
        padding: 0 6px;
        font-size: 12px; font-weight: 700; color: var(--accent);
        white-space: nowrap;
    }
    .calc-preview-dim-h span { transform: translateX(50%); padding: 4px 6px; }
    .calc-preview-caption { margin: 2px 0 0; font-size: 11px; color: var(--text-muted); text-align: center; }
    @media (max-width: 720px) {
        .calc-body { grid-template-columns: 1fr; gap: 18px; }
        /* схему-превью на мобильном не показываем */
        .calc-preview { display: none; }
    }

    .result-main { margin-top: 0; display: block; }
    .rec-price-box { position:relative; background:var(--accent-strong); padding:24px; border-radius:var(--r-lg); border:none; text-align:left; margin-bottom:16px; box-shadow:0 10px 30px rgba(6,77,188,0.22); }
    .rec-price-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding-right:30px; }
    .rec-price-gear {
        position:absolute; top:16px; right:16px;
        width:32px; height:32px; margin:0; padding:0;
        display:inline-flex; align-items:center; justify-content:center;
        background:rgba(255,255,255,0.12); color:#fff;
        border:none; border-radius:var(--r-sm); box-shadow:none;
    }
    .rec-price-gear:hover { background:rgba(255,255,255,0.24); }
    .rec-price-label { color:rgba(255,255,255,0.75); font-size:10px; font-weight:700; letter-spacing:0.14em; text-transform:uppercase; }
    .rec-price-val { font-size:42px; color:#fff; font-weight:700; letter-spacing:-0.025em; display:block; margin-top:10px; line-height:1; font-variant-numeric:tabular-nums; }
    .rec-price-val small { color:rgba(255,255,255,0.82); font-weight:600; font-size:14px; }
    .rec-price-stubs { margin-top:20px; padding-top:18px; border-top:1px solid rgba(255,255,255,0.18); display:flex; flex-direction:column; gap:14px; }
    .rec-stub-label { color:rgba(255,255,255,0.82); font-size:14px; font-weight:500; flex:0 0 auto; }
    /* Ряд коэффициентов наценки (переносится, чтобы все были видны) */
    .rec-markup-row { display:flex; align-items:center; gap:10px; min-width:0; }
    .rec-coef-btns { display:flex; flex-wrap:wrap; gap:4px; min-width:0; padding:2px; background:rgba(255,255,255,0.12); border-radius:var(--r-sm); }
    .rec-coef-btn {
        margin:0; width:auto; flex:0 0 auto; padding:5px 9px;
        font-size:13px; font-weight:700; border-radius:6px;
        background:transparent; color:rgba(255,255,255,0.9); box-shadow:none;
        font-variant-numeric:tabular-nums;
    }
    .rec-coef-btn:hover { background:rgba(255,255,255,0.16); }
    .rec-coef-btn.is-active { background:#fff; color:var(--accent-strong); }
    .rec-coef-btn.is-active:hover { background:#fff; }
    /* Округление цены (кнопки в блоке) */
    .rec-round-btns { display:inline-flex; gap:4px; background:rgba(255,255,255,0.12); border-radius:var(--r-sm); padding:2px; }
    .rec-round-btns button { margin:0; width:auto; padding:5px 12px; font-size:13px; font-weight:600; border-radius:6px; background:transparent; color:rgba(255,255,255,0.9); box-shadow:none; }
    .rec-round-btns button:hover { background:rgba(255,255,255,0.18); }
    /* Инлайн-редактирование цены (по шестерёнке) */
    .rec-price-gear.is-active { background:#fff; color:var(--accent-strong); }
    .rec-price-val[hidden] { display:none; }
    .rec-price-edit { display:flex; gap:12px; margin-top:12px; }
    .rec-price-edit[hidden] { display:none; }
    .rec-edit-field { display:flex; flex-direction:column; gap:4px; margin:0; flex:1 1 0; min-width:0; }
    .rec-edit-field > span { font-size:10px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; color:rgba(255,255,255,0.72); }
    .rec-edit-field input { margin:0; width:100%; padding:9px 10px; font-size:17px; font-weight:700; background:#fff; border:none; border-radius:var(--r-sm); color:var(--accent-strong); font-variant-numeric:tabular-nums; box-sizing:border-box; }
    .rec-edit-field input:focus { box-shadow:0 0 0 3px rgba(255,255,255,0.45); outline:none; }
    .rec-order-stub { margin:6px 0 0; width:100%; display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:13px; background:#fff; color:var(--accent-strong); border-radius:var(--r-sm); font-size:15px; font-weight:600; box-shadow:none; transition:background 0.15s ease, color 0.15s ease; }
    /* hover — серый (на синем фоне контрастнее белого, не сливается) */
    .rec-order-stub:hover { background:#e3e5ec; color:var(--accent-strong); }
    .rec-order-stub:active { background:#d6d9e2; }
    .rec-order-stub .icn { width:1.15em; height:1.15em; }
    .rec-order-stub:disabled { opacity:0.55; cursor:not-allowed; }
    .rec-order-stub:disabled:hover { background:#fff; }

    /* Всплывающая настройка цены — поверх синего блока */
    .rec-price-settings {
        position:absolute; top:0; left:0; right:0; z-index:5;
        min-height:100%;
        display:flex; flex-direction:column; gap:12px;
        padding:20px; border-radius:var(--r-lg);
        background:var(--surface); color:var(--text);
        box-shadow:var(--shadow-pop);
        animation:rpsIn 0.16s ease-out;
    }
    .rec-price-settings[hidden] { display:none; }
    @keyframes rpsIn { from { opacity:0; transform:scale(0.98); } to { opacity:1; transform:scale(1); } }
    .rps-head { display:flex; align-items:center; justify-content:space-between; }
    .rps-title { font-size:15px; font-weight:600; color:var(--text); }
    .rps-close { margin:0; width:28px; height:28px; padding:0; display:inline-flex; align-items:center; justify-content:center; font-size:20px; line-height:1; background:var(--surface-3); color:var(--text-2); border:none; border-radius:var(--r-sm); box-shadow:none; }
    .rps-close:hover { background:var(--border-2); color:var(--text); }
    .rps-field { display:flex; flex-direction:column; gap:4px; margin:0; }
    .rps-field > span { font-size:11px; font-weight:600; letter-spacing:0.04em; text-transform:uppercase; color:var(--text-muted); }
    .rps-field input { margin:0; }
    .rps-round { display:flex; align-items:center; gap:8px; margin-top:2px; flex-wrap:wrap; }
    .rps-round > span { font-size:13px; font-weight:500; color:var(--text-2); }
    .rps-round button { margin:0; width:auto; flex:0 0 auto; padding:7px 12px; font-size:13px; font-weight:600; background:var(--surface-3); color:var(--text); border-radius:var(--r-sm); box-shadow:none; }
    .rps-round button:hover { background:var(--accent-tint); color:var(--accent-strong); }

    /* Кнопка входа в настройки калькулятора (в модалке аккаунта) */
    .auth-settings-btn {
        margin: 10px 0 0; width: 100%; padding: 12px;
        display: inline-flex; align-items: center; justify-content: center; gap: 8px;
        background: var(--surface-2); color: var(--text);
        border: 1px solid var(--border-2); border-radius: var(--r-sm);
        font-size: 14px; font-weight: 600; box-shadow: none;
    }
    .auth-settings-btn:hover { background: var(--accent-tint); color: var(--accent-strong); border-color: var(--accent); }
    .auth-settings-btn .icn { width: 1.1em; height: 1.1em; }

    /* === Модалка «Настройки калькулятора» === */
    #calc-settings-modal {
        position: fixed; inset: 0; z-index: 1500;
        display: none; align-items: flex-start; justify-content: center;
        padding: 24px 16px;
        background: rgba(28, 27, 25, 0.45);
        overflow-y: auto;
    }
    #calc-settings-modal.open { display: flex; }
    .cs-dialog {
        width: 100%; max-width: 720px; margin: auto;
        background: var(--surface); border-radius: var(--r-lg);
        box-shadow: var(--shadow-pop); overflow: hidden;
        display: flex; flex-direction: column;
    }
    .cs-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
    .cs-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
    .cs-close { margin: 0; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; background: var(--surface-3); color: var(--text-2); border: none; border-radius: var(--r-sm); box-shadow: none; }
    .cs-close:hover { background: var(--border-2); color: var(--text); }
    .cs-tabs { display: flex; gap: 4px; padding: 12px 22px 0; border-bottom: 1px solid var(--border); }
    .cs-tab { margin: 0; width: auto; padding: 9px 16px; background: transparent; color: var(--text-2); border: none; border-radius: var(--r-sm) var(--r-sm) 0 0; font-size: 14px; font-weight: 600; box-shadow: none; }
    .cs-tab:hover { background: var(--surface-2); color: var(--text); }
    .cs-tab.is-active { background: var(--accent-container); color: #fff; }
    .cs-tab.is-active:hover { background: var(--accent-container); color: #fff; }
    .cs-body { padding: 20px 22px; max-height: 62vh; overflow-y: auto; }
    .cs-note { margin: 0 0 16px; font-size: 13px; line-height: 1.5; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; }
    .cs-note b { color: var(--text); }
    .cs-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
    .cs-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
    .cs-field > span { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
    .cs-field input, .cs-field select { margin: 0; }
    .cs-field--inline { flex-direction: row; align-items: center; gap: 12px; max-width: 420px; margin-bottom: 16px; }
    .cs-field--inline > span { flex: 0 0 auto; }
    .cs-hint { display: block; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-muted); font-size: 11px; }
    /* Материалы */
    .cs-cat { margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
    .cs-cat > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 14px; color: var(--text); background: var(--surface-2); list-style: none; display: flex; align-items: center; gap: 8px; }
    .cs-cat > summary::-webkit-details-marker { display: none; }
    .cs-count { min-width: 22px; height: 22px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-4); color: var(--text-2); border-radius: var(--r-pill); font-size: 12px; font-weight: 700; }
    .cs-mat-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
    .cs-mat-row { display: flex; align-items: center; gap: 8px; }
    .cs-mat-row input { margin: 0; }
    .cs-mat-name { flex: 1 1 auto; min-width: 0; }
    .cs-mat-id { flex: 0 0 140px; width: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
    .cs-hq { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; margin: 0; }
    .cs-hq input { width: auto; margin: 0; }
    .cs-mat-del { flex: 0 0 auto; margin: 0; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1; background: var(--surface-3); color: var(--text-2); border: none; border-radius: var(--r-sm); box-shadow: none; }
    .cs-mat-del:hover { background: var(--danger-bg); color: var(--danger); }
    .cs-add { margin: 10px 14px 12px; width: auto; padding: 8px 14px; background: var(--surface-3); color: var(--text); border-radius: var(--r-sm); font-size: 13px; font-weight: 600; box-shadow: none; }
    .cs-add:hover { background: var(--accent-tint); color: var(--accent-strong); }
    .cs-empty { color: var(--text-muted); font-size: 13px; padding: 6px 0; }
    /* Правила по продуктам */
    .cs-rule-group { margin-bottom: 18px; }
    .cs-rule-group h4 { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--text); }
    .cs-chk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 14px; }
    .cs-chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 0; cursor: pointer; }
    .cs-chk input { width: auto; margin: 0; }
    .cs-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-top: 1px solid var(--border); }
    .cs-reset { margin: 0; width: auto; padding: 11px 16px; background: transparent; color: var(--text-2); border: 1px solid var(--border-2); border-radius: var(--r-sm); font-size: 14px; font-weight: 600; box-shadow: none; }
    .cs-reset:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bg); }
    .cs-reset.is-armed { background: var(--danger); color: #fff; border-color: var(--danger); }
    .cs-save { margin: 0; width: auto; padding: 11px 22px; background: var(--accent-container); color: #fff; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; }
    .cs-save:hover { background: var(--accent-strong); }
    @media (max-width: 560px) {
        .cs-mat-id { flex-basis: 96px; width: 96px; }
        .cs-tabs { flex-wrap: wrap; }
    }

    @media (max-width: 860px) {
        #calcContainer { max-width: 900px; }
        .calc-grid { grid-template-columns: 1fr; gap: 20px; }
        .calc-side-col { position: static; top: auto; }
    }
    details { background:#F2F0EA; border-radius:12px; padding:12px; margin-bottom:15px; }
    details summary { cursor: pointer; font-weight: bold; color: #6b675e; outline: none; }
    .price-list-hidden { margin-top: 10px; font-size: 15px; border-top: 1px solid #d3cdc0; padding-top: 10px; }
    .cost-detail { background:#FAF9F6; padding:18px; border:1px solid #EAE8E2; border-radius:14px; font-size:14px; line-height:1.6; }
    .tech-info { margin-top:15px; padding:15px; background:#FAF9F6; border:1px dashed #D9CFC2; border-radius:12px; font-size:14px; color:#6E6C65; }
    .section-title { margin-top: 20px; padding-bottom: 5px; border-bottom: 1px solid #ebe8e0; color: #7a766c; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
    .checkbox-group { margin-top:15px; background:#FAF9F6; padding:14px; border-radius:12px; border:1px solid #EAE8E2; }

    .crm-item { border:1px solid var(--border); border-radius:var(--r-md); padding:15px; margin-top:15px; background:var(--surface); box-shadow:var(--shadow-card); }

    /* Саммари под списком заказов: всего / оплачено / не оплачено */
    .crm-list-summary {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 16px;
        padding: 14px 16px;
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: var(--r-md);
    }
    .crm-sum-item {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1 1 auto;
        min-width: 120px;
    }
    .crm-sum-label {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }
    .crm-sum-item b { font-size: 16px; font-weight: 700; color: var(--text); }
    .crm-sum-paid { color: var(--success) !important; }
    .crm-sum-debt { color: var(--danger) !important; }

    /* Саммари под колонкой канбана */
    .crm-kanban-column-summary {
        flex: 0 0 auto;
        margin: 6px 8px 2px;
        padding: 8px 10px;
        background: rgba(255,255,255,0.72);
        border: 1px solid var(--border);
        border-radius: 10px;
        font-size: 12px;
    }
    .crm-kanban-column-summary .csum-row {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 8px;
        padding: 2px 0;
    }
    .crm-kanban-column-summary .csum-row span { color: var(--text-muted); font-weight: 600; }
    .crm-kanban-column-summary .csum-row b { font-weight: 700; color: var(--text); }

    .crm-search-pagination {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 6px;
        margin: 18px 0 8px;
        padding: 12px 8px 4px;
        border-top: 1px solid #eae8e2;
    }
    .crm-search-page-btn {
        min-width: 34px;
        height: 34px;
        padding: 0 10px;
        border: 1px solid #dedbd2;
        border-radius: 8px;
        background: #fff;
        color: #3a3833;
        font-size: 13px;
        cursor: pointer;
    }
    .crm-search-page-btn:hover:not(:disabled) {
        border-color: var(--accent);
        color: var(--accent);
        background: #f5f9ff;
    }
    .crm-search-page-btn.active {
        border-color: var(--accent);
        background: var(--accent);
        color: #fff;
        cursor: default;
    }
    .crm-search-page-btn:disabled {
        opacity: 0.45;
        cursor: default;
    }
    .crm-search-page-dots {
        color: #a8a498;
        font-size: 14px;
        padding: 0 2px;
        user-select: none;
    }
    .crm-search-page-info {
        flex: 0 0 100%;
        text-align: center;
        color: #8c887e;
        font-size: 12px;
        margin-top: 2px;
    }
    .status-badge { padding: 4px 11px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
    .editable-status { margin:0; width:auto; padding:3px 8px; border-radius:4px; border:none; font-size:11px; line-height:1.2; font-weight:bold; text-transform:uppercase; cursor:pointer; }
    .editable-status:hover { filter: brightness(0.96); box-shadow: 0 0 0 2px rgba(47,125,246,0.12); }
    .item-status-control { margin:0 10px 0 0; width:auto; max-width:150px; padding:4px 7px; border-radius:999px; border:1px solid #d3cdc0; background:#f1efe9; color:#3a3833; font-size:12px; line-height:1.15; font-weight:normal; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .item-status-control:hover { background:#eef4ff; color:var(--accent); }
    .status-menu { position: fixed; z-index: 2100; width: 260px; max-height: 320px; overflow-y: auto; padding: 6px; background: white; border: 1px solid #eae8e2; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); }
    .status-menu-option { display:flex; align-items:center; gap:8px; width:100%; margin:0; padding:8px 10px; background:white; color:#3a3833; border:none; border-radius:7px; font-size:14px; font-weight:normal; text-align:left; }
    .status-menu-option:hover { background:#f1efe9; }
    .status-menu-color { width:14px; height:14px; border-radius:4px; flex:0 0 14px; }
    .elements-list { background: #faf9f6; border: none; border-radius: 8px; padding: 8px 12px; }
    .element-row { border-bottom: 1px solid #ebe8e0; transition: background 0.5s; display: flex; align-items: flex-start; flex-wrap: nowrap; gap: 6px; padding: 6px 0; position: relative; }
    .element-row:last-child { border-bottom: none; }
    /* Второстепенные данные под позицией: Себ. HQ · Листов SRA3 */
    .element-row-meta {
        font-size: 11px; line-height: 1.3;
        color: var(--text-muted);
        padding: 0 0 6px 30px;
        border-bottom: 1px solid #ebe8e0;
    }
    .element-row-meta b { font-weight: 600; color: var(--text-2); }
    /* Себ. HQ под маской: скрыта по умолчанию, раскрывается тем же глазиком */
    .element-row-meta .meta-hq .cost-mask { display: none; color: #b8b2a4; letter-spacing: 1px; }
    .elements-list.costs-hidden .element-row-meta .meta-hq .cost-val { display: none; }
    .elements-list.costs-hidden .element-row-meta .meta-hq .cost-mask { display: inline; }
    /* бордер отдаём мете, чтобы строка и её мета читались как один блок */
    .element-row:has(+ .element-row-meta) { border-bottom: none; }
    .element-row-meta:last-child { border-bottom: none; }
    .element-row > .item-status-control,
    .element-row > span:first-child { flex: 0 0 auto; }
    .element-row-text { flex: 1 1 auto; min-width: 0; padding-right: 6px; font-size: 12px; line-height: 1.2; overflow-wrap: anywhere; word-break: break-word; }
    .element-row-text-clickable { cursor: pointer; color: var(--accent); }
    .element-row-text-clickable:hover { text-decoration: underline; }
    /* Десктопные столбцы строки позиции (кол-во / себестоимость / название) — по умолчанию скрыты,
       включаются только на десктопе в детальной карточке заказа. На мобильных остаётся компактная строка. */
    .element-row-col { display: none; }
    .element-cols-head { display: none; }
    .element-preview-thumb {
        flex: 0 0 22px;
        width: 22px;
        height: 22px;
        border-radius: 4px;
        background: #f1efe9;
        border: 1px solid #e3e0d6;
        overflow: hidden;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .element-preview-thumb.is-loading {
        background: linear-gradient(90deg, #f1efe9 25%, #faf9f6 50%, #f1efe9 75%);
        background-size: 200% 100%;
        animation: previewShimmer 1.2s infinite;
    }
    .element-preview-thumb.has-preview img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }
    .element-preview-thumb-clickable {
        cursor: zoom-in;
    }
    .preview-lightbox {
        position: fixed;
        inset: 0;
        z-index: 2400;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
        background: rgba(0, 0, 0, 0.92);
        box-sizing: border-box;
    }
    .preview-lightbox img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        border-radius: 6px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    }
    .preview-lightbox-close {
        position: absolute;
        top: 12px;
        right: 12px;
        margin: 0;
        width: 36px;
        height: 36px;
        min-width: 36px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
    }
    .preview-lightbox-close:hover {
        background: rgba(255, 255, 255, 0.28);
    }
    @keyframes previewShimmer {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
    .element-editor-backdrop {
        position: fixed;
        inset: 0;
        z-index: 2300;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
        background: rgba(0, 0, 0, 0.4);
        box-sizing: border-box;
    }
    .element-editor-modal {
        width: 100%;
        max-width: 420px;
        max-height: 92vh;
        overflow: auto;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
    }
    .element-editor-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 14px 8px;
        border-bottom: 1px solid #f1efe9;
    }
    .element-editor-header-minimal {
        justify-content: flex-end;
        padding: 8px 10px 4px;
        border-bottom: none;
    }
    .element-editor-title { font-weight: bold; font-size: 15px; color: #3a3833; }
    .element-editor-close {
        margin: 0;
        width: 28px;
        height: 28px;
        min-width: 28px;
        padding: 0;
        border: none;
        background: #f1efe9;
        border-radius: 50%;
        font-size: 18px;
        line-height: 1;
        color: #7a766c;
        cursor: pointer;
    }
    .element-editor-body { padding: 10px 14px 12px; }
    .element-editor-label {
        display: block;
        margin: 8px 0 4px;
        font-size: 11px;
        font-weight: bold;
        color: #8c887e;
        text-transform: uppercase;
    }
    .element-editor-label:first-child { margin-top: 0; }
    .element-editor-input {
        width: 100%;
        margin-top: 0;
        padding: 8px 10px;
        font-size: 16px;
        box-sizing: border-box;
    }
    .element-editor-input-readonly {
        background: #f4f2ec;
        color: #6b675e;
        cursor: default;
    }
    /* Наименование в режиме переименования — явно редактируемое поле */
    .element-editor-input-rename {
        background: #fff;
        border: 1px solid var(--accent, #2f7df6);
        box-shadow: 0 0 0 2px rgba(47, 125, 246, 0.12);
    }
    .element-editor-rename-btn {
        margin-top: 6px;
        padding: 6px 12px;
        font-size: 13px;
        font-weight: 600;
        color: var(--accent, #2f7df6);
        background: rgba(47, 125, 246, 0.08);
        border: 1px solid rgba(47, 125, 246, 0.35);
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.15s ease;
    }
    .element-editor-rename-btn:hover {
        background: rgba(47, 125, 246, 0.16);
    }
    #elementEditorCategory:disabled {
        background: #f4f2ec;
        color: #6b675e;
        cursor: default;
        opacity: 1;
    }
    .element-editor-row3 {
        display: grid;
        grid-template-columns: 1fr 0.7fr 1fr;
        gap: 8px;
    }
    .element-editor-row4 {
        display: grid;
        grid-template-columns: 0.85fr 1fr 1fr 1fr;
        gap: 6px;
        margin-top: 8px;
    }
    .element-editor-row5 {
        display: grid;
        grid-template-columns: 0.72fr 0.82fr 1fr 1fr 1fr;
        gap: 6px;
        margin-top: 8px;
    }
    .element-editor-secondary-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 8px;
    }
    .element-editor-secondary-row > div {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 110px;
    }
    .element-editor-secondary-row > .element-editor-responsibles-wrap,
    .element-editor-secondary-row > .element-editor-units-wrap {
        min-width: 140px;
    }
    .element-editor-units-wrap {
        min-width: 0;
    }
    .element-editor-units-dropdown {
        margin-top: 0;
    }
    .element-editor-units-dropdown .status-dropdown-btn,
    .element-editor-responsibles-dropdown .status-dropdown-btn {
        margin-top: 0;
        height: 36px;
        min-height: 36px;
        padding: 8px 28px 8px 10px;
        font-size: 16px;
    }
    .element-editor-units-list {
        z-index: 1300;
    }
    .element-editor-responsibles-wrap {
        min-width: 0;
    }
    .element-editor-responsibles-dropdown .status-dropdown-list {
        z-index: 1300;
    }
    .element-units-preset {
        display: block;
        width: 100%;
        margin: 0;
        padding: 9px 10px;
        border: none;
        border-radius: 6px;
        background: transparent;
        color: #3a3833;
        font-size: 16px;
        line-height: 1.2;
        text-align: left;
        cursor: pointer;
    }
    .element-units-preset:hover {
        background: #f1efe9;
    }
    .element-units-preset.is-selected {
        background: #eef4ff;
        color: var(--accent);
        font-weight: 600;
    }
    .element-units-custom-row {
        padding: 6px 8px 4px;
        border-top: 1px solid #f1efe9;
        margin-top: 4px;
    }
    .element-units-custom-row .element-editor-input {
        margin-top: 0;
    }
    .element-responsible-none .status-option-name {
        min-height: 1em;
    }
    .element-editor-readonly-text {
        min-height: 36px;
        padding: 7px 10px;
        border: 1px solid #eae8e2;
        border-radius: 8px;
        background: #faf9f6;
        color: #3a3833;
        font-size: 16px;
        line-height: 1.35;
        word-break: break-word;
    }
    .element-editor-preview-wrap {
        margin-top: 12px;
    }
    .element-editor-preview-box {
        position: relative;
        width: 100%;
    }
    .element-editor-drop-target.drop-active::after {
        content: "";
        position: absolute;
        inset: 0;
        border: 2px dashed var(--accent);
        border-radius: 8px;
        background: rgba(47, 125, 246, 0.08);
        pointer-events: none;
        z-index: 4;
    }
    .element-editor-preview-upload-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
        box-sizing: border-box;
        background: rgba(255, 255, 255, 0.88);
        border-radius: 8px;
        z-index: 3;
    }
    .element-editor-preview-upload-overlay[hidden] {
        display: none !important;
    }
    .element-editor-layouts-wrap {
        position: relative;
        min-height: 48px;
        border-radius: 8px;
    }
    .element-editor-layout-drop-zone {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        margin-top: 8px;
        min-height: 135px;
        padding: 32px 12px;
        border: 1.5px dashed rgba(47, 125, 246, 0.32);
        border-radius: 8px;
        background: rgba(47, 125, 246, 0.035);
        color: #8c887e;
        font-size: 13px;
        line-height: 1.35;
        text-align: center;
        cursor: pointer;
        box-sizing: border-box;
    }
    .element-editor-layout-drop-title {
        color: #5f5c54;
        font-weight: 600;
    }
    .element-editor-layout-drop-hint {
        font-size: 12px;
        color: #a8a498;
    }
    .element-editor-layout-drop-zone.drop-active {
        border-color: var(--accent);
        background: rgba(47, 125, 246, 0.1);
    }
    .element-editor-layout-drop-zone.drop-active .element-editor-layout-drop-title,
    .element-editor-layout-drop-zone.drop-active .element-editor-layout-drop-hint {
        color: var(--accent);
    }
    .element-editor-layout-drop-zone::after {
        display: none;
    }
    .element-layout-upload-item {
        margin-top: 6px;
        padding: 8px;
        background: #faf9f6;
        border-radius: 6px;
        border: 1px dashed #d6d0c4;
    }
    .element-layout-item.is-deleting {
        opacity: 0.72;
    }
    .element-layout-item-progress {
        flex: 1 1 100%;
        width: 100%;
        margin-top: 6px;
    }
    .element-layout-item-progress .element-editor-progress {
        padding: 4px 0 0;
    }
    .element-editor-preview {
        width: 100%;
        min-height: 72px;
        max-height: 120px;
        border-radius: 8px;
        border: 1px dashed #d6d0c4;
        background: #faf9f6;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
    .element-editor-preview img {
        width: 100%;
        max-height: 120px;
        object-fit: contain;
        display: block;
    }
    .element-editor-preview-placeholder {
        font-size: 13px;
        color: #a6a294;
        text-align: center;
        padding: 12px;
    }
    .element-editor-preview-placeholder.loading { color: var(--accent); }
    .element-editor-progress {
        width: 100%;
        padding: 10px 8px;
        box-sizing: border-box;
    }
    .element-editor-progress-label {
        margin-bottom: 8px;
        font-size: 13px;
        color: #8c887e;
        text-align: center;
    }
    .element-editor-progress-track {
        height: 5px;
        border-radius: 999px;
        background: #eae8e2;
        overflow: hidden;
    }
    .element-editor-progress-bar {
        height: 100%;
        width: 38%;
        border-radius: 999px;
        background: linear-gradient(90deg, var(--accent), #5b9dff);
        animation: elementEditorProgressSlide 1.15s ease-in-out infinite;
    }
    .element-editor-progress-bar.determinate {
        width: 0;
        animation: none;
        transition: width 0.15s ease;
    }
    @keyframes elementEditorProgressSlide {
        0% { transform: translateX(-120%); }
        100% { transform: translateX(320%); }
    }
    .element-editor-preview-actions {
        position: absolute;
        top: 8px;
        right: 8px;
        display: flex;
        flex-direction: row;
        gap: 6px;
    }
    .element-editor-mini-btn {
        margin: 0;
        width: 32px;
        height: 32px;
        min-width: 32px;
        padding: 0;
        border-radius: 8px;
        border: 1px solid #eae8e2;
        background: #faf9f6;
        font-size: 15px;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    .element-editor-mini-btn.primary { background: #27ae60; color: #fff; border-color: #27ae60; }
    .element-editor-mini-btn.danger { color: #c0392b; }
    .element-editor-section-title {
        margin: 12px 0 6px;
        font-size: 11px;
        font-weight: bold;
        color: #8c887e;
        text-transform: uppercase;
    }
    .element-editor-layouts { display: flex; flex-direction: column; gap: 4px; }
    .element-layout-item {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 6px 8px;
        background: #faf9f6;
        border-radius: 6px;
        font-size: 12px;
    }
    .element-layout-link {
        flex: 1;
        min-width: 0;
        color: var(--accent);
        text-decoration: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .element-layout-size { color: #9a988f; font-size: 10px; white-space: nowrap; }
    .element-layout-del {
        margin: 0;
        width: 20px;
        height: 20px;
        min-width: 20px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: #fdeaea;
        color: #c0392b;
        font-size: 14px;
        line-height: 1;
        cursor: pointer;
    }
    .element-editor-layout-empty {
        font-size: 12px;
        color: #a6a294;
        padding: 4px 0;
    }
    .element-editor-layout-empty.loading { color: var(--accent); }
    .element-editor-layout-add {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-top: 8px;
    }
    .element-editor-layout-add .element-editor-input { flex: 1; }
    .element-editor-footer {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        padding: 10px 14px 14px;
        border-top: 1px solid #f1efe9;
    }
    .element-editor-footer button {
        margin: 0;
        width: auto;
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 7px;
    }
    .element-editor-cancel { background: #f1efe9; color: #6b675e; }
    .element-editor-save { background: var(--accent); color: #fff; }
    .element-editor-save-secondary { background: #27ae60; color: #fff; }
    .element-editor-assets-hidden .element-editor-assets-block { display: none; }
    .element-row-total { flex: 0 0 auto; margin-left: auto; font-weight: bold; white-space: nowrap; font-size: 12px; line-height: 1.2; text-align: right; }
    .element-row-delete-btn {
        flex: 0 0 auto;
        margin: 0;
        width: 20px;
        height: 20px;
        min-width: 20px;
        padding: 0;
        border: 1px solid #e2b5b5;
        border-radius: 50%;
        background: #f3d5d5;
        color: #9b2c2c;
        font-size: 14px;
        line-height: 18px;
        cursor: pointer;
        text-align: center;
    }
    .element-row-delete-btn:hover { background: #ff4d4d; color: #fff; border-color: #ff4d4d; }
    /* Строка просчёта, вставленного из калькулятора (до сохранения): самостоятельная
       раскладка, не зависящая от адаптивных колонок .element-row (иначе на мобиле
       текст скрывался и кнопка × пропадала). Полная рамка вместо side-stripe. */
    .element-row.new-row {
        display: flex !important; align-items: flex-start; gap: 8px;
        padding: 8px 10px; margin: 6px 0;
        background: #f6f9ff; border: 1px solid #d4e1f5; border-radius: var(--r-sm);
    }
    .element-row.new-row > .element-row-text { display: block !important; flex: 1 1 auto; min-width: 0; padding-right: 4px; }
    .new-row-costs { display: block; margin-top: 3px; font-size: 11px; font-weight: normal; color: #6b7280; }
    .new-row-costs b { color: #3a3833; font-weight: 600; }
    .staff-cost-summary {
        margin: 0 0 12px; padding: 9px 12px; font-size: 12.5px; color: #6b675e;
        background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
    }
    .staff-cost-summary b { color: #1c1b19; font-weight: 600; font-variant-numeric: tabular-nums; }
    .element-row.new-row > .element-row-total { display: block !important; flex: 0 0 auto; margin-left: 0; }
    .element-row.new-row > .element-row-delete-btn { display: inline-flex !important; align-items: center; justify-content: center; }
    /* Кнопка сохранения заказа: компактная, иконка + текст в одну строку */
    /* Кнопка сохранения заказа: отдельная строка над футером, акцентная, крупный тап-таргет */
    .deal-save-area { margin: 2px 0 12px; }
    .deal-save-area button {
        width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
        white-space: nowrap; margin: 0;
        background: var(--accent) !important; color: #fff !important;
        padding: 11px 18px !important; border: none !important; border-radius: var(--r-md) !important;
        font-size: 15px !important; font-weight: 700 !important; cursor: pointer;
        box-shadow: 0 4px 14px rgba(36,89,184,0.26);
    }
    .deal-save-area button:hover { background: var(--accent-strong) !important; }
    .deal-save-area button .icn { width: 1.15em; height: 1.15em; }
    .deal-element-delete-banner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 10px;
        padding: 10px 12px;
        border-radius: 8px;
        background: #fff4e5;
        border: 1px solid #f0c987;
        color: #7a4b00;
        font-size: 13px;
    }
    .deal-element-delete-banner[hidden] { display: none !important; }
    .deal-element-delete-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
    .deal-element-delete-cancel,
    .deal-element-delete-confirm {
        margin: 0;
        width: auto;
        height: auto;
        min-width: 0;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 12px;
        cursor: pointer;
    }
    .deal-element-delete-cancel { background: #fff; color: #6b675e; border: 1px solid #eae8e2; }
    .deal-element-delete-confirm { background: #ff4d4d; color: #fff; border: 1px solid #ff4d4d; }
    .deal-element-delete-confirm:disabled { opacity: 0.6; cursor: wait; }
    .deal-extra-panel {
        margin-top: 14px;
        padding-top: 14px;
        border-top: 1px solid #f1efe9;
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .deal-extra-section { display: flex; flex-direction: column; gap: 6px; }
    .deal-extra-label { font-size: 12px; font-weight: 600; color: #6b675e; text-transform: none; letter-spacing: 0; }
    .deal-extra-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    /* Контакт для уведомлений о готовности */
    .deal-notify-section {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        border: 1px solid #dedbd2;
        border-radius: 8px;
        background: #f7faff;
        transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
    }
    .deal-notify-section.is-unset {
        border-color: #e7b3b3;
        background: #fdf4f4;
        box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.06);
    }
    .deal-notify-section.is-saving { opacity: 0.6; pointer-events: none; }
    .deal-notify-alert {
        font-size: 12px;
        font-weight: 600;
        color: #b03434;
        background: #fbe3e3;
        border: 1px solid #f0c2c2;
        border-radius: 6px;
        padding: 7px 10px;
        line-height: 1.35;
    }
    .deal-notify-row { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
    /* Кастомный дропдаун выбора контакта (с кнопкой удаления внутри списка) */
    .deal-notify-dd { position: relative; flex: 1 1 auto; min-width: 0; }
    .deal-notify-dd-toggle {
        display: flex; align-items: center; gap: 6px;
        width: 100%; height: 34px; margin: 0; padding: 6px 10px;
        border: 1px solid #dedbd2; border-radius: 8px; background: #fff;
        font-size: 13px; cursor: pointer; box-sizing: border-box; text-align: left;
    }
    .deal-notify-dd-toggle:hover, .deal-notify-dd-toggle:focus { background: #fff; }
    .deal-notify-dd.is-open .deal-notify-dd-toggle { background: #fff; border-color: var(--accent); }
    .deal-notify-dd-toggle.is-unset { border-color: #e7b3b3; }
    .deal-notify-dd-current { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1c1b19; }
    .deal-notify-dd-caret { flex: 0 0 auto; color: #9a988f; font-size: 11px; transition: transform .15s ease; }
    .deal-notify-dd.is-open .deal-notify-dd-caret { transform: rotate(180deg); }
    .deal-notify-dd-menu {
        position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0;
        max-height: 280px; overflow-y: auto;
        background: #fff; border: 1px solid #dedbd2; border-radius: 8px;
        box-shadow: 0 8px 24px rgba(28, 27, 25,0.16); padding: 4px;
    }
    .deal-notify-dd-menu[hidden] { display: none; }
    .deal-notify-dd.is-up .deal-notify-dd-menu { top: auto; bottom: calc(100% + 4px); }
    .deal-notify-dd-opt-row { display: flex; align-items: center; gap: 2px; }
    .deal-notify-dd-opt {
        flex: 1 1 auto; min-width: 0; margin: 0; text-align: left;
        padding: 8px 10px; border: none; border-radius: 6px; background: transparent;
        font-size: 13px; color: #1c1b19; cursor: pointer;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .deal-notify-dd-opt:hover { background: #eef4ff; }
    .deal-notify-dd-opt.is-sel { background: #e8f0fe; font-weight: 600; }
    .deal-notify-dd-del {
        flex: 0 0 auto; width: 30px; height: 30px; margin: 0; padding: 0;
        border: none; border-radius: 6px; background: transparent; color: #b03434;
        font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    }
    .deal-notify-dd-del:hover { background: #fbe3e3; }
    .deal-notify-dd-edit {
        flex: 0 0 auto; width: 30px; height: 30px; margin: 0; padding: 0;
        border: none; border-radius: 6px; background: transparent; color: var(--accent);
        font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    }
    .deal-notify-dd-edit:hover { background: var(--accent-tint); }
    /* Подвал дропдауна: «Добавить» / «Добавить в CRM» в одну строку + ТГ-ссылка ниже */
    .deal-notify-dd-foot {
        display: flex; align-items: center; justify-content: space-between; gap: 8px;
        margin-top: 4px; padding: 6px 6px 2px; border-top: 1px solid var(--border);
    }
    .deal-notify-dd-add {
        margin: 0; width: auto; padding: 6px 10px; border-radius: var(--r-sm);
        border: 1px dashed #b8c4d4; background: #fff; color: var(--accent);
        font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
    }
    .deal-notify-dd-add:hover { background: var(--accent-tint); }
    .deal-notify-dd-crm { font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
    .deal-notify-dd-crm:hover { text-decoration: underline; }
    .deal-notify-dd-tg {
        margin: 2px 0 0; width: 100%; display: inline-flex; align-items: center; gap: 6px;
        padding: 7px 10px; border: none; border-radius: var(--r-sm); background: var(--accent-tint);
        color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; text-align: left;
    }
    .deal-notify-dd-tg:hover { background: #e3ecfb; }
    .deal-notify-add-btn {
        margin: 0; width: auto; flex: 0 0 auto;
        padding: 7px 10px; border-radius: 8px;
        border: 1px dashed #c7c0b2; background: #fff; color: var(--accent);
        font-size: 12px; cursor: pointer; white-space: nowrap;
    }
    .deal-notify-add-btn:hover { background: #eef4ff; }
    .deal-notify-crm-link { flex: 0 0 auto; font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
    .deal-notify-crm-link:hover { text-decoration: underline; }
    /* Модалка добавления контакта — поверх списка */
    .deal-notify-modal {
        position: fixed; inset: 0; z-index: 1000;
        display: flex; align-items: center; justify-content: center;
        background: rgba(28, 27, 25,0.45); padding: 16px;
    }
    .deal-notify-modal[hidden] { display: none; }
    .deal-notify-modal-card {
        width: 100%; max-width: 380px;
        display: flex; flex-direction: column; gap: 8px;
        background: #fff; border-radius: 12px; padding: 16px;
        box-shadow: 0 16px 48px rgba(28, 27, 25,0.3);
    }
    .deal-notify-modal-title { font-size: 15px; font-weight: 700; color: #1c1b19; }
    .deal-notify-input {
        height: 34px; margin: 0; box-sizing: border-box;
        border: 1px solid #dedbd2; border-radius: 8px;
        padding: 6px 10px; font-size: 13px;
    }
    .deal-notify-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,125,246,0.12); }
    .deal-notify-form-actions { display: flex; gap: 8px; justify-content: flex-end; }
    .deal-notify-form-cancel, .deal-notify-form-save {
        margin: 0; width: auto; padding: 7px 14px; border-radius: 8px;
        font-size: 13px; font-weight: 600; cursor: pointer; border: none;
    }
    .deal-notify-form-cancel { background: #e8eef6; color: var(--accent); }
    .deal-notify-form-cancel:hover { background: #dce4f0; }
    .deal-notify-form-save { background: var(--accent); color: #fff; }
    .deal-notify-form-save:hover { background: var(--accent-strong); }
    .deal-notify-loading, .deal-notify-empty, .deal-notify-error { font-size: 12px; color: #9a988f; font-style: italic; }
    .deal-notify-error { color: #c0392b; }
    .deal-notify-channels {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: nowrap;
        font-size: 11.5px;
        white-space: nowrap;
    }
    .deal-notify-channels-label { color: #6b675e; font-weight: 600; white-space: nowrap; }
    .deal-notify-ch-label {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        cursor: pointer;
        color: #1c1b19;
        user-select: none;
        text-transform: none;
        white-space: nowrap;
        letter-spacing: 0;
    }
    .deal-notify-ch-label input { margin: 0; width: auto; cursor: pointer; }
    .deal-notify-ch-label.is-disabled { color: #b3ada0; cursor: not-allowed; }
    .deal-notify-ch-label.is-disabled input { cursor: not-allowed; }
    .deal-notify-send-btn {
        margin: 2px 0 0; width: auto; align-self: flex-start;
        padding: 8px 14px; border-radius: 8px; border: none;
        background: #27ae60; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
        transition: background .15s ease;
    }
    .deal-notify-send-btn:hover { background: #219150; }
    .deal-notify-send-btn:disabled { background: #9fd3b4; cursor: default; }
    .deal-notify-sublink {
        margin: 4px 0 0; width: auto; align-self: flex-start;
        display: inline-flex; align-items: center; gap: 6px;
        padding: 6px 10px; border-radius: var(--r-sm);
        background: var(--accent-tint); color: var(--accent); border: 1px solid #cfe0fb;
        font-size: 12px; font-weight: 600; cursor: pointer;
    }
    .deal-notify-sublink:hover { background: #e3ecfb; }
    .deal-notify-sent {
        font-size: 12px;
        color: #1f7a44;
        background: #e9f7ef;
        border: 1px solid #bfe6ce;
        border-radius: 6px;
        padding: 6px 10px;
        line-height: 1.35;
    }
    .deal-notify-sent b { font-weight: 700; }
    .readiness-toast {
        position: fixed;
        left: 50%;
        bottom: 24px;
        transform: translate(-50%, 16px);
        max-width: 92vw;
        padding: 12px 18px;
        background: #1f9d55;
        color: #fff;
        font-size: 14px;
        font-weight: 600;
        border-radius: 10px;
        box-shadow: 0 8px 24px rgba(28, 27, 25, 0.22);
        opacity: 0;
        pointer-events: none;
        z-index: 4000;
        transition: opacity .2s ease, transform .2s ease;
    }
    .readiness-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
    .deal-cost-info-input {
        width: 100%;
        box-sizing: border-box;
        border: 1px solid #dedbd2;
        border-radius: 8px;
        padding: 8px 10px;
        font-size: 13px;
        line-height: 1.4;
        font-family: inherit;
        resize: vertical;
        min-height: 72px;
    }
    .deal-cost-info-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 125, 246, 0.12); }
    .deal-extra-actions-row { align-items: flex-start; }
    .deal-create-invoice-btn {
        margin: 0;
        width: auto;
        height: auto;
        min-width: 0;
        padding: 8px 14px;
        border-radius: 8px;
        border: 1px solid var(--accent);
        background: var(--accent);
        color: #fff;
        font-size: 13px;
        cursor: pointer;
    }
    .deal-create-invoice-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
    .deal-requisites-add-btn {
        margin: 0;
        width: auto;
        height: auto;
        min-width: 0;
        padding: 4px 8px;
        border-radius: 6px;
        border: 1px dashed #c7c0b2;
        background: #fff;
        color: var(--accent);
        font-size: 12px;
        cursor: pointer;
        white-space: nowrap;
    }
    .deal-requisites-add-btn:hover { background: #eef4ff; }
    /* Реквизиты клиента: поиск + выбираемый список */
    .deal-req-search { margin-bottom: 8px; }
    .deal-req-search-input {
        width: 100%;
        box-sizing: border-box;
        border: 1px solid #dedbd2;
        border-radius: 8px;
        padding: 7px 10px;
        font-size: 13px;
        font-family: inherit;
    }
    .deal-req-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 125, 246, 0.12); }
    .deal-req-list {
        display: flex;
        flex-direction: column;
        gap: 4px;
        max-height: 260px;
        overflow-y: auto;
        border: 1px solid #f1efe9;
        border-radius: 10px;
        padding: 4px;
        background: #fff;
    }
    .deal-req-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        margin: 0;
        text-align: left;
        padding: 8px 10px;
        border: 1px solid transparent;
        border-radius: 8px;
        background: transparent;
        cursor: pointer;
        transition: background .12s ease, border-color .12s ease;
    }
    .deal-req-item:hover { background: #f4f8ff; }
    .deal-req-item.is-selected { background: #eef4ff; border-color: var(--accent); }
    .deal-req-radio {
        flex: 0 0 auto;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        border: 2px solid #ccc5b6;
        position: relative;
        box-sizing: border-box;
    }
    .deal-req-item.is-selected .deal-req-radio { border-color: var(--accent); }
    .deal-req-item.is-selected .deal-req-radio::after {
        content: "";
        position: absolute;
        top: 50%; left: 50%;
        width: 8px; height: 8px;
        border-radius: 50%;
        background: var(--accent);
        transform: translate(-50%, -50%);
    }
    .deal-req-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
    .deal-req-name {
        font-size: 13px;
        font-weight: 600;
        color: #1c1b19;
        line-height: 1.3;
        word-break: break-word;
    }
    .deal-req-inn {
        font-size: 11px;
        color: #9a988f;
        font-variant-numeric: tabular-nums;
        letter-spacing: .2px;
    }
    .deal-req-empty {
        padding: 14px 10px;
        text-align: center;
        font-size: 12px;
        color: #9a988f;
    }
    .deal-req-loading { font-style: italic; }
    .deal-req-error { color: #c0392b; }
    .deal-invoice-info-body { font-size: 13px; }
    .deal-invoice-empty { color: #9a988f; font-style: italic; }
    .deal-invoice-card {
        display: flex;
        flex-direction: column;
        gap: 6px;
        /* Контейнером выступает .deal-invoice-row — своя рамка карточке не нужна */
    }
    .deal-invoice-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
    .deal-invoice-title { font-weight: 600; color: #1c1b19; }
    .deal-invoice-date { color: #6b675e; font-size: 12px; }
    .deal-invoice-link { color: var(--accent); font-size: 13px; text-decoration: none; background: transparent; border: none; padding: 0; margin: 0; width: auto; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
    .deal-invoice-link:hover { text-decoration: underline; }
    .deal-invoice-unlink { color: var(--danger); }
    .deal-invoice-unlink:hover { color: #9b2c2c; }
    /* Старый счёт без встроенного превью */
    .deal-invoice-nopreview {
        font-size: 11px;
        color: #b06a1f;
        background: #fdf3e6;
        border: 1px solid #f3dcbd;
        border-radius: 6px;
        padding: 1px 7px;
        font-style: italic;
    }
    /* Появление готовой карточки счёта */
    .deal-invoice-card.is-fresh { animation: dealInvoiceIn .28s ease-out; }
    @keyframes dealInvoiceIn {
        from { opacity: 0; transform: translateY(-4px); }
        to { opacity: 1; transform: translateY(0); }
    }
    /* Анимация «счёт выставляется» */
    .deal-invoice-loading {
        display: flex;
        align-items: center;
        gap: 9px;
        font-size: 13px;
        color: var(--accent);
        font-weight: 600;
    }
    .deal-invoice-spinner {
        width: 16px;
        height: 16px;
        flex: 0 0 auto;
        border: 2px solid #cfe0fb;
        border-top-color: var(--accent);
        border-radius: 50%;
        animation: dealInvoiceSpin .7s linear infinite;
    }
    .deal-invoice-loading-text { animation: dealInvoicePulse 1.1s ease-in-out infinite; }
    @keyframes dealInvoiceSpin { to { transform: rotate(360deg); } }
    @keyframes dealInvoicePulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
    /* Раскрывающееся inline-превью счёта */
    .deal-invoice-card.is-expandable > .deal-invoice-head { cursor: pointer; user-select: none; }
    .deal-invoice-card.is-expandable > .deal-invoice-head:hover .deal-invoice-title { color: var(--accent); }
    .deal-invoice-caret {
        display: inline-block;
        align-self: center;
        color: var(--accent);
        font-size: 11px;
        transition: transform .15s ease;
    }
    .deal-invoice-card.is-expanded > .deal-invoice-head .deal-invoice-caret { transform: rotate(90deg); }
    .deal-invoice-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
    /* Кнопка «Скопировать ссылку» — выглядит как ссылка (сброс стилей button) */
    .deal-invoice-copy {
        margin: 0;
        padding: 0;
        width: auto;
        background: none;
        border: none;
        border-radius: 0;
        font: inherit;
        font-size: 13px;
        color: var(--accent);
        cursor: pointer;
        transition: color .15s ease;
    }
    .deal-invoice-copy:hover { background: none; text-decoration: underline; }
    .deal-invoice-copy.is-copied { color: #1f9d55; text-decoration: none; cursor: default; }
    .deal-invoice-preview { margin-top: 8px; }
    .deal-invoice-preview[hidden] { display: none; }
    /* Сцена масштабирования: клипует iframe до вписанного по ширине размера */
    .deal-invoice-stage {
        position: relative;
        width: 100%;
        overflow: hidden;
        border: 1px solid #dedbd2;
        border-radius: 8px;
        background: #fff;
    }
    .deal-invoice-iframe {
        display: block;
        border: none;
        background: #fff;
        /* width/height/transform задаются из JS (fitInvoicePreview) */
    }
    .deal-invoice-preview-hint { margin-top: 6px; font-size: 11px; color: #9a988f; }
    .deal-invoice-preview-hint a { color: var(--accent); }
    .deal-invoice-row {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        background: #f7faff;
        border: 1px solid #dedbd2;
        border-radius: 8px;
    }
    .deal-invoice-row-main {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .deal-invoice-row .deal-create-invoice-btn {
        margin: 0;
        flex: 0 0 auto;
    }
    .deal-invoice-display {
        flex: 1;
        min-width: 0;
    }
    .deal-invoice-preview-slot:empty { display: none; }
    /* Модальное окно для выбора реквизитов */
    .invoice-modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(28, 27, 25, 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 2000;
    }
    .invoice-modal {
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 10px 40px rgba(28, 27, 25, 0.2);
        width: 90%;
        max-width: 450px;
        max-height: 80vh;
        display: flex;
        flex-direction: column;
    }
    .invoice-modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        border-bottom: 1px solid #f1efe9;
    }
    .invoice-modal-header h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: #1c1b19;
    }
    .invoice-modal-header-actions { display: flex; align-items: center; gap: 8px; }
    .invoice-req-add-btn {
        margin: 0;
        width: auto;
        height: auto;
        min-width: 0;
        padding: 5px 9px;
        border-radius: 6px;
        border: 1px dashed #c7c0b2;
        background: #fff;
        color: var(--accent);
        font-size: 12px;
        cursor: pointer;
        white-space: nowrap;
    }
    .invoice-req-add-btn:hover { background: #eef4ff; }
    .invoice-modal-close {
        margin: 0;
        width: 28px;
        height: 28px;
        min-width: 28px;
        padding: 0;
        border: none;
        border-radius: 6px;
        background: transparent;
        color: #9a988f;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .invoice-modal-close:hover { background: #faf9f6; color: #1c1b19; }
    .invoice-modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 12px;
    }
    .invoice-req-empty {
        padding: 24px 12px;
        text-align: center;
        font-size: 13px;
        color: #9a988f;
        line-height: 1.5;
    }
    .invoice-req-list {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .invoice-req-option {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px;
        border-radius: 8px;
        border: 1px solid transparent;
        background: transparent;
        cursor: pointer;
        transition: background .12s ease, border-color .12s ease;
    }
    .invoice-req-option:hover { background: #f4f8ff; }
    .invoice-req-option input[type="radio"] {
        flex: 0 0 auto;
        width: 18px;
        height: 18px;
        cursor: pointer;
        margin: 0;
        padding: 0;
        border: none;
        background: none;
    }
    .invoice-req-option-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }
    .invoice-req-name {
        font-size: 13px;
        font-weight: 600;
        color: #1c1b19;
        line-height: 1.3;
        word-break: break-word;
    }
    .invoice-req-inn {
        font-size: 11px;
        color: #9a988f;
        font-variant-numeric: tabular-nums;
        letter-spacing: .2px;
    }
    .invoice-modal-footer {
        display: flex;
        gap: 10px;
        justify-content: flex-end;
        padding: 12px 16px;
        border-top: 1px solid #f1efe9;
        background: #faf9f6;
    }
    .btn-primary, .btn-secondary {
        margin: 0;
        padding: 9px 16px;
        font-size: 13px;
        font-weight: 600;
        border-radius: 8px;
        border: none;
        cursor: pointer;
        transition: background .12s ease, color .12s ease;
    }
    .btn-primary {
        background: var(--accent);
        color: #fff;
    }
    .btn-primary:hover { background: var(--accent-strong); }
    .btn-primary:disabled { background: #d3cdc0; cursor: not-allowed; }
    .btn-secondary {
        background: #e8eef6;
        color: var(--accent);
    }
    .btn-secondary:hover { background: #dce4f0; }
    .deal-total-only { font-weight: bold; font-size: 12px; line-height: 1.2; }
    .loader { text-align: center; display: none; margin: 20px 0; font-style: italic; color: #7a766c; }
    .add-btn { margin:0; padding: 4px 10px; font-size: 12px; font-weight:600; background: var(--accent-tint); color: var(--accent); border:1px solid #cfe0fb; width: auto; height: auto; }
    .add-btn:hover { background:#e3ecfb; color:var(--accent-strong); }
    .readonly-mode .add-btn, .readonly-mode .deal-save-area { display: none !important; }
    .deal-num-btn { margin:0; padding:0; width:auto; background:transparent; color:var(--accent); border:none; font-size:16px; line-height:1.2; }
    .deal-num-btn:hover { background:transparent; color:var(--accent-strong); text-decoration: underline; }
    .deal-action-btn { margin:0 0 0 6px; width:24px; height:24px; min-width:24px; padding:0; border-radius:6px; background:#faf9f6; color:#6b675e; border:1px solid #eae8e2; font-size:13px; line-height:22px; display:inline-flex; align-items:center; justify-content:center; vertical-align:middle; }
    .deal-action-btn:hover { background:#e8eef6; color:var(--accent); }
    .deal-action-group { display:inline-flex; align-items:center; gap:2px; margin-left:6px; vertical-align:middle; }
    .deal-action-group .deal-action-btn { margin:0; width:17px; height:17px; min-width:17px; font-size:10px; line-height:15px; border-radius:4px; }
    .deal-action-group .deal-crm-btn { margin-left:5px; }
    /* Свёртка кнопок действий сделки в «⋯» на узких экранах */
    .deal-actions { display: inline-flex; align-items: center; }
    .deal-actions-more { display: none; }
    .deal-actions-menu {
        position: fixed;
        z-index: 2000;
        display: flex;
        gap: 6px;
        padding: 7px;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    }
    .deal-actions-menu .deal-action-btn {
        width: 32px !important; height: 32px; min-width: 32px !important;
        font-size: 15px; line-height: 30px; border-radius: 8px;
    }
    /* Когда таблица сжата (планшет/узкое окно) — три кнопки прячем, показываем «⋯». */
    @media (min-width: 601px) and (max-width: 1100px) {
        .crm-item--list .deal-actions .deal-crm-btn,
        .crm-item--list .deal-actions .deal-create-btn,
        .crm-item--list .deal-actions .deal-copy-btn { display: none !important; }
        .crm-item--list .deal-actions .deal-actions-more { display: inline-flex; }
    }
    .deal-add-buttons { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
    .add-btn-secondary { background:#f1efe9; color:#3a3833; border:1px solid #eae8e2; }
    .add-btn-secondary:hover { background:#eae8e2; }
    .deal-category-select-wrap { display:flex; align-items:center; gap:8px; margin-top:2px; }
    .deal-category-select-label { font-size:12px; color:#7a766c; }
    .deal-category-select { height:28px; border:1px solid #dedbd2; border-radius:7px; padding:0 10px; background:#fff; font-size:12px; color:#3a3833; max-width: 360px; }
    .deal-header-detail { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom:8px; }
    .deal-num-line { display:flex; align-items:center; flex-wrap:wrap; gap:4px; min-width:0; }
    .deal-header-side { display:flex; align-items:flex-start; gap:8px; flex-shrink:0; }
    .deal-footer-left { display:flex; flex-direction:column; align-items:flex-start; gap:6px; min-width:0; }
    .deal-footer-meta { font-size:12px; color:#8c887e; line-height:1.45; }
    .deal-footer-meta b { color:#46443f; font-weight:bold; }
    .deal-confirm-popover, .deal-contact-popover { position: fixed; z-index: 2000; width: 260px; padding: 12px; background: white; border: 1px solid #eae8e2; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); font-size: 13px; color: #3a3833; }
    .deal-contact-popover a { color:var(--accent); text-decoration:none; }
    .deal-contact-popover a:hover { text-decoration:underline; }
    .deal-confirm-popover button { margin:0; width:auto; padding:6px 12px; font-size:12px; border-radius:6px; }
    .crm-footer { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-top:12px; padding-top:10px; border-top:1px solid #f1efe9; }
    /* Прибыль по сделке — прижата к блоку суммы справа */
    .deal-profit-block { margin-left:auto; flex:0 0 auto; }
    .crm-footer:has(.deal-profit-block) .deal-payment-block { margin-left:0; }
    .deal-profit-btn { margin:0; width:auto; padding:7px 14px; font-size:12px; font-weight:600; background:var(--surface-3); color:var(--text-2); border-radius:var(--r-sm); box-shadow:none; }
    .deal-profit-btn:hover { background:var(--accent-tint); color:var(--accent-strong); }
    .deal-profit-data { cursor:pointer; display:flex; flex-direction:column; gap:2px; padding:6px 10px; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r-sm); }
    .deal-profit-row { display:flex; align-items:baseline; justify-content:space-between; gap:14px; font-size:11px; color:var(--text-muted); white-space:nowrap; }
    .deal-profit-row b { font-size:12px; font-weight:700; font-variant-numeric:tabular-nums; }
    .deal-profit-row b.is-plus { color:var(--success); }
    .deal-profit-row b.is-minus { color:var(--danger); }
    .deal-profit-empty, .deal-profit-note { font-size:10px; color:var(--text-muted); white-space:nowrap; }
    .add-btn-container { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #d3cdc0; text-align: left; }
    .crm-list-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
    .crm-list-header-main { flex: 1 1 auto; min-width: 0; }
    .crm-list-header-meta { display: none; }
    .crm-list-header-status { flex: 0 0 auto; }
    .client-name--mobile { display: block; }
    .deal-footer-meta--mobile { display: block; }

    /* Мобильный список сделок: те же ячейки, но в виде карточки (шапка колонок скрыта). */
    @media (max-width: 600px) {
        .crm-list-thead { display: none; }
        .crm-item--list {
            display: grid;
            grid-template-columns: 1fr auto;
            grid-template-areas:
                "num status"
                "client client"
                "content content"
                "resp date"
                "sum sum";
            gap: 4px 10px;
            align-items: center;
        }
        .crm-item--list .dl-num { grid-area: num; display: flex; align-items: center; gap: 2px; }
        .crm-item--list .dl-num .deal-num-btn { font-size: 16px; font-weight: bold; }
        .crm-item--list .dl-status { grid-area: status; justify-self: end; }
        .crm-item--list .dl-client { grid-area: client; }
        .crm-item--list .dl-client-name { font-weight: 600; }
        .crm-item--list .dl-content { grid-area: content; }
        .crm-item--list .dl-resp { grid-area: resp; font-size: 12px; color: var(--text-muted); }
        .crm-item--list .dl-date { grid-area: date; justify-self: end; font-size: 12px; color: var(--text-muted); }
        .crm-item--list .dl-sum { grid-area: sum; justify-self: end; text-align: right; }
        .crm-item--list .dl-sum-total { font-weight: 700; }
        .crm-item--list .dl-sum-total.is-ok { color: var(--success); }
        .crm-item--list .dl-sum-total.is-unpaid { color: var(--danger); }
        .crm-item--list .dl-sum-total.is-partial { color: var(--pay-partial); }
        .crm-item--list .dl-sum-note { font-size: 12px; font-weight: 600; color: var(--text-muted); }
        .crm-item--list .dl-add-calc {
            display: inline-block;
            margin: 6px 0 0; padding: 4px 10px; width: auto;
            font-size: 12px; font-weight: 600; line-height: 1.3;
            color: var(--accent); background: var(--accent-tint);
            border: 1px solid #cfe0fb; border-radius: 6px; box-shadow: none; cursor: pointer;
        }
    }

    @media (min-width: 601px) {
        /* ===== Плотный табличный список сделок (десктоп) =====
           № · Клиент · Содержимое · Сумма/Долг · Статус · Ответственный · Создано.
           Колонки выровнены между строками через CSS subgrid. */
        .crm-list-table {
            display: grid;
            grid-template-columns:
                minmax(112px, auto)    /* № */
                minmax(120px, 1.1fr)   /* клиент */
                minmax(240px, 2.8fr)   /* содержимое */
                minmax(108px, auto)    /* сумма/долг */
                144px                  /* статус (фикс. ширина = одинаковые пилюли) */
                minmax(100px, auto)    /* ответственный */
                minmax(84px, auto);    /* создано */
            align-items: stretch;
            border: 1px solid var(--border);
            border-radius: var(--r-md);
            overflow: hidden;
            background: var(--surface);
        }
        .crm-list-thead,
        .crm-item--list {
            grid-column: 1 / -1;
            display: grid;
            grid-template-columns: subgrid;
            /* stretch → ячейки на всю высоту строки: контент прижат кверху,
               а вертикальные разделители тянутся во всю высоту. */
            align-items: stretch;
        }
        /* Тонкие вертикальные разделители между колонками. */
        .crm-list-thead .dl-cell,
        .crm-item--list .dl-cell { border-right: 1px solid var(--border); }
        .crm-list-thead .dl-date,
        .crm-item--list .dl-date { border-right: none; }
        .crm-list-thead {
            background: var(--surface-2);
            border-bottom: 1px solid var(--border);
            font-size: 9.5px;
            font-weight: 700;
            letter-spacing: 0.03em;
            text-transform: uppercase;
            color: var(--text-muted);
        }
        .crm-list-thead .dl-cell { padding: 6px 9px; }
        .crm-item--list {
            margin: 0;
            padding: 0;
            border: none;
            border-top: 1px solid var(--border);
            border-radius: 0;
            box-shadow: none;
            background: var(--surface);
        }
        .crm-list-thead + .crm-item--list { border-top: none; }
        .crm-item--list:hover { background: var(--surface-2); }
        .crm-item--list .dl-cell { padding: 3px 9px; min-width: 0; }

        .crm-item--list .dl-num { display: flex; align-items: flex-start; gap: 3px; white-space: nowrap; }
        .crm-item--list .dl-num .deal-num-btn { font-size: 12.5px; font-weight: bold; }
        /* Компактные кнопки действий в списке (крупные 24px слишком выделяются). */
        .crm-item--list .dl-num .deal-action-btn {
            width: 18px !important; height: 18px; min-width: 18px !important;
            margin: 0 0 0 3px;
            font-size: 10px; line-height: 16px;
            border-radius: 5px;
        }
        .crm-item--list .dl-client-name {
            display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
            color: var(--text); font-size: 11.5px;
        }
        .crm-item--list .dl-content .deal-elements-list { display: flex; flex-direction: column; gap: 1px; }
        /* Обычные строки-позиции: только наименование (без иконки статуса, суммы, меты).
           Строку добавленного просчёта (.new-row) не трогаем — у неё своя раскладка. */
        .crm-item--list .dl-content .element-row:not(.new-row) {
            border: none !important; padding: 0; gap: 6px; align-items: center; flex-wrap: nowrap;
        }
        .crm-item--list .dl-content .element-row:not(.new-row) > .item-status-control,
        .crm-item--list .dl-content .element-row:not(.new-row) > span:first-child,
        .crm-item--list .dl-content .element-row:not(.new-row) .element-row-total,
        .crm-item--list .dl-content .element-row:not(.new-row) .element-row-meta { display: none !important; }
        .crm-item--list .dl-content .element-row:not(.new-row) .element-row-text {
            font-size: 11px !important; line-height: 1.3; padding: 0;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
        }
        /* Инлайн-сохранение и добавленная позиция под калькулятором. */
        .crm-item--list .dl-content .deal-save-area { margin-top: 6px; }
        .crm-item--list .dl-content .deal-save-area button {
            width: auto; margin: 0; padding: 6px 14px; font-size: 12px; font-weight: 600;
            background: var(--accent-container); color: #fff; border-radius: var(--r-sm); box-shadow: none;
            display: inline-flex; align-items: center; gap: 6px;
        }
        /* Компактная кнопка «добавить просчёт из калькулятора» под позициями. */
        .crm-item--list .dl-add-calc {
            display: inline-block;
            margin: 4px 0 0;
            padding: 2px 8px;
            width: auto;
            font-size: 10px;
            font-weight: 600;
            line-height: 1.35;
            color: var(--accent);
            background: var(--accent-tint);
            border: 1px solid #cfe0fb;
            border-radius: 5px;
            cursor: pointer;
            white-space: nowrap;
            box-shadow: none;
        }
        .crm-item--list .dl-add-calc:hover { background: #e3ecfb; color: var(--accent-strong); }
        .crm-item--list .dl-sum { text-align: right; white-space: nowrap; }
        .crm-item--list .dl-sum-total { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
        .crm-item--list .dl-sum-total.is-ok { color: var(--success); }
        .crm-item--list .dl-sum-total.is-unpaid { color: var(--danger); }
        .crm-item--list .dl-sum-total.is-partial { color: var(--pay-partial); }
        /* Подпись под суммой — всегда серая (цветом выделяется сама сумма). */
        .crm-item--list .dl-sum-note { font-size: 10px; font-weight: 600; color: var(--text-muted); }
        /* Статусы одной ширины и одинакового скругления: пилюля заполняет
           фиксированную колонку. width !important перебивает #adv-search-container button{width:auto}. */
        .crm-item--list .dl-status .status-badge,
        .crm-item--list .dl-status .editable-status {
            display: block;
            width: 100% !important;
            box-sizing: border-box;
            margin: 0;
            text-align: center;
            font-size: 10.5px;
            line-height: 1.2;
            padding: 4px 6px;
            border-radius: 6px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .crm-item--list .dl-resp { font-size: 11px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .crm-item--list .dl-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
        /* Детальная карточка заказа на десктопе: позиция отображается столбцами
           статус | превью | название | количество | себестоимость | сумма.
           Ширины колонок одинаковы у шапки (.ecol-*) и у строк — выравнивание гарантировано. */
        .crm-item:not(.crm-item--list) .element-row { align-items: center; }
        .crm-item:not(.crm-item--list) .element-row > .element-row-text { display: none; }
        .crm-item:not(.crm-item--list) .element-row-col { display: block; }

        .crm-item:not(.crm-item--list) .element-cols-head {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 2px 0 5px;
            margin: 0 0 2px;
            border-bottom: 1px solid #eae8e2;
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .3px;
            color: #a6a294;
        }
        .crm-item:not(.crm-item--list) .ecol { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        /* фиксированные ширины должны включать padding/border, иначе кнопка статуса «разъедет» */
        .crm-item:not(.crm-item--list) .element-cols-head .ecol,
        .crm-item:not(.crm-item--list) .element-row > .element-status-cell,
        .crm-item:not(.crm-item--list) .element-row > .element-preview-thumb,
        .crm-item:not(.crm-item--list) .element-row-qty,
        .crm-item:not(.crm-item--list) .element-row-cost,
        .crm-item:not(.crm-item--list) .element-row > .element-row-total { box-sizing: border-box; }

        /* колонка СТАТУС (узкая) */
        .crm-item:not(.crm-item--list) .ecol-status,
        .crm-item:not(.crm-item--list) .element-row > .element-status-cell {
            flex: 0 0 40px;
            width: 40px;
            max-width: 40px;
            min-width: 40px;
            margin: 0 !important;
            text-align: center;
        }
        /* колонка ПРЕВЬЮ (узкая) */
        .crm-item:not(.crm-item--list) .ecol-thumb,
        .crm-item:not(.crm-item--list) .element-row > .element-preview-thumb {
            flex: 0 0 22px;
            width: 22px;
            min-width: 22px;
            text-align: center;
        }
        /* колонка НАЗВАНИЕ (растягивается) */
        .crm-item:not(.crm-item--list) .ecol-name,
        .crm-item:not(.crm-item--list) .element-row-name {
            flex: 1 1 auto;
            min-width: 0;
            text-align: left;
            font-size: 12px;
            line-height: 1.2;
            padding-right: 6px;
            overflow-wrap: anywhere;
            word-break: break-word;
        }
        .crm-item:not(.crm-item--list) .ecol-name { white-space: nowrap; }
        /* колонка КОЛИЧЕСТВО (узкая — данных мало, отдаём место названию) */
        .crm-item:not(.crm-item--list) .ecol-qty,
        .crm-item:not(.crm-item--list) .element-row-qty {
            flex: 0 0 56px;
            width: 56px;
            text-align: right;
            white-space: nowrap;
            color: #6b675e;
            font-size: 12px;
            line-height: 1.2;
        }
        /* колонка СЕБЕСТОИМОСТЬ (узкая) */
        .crm-item:not(.crm-item--list) .ecol-cost,
        .crm-item:not(.crm-item--list) .element-row-cost {
            flex: 0 0 74px;
            width: 74px;
            text-align: right;
            white-space: nowrap;
            color: #807c72;
            font-size: 12px;
            line-height: 1.2;
        }
        /* себестоимость под маской: скрыта по умолчанию, раскрывается глазиком */
        .crm-item:not(.crm-item--list) .element-row-cost .cost-mask { display: none; color: #b8b2a4; letter-spacing: 1px; }
        .crm-item:not(.crm-item--list) .elements-list.costs-hidden .element-row-cost .cost-val { display: none; }
        .crm-item:not(.crm-item--list) .elements-list.costs-hidden .element-row-cost .cost-mask { display: inline; }
        /* третье состояние: себестоимость не заполнена — заметный индикатор, виден всегда */
        .crm-item:not(.crm-item--list) .element-row-cost.is-empty {
            color: #d98324;
            font-style: italic;
            font-size: 11px;
        }
        /* кнопка-глазик у заголовка «Себес.» */
        .cost-eye-btn {
            margin: 0 0 0 5px;
            padding: 0;
            width: 20px;
            height: 18px;
            min-width: 20px;
            border: none;
            background: transparent;
            cursor: pointer;
            font-size: 13px;
            line-height: 1;
            vertical-align: middle;
            color: var(--accent);
            opacity: 1;
        }
        .cost-eye-btn:hover { color: var(--accent-strong); }
        /* колонка СУММА — на десктопе без «руб.» (только цифры) */
        .crm-item:not(.crm-item--list) .ecol-total,
        .crm-item:not(.crm-item--list) .element-row > .element-row-total {
            flex: 0 0 116px;
            width: 116px;
            margin-left: 0;
            text-align: right;
        }
        .crm-item:not(.crm-item--list) .element-row > .element-row-total .rub-suffix { display: none; }
        /* хвостовая ячейка под кнопку удаления */
        .crm-item:not(.crm-item--list) .ecol-actions { flex: 0 0 20px; width: 20px; }
    }
    .payment-actions { display:flex; gap:5px; justify-content:center; }
    .payment-action-btn { margin:0; width:21px; height:21px; min-width:21px; padding:0; border-radius:5px; display:inline-flex; align-items:center; justify-content:center; border:0; box-shadow:0 2px 6px rgba(0,0,0,0.12); }
    .payment-action-icon { width:12px; height:12px; border-radius:3px; display:inline-flex; align-items:center; justify-content:center; font-size:16px; line-height:10px; font-weight:bold; }
    .payment-partial-btn { background:#40bd72; }
    .payment-partial-btn .payment-action-icon { background:white; color:#40bd72; }
    .payment-full-btn { background:white; }
    .payment-full-btn .payment-action-icon { background:#40bd72; color:white; }
    .payment-summary { width:230px; text-align:right; border:1px solid #f1efe9; border-radius:8px; overflow:hidden; font-size:12px; }
    .payment-summary-row { display:grid; grid-template-columns: 70px 82px 62px; align-items:center; gap:4px; padding:3px 7px; background:#fff; border-bottom:1px solid #f1efe9; }
    .payment-summary-row:last-child { border-bottom:none; }
    .payment-summary-row.paid-row { background:#e9f8df; }
    .payment-summary-label { color:#8c887e; font-size:12px; font-weight:bold; }
    .payment-summary-value { color:#3a3833; font-size:12px; font-weight:bold; min-width:0; }
    .payment-ok { color:var(--success); }
    .payment-alert { color:var(--danger); }
    .payment-modal-backdrop { position:fixed; inset:0; z-index:2200; display:flex; align-items:center; justify-content:center; padding:20px; background:rgba(0,0,0,0.35); box-sizing:border-box; }
    .payment-modal { width:100%; max-width:420px; background:white; border-radius:12px; padding:18px; box-shadow:0 14px 36px rgba(0,0,0,0.22); }
    .payment-modal h3 { margin-bottom:12px; }
    .payment-modal-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:14px; }
    .payment-modal-actions button { margin:0; width:auto; padding:9px 14px; font-size:14px; border-radius:7px; }
    .filter-btn { margin-top:0; padding:10px; min-height:39px; font-size:14px; }
    .status-dropdown { position: relative; }
    .status-dropdown-btn {
        position: relative;
        width: 100%;
        margin-top: 5px;
        padding: 10px 28px 10px 10px;
        background: white;
        color: #3a3833;
        border: 1px solid #d3cdc0;
        border-radius: 6px;
        font-size: 14px;
        line-height: 1.15;
        font-weight: normal;
        text-align: left;
        height: 40px;
        min-height: 40px;
        box-sizing: border-box;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .status-dropdown-btn:hover,
    .status-dropdown-btn:focus { background: white; color: #3a3833; }
    .status-dropdown-btn::after,
    .date-range-btn::after {
        content: "⌄";
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        color: #8c887e;
        font-size: 13px;
        pointer-events: none;
    }
    .status-dropdown-list {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        right: 0;
        max-height: 260px;
        overflow-y: auto;
        background: white;
        border: 1px solid #d3cdc0;
        border-radius: 8px;
        box-shadow: 0 8px 20px rgba(0,0,0,0.12);
        z-index: 1000;
        padding: 6px;
    }
    .status-dropdown.open .status-dropdown-list { display: block; }
    .status-option {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 10px;
        border-radius: 6px;
        font-weight: normal;
        margin: 0;
        cursor: pointer;
        color: #3a3833;
        font-size: 16px;
    }
    .status-option:hover { background: #f1efe9; }
    .status-option input { display: none; }
    .status-color-marker {
        width: 15px;
        height: 21px;
        flex: 0 0 15px;
        clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%);
    }
    .status-option-name { flex: 1; min-width: 0; }
    .status-checkmark {
        visibility: hidden;
        color: #3a3833;
        font-size: 22px;
        font-weight: bold;
        line-height: 1;
    }
    .status-option input:checked ~ .status-checkmark { visibility: visible; }
    .status-option-preset .status-option-name { font-weight: 600; }
    .status-filter-divider {
        height: 1px;
        margin: 4px 8px 6px;
        background: #eae8e2;
    }
    .advanced-toolbar {
        display: flex;
        align-items: flex-end;
        gap: 10px;
        margin-bottom: 14px;
        flex-wrap: nowrap;
    }
    .advanced-toolbar .col { flex: 1 1 0; min-width: 0; }
    .advanced-toolbar .clear-filters-btn {
        flex: 0 0 auto;
        margin-left: auto;
        align-self: flex-end;
        width: 44px;
        min-width: 44px;
        height: 40px;
        margin-top: 0;
        padding: 0;
        border-radius: 8px;
        background: var(--accent);
        font-size: 22px;
        line-height: 1;
    }
    .manager-option { padding-left: 10px; }
    .advanced-search-row {
        display: flex;
        align-items: stretch;
        gap: 0;
        margin-top: 10px;
    }
    .advanced-search-row input {
        flex: 1;
        margin-top: 0;
        border-radius: 6px 0 0 6px;
    }
    .advanced-search-row button {
        width: 54px;
        min-width: 54px;
        margin-top: 0;
        padding: 0;
        border-radius: 0;
        font-size: 22px;
        line-height: 1;
    }
    .advanced-search-row button:last-child { border-radius: 0 6px 6px 0; }
    .date-range-dropdown { position: relative; }
    .date-range-btn {
        position: relative;
        width: 100%;
        margin-top: 5px;
        padding: 10px 28px 10px 10px;
        background: white;
        color: #3a3833;
        border: 1px solid #d3cdc0;
        border-radius: 6px;
        font-size: 13px;
        line-height: 1.15;
        font-weight: normal;
        text-align: left;
        height: 40px;
        min-height: 40px;
        box-sizing: border-box;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .date-range-btn:hover,
    .date-range-btn:focus { background: white; color: #3a3833; }
    .date-range-panel {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        right: 0;
        background: white;
        border: 1px solid #d3cdc0;
        border-radius: 8px;
        box-shadow: 0 8px 20px rgba(0,0,0,0.12);
        z-index: 1000;
        padding: 10px;
    }
    .date-range-dropdown.open .date-range-panel { display: block; }
    .calendar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 10px;
    }
    .calendar-title-wrap {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .calendar-month-select {
        width: auto;
        min-height: 32px;
        margin-top: 0;
        padding: 4px 24px 4px 8px;
        font-size: 14px;
        text-transform: capitalize;
    }
    .calendar-year-select {
        width: auto;
        min-height: 32px;
        margin-top: 0;
        padding: 4px 24px 4px 8px;
        font-size: 14px;
    }
    .calendar-nav {
        width: 32px;
        height: 32px;
        margin: 0;
        padding: 0;
        border-radius: 50%;
        font-size: 18px;
        line-height: 1;
        background: #f1efe9;
        color: #3a3833;
    }
    .calendar-weekdays,
    .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }
    .calendar-weekdays span {
        text-align: center;
        font-size: 12px;
        color: #8c887e;
        padding: 4px 0;
    }
    .calendar-day {
        height: 34px;
        border: none;
        border-radius: 8px;
        background: transparent;
        color: #3a3833;
        font-size: 14px;
        font-weight: normal;
        margin: 0;
        padding: 0;
    }
    .calendar-day:hover { background: #eef4ff; }
    .calendar-day.muted { color: #c2bcae; }
    .calendar-day.future { color: #d3cdc0; opacity: 0.55; }
    .calendar-day.in-range { background: #e8f1ff; border-radius: 0; }
    .calendar-day.selected { background: var(--accent); color: white; border-radius: 10px; }
    #auth-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        min-height: 100%;
        background: rgba(0,0,0,0.7);
        z-index: 10000;
        align-items: flex-start;
        justify-content: center;
        box-sizing: border-box;
        padding: 32px 20px 24px;
        overflow-y: auto;
    }
    #auth-modal .auth-box {
        max-width: 350px;
        width: 100%;
        margin: 0;
        padding: 30px;
        border-radius: 15px;
        position: relative;
    }
    .auth-modal-close {
        position: absolute;
        top: 15px;
        right: 20px;
        cursor: pointer;
        font-size: 24px;
        color: #9a988f;
        line-height: 1;
    }
    .auth-panel-title {
        text-align: center;
        margin: 0 0 20px;
        color: var(--accent);
    }
    .auth-user-card {
        text-align: center;
        margin-bottom: 16px;
    }
    .auth-role-badge {
        display: inline-block;
        background: #807c72;
        padding: 4px 10px;
        border-radius: 4px;
        font-size: 11px;
        font-weight: bold;
        text-transform: uppercase;
        color: #fff;
    }
    .auth-role-badge--staff { background: #e67e22; }
    .auth-role-badge--client { background: #27ae60; }
    .auth-user-name {
        margin-top: 10px;
        font-size: 16px;
        font-weight: bold;
        color: #3a3833;
        word-break: break-word;
    }
    .auth-logout-btn {
        margin-top: 0;
        background: #f1efe9;
        color: #6b675e;
    }
    .auth-logout-btn:hover { background: #eae8e2; color: #3a3833; }
    .auth-login-error {
        color: #e74c3c;
        margin-top: 15px;
        font-size: 13px;
        text-align: center;
        font-weight: bold;
    }
    @media (max-width: 600px), (max-height: 700px) {
        #auth-modal {
            padding-top: 16px;
            align-items: flex-start;
        }
    }
    @media (max-width: 600px) {
        body { padding: 8px; font-size: 14px; overflow-x: hidden; }
        .app-top-bar {
            margin: -8px -8px 8px;
            padding: 4px 8px 0;
            gap: 4px;
        }
        .app-user-btn { width: 28px; height: 28px; min-width: 28px; margin-bottom: 1px; }
        .container { width: 100%; padding: 14px; border-radius: 10px; box-sizing: border-box; }
        h2 { font-size: 20px; line-height: 1.2; }
        h3 { font-size: 18px; line-height: 1.25; }
        label { font-size: 14px; line-height: 1.25; }
        select,input,textarea {
            min-height: 42px;
            padding: 9px 10px;
            font-size: 16px;
            line-height: 1.25;
        }
        input[type="checkbox"] { min-height: 0; }
        button { padding: 11px 12px; font-size: 16px; line-height: 1.2; }
        .filter-btn { min-height: 42px; font-size: 15px; white-space: normal; }
        .status-dropdown-btn, .date-range-btn { height: 42px; min-height: 42px; padding: 9px 28px 9px 10px; }
        .status-dropdown-btn { font-size: 14px; }
        .date-range-btn { font-size: 13px; }
        .status-dropdown-list, .date-range-panel { position: fixed; left: 12px; right: 12px; top: auto; max-height: 50vh; overflow-y: auto; }
        .status-option { font-size: 16px; padding: 10px 12px; }
        .row { gap: 12px; }
        .row > div[style*="flex: 0 0"] { flex: 0 0 auto !important; width: 100%; }
        #search-tab .row { flex-direction: column; align-items: stretch !important; }
        #search-tab .adv-toolbar-line { gap: 4px; }
        #search-tab .adv-toolbar-actions { gap: 4px; }
        #adv-search-container.container {
            max-width: 100%;
            padding: 12px;
        }
        #adv-search-container .adv-toolbar-icon-btn,
        #adv-search-container .adv-search-submit {
            width: 32px;
            min-width: 32px;
            max-width: 32px;
            height: 32px;
            font-size: 15px;
        }
        #adv-search-container .adv-search-input {
            height: 36px;
            min-height: 0;
            font-size: 16px;
            padding: 6px 40px 6px 8px;
        }
        #adv-search-container .adv-search-clear-btn {
            width: 38px;
            min-width: 38px;
            height: auto;
            top: 0;
            bottom: 0;
            right: 0;
            transform: none;
            border-radius: 0 8px 8px 0;
            background: transparent;
            font-size: 15px;
        }
        #adv-search-container .adv-search-clear-btn:hover,
        #adv-search-container .adv-search-clear-btn:active {
            background: rgba(58, 56, 51, 0.06);
            color: #3a3833;
        }
        .adv-search-header {
            position: relative;
        }
        .adv-filters-popover .status-dropdown-btn,
        .adv-filters-popover .date-range-btn,
        .adv-filters-popover .status-option,
        .adv-filters-popover .status-option-name,
        .adv-filters-popover .calendar-day,
        .adv-filters-popover .calendar-month-select,
        .adv-filters-popover .calendar-year-select {
            font-size: 14px;
        }
        .adv-filters-popover label.status-option {
            margin-top: 0;
            font-weight: normal;
        }
        .adv-filters-popover .adv-filters-reset-btn,
        .adv-filters-popover .adv-filters-apply-btn {
            font-size: 14px;
        }
        #advFiltersPopover .status-dropdown-list .status-option,
        #advFiltersPopover .status-dropdown-list .status-option-name {
            font-size: 14px;
        }
        #adv-search-container .crm-view-btn {
            width: 26px;
            min-width: 26px;
            max-width: 26px;
            height: 26px;
            font-size: 12px;
        }
        #main-tab .row { flex-direction: row; gap: 10px; }
        #main-tab .col { min-width: 0; }
        #main-tab #crm-search-container .row { flex-direction: column; align-items: stretch !important; }
        #main-tab #crm-search-container .row > div[style*="flex: 0 0"] { flex: 0 0 auto !important; width: 100%; }
        .tabs-nav { gap: 3px; margin-bottom: 0; border-bottom-width: 1px; padding-bottom: 0; }
        .tab-btn { flex: 1 1 0; min-width: 0; margin-top: 0; padding: 5px 12px; font-size: 13px; border-radius: 6px 6px 0 0; }
        .rec-price-box { padding: 14px; }
        .rec-price-label { font-size: 12px; }
        .rec-price-val { font-size: 24px; line-height: 1.15; }
        #roundPriceControls { flex-wrap: wrap; }
        #roundPriceControls button { flex: 1 1 140px; font-size: 14px !important; }
        .cost-detail, .tech-info { font-size: 14px; overflow-x: auto; }
        .crm-item { padding: 12px; overflow: hidden; }
        .crm-header { gap: 8px; flex-wrap: wrap; }
        .deal-num { flex: 1 1 auto; min-width: 0; font-size: 13px !important; line-height: 1.25; }
        .deal-num small { display: inline !important; margin-left: 6px !important; margin-top: 0; white-space: nowrap; }
        .deal-num button { font-size: 10px !important; padding: 2px 7px !important; }
        .status-badge { max-width: 100%; font-size: 9px; line-height: 1.2; white-space: normal; padding: 3px 7px; }
        .client-name { font-size: 12px; line-height: 1.25; }
        .elements-list { padding: 8px; overflow: hidden; }
        .element-row { align-items: flex-start; gap: 6px; flex-wrap: nowrap; }
        .element-row-text, .element-row-total, .deal-total-only { font-size: 11px !important; line-height: 1.2; }
        .element-preview-thumb { flex: 0 0 20px; width: 20px; height: 20px; }
        .element-editor-modal { max-width: 100%; border-radius: 10px; }
        .element-editor-preview { min-height: 64px; max-height: 104px; }
        .element-editor-preview img { max-height: 104px; }
        .element-editor-layout-drop-zone { min-height: 112px; padding: 26px 12px; }
        .element-editor-row4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
        .element-editor-row5 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
        .element-editor-row3 { grid-template-columns: 1fr 0.65fr 1fr; gap: 6px; }
        .element-row-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
        .element-row-total { flex: 0 0 auto; margin-left: auto; white-space: nowrap; }
        .crm-item > div:last-child { gap: 8px; flex-wrap: wrap; font-size: 11px !important; }
        .crm-item > div:last-child > div { font-size: 11px !important; }
        .crm-footer { flex-wrap: nowrap !important; align-items: center !important; gap: 8px !important; }
        .crm-footer .deal-payment-block { margin-left: auto; flex: 0 0 auto; }
        .payment-summary { width: 218px; font-size: 11px; }
        .payment-summary-row { grid-template-columns: 66px 78px 60px; gap: 4px; padding: 3px 6px; }
        .payment-summary-label, .payment-summary-value { font-size: 11px !important; line-height: 1.15; }
        .payment-action-btn { width: 20px; height: 20px; min-width: 20px; padding: 0 !important; }
        .payment-action-icon { width: 11px; height: 11px; font-size: 15px !important; }
        .add-btn { font-size: 11px; padding: 5px 9px; }
    }

    /* CRM toolbar + Kanban (вкладка «Поиск») */
    #adv-search-container.container {
        max-width: min(1600px, 100%);
        width: 100%;
        box-sizing: border-box;
    }
    /* Табличный список сделок использует всю ширину экрана (как канбан),
       чтобы разместить 7 колонок; тесниться до 900px больше не нужно. */
    #adv-search-container.container:not(.crm-kanban-layout) {
        max-width: min(1600px, 100%);
    }
    #adv-search-container button {
        margin-top: 0;
        width: auto;
        box-sizing: border-box;
    }
    #adv-search-container .adv-toolbar-icon-btn,
    #adv-search-container .adv-search-submit,
    #adv-search-container .crm-view-btn {
        padding: 0;
    }
    .adv-search-header {
        margin-bottom: 10px;
        flex: 0 0 auto;
        overflow: visible;
    }
    .adv-toolbar-line {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        flex-wrap: nowrap;
        width: 100%;
        min-width: 0;
    }
    .adv-search-input-wrap {
        position: relative;
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
    }
    .adv-search-input {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
        height: 34px;
        margin-top: 0;
        padding: 6px 30px 6px 10px;
        font-size: 14px;
        border-radius: 8px;
        box-sizing: border-box;
    }
    .adv-search-clear-btn {
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        width: 22px;
        height: 22px;
        min-width: 22px;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: #eae8e2;
        color: #8c887e;
        font-size: 12px;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .adv-search-clear-btn:hover { background: #d6d0c4; color: #3a3833; }
    .adv-search-clear-btn[hidden] { display: none; }
    .adv-toolbar-actions {
        display: flex;
        align-items: center;
        gap: 5px;
        flex: 0 0 auto;
        flex-shrink: 0;
        margin-left: auto;
    }
    .adv-toolbar-icon-btn {
        margin: 0;
        width: 34px;
        min-width: 34px;
        max-width: 34px;
        height: 34px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        background: #f1efe9;
        color: #5f5c54;
        font-size: 16px;
        line-height: 1;
        box-shadow: inset 0 0 0 1px rgba(28, 27, 25, 0.08);
        flex-shrink: 0;
        transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    }
    .adv-toolbar-icon-btn:hover {
        background: #eae8e2;
        color: #3a3833;
    }
    .adv-filters-popover-wrap {
        position: relative;
        flex: 0 0 auto;
    }
    .adv-filters-btn {
        position: relative;
    }
    .adv-filters-btn.has-filters {
        background: #fff4e6;
        color: #e67e22;
        box-shadow: inset 0 0 0 1.5px rgba(230, 126, 34, 0.45);
        animation: advFiltersPulse 2.2s ease-in-out infinite;
    }
    .adv-filters-btn.has-filters::after {
        content: "";
        position: absolute;
        top: 4px;
        right: 4px;
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #e67e22;
        box-shadow: 0 0 0 2px #fff4e6;
    }
    @keyframes advFiltersPulse {
        0%, 100% { box-shadow: inset 0 0 0 1.5px rgba(230, 126, 34, 0.45), 0 0 0 0 rgba(230, 126, 34, 0.15); }
        50% { box-shadow: inset 0 0 0 1.5px rgba(230, 126, 34, 0.65), 0 0 0 4px rgba(230, 126, 34, 0.12); }
    }
    .adv-filters-popover {
        display: none;
        position: absolute;
        top: calc(100% + 6px);
        right: 0;
        left: auto;
        z-index: 1300;
        width: min(320px, calc(100vw - 24px));
        padding: 12px;
        background: #fff;
        border: 1px solid #eae8e2;
        border-radius: 12px;
        box-shadow: 0 12px 32px rgba(28, 27, 25, 0.16);
    }
    .adv-filters-popover-wrap.open .adv-filters-popover {
        display: block;
    }
    @media (max-width: 600px) {
        #advFiltersPopover.adv-filters-popover {
            position: fixed;
            left: 12px;
            right: 12px;
            width: auto;
            max-width: none;
            margin: 0;
            box-sizing: border-box;
            z-index: 1500;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }
    }
    .adv-filters-popover-section {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
    }
    .adv-filters-popover-section:last-of-type {
        margin-bottom: 0;
    }
    .adv-filter-label {
        flex: 0 0 72px;
        margin: 0;
        font-size: 12px;
        font-weight: bold;
        color: #8c887e;
        cursor: pointer;
        user-select: none;
    }
    .adv-pay-filter {
        flex: 1 1 auto;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        margin: 0;
        font-size: 13px;
        font-weight: 500;
        text-transform: none;
        letter-spacing: 0;
        color: var(--text);
        cursor: pointer;
        user-select: none;
    }
    .adv-pay-filter input { width: auto; margin: 0; flex: 0 0 auto; }
    .adv-filters-popover-section .status-dropdown,
    .adv-filters-popover-section .date-range-dropdown {
        flex: 1 1 auto;
        min-width: 0;
    }
    .adv-filters-popover-footer {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 10px;
        border-top: 1px solid #eae8e2;
    }
    .adv-filters-reset-btn,
    .adv-filters-apply-btn {
        flex: 1 1 0;
        width: auto;
        margin: 0;
        padding: 9px 12px;
        border: none;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.2;
        cursor: pointer;
        transition: background 0.2s ease, color 0.2s ease;
    }
    .adv-filters-reset-btn {
        background: #f1efe9;
        color: #5f5c54;
    }
    .adv-filters-reset-btn:hover {
        background: #eae8e2;
        color: #3a3833;
    }
    .adv-filters-apply-btn {
        background: var(--accent);
        color: #fff;
    }
    .adv-filters-apply-btn:hover {
        background: var(--accent-strong);
        color: #fff;
    }
    .adv-filters-apply-btn:disabled {
        opacity: 0.65;
        cursor: wait;
    }
    .adv-filters-popover .status-dropdown-btn,
    .adv-filters-popover .date-range-btn {
        margin-top: 0;
        height: 38px;
        min-height: 38px;
        font-size: 14px;
    }
    .adv-filters-popover .status-option,
    .adv-filters-popover label.status-option {
        font-size: 14px;
        font-weight: normal;
        margin-top: 0;
    }
    .adv-filters-popover .status-option-name {
        font-size: 14px;
    }
    .adv-filters-popover .calendar-day,
    .adv-filters-popover .calendar-month-select,
    .adv-filters-popover .calendar-year-select {
        font-size: 14px;
    }
    #adv-search-container .clear-filters-btn {
        background: #f1efe9;
        color: #5f5c54;
        font-size: 16px;
    }
    #adv-search-container .clear-filters-btn:hover {
        background: #eae8e2;
        color: #3a3833;
    }
    .adv-search-submit {
        flex-shrink: 0;
    }
    .crm-view-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        flex-shrink: 0;
        gap: 1px;
        padding: 2px;
        background: #f1efe9;
        border-radius: 8px;
        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
    }
    .crm-view-btn {
        margin: 0;
        width: 28px;
        min-width: 28px;
        max-width: 28px;
        height: 28px;
        padding: 0;
        font-size: 13px;
        line-height: 1;
        border-radius: 6px;
        background: transparent;
        color: #8c887e;
        box-shadow: none;
        flex-shrink: 0;
        transition: background 0.2s ease, color 0.2s ease;
    }
    .crm-view-btn:hover {
        background: rgba(255, 255, 255, 0.65);
        color: #3a3833;
    }
    .crm-view-btn.active {
        background: #fff;
        color: var(--accent);
        box-shadow: 0 1px 3px rgba(28, 27, 25, 0.12);
    }

    #adv-search-container.crm-kanban-layout {
        max-width: min(1600px, 100%);
        width: 100%;
    }

    /* Полноэкранный канбан: компактная шапка, без скролла страницы */
    body.crm-kanban-active {
        height: 100dvh;
        overflow: hidden;
        padding: 6px 10px 8px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }
    body.crm-kanban-active .app-top-bar {
        flex: 0 0 auto;
        margin: -6px -10px 4px;
        padding: 0;
    }
    /* Полноэкранный канбан: компактная одностр. шапка (лого + меню + аватар) */
    body.crm-kanban-active .app-brandbar {
        padding: 6px 10px;
        gap: 8px;
    }
    body.crm-kanban-active .tab-close-btn {
        width: 14px;
        height: 14px;
        font-size: 12px;
    }
    body.crm-kanban-active .tab-content {
        display: none !important;
    }
    body.crm-kanban-active #search-tab.active {
        display: flex !important;
        flex: 1 1 auto;
        min-height: 0;
        flex-direction: column;
        overflow: hidden;
    }
    body.crm-kanban-active #adv-search-container {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        margin: 0;
        padding: 8px 12px 6px;
        max-width: none;
        width: 100%;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.06);
    }
    body.crm-kanban-active .adv-search-header {
        margin-bottom: 6px;
        flex: 0 0 auto;
    }
    body.crm-kanban-active #advCrmLoader {
        flex: 0 0 auto;
    }
    body.crm-kanban-active #advCrmResults.crm-kanban-results-host {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    body.crm-kanban-active .crm-kanban-board {
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        padding-bottom: 2px;
        align-items: stretch;
    }
    body.crm-kanban-active .crm-kanban-column {
        max-height: 100%;
        min-height: 0;
    }
    body.crm-kanban-active .adv-toolbar-icon-btn,
    body.crm-kanban-active #adv-search-container .adv-search-submit,
    body.crm-kanban-active #adv-search-container .adv-toolbar-icon-btn {
        width: 36px;
        min-width: 36px;
        max-width: 36px;
        height: 36px;
        font-size: 15px;
    }
    body.crm-kanban-active #adv-search-container .adv-search-input {
        height: 36px;
        min-height: 0;
    }
    body.crm-kanban-active .crm-view-btn {
        width: 26px;
        min-width: 26px;
        max-width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .crm-kanban-board {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        padding: 4px 2px 18px;
        scroll-behavior: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #d3cdc0 transparent;
        cursor: grab;
    }
    .crm-kanban-board.is-panning {
        cursor: grabbing;
        user-select: none;
    }
    .crm-kanban-board.kanban-board--zoomed .crm-kanban-column { zoom: 0.6; }
    /* Zoom button: hidden by default, shown in kanban mode on any screen size */
    #kanbanZoomBtn { display: none; }
    body.crm-kanban-active #kanbanZoomBtn { display: inline-flex; }
    .kanban-zoom-btn.is-active { background: var(--accent) !important; color: white !important; }
    .kanban-zoom-btn.is-active:hover { background: #1a6fe8 !important; }
    .crm-kanban-board .kanban-card {
        cursor: pointer;
    }
    .crm-kanban-board .crm-kanban-column-header {
        cursor: grab;
    }
    .crm-kanban-board::-webkit-scrollbar {
        height: 8px;
    }
    .crm-kanban-board::-webkit-scrollbar-thumb {
        background: #d3cdc0;
        border-radius: 999px;
    }
    .crm-kanban-column {
        flex: 0 0 280px;
        width: 280px;
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 240px);
        background: transparent;
        border-radius: 12px;
        box-shadow: none;
    }
    .crm-kanban-column-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 6px 6px 10px;
        position: sticky;
        top: 0;
        z-index: 1;
        background: linear-gradient(180deg, var(--bg) 78%, rgba(232, 230, 225, 0));
        cursor: grab;
        user-select: none;
    }
    .crm-kanban-column-header:active {
        cursor: grabbing;
    }
    .crm-kanban-column-grip {
        flex: 0 0 auto;
        opacity: 0.42;
        font-size: 11px;
        line-height: 1;
        color: #8c887e;
    }
    .crm-kanban-column.is-dragging {
        opacity: 0.72;
    }
    .crm-kanban-column.drop-target {
        box-shadow: inset 0 0 0 2px var(--accent);
    }
    .crm-kanban-column-title {
        flex: 1 1 auto;
        min-width: 0;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        font-weight: 600;
        line-height: 1.25;
        padding: 4px 2px;
        background: transparent;
        color: var(--text);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .crm-kanban-column-title::before {
        content: "";
        flex: 0 0 auto;
        width: 9px;
        height: 9px;
        border-radius: 50%;
        background: var(--col-bg, var(--border-strong));
        box-shadow: 0 0 0 1px rgba(28, 27, 25, 0.06) inset;
    }
    .crm-kanban-column-count {
        flex: 0 0 auto;
        min-width: 24px;
        height: 24px;
        padding: 0 7px;
        border-radius: 999px;
        background: var(--surface);
        color: var(--text-2);
        font-size: 12px;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-sm);
    }
    .crm-kanban-column-body {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 0 8px 10px;
        scroll-behavior: smooth;
        scrollbar-width: thin;
        scrollbar-color: #d3cdc0 transparent;
    }
    .crm-kanban-empty {
        padding: 10px 8px;
        border-radius: 8px;
        border: 1px dashed #d6d0c4;
        color: #a8a498;
        font-size: 12px;
        text-align: center;
        background: rgba(255, 255, 255, 0.35);
    }
    .kanban-drop-indicator {
        height: 3px;
        margin: 4px 4px;
        border-radius: 999px;
        background: var(--accent);
        box-shadow: 0 0 0 1px rgba(47, 125, 246, 0.25);
        pointer-events: none;
    }
    @keyframes kanbanCardIn {
        from {
            opacity: 0;
            transform: translateY(10px) scale(0.98);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
    .kanban-card {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 12px 13px;
        margin-bottom: 10px;
        background: var(--surface);
        border-radius: var(--r-sm);
        border-left: 4px solid var(--col-bg, var(--border-strong));
        box-shadow: var(--shadow-card);
        cursor: grab;
        outline: none;
        opacity: 0;
        transform: translateY(10px);
        transition: box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
    }
    .kanban-card:active {
        cursor: grabbing;
    }
    .kanban-card.is-dragging {
        opacity: 0.55;
        cursor: grabbing;
        transform: rotate(1.5deg) scale(0.98);
        box-shadow: 0 8px 20px rgba(28, 27, 25, 0.16);
    }
    .kanban-card.is-updating {
        opacity: 0.65;
        pointer-events: none;
        cursor: wait;
    }
    .crm-kanban-column.card-drop-target {
        background: rgba(47, 125, 246, 0.07);
        box-shadow: inset 0 0 0 2px rgba(47, 125, 246, 0.35);
    }
    .crm-kanban-column.card-drop-target .crm-kanban-column-body {
        background: rgba(255, 255, 255, 0.35);
        border-radius: 0 0 10px 10px;
    }
    .crm-kanban-board.is-ready .kanban-card {
        animation: kanbanCardIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) forwards;
        animation-delay: calc(var(--card-index, 0) * 45ms);
    }
    .kanban-card:hover,
    .kanban-card:focus-visible {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(28, 27, 25, 0.12);
        background: #fcfdff;
    }
    .kanban-card:active {
        transform: translateY(0);
        box-shadow: 0 2px 6px rgba(28, 27, 25, 0.1);
    }
    .kanban-card-top-row {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 6px;
        min-width: 0;
    }
    .kanban-card-num {
        font-size: 14px;
        font-weight: 700;
        color: var(--accent);
        line-height: 1.2;
        flex-shrink: 0;
    }
    .kanban-card-client {
        font-size: 13px;
        font-weight: 600;
        color: #1c1b19;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .kanban-card-manager {
        font-size: 11px;
        color: #8c887e;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
    .kanban-card-desc {
        font-size: 11px;
        color: #a09b93;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .kanban-card-amount {
        margin-top: 2px;
        font-size: 13px;
        font-weight: 700;
        line-height: 1.2;
    }
    .kanban-card-amount.payment-ok { color: var(--success); }
    .kanban-card-amount.payment-alert { color: var(--danger); }
    @media (max-width: 875px) {
        #adv-search-container.crm-kanban-layout {
            max-width: calc(100vw - 16px);
        }
        .crm-kanban-column {
            flex-basis: 248px;
            width: 248px;
            max-height: calc(100vh - 210px);
        }
        /* Native touch scroll with column snap */
        .crm-kanban-board {
            scroll-snap-type: x mandatory;
            overscroll-behavior-x: contain;
        }
        .crm-kanban-column {
            scroll-snap-align: start;
        }
        /* Fixed bottom toolbar in kanban mode */
        body.crm-kanban-active .adv-search-header {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 200;
            background: white;
            border-top: 1px solid #e5e0d8;
            padding-top: 9px;
            padding-left: max(22px, env(safe-area-inset-left, 0px));
            padding-right: max(22px, env(safe-area-inset-right, 0px));
            padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
            margin-bottom: 0;
            box-shadow: 0 -2px 12px rgba(28, 27, 25, 0.1);
        }
        body.crm-kanban-active .crm-kanban-column-body {
            padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        }
    }

    /* === Расчётный лист (черновик заказа) === */
    .calc-sheet { max-width: 780px; }
    .csh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
    .csh-head h2 { margin: 0; }
    .csh-note { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
    .csh-count { flex: 0 0 auto; min-width: 26px; height: 26px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-container); color: #fff; border-radius: var(--r-pill); font-size: 13px; font-weight: 700; }
    .csh-items { margin-top: 16px; display: flex; flex-direction: column; }
    .csh-empty { color: var(--text-muted); font-size: 14px; text-align: center; padding: 26px 12px; background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: var(--r-md); }
    .csh-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
    .csh-item:last-child { border-bottom: none; }
    .csh-item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
    .csh-item-name { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
    .csh-item-sub { font-size: 12px; color: var(--text-2); }
    .csh-item-cost { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
    .csh-item-cost b { font-weight: 600; color: var(--text-2); }
    .csh-item-total { flex: 0 0 auto; font-size: 14px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .csh-item-del { flex: 0 0 auto; margin: 0; width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1; background: var(--surface-3); color: var(--text-2); border: none; border-radius: var(--r-sm); box-shadow: none; }
    .csh-item-del:hover { background: var(--danger-bg); color: var(--danger); }
    /* редактируемые позиции (наименование/кол-во/цена) */
    .csh-item--edit { flex-wrap: wrap; align-items: flex-start; }
    .csh-name-input { width: 100%; margin: 0; }
    .csh-item-main .csh-item-cost { margin-top: 4px; }
    .csh-item-calc { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; }
    .csh-item-calc input { margin: 0; width: 78px; }
    .csh-qty-input { width: 64px !important; }
    .csh-x { font-size: 12px; color: var(--text-2); white-space: nowrap; }
    @media (max-width: 560px) {
        .csh-item-calc { width: 100%; margin-top: 6px; }
    }
    .csh-add-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border-2); }
    .csh-add-row .add-btn { margin: 0; width: auto; }
    .csh-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
    .csh-total { font-size: 16px; color: var(--text); }
    .csh-total b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
    .csh-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
    .csh-clear { margin: 0; width: auto; padding: 11px 16px; background: transparent; color: var(--text-2); border: 1px solid var(--border-2); border-radius: var(--r-sm); font-size: 14px; font-weight: 600; box-shadow: none; }
    .csh-clear:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bg); }
    .csh-tocrm { margin: 0; width: auto; padding: 11px 20px; background: var(--accent-container); color: #fff; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; }
    .csh-tocrm:hover { background: var(--accent-strong); }
    .csh-tocrm:disabled { opacity: 0.5; cursor: not-allowed; }
    .nav-tab--sheet { color: var(--secondary); }
    .nav-tab--sheet.active { color: #fff; }
    .csh-tab-count { display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:18px; padding:0 5px; margin-left:2px; background:var(--secondary); color:#fff; border-radius:var(--r-pill); font-size:11px; font-weight:700; line-height:1; }
    .nav-tab--sheet.active .csh-tab-count { background:rgba(255,255,255,0.28); }
