/* Cosmic: проверка интерфейса сотрудника, изолированный режим только для чтения. */
:root { --imp-bar-height: 0px; }
body.impersonation-active { padding-top: var(--imp-bar-height) !important; }

.imp-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 10000;
    box-sizing: border-box;
    padding: 10px 18px;
    color: #fff;
    background: #17131f;
    border-bottom: 2px solid #e11d48;
    box-shadow: 0 8px 28px rgba(0,0,0,.45);
    font-size: 14px;
    line-height: 1.45;
}
.imp-bar-main { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px; min-width: 0; }
.imp-bar-main strong { min-width: 0; overflow-wrap: anywhere; }
.imp-lock { flex: 0 0 auto; }
.imp-purpose { min-width: 0; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e8e2ee; }
.imp-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: #fff; font-weight: 650; }
.imp-return, .imp-start {
    min-height: 44px;
    min-width: 44px;
    box-sizing: border-box;
    border: 1px solid #fb7185;
    border-radius: 10px;
    padding: 9px 15px;
    background: #be123c;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.imp-return:hover, .imp-start:hover { background: #9f1239; }
.imp-return:focus-visible, .imp-start:focus-visible, .imp-cancel:focus-visible,
.imp-target:focus-visible, .imp-search:focus-visible, .imp-dialog textarea:focus-visible,
.imp-details summary:focus-visible {
    outline: 3px solid #fda4af;
    outline-offset: 3px;
}
.imp-details { max-width: 100%; margin: 4px auto 0; width: fit-content; color: #e8e2ee; }
.imp-details summary { min-height: 44px; cursor: pointer; text-align: center; }
.imp-details div { max-width: min(760px, calc(100vw - 36px)); overflow-wrap: anywhere; padding: 5px 0; }
.imp-sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.imp-toast {
    position: fixed;
    z-index: 10002;
    top: calc(var(--imp-bar-height) + 12px);
    left: 50%;
    transform: translate(-50%, -8px);
    max-width: min(620px, calc(100vw - 28px));
    box-sizing: border-box;
    padding: 12px 16px;
    border: 1px solid #fb7185;
    border-radius: 12px;
    background: #3b1020;
    color: #fff;
    box-shadow: 0 10px 32px rgba(0,0,0,.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s, transform .18s;
    overflow-wrap: anywhere;
}
.imp-toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

.imp-card {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid var(--border-2, rgba(255,255,255,.12));
    border-radius: 16px;
    background: var(--surface-2, rgba(255,255,255,.025));
    box-shadow: 0 12px 32px rgba(0,0,0,.16);
}
.imp-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.imp-card h2 { margin: 0 0 7px; font-size: 19px; }
.imp-card p { margin: 0; color: var(--muted, #b9b4c2); line-height: 1.55; max-width: 78ch; }
.imp-readonly-badge { padding: 6px 10px; border: 1px solid rgba(251,113,133,.5); border-radius: 999px; color: #fda4af; white-space: nowrap; font-size: 12px; }
.imp-search-label { display: block; margin: 18px 0 7px; font-size: 13px; color: var(--muted, #c7c1cf); }
.imp-search {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    border: 1px solid var(--border-2, rgba(255,255,255,.18));
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface, #121218);
    color: var(--text, #fff);
    font: inherit;
}
.imp-target-list { display: grid; gap: 8px; margin-top: 12px; max-height: 420px; overflow-y: auto; }
.imp-target {
    display: grid;
    gap: 3px;
    min-height: 44px;
    padding: 11px 13px;
    text-align: left;
    border: 1px solid var(--border-2, rgba(255,255,255,.12));
    border-radius: 11px;
    background: var(--surface, #121218);
    color: var(--text, #fff);
    font: inherit;
    cursor: pointer;
}
.imp-target:hover:not(:disabled) { border-color: #e11d48; background: rgba(225,29,72,.08); }
.imp-target:disabled { cursor: not-allowed; opacity: .64; }
.imp-target-name { font-weight: 700; overflow-wrap: anywhere; }
.imp-target-meta { color: var(--muted, #b9b4c2); font-size: 12px; overflow-wrap: anywhere; }
.imp-target-reason { color: #fda4af; font-size: 12px; overflow-wrap: anywhere; }
.imp-empty { padding: 16px 4px; color: var(--muted, #b9b4c2); }

.imp-dialog {
    width: min(560px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    box-sizing: border-box;
    overflow-y: auto;
    padding: 22px;
    border: 1px solid rgba(251,113,133,.5);
    border-radius: 16px;
    background: #17131f;
    color: #fff;
    box-shadow: 0 20px 70px rgba(0,0,0,.65);
}
.imp-dialog::backdrop { background: rgba(0,0,0,.72); }
.imp-dialog h3 { margin: 0 0 14px; font-size: 20px; }
.imp-dialog p { line-height: 1.55; color: #d8d1df; overflow-wrap: anywhere; }
.imp-dialog label { display: block; margin: 16px 0 7px; font-weight: 650; }
.imp-dialog textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 10px;
    padding: 11px;
    background: #0f0d15;
    color: #fff;
    font: inherit;
}
.imp-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.imp-cancel {
    min-height: 44px;
    min-width: 44px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 10px;
    padding: 9px 15px;
    background: transparent;
    color: #fff;
    font: inherit;
    cursor: pointer;
}
.imp-error { min-height: 22px; margin-top: 8px; color: #fda4af; overflow-wrap: anywhere; }

.impersonation-active .imp-write {
    position: relative;
    cursor: not-allowed !important;
    outline: 1px dashed rgba(253,164,175,.8) !important;
    outline-offset: 2px;
}
.impersonation-active .imp-write::before { content: '🔒 '; }
.impersonation-active .imp-write::after {
    content: 'Только просмотр';
    display: inline-block;
    margin-left: 7px;
    font-size: .78em;
    color: #fda4af;
}

@media (max-width: 520px) {
    .imp-bar { padding: 8px 10px; font-size: 13px; }
    .imp-bar-main { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 9px; align-items: center; }
    .imp-lock { display: none; }
    .imp-bar-main strong { grid-column: 1 / -1; }
    .imp-purpose { max-width: none; white-space: normal; overflow-wrap: anywhere; }
    .imp-time { grid-column: 1; }
    .imp-return { grid-column: 2; grid-row: 2 / 4; max-width: 155px; padding: 8px 10px; }
    .imp-card { padding: 15px; }
    .imp-dialog { padding: 17px; }
    .imp-dialog-actions > button { flex: 1 1 150px; }
}

@media (prefers-reduced-motion: reduce) {
    .imp-toast { transition: none; }
}
