/* Панель сотрудника ItManul — оформление повторяет WordPress-панель
   (cabinet-staff.php), чтобы переход был незаметным. */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body.im-staff-app {
    display: flex;
    min-height: 100vh;
    background: #f7f8fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: #2d3748;
    font-size: 16px;
    line-height: 1.5;
}

/* --- сайдбар --- */

.im-staff-sidebar {
    width: 260px;
    background: #1a202c;
    color: #cbd5e0;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.im-staff-sidebar-logo {
    padding: 0 1.5rem 1.5rem 1.5rem;
    border-bottom: 1px solid #2d3748;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.im-staff-sidebar-logo small {
    display: block;
    font-size: 0.75rem;
    color: #718096;
    font-weight: 400;
    margin-top: 0.2rem;
}

.im-staff-menu {
    flex: 1;
    overflow-y: auto;
}

.im-staff-menu a {
    display: block;
    padding: 0.7rem 1.5rem;
    color: #cbd5e0;
    text-decoration: none;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.im-staff-menu a:hover {
    background: #2d3748;
    color: #fff;
}

.im-staff-menu a.active {
    background: #2d3748;
    color: #fff;
    border-left-color: #4299e1;
    font-weight: 600;
}

.im-staff-logout {
    display: block;
    padding: 0.8rem 1.5rem;
    color: #a0aec0;
    text-decoration: none;
    font-size: 0.9rem;
    border-top: 1px solid #2d3748;
    margin-top: 1rem;
}

.im-staff-logout:hover { color: #fff; }

/* --- контент --- */

.im-staff-content {
    flex: 1;
    padding: 1.5rem 2rem 3rem 2rem;
    min-width: 0;
}

.im-staff-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.im-staff-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a202c;
}

.im-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.9rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.9rem;
    color: #4a5568;
}

.im-user-btn-name { font-weight: 600; }

/* --- карточки --- */

.im-cab-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
    margin-bottom: 1.5rem;
}

.im-cab-card h2 {
    margin: 0 0 1rem 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a202c;
}

.im-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.im-card-head h2 { margin: 0; }

