/* ============================================
   МОДАЛЬНЫЕ ОКНА (Modal)
   Поддерживает два варианта разметки:
   1. .crud-modal (основной, через JS)
   2. .modal-overlay / .modal-container (простой, через CSS-классы)
   ============================================ */

/* ========== Базовый контейнер модалки ========== */
.crud-modal,
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.crud-modal.visible,
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ========== Затемнение (overlay) ========== */
/* .crud-modal__overlay — слой ВНУТРИ фиксированного .crud-modal (display: flex),
   поэтому его нужно растянуть на весь контейнер: без position:absolute + inset:0
   он остаётся flex-элементом нулевого размера и фон не затемняется. */
.crud-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

/* .modal-overlay — это сам контейнер простой модалки (см. блок выше), затемнение на нём */
.modal-overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

/* ========== Контейнер содержимого ========== */
.crud-modal__container,
.modal-container {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: var(--md-surface);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
}

/* ========== Шапка ========== */
.crud-modal__header,
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--md-surface-variant);
    flex-shrink: 0;
}

.crud-modal__title,
.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--md-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

/* ========== Кнопка закрытия ========== */
.crud-modal__close,
.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--md-on-surface-variant);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.crud-modal__close:hover,
.modal-close:hover {
    background: var(--md-surface-variant);
    color: var(--md-on-surface);
}

/* ========== Тело ========== */
.crud-modal__body,
.modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    word-wrap: break-word;
}

/* Форма внутри контейнера модалки: flex-колонка, иначе форма не сжимается,
   тело не прокручивается, а подвал с кнопками уезжает за край контейнера.
   См. docs/ui-kit/modals.md → «Длинные формы: прокрутка и видимый подвал». */
.crud-modal__container > form:not(.crud-modal__form),
.modal-container > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ========== Подвал ========== */
.crud-modal__footer,
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--md-surface-variant);
    flex-shrink: 0;
}

/* ========== Кнопки в модалке ========== */
.crud-modal__btn {
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.crud-modal__btn--primary {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.crud-modal__btn--primary:hover {
    opacity: 0.9;
}

.crud-modal__btn--danger {
    background: var(--md-error, #b3261e);
    color: var(--md-on-error, #fff);
}

.crud-modal__btn--danger:hover {
    opacity: 0.9;
}

.crud-modal__btn--secondary {
    background: transparent;
    border: 1px solid var(--md-surface-variant);
    color: var(--md-on-surface-variant);
}

.crud-modal__btn--secondary:hover {
    border-color: var(--md-link);
    color: var(--md-link);
}

/* Кнопка опасного действия в модалке */
.crud-modal__btn--danger {
    background: #dc3545;
    color: #fff;
}

.crud-modal__btn--danger:hover {
    opacity: 0.9;
}

/* Варианты ширины контейнера (страницы документов: 600px / 400px) */
.crud-modal__container--md {
    max-width: 600px;
}

.crud-modal__container--sm {
    max-width: 400px;
}

/* Ширина контейнера 420px (участники мероприятия) */
.crud-modal__container--w420 {
    max-width: 420px;
}

/* ========== Сетка просмотра ========== */
.crud-modal__view-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.crud-modal__field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--md-surface-variant);
}

.crud-modal__field--full {
    grid-column: span 2;
}

.crud-modal__field-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.crud-modal__field-value {
    font-size: 0.95rem;
    line-height: 1.35;
    color: var(--md-on-surface);
    word-break: break-word;
    overflow-wrap: break-word;
}

.crud-modal__field-value code {
    background: var(--md-surface-variant);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    word-break: break-all;
}

.crud-modal__field-value img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* ========== Форма в модалке ========== */
.crud-modal__form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.crud-modal__form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.crud-modal__form-group--full {
    grid-column: span 2;
}

.crud-modal__form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-on-surface-variant);
}

.crud-modal__form-label .required {
    color: var(--md-error, #dc3545);
    margin-left: 4px;
}

.crud-modal__form-input,
.crud-modal__form-select,
.crud-modal__form-textarea {
    padding: 12px 16px;
    border: 1px solid var(--md-surface-variant);
    border-radius: 12px;
    background: var(--md-surface);
    color: var(--md-on-surface);
    font-size: 0.875rem;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.crud-modal__form-input:focus,
.crud-modal__form-select:focus,
.crud-modal__form-textarea:focus {
    outline: none;
    border-color: var(--md-link);
    box-shadow: 0 0 0 2px rgba(98, 0, 238, 0.1);
}

.crud-modal__form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ========== Загрузка файла ========== */
.crud-modal__file-wrapper {
    position: relative;
}

.crud-modal__file-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--md-surface-variant);
    border: 1px solid var(--md-surface-variant);
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-on-surface);
    cursor: pointer;
    transition: all 0.2s;
}

