/* ИИ-админ — ИИ-чат: список чатов, сообщения, ответ ИИ (markdown), карточки задач и подтверждений; «Задачи». */
.chat-layout { display: flex; height: calc(100vh - 81px); min-height: 500px; border: 1px solid var(--card-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
/* в чате страница занимает ровно экран, поле ввода всегда видно */
body.chat-mode .content { height: 100vh; min-height: 0; overflow: hidden; }
body.chat-mode .page-body { padding: 16px 20px; min-height: 0; display: flex; flex-direction: column; }
body.chat-mode .chat-layout { flex: 1; height: auto; min-height: 0; }
body.chat-mode .chat-main, body.chat-mode .chat-sidebar { min-height: 0; }
@media (max-width: 1023px) {
  body.chat-mode #main-view { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  body.chat-mode .content { flex: 1 1 auto; height: auto; min-height: 0; }
  body.chat-mode #page-header { display: none; }
  body.chat-mode .page-body { padding: 8px 10px; }
}
.chat-sidebar { width: 260px; flex-shrink: 0; border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 0 -6px; padding: 0 6px; }
.chat-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--card); }
.chat-item-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--card); position: relative; }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; max-width: 80%; }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg-bubble { padding: 12px 16px; border-radius: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.user .msg-bubble { background: var(--accent); color: var(--on-accent); border-radius: 16px 16px 4px 16px; }
.msg.assistant .msg-bubble { background: var(--chip); border: 1px solid transparent; border-radius: 16px 16px 16px 4px; }
.ai-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(140deg, #ffb340, #ff7a00); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; margin-right: 10px; flex-shrink: 0; }
.system-note { align-self: center; background: color-mix(in srgb, var(--success) 10%, transparent); border: 1px solid color-mix(in srgb, var(--success) 25%, transparent); color: var(--success); padding: 8px 14px; border-radius: 999px; font-size: 12px; }
.chat-greeting { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.chat-greeting h2 { margin: 16px 0 8px; }
.suggestions-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; margin-top: 24px; max-width: 720px; }
.suggestion-card { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; cursor: pointer; transition: all .15s; }
.suggestion-card:hover { border-color: var(--accent); background: var(--hover); }
.suggestion-card svg { color: var(--accent); margin-bottom: 8px; }
.suggestion-card div { font-weight: 500; font-size: 13px; }
.chat-input-area { padding: 16px 28px 24px; border-top: 1px solid var(--line); background: var(--card); }
.chat-input-wrap { display: flex; align-items: flex-end; gap: 10px; background: var(--input-bg); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.chat-textarea { flex: 1; background: transparent; border: none; color: var(--text); resize: none; max-height: 200px; min-height: 24px; outline: none; font-size: 14px; line-height: 1.5; font-family: inherit; }
.chat-hint { text-align: center; color: var(--muted); font-size: 11px; margin-top: 8px; }
.chat-attach { font-size: 13px; color: var(--secondary); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.attach-btn { cursor: pointer; flex-shrink: 0; }
.send-btn { background: var(--accent); border: none; color: var(--on-accent); border-radius: 50%; }
.send-btn:hover { filter: brightness(1.1); }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--secondary); font-size: 13px; align-self: flex-start; margin-left: 38px; }
.thinking-dots { display: flex; gap: 4px; }
.thinking-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
.thinking-dots span:nth-child(2) { animation-delay: .2s; }
.thinking-dots span:nth-child(3) { animation-delay: .4s; }
.file-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); text-decoration: none; font-weight: 600; }
.file-link:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
@media (max-width: 900px) { .chat-sidebar { display: none; } .suggestions-grid { grid-template-columns: 1fr; } .chat-messages, .chat-input-area { padding-left: 16px; padding-right: 16px; } .msg { max-width: 92%; } }

/* ответ ИИ (markdown) */
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 16px 0 8px; color: var(--text); }
.markdown p { margin: 0 0 10px; }
.markdown ul, .markdown ol { margin: 0 0 10px 18px; padding: 0; }
.markdown li { margin-bottom: 4px; }
.markdown code { background: color-mix(in srgb, var(--text) 6%, transparent); padding: 2px 5px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }
.markdown pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; overflow: auto; }
.code-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--line); border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; font-size: 11px; color: var(--secondary); }
.code-header button { padding: 4px 8px; font-size: 11px; }
.markdown pre code { background: transparent; padding: 12px; display: block; font-size: 12px; color: var(--text); }
.markdown table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 6px 10px; }
.markdown th { background: var(--hover); color: var(--secondary); }

/* карточки задач и подтверждений в чате */
.task-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; max-width: 640px; }
.task-card.approval { border-left: 4px solid var(--accent); }
.task-card.approval.danger { border-left-color: var(--danger); }
.task-card-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.task-card.approval.danger .task-card-title { color: var(--danger); }
.task-purpose { color: var(--secondary); font-size: 13px; margin-bottom: 10px; }
.task-pcs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.task-actions { display: flex; gap: 10px; margin-top: 12px; }
.task-script { margin-bottom: 8px; }
.task-script summary { cursor: pointer; color: var(--accent); font-size: 12px; margin-bottom: 6px; }
.task-script pre { margin: 0; }
.task-summary { display: flex; align-items: center; gap: 8px; color: var(--secondary); font-size: 13px; cursor: pointer; padding: 8px 0; }
.task-details { display: none; flex-direction: column; gap: 10px; margin-top: 8px; }
.task-card.results.open .task-details { display: flex; }
.task-card.results.compact { padding: 6px 14px; background: transparent; border-style: dashed; }
.task-more { margin-left: auto; font-size: 12px; color: var(--muted); }
.task-step { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.task-step:last-child { border-bottom: 0; }
.task-step-title { font-size: 13px; font-weight: 600; color: var(--secondary); }
.pc-result-header { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.pc-result-header .status-badge { margin-left: auto; }
/* «Задачи»: раскрытая строка с выводом команды */
.task-detail-content { padding: 14px 16px; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 12px; }
.task-detail-content pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow: auto; max-height: 300px; margin: 8px 0 0; }