.im-muted { color: #718096; font-size: 0.9rem; }

/* --- плитки главной --- */

.im-home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.im-home-tile {
    display: block;
    padding: 1.2rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.im-home-tile:hover {
    border-color: #4299e1;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(66, 153, 225, 0.15);
}

.im-home-tile-title {
    font-weight: 700;
    color: #2b6cb0;
    margin-bottom: 0.35rem;
}

.im-home-tile-sub {
    font-size: 0.85rem;
    color: #718096;
}

/* --- сборки --- */

.im-build-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.im-build-cell {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.9rem 1.2rem;
    min-width: 180px;
}

.im-build-label {
    font-size: 0.8rem;
    color: #718096;
    margin-bottom: 0.25rem;
}

.im-build-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a202c;
}

.im-build-sub {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 0.25rem;
}

.im-build-download {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    background: #2b6cb0;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.im-build-download:hover { background: #2c5282; }

.im-build-publish-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.5rem;
}

.im-build-pin {
    padding: 0.6rem 0.9rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 0.95rem;
    width: 160px;
}

.im-build-publish {
    padding: 0.65rem 1.2rem;
    background: #c05621;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.im-build-publish:hover { background: #9c4221; }
.im-build-publish:disabled { background: #a0aec0; cursor: default; }

.im-build-hint {
    font-size: 0.85rem;
    color: #718096;
    margin: 0.75rem 0 0 0;
    line-height: 1.5;
}

.im-build-result {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.im-build-result-ok {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.im-build-result-err {
    background: #fff5f5;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

/* --- таблица --- */

.im-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.im-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid #e2e8f0;
    color: #718096;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.im-table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
}

.im-table tr:hover td { background: #f7fafc; }

.im-table-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.im-table code {
    background: #edf2f7;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* --- бейджи и кнопки --- */

.im-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 0.75rem;
    font-weight: 600;
}

.im-badge-ok {
    background: #c6f6d5;
    color: #22543d;
}

.im-btn {
    display: inline-block;
    padding: 0.5rem 0.9rem;
    border: 1px solid #cbd5e0;
    background: #fff;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #2d3748;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.im-btn:hover { background: #f7fafc; border-color: #a0aec0; }

.im-btn-primary {
    background: #2b6cb0;
    border-color: #2b6cb0;
    color: #fff;
    font-weight: 600;
}

.im-btn-primary:hover { background: #2c5282; border-color: #2c5282; }

.im-btn-danger {
    background: #fff;
    border-color: #feb2b2;
    color: #c53030;
}

.im-btn-danger:hover { background: #fff5f5; border-color: #fc8181; }

.im-btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.im-btn-block { display: block; width: 100%; text-align: center; }

/* --- формы --- */

.im-field { margin-bottom: 1rem; flex: 1; min-width: 200px; }

.im-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.35rem;
}

.im-label-hint { font-weight: 400; }

.im-field input[type="text"],
.im-field input[type="password"],
.im-field textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    color: #2d3748;
    background: #fff;
}

.im-field input:focus,
.im-field textarea:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.im-field textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    resize: vertical;
}

.im-field-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.im-slug-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.im-slug-prefix {
    padding: 0 0.1rem 0 0.8rem;
    color: #a0aec0;
}

.im-slug-wrap input {
    border: none !important;
    box-shadow: none !important;
    padding-left: 0.2rem;
}

.im-form-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.im-alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.im-alert-error {
    background: #fff5f5;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

.im-preview-frame {
    width: 100%;
    height: 600px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
}

/* --- вход --- */

.im-login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f7f8fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: #2d3748;
    margin: 0;
}

.im-login-card {
    background: #fff;
    padding: 2.2rem 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
    width: 100%;
    max-width: 380px;
}

.im-login-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a202c;
    text-align: center;
}

.im-login-sub {
    text-align: center;
    color: #718096;
    font-size: 0.9rem;
    margin: 0.25rem 0 1.5rem 0;
}

.im-login-hint {
    text-align: center;
    color: #a0aec0;
    font-size: 0.8rem;
    margin: 1.2rem 0 0 0;
}

/* --- мобильный --- */

.im-staff-burger, .im-staff-overlay { display: none; }

@media (max-width: 1024px) {
    .im-staff-burger {
        display: inline-flex;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 1200;
        width: 44px;
        height: 44px;
        border-radius: 10px;
        border: none;
        background: #1a202c;
        color: #fff;
        font-size: 20px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .im-staff-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        z-index: 1100;
    }

    body.im-staff-nav-open .im-staff-overlay { display: block; }

    .im-staff-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1150;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    body.im-staff-nav-open .im-staff-sidebar { transform: translateX(0); }

    .im-staff-content { padding: 4.25rem 1rem 1.5rem 1rem; width: 100%; }
}

@media (max-width: 640px) {
    .im-staff-content { padding: 4.25rem 0.6rem 1.25rem 0.6rem; }
    .im-table { font-size: 0.82rem; }
    .im-table-actions { flex-direction: column; align-items: flex-start; }
}

/* --- методика --- */

.im-method-app {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    flex-wrap: wrap;
}

.im-method-app-info { display: flex; flex-direction: column; gap: 0.15rem; }
.im-method-app-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.im-course-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.im-course-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 1.05rem;
}

.im-course-toggle, .im-lesson-toggle {
    cursor: pointer;
    user-select: none;
    color: #4299e1;
    font-size: 0.9rem;
    width: 1rem;
    display: inline-block;
}

.im-course-desc { margin: 0.5rem 0 0 0; }

.im-course-body { margin-top: 1rem; border-top: 1px solid #edf2f7; padding-top: 0.75rem; }

.im-lesson {
    border: 1px solid #edf2f7;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.6rem;
    background: #fcfcfd;
}

.im-lesson-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.im-lesson-body { margin-top: 0.75rem; }

/* --- модальное окно --- */

.im-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.im-modal[hidden] { display: none; }

.im-modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.im-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

.im-modal-box select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: #2d3748;
}

.im-modal-box input[type="file"] {
    width: 100%;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

/* --- чаты --- */

.im-chat-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    min-height: calc(100vh - 8rem);
}

.im-chat-list {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
    overflow-y: auto;
    max-height: calc(100vh - 8rem);
}

.im-chat-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid #edf2f7;
}

.im-chat-item {
    display: block;
    padding: 0.7rem 1.1rem;
    border-bottom: 1px solid #f7fafc;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
}

.im-chat-item:hover { background: #f7fafc; }
.im-chat-item.active { background: #ebf8ff; border-left: 3px solid #4299e1; }

.im-chat-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.im-chat-item-title { font-weight: 600; font-size: 0.92rem; }

.im-chat-item-preview {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 0.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.im-chat-main {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 8rem);
}

.im-chat-main-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #edf2f7;
}

.im-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.im-msg {
    position: relative;
    background: #f7fafc;
    border-radius: 10px;
    padding: 0.6rem 0.85rem;
    max-width: 75%;
    align-self: flex-start;
}

.im-msg-own {
    background: #ebf8ff;
    align-self: flex-end;
}

.im-msg-head {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
    font-size: 0.82rem;
    margin-bottom: 0.2rem;
}

.im-msg-body { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; }

.im-msg-del {
    position: absolute;
    top: 0.25rem;
    right: 0.35rem;
    border: none;
    background: transparent;
    color: #a0aec0;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.12s;
}

.im-msg:hover .im-msg-del { opacity: 1; }
.im-msg-del:hover { color: #c53030; }

.im-chat-compose {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    padding: 0.85rem 1.2rem;
    border-top: 1px solid #edf2f7;
}

.im-chat-compose textarea {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.92rem;
    resize: vertical;
    min-height: 2.6rem;
}

.im-chat-compose textarea:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.im-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.im-stud-toolbar {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .im-chat-layout { grid-template-columns: 1fr; }
    .im-chat-list { max-height: 260px; }
    .im-msg { max-width: 90%; }
}

/* --- задачи --- */

.im-task-list { display: flex; flex-direction: column; gap: 0.6rem; }

.im-task {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.9rem;
    padding: 0.85rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    flex-wrap: wrap;
}

.im-task-done { background: #f7fafc; opacity: 0.75; }
.im-task-overdue { border-color: #feb2b2; background: #fffaf8; }

.im-task-main { display: flex; gap: 0.7rem; align-items: flex-start; flex: 1; min-width: 240px; }
.im-task-check { padding-top: 0.15rem; }
.im-task-check input { width: 18px; height: 18px; cursor: pointer; }

.im-task-body { flex: 1; min-width: 0; }

.im-task-title { font-weight: 600; font-size: 0.95rem; }
.im-task-done .im-task-title { text-decoration: line-through; color: #718096; }

.im-task-desc { margin-top: 0.2rem; font-size: 0.86rem; }

.im-task-meta {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
    font-size: 0.8rem;
}

.im-badge-danger { background: #fed7d7; color: #742a2a; }

/* --- чаты: дополнения к chat.css из WP --- */

.im-chat-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #3b82f6;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.im-chat-item.active .im-chat-unread {
    background: rgba(255, 255, 255, 0.28);
    color: #fff;
}

.im-chat-msg-del {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #e53e3e;
    color: #fff;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.im-chat-msg:hover .im-chat-msg-del { opacity: 1; }

.im-chat-input-area {
    display: flex;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    background: #fff;
    border-top: 1px solid #eef1f5;
    align-items: flex-end;
}

/* --- редактор страниц: панель инструментов --- */

.im-editor-tools {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
    padding: 0.6rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.im-editor-wrap { display: flex; gap: 1rem; }

#im-html {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    tab-size: 2;
}

#im-assets-list code {
    background: #edf2f7;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.82rem;
}

/* --- визуальный редактор --- */

.im-visual-frame {
    width: 100%;
    height: 78vh;
    border: 1px solid #cbd5e0;
    border-radius: 10px;
    background: #fff;
}

.im-visual-hint {
    padding: 0.5rem 0.75rem;
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    border-radius: 8px;
    color: #2c5282;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.im-tools-sep {
    width: 1px;
    height: 22px;
    background: #e2e8f0;
    margin: 0 0.25rem;
}

#im-html {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    padding: 0.7rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
}

/* --- графики на главной: фиксированная высота, иначе Chart.js растит
       контейнер в grid и получается бесконечный рост --- */

.im-chart-box {
    position: relative;
    width: 100%;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.im-chart-box canvas {
    display: block !important;
    max-height: 100%;
    max-width: 100%;
}

.im-home-card {
    min-width: 0;
    overflow: hidden;
}