.crud-modal__file-btn:hover {
    background: var(--md-surface);
    border-color: var(--md-link);
    color: var(--md-link);
}

.crud-modal__file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.crud-modal__file-preview {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.crud-modal__file-preview img {
    max-width: 80px;
    max-height: 60px;
    border-radius: 8px;
    border: 1px solid var(--md-surface-variant);
    object-fit: cover;
}

/* ========== Бейджи статусов ========== */
.crud-modal__badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.875rem;
    white-space: nowrap;
}

.crud-modal__badge--active {
    background: var(--md-success-container, #e8f5e9);
    color: var(--md-on-success-container, #2e7d32);
}

.crud-modal__badge--inactive {
    background: var(--md-error-container, #ffebee);
    color: var(--md-on-error-container, #c62828);
}

/* Нейтральный бейдж: «нет признака» / «не активно» (например, ЕКП = Нет) */
.crud-modal__badge--neutral {
    background: var(--md-surface);
    color: var(--md-on-surface-variant);
    border: 1px solid var(--md-outline-variant, rgba(0, 0, 0, 0.12));
}

/* ========== Загрузка и ошибка ========== */
.crud-modal__loading {
    text-align: center;
    padding: 40px;
    color: var(--md-on-surface-variant);
}

.crud-modal__error {
    text-align: center;
    padding: 40px;
}

.crud-modal__error p {
    margin-top: 16px;
    color: var(--md-on-surface);
}

/* Изображение в карточке просмотра (backlog #59) */
.crud-modal__image {
    max-width: 100%;
    max-height: 100px;
    border-radius: 8px;
}

/* Превью загружаемого файла в форме (backlog #59) */
.crud-modal__thumb {
    max-width: 80px;
    max-height: 60px;
    border-radius: 8px;
}

/* Иконка ошибки загрузки формы (backlog #59) */
.crud-modal__error-icon {
    font-size: 48px;
    color: var(--md-error);
}

/* ========== Адаптивность ========== */
@media (max-width: 640px) {
    .crud-modal__container,
    .modal-container {
        width: 95%;
        max-height: 90vh;
    }

    .crud-modal__header,
    .crud-modal__body,
    .crud-modal__footer,
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .crud-modal__view-grid,
    .crud-modal__form {
        grid-template-columns: 1fr;
    }

    .crud-modal__field--full,
    .crud-modal__form-group--full {
        grid-column: span 1;
    }

    .crud-modal__title,
    .modal-header h2 {
        font-size: 1.1rem;
    }
}

/* ========== Анимации ========== */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================
   Person-search / profile modals (.ps-*)
   Shared modal shell used by people/profile.php and profile/modals.php
   ============================================ */
.ps-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    /* Скрыт по умолчанию; JS показывает модалку, выставляя style.display (см. app.js).
       Раньше скрытие задавалось инлайн-стилем на каждом окне (backlog #36). */
    display: none;
    align-items: center;
    justify-content: center;
}

/* Открытое окно (если JS выставляет атрибут, а не style.display) */
.ps-modal[data-open="1"],
.ps-modal.is-open {
    display: flex;
}

.ps-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.ps-modal__container {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--md-surface);
    border-radius: 20px;
    box-shadow: var(--md-elevation-4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ps-modal__container--lg {
    max-width: 720px;
}

/* Окно загрузки фото: ширина подбирается под пропорцию кропа (см. --photo-stage-w). */
.ps-modal__container--lg.ps-modal__container--photo {
    width: calc(var(--photo-stage-w, 380px) + 48px);
    max-width: min(96vw, 700px);
}

.ps-modal__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--md-surface-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ps-modal__header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.ps-modal__close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--md-text-secondary);
}

.ps-modal__container form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.ps-modal__body {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Окно загрузки фото: тело прокручивается только при переполнении, сцена
   не сжимается (иначе crop-бокс снова станет меньше окна). */
.ps-modal__container--photo .ps-modal__body {
    flex: 0 0 auto;
    overflow: visible;
}

.ps-modal__footer {
    padding: 12px 16px;
    border-top: 1px solid var(--md-surface-variant);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--md-surface);
    flex-shrink: 0;
}

/* ============================================
   Modal form fields (.ps-field / .ps-btn)
   ============================================ */
.ps-field {
    margin-top: 16px;
}

/* Поле формы без верхнего отступа (первое в блоке) */
.ps-field--flush {
    margin-top: 0;
}

/* Компактный вариант строки-чекбокса (меньше отступы; используется в списках).
   Специфичность выше, чем у .ps-field--checkbox, — правило идёт раньше него в файле. */
.ps-field--checkbox.ps-field--compact {
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    margin-top: 8px;
}

.ps-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--md-text-secondary);
}

