 /**
 * widget.css — общий CSS для всех форм и селектора приложения «Результат задачи».
 *
 * Раздаётся через API Gateway по роуту /widget.css.
 * Подключается в формах через <link> с $config['css_url'].
 *
 * Контракт: docs/form-contract.md (v1.2)
 *
 * Правила:
 *   - Общие стили (дублируются в 2+ формах) — здесь.
 *   - Уникальные стили (1 форма) — в форме, в отдельном <style>.
 *   - Уникальные цвета (subtask — оранжевые кнопки) — через CSS-переменные.
 *
 * Версионирование: ?v=N в config['css_url'] (bump при обновлении).
 */

/* ============================================================
   БАЗОВЫЕ
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    background: #eef2f4;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    padding: 16px;
    margin: 0;
}

/* ============================================================
   КАРТОЧКА
   ============================================================ */
.widget-card {
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.widget-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e6e9eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.widget-header h3 {
    font-size: 16px;
    font-weight: 500;
    color: #1d2b36;
    margin: 0;
}
.widget-body {
    padding: 20px;
}

/* ============================================================
   ФОРМЫ
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #58616b;
}
.form-group label .required {
    color: #e92f2f;
}
.b24-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    transition: 0.2s;
}
.b24-input:focus {
    outline: none;
    border-color: #2fc6f6;
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}
.b24-select {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    transition: 0.2s;
    cursor: pointer;
    appearance: auto;
}
.b24-select:focus {
    outline: none;
    border-color: #2fc6f6;
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}
textarea.b24-input {
    resize: vertical;
    min-height: 80px;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.button-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.b24-button {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: 0.2s;
}
/* Акцентный цвет — через CSS-переменную.
   По умолчанию — синий (2fc6f6). Форма может переопределить. */
.b24-button-primary {
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    flex: 1;
}
.b24-button-primary:hover {
    background: var(--widget-accent-hover, #1da9d6);
}
.b24-button-primary:disabled {
    background: #cfd4d9;
    cursor: not-allowed;
}
.b24-button-secondary {
    background: #eef2f4;
    color: #58616b;
}
.b24-button-secondary:hover {
    background: #e2e6e9;
}
.b24-button-success {
    background: #9dcf00;
    color: #fff;
}
.b24-button-success:hover {
    background: #89b800;
}
.b24-button-success:disabled {
    background: #cfd4d9;
    cursor: not-allowed;
}
.b24-button-danger {
    background: #e92f2f;
    color: #fff;
}
.b24-button-danger:hover {
    background: #d02525;
}
.b24-button-danger:disabled {
    background: #cfd4d9;
    cursor: not-allowed;
}

/* ============================================================
   УВЕДОМЛЕНИЯ
   ============================================================ */
.b24-notify {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 350px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.b24-notify.show {
    opacity: 1;
}
.b24-notify-success {
    background: #9dcf00;
}
.b24-notify-error {
    background: #e92f2f;
}
.b24-notify-info {
    background: #2fc6f6;
}

/* ============================================================
   СКРЫТЫЕ ФОРМЫ
   ============================================================ */
.hidden-form {
    display: none;
}

/* ============================================================
   ЧИПСЫ
   ============================================================ */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.chip {
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid #cfd4d9;
    background: #fafbfc;
    font-size: 12px;
    color: #58616b;
    cursor: pointer;
    transition: 0.2s;
    user-select: none;
}
.chip:hover {
    background: #eef2f4;
    border-color: #a3acb6;
}
.chip.selected {
    background: var(--widget-chip-bg, #f0f9fd);
    border-color: var(--widget-accent, #2fc6f6);
    color: #1d2b36;
}

/* ============================================================
   ФАЙЛЫ (одиночная загрузка)
   ============================================================ */
.file-upload-box {
    border: 2px dashed #cfd4d9;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    background: #fafbfc;
}
.file-upload-box:hover {
    border-color: var(--widget-accent, #2fc6f6);
    background: var(--widget-chip-bg, #f0f9fd);
}
.file-upload-box .text {
    font-size: 13px;
    color: #58616b;
}
.file-upload-box .hint {
    font-size: 11px;
    color: #a3acb6;
    margin-top: 4px;
}
.file-selected {
    display: none;
    background: #eef9ee;
    border: 1px solid #8dc779;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
    align-items: center;
    gap: 12px;
}
.file-selected.show {
    display: flex;
}
.file-selected .file-name {
    flex: 1;
    font-size: 14px;
    color: #1d2b36;
}
.file-selected .file-remove {
    background: none;
    border: none;
    color: #e92f2f;
    cursor: pointer;
    font-size: 18px;
}

/* ============================================================
   ПОИСК ПОЛЬЗОВАТЕЛЯ
   ============================================================ */
.user-search {
    position: relative;
}
.user-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    margin-top: 4px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.user-search-results.show {
    display: block;
}
.user-search-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #e6e9eb;
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-search-item:hover {
    background: #eef2fc;
}
.user-search-item .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
}
.user-search-item .info {
    font-size: 13px;
}
.user-search-item .info .name {
    color: #1d2b36;
}
.user-search-item .info .hint {
    font-size: 11px;
    color: #a3acb6;
}
.selected-user {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--widget-chip-bg, #f0f9fd);
    border: 1px solid var(--widget-accent, #2fc6f6);
    border-radius: 6px;
    margin-top: 8px;
}
.selected-user.show {
    display: flex;
}
.selected-user .remove-user {
    margin-left: auto;
    background: none;
    border: none;
    color: #e92f2f;
    cursor: pointer;
    font-size: 16px;
}

/* ============================================================
   PRELOADER
   ============================================================ */
.preloader {
    display: none;
    text-align: center;
    padding: 40px 20px;
    color: #58616b;
    font-size: 14px;
}
.preloader.show {
    display: block;
}
.preloader .spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #e6e9eb;
    border-top-color: #2fc6f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ============================================================
   ФОРМА: БАННЕР, ГРУППЫ, SUBMIT (E8.1)
   ============================================================ */

.form-banner {
    padding: 12px 16px;
    margin-bottom: 20px;
    background: var(--widget-chip-bg, #f0f9fd);
    border-left: 4px solid var(--widget-accent, #2fc6f6);
    border-radius: 6px;
}
.form-banner-action {
    font-size: 15px;
    font-weight: 600;
    color: #1d2b36;
    margin-bottom: 4px;
}
.form-banner-subdivisions {
    font-size: 12px;
    color: #58616b;
}

.form-group {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e6e9eb;
}
.form-group:last-of-type {
    border-bottom: none;
}
.form-group-title {
    font-size: 14px;
    font-weight: 600;
    color: #1d2b36;
    margin: 0 0 12px 0;
    padding: 0;
}
.form-group-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.form-group-placeholder {
    font-size: 12px;
    color: #a3acb6;
}

.form-submit-row {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================================
   ФОРМА: ЭЛЕМЕНТЫ (E8.2)
   ============================================================ */

.form-element {
    display: grid;
    grid-template-columns: 200px 1fr 32px;
    gap: 12px;
    align-items: center;
    padding: 4px 0;
}

.form-element-label {
    font-size: 13px;
    font-weight: 500;
    color: #58616b;
    line-height: 1.3;
}

.form-element-title {
    margin-right: 2px;
}

.form-element-required {
    color: #e92f2f;
    margin-left: 2px;
}

.form-element-control {
    min-width: 0;
}

.form-element-status {
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    justify-self: end;
}

.form-element-status.status-success {
    background: #e6f7e6;
    color: #1a7f1a;
}
.form-element-status.status-required {
    background: #fdecea;
    color: #c00;
}
.form-element-status.status-warning {
    background: #fff7e6;
    color: #a35b00;
}

/* === Reactive Field: состояние invalid (валидация) === */
.form-element-status.status-invalid {
    background: #fdecea;
    color: #c00;
    font-weight: 700;
    cursor: help;
}

.form-element input[readonly],
.form-element textarea[readonly] {
    background: #f7f9fa;
    color: #58616b;
    cursor: default;
}

.form-element-unsupported {
    grid-template-columns: 1fr;
    padding: 8px 12px;
    border: 1px dashed #cfd4d9;
    border-radius: 6px;
    color: #a3acb6;
    font-size: 12px;
}

/* На узких экранах — метка над полем */
@media (max-width: 600px) {
    .form-element {
        grid-template-columns: 1fr 32px;
    }
    .form-element-label {
        grid-column: 1 / 2;
    }
    .form-element-control {
        grid-column: 1 / 3;
    }
    .form-element-status {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        align-self: start;
    }
}

/* ============================================================
   ФОРМА: СПИСКИ (E8.3)
   ============================================================ */

.form-element select[multiple] {
    min-height: 80px;
    padding: 4px;
}
.form-element select[multiple] option {
    padding: 4px 8px;
    border-radius: 4px;
}

/* ============================================================
   ФОРМА: CRM-СУЩНОСТИ (E8.4)
   ============================================================ */

.crm-entity-item {
    padding: 4px 0;
    font-size: 14px;
}
.crm-entity-link {
    color: #1d2b36;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.crm-entity-link:hover {
    color: var(--widget-accent, #2fc6f6);
    border-bottom-color: var(--widget-accent, #2fc6f6);
}
.crm-entity-extra {
    color: #58616b;
    font-size: 12px;
    margin-left: 6px;
}
.crm-entity-list .crm-entity-item {
    padding: 4px 0;
    border-bottom: 1px solid #f0f3f5;
}
.crm-entity-list .crm-entity-item:last-child {
    border-bottom: none;
}
.crm-entity-empty {
    color: #a3acb6;
    font-size: 13px;
    padding: 4px 0;
}

/* ============================================================
   ФОРМА: ФАЙЛЫ (E8.5)
   ============================================================ */

.file-info {
    font-size: 14px;
    color: #1d2b36;
    padding: 4px 0;
}
.file-info-empty {
    color: #a3acb6;
    font-size: 13px;
}
.file-info b {
    font-weight: 600;
    color: #2fc6f6;
}

/* ============================================================
   ФОРМА: USER_REF (E8.6)
   ============================================================ */

.user-ref {
    font-size: 14px;
    padding: 4px 0;
}
.user-ref-empty {
    color: #a3acb6;
    font-size: 13px;
}

/* ============================================================
   ФОРМА: ЧЕКБОКС-ИНДИКАТОР (E8.7.1)
   ============================================================ */

.form-element-status.status-check {
    background: transparent;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.check-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(233, 47, 47, 0.45);  /* мягкий required-акцент (45%) */
    border-radius: 3px;
    background: #fff;
    box-sizing: border-box;
    position: relative;
    transition: 0.15s;
}

.check-indicator:hover {
    border-color: #2fc6f6;
    background: #f0f9fd;
}

.check-indicator.checked {
    border-color: #2fc6f6;
    background: #2fc6f6;
}

.check-indicator.checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ============================================================
   ФОРМА: ЗАБЛОКИРОВАННЫЕ ПОЛЯ ПО ЧЕКУ (E8.7.2)
   ============================================================ */

.form-element input[readonly],
.form-element textarea[readonly],
.form-element select:disabled {
    background: #f0f3f5;
    color: #1d2b36;
    cursor: not-allowed;
}

/* ============================================================
   ФОРМА: ЭКРАН УСПЕХА (E10.3, стиль Б24)
   ============================================================ */

.form-success-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px 20px;
}

.form-success-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 48px 40px 40px;
    max-width: 480px;
    width: 100%;
    text-align: center;
}

.form-success-icon-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: #e6f7e6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.form-success-icon-glyph {
    font-size: 44px;
    line-height: 1;
    color: #4caf50;
    font-weight: bold;
}

.form-success-message {
    font-size: 15px;
    color: #58616b;
    line-height: 1.5;
    margin-bottom: 24px;
}

.form-success-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.form-success-btn {
    display: inline-block;
    padding: 10px 32px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    min-width: 160px;
    text-align: center;
    font-family: inherit;
}

.form-success-btn-primary {
    background: #2fc6f6;
    color: #fff;
}
.form-success-btn-primary:hover {
    background: #1da9d6;
}

.form-success-btn-secondary {
    background: #eef2f4;
    color: #58616b;
}
.form-success-btn-secondary:hover {
    background: #e2e6e9;
}


/* ============================================================
   MULTI-SELECT (backlog #1): чипсы + поиск + чекбоксы
   ============================================================ */

.multi-select {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- Поле поиска --- */
.multi-select-search {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    transition: 0.2s;
}
.multi-select-search:focus {
    outline: none;
    border-color: var(--widget-accent, #2fc6f6);
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}
.multi-select-search[readonly] {
    background: #f0f3f5;
    cursor: not-allowed;
}

/* --- Чипсы выбранных --- */
.multi-select-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.multi-select-chips:empty {
    display: none;
}
.multi-select-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 14px;
    background: var(--widget-chip-bg, #f0f9fd);
    border: 1px solid var(--widget-accent, #2fc6f6);
    font-size: 12px;
    color: #1d2b36;
    line-height: 1.4;
    max-width: 100%;
}
.multi-select-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}
.multi-select-chip-remove {
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #58616b;
    user-select: none;
    padding: 0 2px;
    border-radius: 50%;
    transition: 0.15s;
}
.multi-select-chip-remove:hover {
    color: #e92f2f;
    background: rgba(233,47,47,0.1);
}

/* --- Список опций (скрыт по умолчанию, раскрывается по .open) --- */
.multi-select-options {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    padding: 4px;
    display: none;               /* ← по умолчанию скрыт */
}
.multi-select.open .multi-select-options {
    display: block;              /* ← показан при .open */
}
.multi-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #1d2b36;
    transition: 0.15s;
    user-select: none;
}
.multi-select-option:hover {
    background: #f0f9fd;
}
.multi-select-option input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
    margin: 0;
}
.multi-select-option-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* КЛЮЧЕВОЕ: скрытие опций — по классу .hidden (JS добавляет/убирает) */
.multi-select-option.hidden {
    display: none;
}

/* --- «Ничего не найдено» --- */
.multi-select-empty {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: #a3acb6;
    border: 1px dashed #cfd4d9;
    border-radius: 6px;
}

/* --- Readonly-состояние (весь multi-select) --- */
.multi-select[data-readonly="1"] {
    opacity: 0.75;
    pointer-events: none;
}


/* ============================================================
   DATE-PICKER (backlog #5): календарь для полей type: 'date'
   ============================================================ */

.date-picker {
    position: relative;
    width: 100%;
}

/* Иконка календаря — через ::after (надёжнее, чем background-image на input) */
.date-picker::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%2358616b' d='M4 1v1H2.5A1.5 1.5 0 0 0 1 3.5v10A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-10A1.5 1.5 0 0 0 13.5 2H12V1h-1v1H5V1H4zm0 3h1v1h6V4h1v1h1.5a.5.5 0 0 1 .5.5V6H2V5.5a.5.5 0 0 1 .5-.5H4V4zm-2 4h12v6.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
    pointer-events: none;  /* клик проходит на input */
    opacity: 0.7;
    transition: opacity 0.15s;
}
.date-picker:hover::after {
    opacity: 1;
}

/* --- Input (наследует .b24-input, добавляем курсор-указатель) --- */
.date-picker-input,
.form-element input.date-picker-input[readonly] {
    cursor: pointer;
    padding-right: 36px;  /* место под иконку календаря */
}
.date-picker-input:hover {
    border-color: #a3acb6;
}
.date-picker.open .date-picker-input {
    border-color: var(--widget-accent, #2fc6f6);
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}

/* --- Календарь --- */
.date-picker-calendar {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    width: 280px;
    background: #fff;
    border: 1px solid #cfd4d9;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 12px;
    user-select: none;
}

/* --- Шапка --- */
.date-picker-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}
.date-picker-nav {
    width: 28px;
    height: 28px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    color: #58616b;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: 0.15s;
    padding: 0;
    flex-shrink: 0;
}
.date-picker-nav:hover {
    background: #f0f9fd;
    border-color: var(--widget-accent, #2fc6f6);
    color: var(--widget-accent, #2fc6f6);
}
.date-picker-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #1d2b36;
    padding: 0 4px;
    white-space: nowrap;
}

/* --- Сетка 7 колонок --- */
.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

/* --- Заголовки дней недели --- */
.date-picker-dow {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #a3acb6;
    padding: 4px 0;
    text-transform: uppercase;
}

/* --- День --- */
.date-picker-day {
    text-align: center;
    padding: 6px 0;
    font-size: 13px;
    color: #1d2b36;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.15s;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.date-picker-day:hover {
    background: #f0f9fd;
    color: var(--widget-accent, #2fc6f6);
}
.date-picker-day-empty {
    cursor: default;
    pointer-events: none;
}
.date-picker-day-empty:hover {
    background: transparent;
}

/* Сегодня */
.date-picker-day.today {
    font-weight: 600;
    color: var(--widget-accent, #2fc6f6);
    border: 1px solid var(--widget-accent, #2fc6f6);
}
.date-picker-day.today:hover {
    background: #f0f9fd;
}

/* Выбранный */
.date-picker-day.selected {
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    font-weight: 600;
}
.date-picker-day.selected:hover {
    background: var(--widget-accent-hover, #1da9d6);
    color: #fff;
}

/* Если сегодня и выбран — приоритет у selected, но оставляем лёгкий оттенок */
.date-picker-day.today.selected {
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    border-color: var(--widget-accent, #2fc6f6);
}

/* --- Readonly-состояние --- */
.date-picker[data-readonly="1"] .date-picker-input {
    cursor: not-allowed;
    background-color: #f0f3f5;
}


/* ============================================================
   USER-REF (backlog #4): поиск исполнителя
   ============================================================ */

.user-ref {
    position: relative;
    width: 100%;
}

/* --- Display (выбранный или placeholder) --- */
.user-ref-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: 0.15s;
    min-height: 40px;
}
.user-ref-display:hover {
    border-color: #a3acb6;
}
.user-ref.open .user-ref-display {
    border-color: var(--widget-accent, #2fc6f6);
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}

.user-ref-link {
    color: #1d2b36;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.user-ref-link:hover {
    color: var(--widget-accent, #2fc6f6);
    border-bottom-color: var(--widget-accent, #2fc6f6);
}

.user-ref-placeholder {
    color: #a3acb6;
    font-size: 13px;
    flex: 1;
    font-style: italic;
}

.user-ref-remove {
    color: #58616b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 50%;
    transition: 0.15s;
    user-select: none;
    flex-shrink: 0;
}
.user-ref-remove:hover {
    color: #e92f2f;
    background: rgba(233,47,47,0.1);
}

/* --- Search-wrap --- */
.user-ref-search-wrap {
    margin-top: 6px;
}

.user-ref-search {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    transition: 0.15s;
}
.user-ref-search:focus {
    outline: none;
    border-color: var(--widget-accent, #2fc6f6);
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}

/* --- Результаты поиска --- */
.user-ref-results {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    padding: 4px;
    margin-top: 4px;
}

.user-ref-result-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.15s;
}
.user-ref-result-item:hover {
    background: #f0f9fd;
}

.user-ref-result-name {
    font-size: 13px;
    color: #1d2b36;
    font-weight: 500;
    line-height: 1.3;
}
.user-ref-result-position {
    font-size: 11px;
    color: #a3acb6;
    line-height: 1.3;
}

.user-ref-no-results {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: #a3acb6;
}

/* --- Readonly-состояние --- */
.user-ref[data-readonly="1"] .user-ref-display {
    cursor: not-allowed;
    background-color: #f0f3f5;
}
.user-ref[data-readonly="1"] .user-ref-display:hover {
    border-color: #cfd4d9;
}


/* ============================================================
   ENTITY-REF (backlog #2/#3): поиск компании / контактов
   ============================================================ */

.entity-ref {
    position: relative;
    width: 100%;
}

/* --- Display (single: company) --- */
.entity-ref-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: 0.15s;
    min-height: 40px;
}
.entity-ref-display:hover {
    border-color: #a3acb6;
}
.entity-ref.open .entity-ref-display {
    border-color: var(--widget-accent, #2fc6f6);
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}

.entity-ref-link {
    color: #1d2b36;
    text-decoration: none;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.entity-ref-link:hover {
    color: var(--widget-accent, #2fc6f6);
    border-bottom-color: var(--widget-accent, #2fc6f6);
}

.entity-ref-inn {
    color: #58616b;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.entity-ref-placeholder {
    color: #a3acb6;
    font-size: 13px;
    flex: 1;
    font-style: italic;
}

.entity-ref-remove {
    color: #58616b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 50%;
    transition: 0.15s;
    user-select: none;
    flex-shrink: 0;
    margin-left: auto;
}
.entity-ref-remove:hover {
    color: #e92f2f;
    background: rgba(233,47,47,0.1);
}

/* --- Display multi (contacts) --- */
.entity-ref-display-multi {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    cursor: default;
    padding: 9px 12px;
}

/* Подсказка о лимите send-контактов (backlog #7)
   Появляется, если в поле >max_send отмечено. */
.entity-ref-send-hint {
    display: none;
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: #c00;
    background: #fdecea;
    border-radius: 4px;
    line-height: 1.3;
}
.entity-ref-send-hint.show {
    display: block;
}

.entity-ref-selected-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: #fafbfc;
    border: 1px solid #e6e9eb;
    transition: 0.15s;
}
.entity-ref-selected-row:hover {
    background: #f0f9fd;
    border-color: var(--widget-accent, #2fc6f6);
}

/* Чекбокс отбора в задачу (backlog #7) */
.entity-ref-send-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
    accent-color: var(--widget-accent, #2fc6f6);
}
.entity-ref-send-checkbox:hover {
    filter: brightness(0.95);
}

.entity-ref-selected-row .entity-ref-link {
    flex: 1;
}

.entity-ref-phone {
    color: #58616b;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.entity-ref-selected-row .entity-ref-remove {
    margin-left: 4px;
}

/* --- Кнопка "+ Добавить контакт" --- */
.entity-ref-add {
    margin-top: 8px;
}
.entity-ref-add-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--widget-accent, #2fc6f6);
    background: #fff;
    border: 1px dashed var(--widget-accent, #2fc6f6);
    border-radius: 6px;
    cursor: pointer;
    transition: 0.15s;
    font-family: inherit;
}
.entity-ref-add-btn:hover {
    background: var(--widget-chip-bg, #f0f9fd);
}

/* --- Search-wrap --- */
.entity-ref-search-wrap {
    margin-top: 6px;
}

.entity-ref-search {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    transition: 0.15s;
}
.entity-ref-search:focus {
    outline: none;
    border-color: var(--widget-accent, #2fc6f6);
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}

/* --- Результаты поиска --- */
.entity-ref-results {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    padding: 4px;
    margin-top: 4px;
}

.entity-ref-result-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.15s;
}
.entity-ref-result-item:hover {
    background: #f0f9fd;
}

.entity-ref-result-name {
    font-size: 13px;
    color: #1d2b36;
    font-weight: 500;
    line-height: 1.3;
}
.entity-ref-result-position {
    font-size: 11px;
    color: #a3acb6;
    line-height: 1.3;
}

.entity-ref-no-results {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: #a3acb6;
}

/* --- Readonly --- */
.entity-ref[data-readonly="1"] {
    pointer-events: none;
    opacity: 0.75;
}
.entity-ref[data-readonly="1"] .entity-ref-display {
    cursor: default;
    background-color: #f0f3f5;
}
.entity-ref[data-readonly="1"] .entity-ref-display:hover {
    border-color: #cfd4d9;
}
.entity-ref[data-readonly="1"] .entity-ref-add-btn {
    display: none;
}

/* Ссылка на объект остаётся кликабельной даже в readonly.
   Позволяет перейти в карточку компании/контакта после чека. */
.entity-ref[data-readonly="1"] .entity-ref-link {
    pointer-events: auto;
    cursor: pointer;
}
.entity-ref[data-readonly="1"] .entity-ref-link:hover {
    color: var(--widget-accent, #2fc6f6);
    border-bottom-color: var(--widget-accent, #2fc6f6);
}

/* ============================================================
   ENTITY-REF: невалидное состояние (backlog #7)
   ============================================================
   Красная обводка display-контейнера при >max_send отмеченных
   send-контактов. Флаг data-invalid ставит updateElementStatus
   (через status.dataset.invalid из RFP).

   Внимание: этот флаг — на корне .form-element, а не на .entity-ref.
   Поэтому селектор — через родителя. */
.form-element:has(.form-element-status.status-invalid) .entity-ref-display,
.form-element:has(.form-element-status.status-invalid) .entity-ref-display-multi {
    border-color: #e92f2f;
    box-shadow: 0 0 0 2px rgba(233,47,47,0.15);
}

/* Fallback для браузеров без :has() — не критично,
   но если :has() не поддержан, обводки не будет.
   Б24 использует современный Chrome/Edge — :has() есть. */

/* Опционально: подсветка строки с непередаваемым контактом — нет, не надо.
   Отбор — не про "невалидность строки", а про агрегат. */

/* ============================================================
   UNIFIED MESSAGES (backlog #12): единый каркас сообщений
   ============================================================ */

.form-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px 20px;
}

.form-message-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 48px 40px 40px;
    max-width: 520px;
    width: 100%;
    text-align: center;
}

/* --- Иконка --- */
.form-message-icon-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    background: #f0f3f5;  /* дефолт, переопределяется типом */
}

.form-message-icon-glyph {
    font-size: 44px;
    line-height: 1;
    font-weight: bold;
    color: #58616b;  /* дефолт, переопределяется типом */
}

/* --- Заголовок --- */
.form-message-title {
    font-size: 20px;
    font-weight: 600;
    color: #1d2b36;
    line-height: 1.3;
    margin-bottom: 12px;
}

/* --- Описание --- */
.form-message-text {
    font-size: 15px;
    color: #58616b;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* --- Детали (список) --- */
.form-message-details {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    text-align: left;
}
.form-message-details li {
    position: relative;
    padding: 8px 12px 8px 32px;
    font-size: 14px;
    color: #1d2b36;
    line-height: 1.4;
    background: #fafbfc;
    border-radius: 6px;
    margin-bottom: 6px;
}
.form-message-details li::before {
    content: '•';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #a3acb6;
    line-height: 1;
}
.form-message-details li:last-child {
    margin-bottom: 0;
}

/* --- Кнопки --- */
.form-message-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.form-message-btn {
    display: inline-block;
    padding: 10px 32px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    min-width: 160px;
    text-align: center;
    font-family: inherit;
}

.form-message-btn-primary {
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
}
.form-message-btn-primary:hover {
    background: var(--widget-accent-hover, #1da9d6);
}

.form-message-btn-secondary {
    background: #eef2f4;
    color: #58616b;
}
.form-message-btn-secondary:hover {
    background: #e2e6e9;
}

/* ============================================================
   UNIFIED MESSAGES: типы (success / error / warning / info / validation)
   ============================================================ */

/* --- success (зелёный) --- */
.form-message-success .form-message-icon-circle {
    background: #e6f7e6;
}
.form-message-success .form-message-icon-glyph {
    color: #4caf50;
}

/* --- error (красный) --- */
.form-message-error .form-message-icon-circle {
    background: #fdecea;
}
.form-message-error .form-message-icon-glyph {
    color: #c00;
}

/* --- warning (оранжевый) --- */
.form-message-warning .form-message-icon-circle {
    background: #fff7e6;
}
.form-message-warning .form-message-icon-glyph {
    color: #a35b00;
}

/* --- info (синий) --- */
.form-message-info .form-message-icon-circle {
    background: #eaf4ff;
}
.form-message-info .form-message-icon-glyph {
    color: #005b9f;
}

/* --- validation (красный, как error, но заголовок другой) --- */
.form-message-validation .form-message-icon-circle {
    background: #fdecea;
}
.form-message-validation .form-message-icon-glyph {
    color: #c00;
}

/* Ссылки в сообщениях (backlog #10) */
.form-message-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 20px;
    text-align: left;
}
.form-message-link {
    display: inline-block;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--widget-accent, #2fc6f6);
    text-decoration: none;
    border: 1px solid var(--widget-accent, #2fc6f6);
    border-radius: 6px;
    transition: 0.15s;
    font-weight: 500;
}
.form-message-link:hover {
    background: var(--widget-chip-bg, #f0f9fd);
    text-decoration: underline;
}


/* ============================================================
   SUBMIT SPINNER (backlog #27)
   ============================================================ */

.submit-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 40px 20px;
}

.submit-spinner-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 40px;
    text-align: center;
}

.submit-spinner-circle {
    width: 48px;
    height: 48px;
    border: 3px solid #e6e9eb;
    border-top-color: var(--widget-accent, #2fc6f6);
    border-radius: 50%;
    animation: submit-spin 0.9s linear infinite;
}

@keyframes submit-spin {
    to { transform: rotate(360deg); }
}

.submit-spinner-text {
    font-size: 16px;
    font-weight: 600;
    color: #1d2b36;
    line-height: 1.4;
}

.submit-spinner-hint {
    font-size: 13px;
    color: #a3acb6;
    line-height: 1.4;
}