/* Текстовые поля. Чекбоксы и радиокнопки исключены: иначе width: 100% перебивал
   .pp-checkbox из components.css и чекбокс растягивался на всю ширину строки. */
.ps-field input:not([type="checkbox"]):not([type="radio"]),
.ps-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--md-surface-variant);
    border-radius: 10px;
    background: var(--md-surface);
    color: var(--md-on-surface);
    font-size: 0.875rem;
    font-family: inherit;
}

.ps-field input:not([type="checkbox"]):not([type="radio"]):focus,
.ps-field select:focus {
    outline: none;
    border-color: var(--md-link);
}

.ps-field .required {
    color: #f44336;
}

.ps-field--checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--md-surface-variant);
    border-radius: 10px;
    cursor: pointer;
}

.ps-field--checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--md-link);
    cursor: pointer;
}

.ps-field--checkbox span {
    font-size: 0.875rem;
    color: var(--md-on-surface);
    cursor: pointer;
}

.ps-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.ps-field-grid .ps-field {
    margin-top: 0;
}

.ps-btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
}

.ps-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ps-btn--cancel {
    background: none;
    border: 1px solid var(--md-surface-variant);
    color: var(--md-text-secondary);
}

.ps-btn--primary {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.ps-btn--primary:hover:not(:disabled) {
    opacity: 0.9;
}

/* ============================================
   Загрузка фото с обрезкой (.ps-upload / редактор / превью)
   ============================================ */

/* Атрибут hidden всегда скрывает элемент, даже если класс задаёт display. */
.ps-modal [hidden] {
    display: none !important;
}

.ps-upload__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ps-upload__drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: var(--photo-stage-w, 380px);
    height: var(--photo-stage-h, 380px);
    flex: 0 0 auto;
    max-width: 100%;
    margin: 0 auto;
    padding: 24px 16px;
    border: 2px dashed var(--md-surface-variant);
    border-radius: 16px;
    background: var(--md-surface-variant);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.ps-upload__drop:hover {
    border-color: var(--md-link);
    background: rgba(98, 0, 238, 0.04);
}

.ps-upload__drop .material-icons {
    font-size: 40px;
    color: var(--md-link);
}

.ps-upload__title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--md-on-surface);
}

.ps-upload__hint {
    font-size: 0.8125rem;
    color: var(--md-text-secondary);
}

.ps-upload__actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.ps-upload__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.ps-upload__btn--camera {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.ps-upload__btn--camera:hover {
    filter: brightness(1.05);
}

.ps-photo-editor__canvas {
    position: relative;
    width: var(--photo-stage-w, 380px);
    height: var(--photo-stage-h, 380px);
    flex: 0 0 auto;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    background: var(--md-surface-variant);
    border-radius: 12px;
}

.ps-photo-editor__canvas > img {
    display: block;
    max-width: 100%;
}

/* Рамка обрезки МЕНЬШЕ окна и стоит по центру. Область вне рамки затемняется,
   чтобы было видно, что именно будет вырезано. */
.ps-photo-editor__canvas .cropper-container {
    border-radius: 12px;
}

.ps-photo-editor__canvas .cropper-modal {
    background: rgba(0, 0, 0, 0.5);
    opacity: 1;
}

.ps-photo-editor__canvas .cropper-wrap-box {
    border-radius: 12px;
}

.ps-photo-editor__canvas .cropper-view-box {
    outline: 2px solid var(--md-primary);
    outline-color: var(--md-link);
}

.ps-photo-editor__controls {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
}

.ps-photo-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.ps-photo-preview img {
    width: var(--photo-stage-w, 380px);
    max-width: 100%;
    max-height: var(--photo-stage-h, 380px);
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid var(--md-surface-variant);
    background: var(--md-surface-variant);
}

.ps-photo-preview__meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.ps-photo-preview__info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--md-text-secondary);
}

.ps-photo-preview__info .material-icons {
    font-size: 18px;
}

/* Toast-сообщения загрузки */
.ps-upload-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    background: var(--md-primary);
    color: var(--md-on-primary);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.4;
    max-width: 360px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ps-upload-toast--error {
    background: #d32f2f;
    color: #fff;
}

/* Cropper.js — фирменная тема */
.cropper-view-box {
    outline: 2px solid var(--md-primary);
    outline-color: var(--md-link);
}

.cropper-point {
    background-color: var(--md-link);
}

.cropper-line {
    background-color: var(--md-link);
}

/* Рамка фиксирована (ресайз не нужен) — скрываем маркеры рамки обрезки,
   чтобы они не отвлекали и не мешали перетаскиванию изображения. */
.ps-photo-editor__canvas .cropper-point {
    display: none;
}

.ps-photo-editor__canvas .cropper-center {
    display: none;
}

/* ============================================
   Компонент поиска человека (перенесено из
   app/views/components/person-search-modal.php, backlog #36)
   ============================================ */
.ps-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.ps-modal__container {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--md-surface);
    border-radius: 20px;
    box-shadow: var(--md-elevation-4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ps-modal__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--md-surface-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ps-modal__header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.ps-modal__close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--md-text-secondary);
}

.ps-modal__container form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.ps-modal__body {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.ps-modal__footer {
    padding: 12px 16px;
    border-top: 1px solid var(--md-surface-variant);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--md-surface);
    flex-shrink: 0;
}

/* Search */
.ps-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--md-surface-variant);
    border-radius: 12px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.ps-search:focus-within {
    border-color: var(--md-link);
}

.ps-search__icon {
    font-size: 20px;
    color: var(--md-text-secondary);
    flex-shrink: 0;
}

.ps-search__input {
    flex: 1;
    border: none;
    background: none;
    font-size: 0.9375rem;
    color: var(--md-on-surface);
    outline: none;
    font-family: inherit;
}

.ps-search__input::placeholder {
    color: var(--md-text-disabled);
}

.ps-search__spinner {
    flex-shrink: 0;
}

.ps-search__spinner .material-icons {
    font-size: 20px;
    color: var(--md-link);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Results */
.ps-results {
    margin-top: 16px;
    max-height: 250px;
    overflow-y: auto;
}

.ps-results__empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--md-text-secondary);
}

.ps-results__empty .material-icons {
    font-size: 40px;
    margin-bottom: 8px;
}

.ps-results__empty p {
    margin: 0;
    font-size: 0.875rem;
}

.ps-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.ps-result-item:hover {
    background: var(--md-surface-variant);
}

.ps-result-item.selected {
    background: rgba(98, 0, 238, 0.08);
    border: 1px solid var(--md-primary);
}

.ps-result-item__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--md-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ps-result-item__avatar .material-icons {
    font-size: 18px;
    color: var(--md-text-secondary);
}

/* Логотип организации в строке результатов поиска (backlog #59) */
.ps-result-item__avatar img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
}

.ps-result-item__info {
    flex: 1;
    min-width: 0;
}

.ps-result-item__name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--md-on-surface);
}

.ps-result-item__meta {
    font-size: 0.75rem;
    color: var(--md-text-secondary);
}

/* Selected person */
.ps-selected {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(98, 0, 238, 0.06);
    border: 1px solid var(--md-primary);
    border-radius: 12px;
}

/* Скрытие: удвоение класса даёт вес 0,2,0 и перебивает `.ps-selected { display: flex }` (backlog #36) */
.ps-selected.is-hidden {
    display: none;
}

.ps-selected__info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
}

.ps-selected__info .material-icons {
    color: var(--md-link);
    font-size: 20px;
}

.ps-selected__clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-text-secondary);
    padding: 4px;
}

.ps-selected__clear:hover {
    color: #f44336;
}

/* Extra fields: правила .ps-field label / input / select описаны выше
   (раздел «Modal form fields»); в блоке, перенесённом из компонента поиска,
   они дублировались и удалены. */

/* Buttons */
.ps-btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
}

.ps-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ps-btn--cancel {
    background: none;
    border: 1px solid var(--md-surface-variant);
    color: var(--md-text-secondary);
}

.ps-btn--primary {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.ps-btn--primary:hover:not(:disabled) {
    opacity: 0.9;
}

/* ============================================
   Перенесено из app/views/components/person-modal.php (backlog #36)
   ============================================ */
.person-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    transition: visibility 0.3s;
}

.person-modal.visible {
    visibility: visible;
}

.person-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s;
}

.person-modal.visible .person-modal__overlay {
    opacity: 1;
}

.person-modal__container {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--md-surface);
    border-radius: 20px;
    box-shadow: var(--md-elevation-4);
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: all 0.3s;
}

.person-modal.visible .person-modal__container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.person-modal__header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--md-surface-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.person-modal__header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.person-modal__close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--md-text-secondary);
}

.person-modal__body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.person-modal__footer {
    padding: 16px 24px;
    border-top: 1px solid var(--md-surface-variant);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel, .btn-edit, .btn-save {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

.btn-cancel {
    background: none;
    border: 1px solid var(--md-surface-variant);
    color: var(--md-text-secondary);
}

.btn-edit {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.btn-save {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--md-text-secondary);
    text-transform: uppercase;
}

.info-value {
    font-size: 0.9rem;
    color: var(--md-on-surface);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--md-text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--md-surface-variant);
    border-radius: 10px;
    background: var(--md-surface);
    color: var(--md-on-surface);
    font-size: 0.875rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--md-text-secondary);
}
