:root {
  --bg: #f4f6f8; --panel: #ffffff; --border: #dde3ea; --text: #1c2733;
  --muted: #6b7a8c; --accent: #2563eb; --accent-dark: #1d4ed8;
  --green: #16a34a; --red: #dc2626; --yellow: #d97706;
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden;
}
button {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--panel); border-radius: 8px; padding: 8px 14px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  font: inherit; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; width: 100%; background: #fff; color: var(--text);
}
.hidden { display: none !important; }

/* Вход */
#login-view {
  height: 100vh; display: flex; align-items: center; justify-content: center;
}
#login-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: 340px; display: flex; flex-direction: column; gap: 12px;
}
#login-box h1 { font-size: 18px; }
#login-error { color: var(--red); font-size: 13px; min-height: 16px; }

/* Основной вид */
#app-view { display: flex; height: 100vh; }
#sidebar {
  width: 280px; min-width: 280px; background: var(--panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
#sidebar header {
  padding: 14px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
}
#sidebar header .who { font-size: 13px; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
#chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.chat-item:hover { background: #f0f4f9; }
.chat-item.active { background: #e8effc; }
.chat-item .t { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .d { font-size: 11px; color: var(--muted); }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eef2f7;
  color: var(--muted); white-space: nowrap;
}
.badge.run { background: #fff7e6; color: var(--yellow); }
.badge.done { background: #e9f9ef; color: var(--green); }
#sidebar footer { padding: 10px 14px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; }
#sidebar footer button { flex: 1; font-size: 13px; }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat-header {
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  font-weight: 600;
}
#messages { flex: 1; overflow-y: auto; padding: 20px; display: flex;
  flex-direction: column; gap: 12px; }
.msg { max-width: 76%; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px; }
.msg.system { align-self: flex-start; background: var(--panel);
  border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .time { display: block; font-size: 10px; opacity: .6; margin-top: 4px; }
.msg .file-link { display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 8px 12px; background: #e9f9ef; border-radius: 8px;
  color: var(--green); text-decoration: none; font-weight: 600; }

/* Подтверждение позиций */
.confirm-box { align-self: stretch; max-width: 100%; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.confirm-box h4 { font-size: 14px; margin-bottom: 8px; }
.confirm-box .warn { color: var(--red); font-size: 13px; margin: 6px 0; }
.confirm-box table { width: 100%; border-collapse: collapse; font-size: 13px; }
.confirm-box th, .confirm-box td { border: 1px solid var(--border); padding: 5px 8px;
  text-align: left; }
.confirm-box th { background: #f0f4f9; }
.confirm-box tr.invalid td { background: #fdecea; }
.confirm-box input { padding: 3px 6px; border-radius: 5px; }
.confirm-box .row-note { font-size: 11px; color: var(--yellow); }
.confirm-actions { display: flex; gap: 10px; margin-top: 10px; align-items: center;
  flex-wrap: wrap; }
.confirm-actions label { font-size: 13px; display: flex; gap: 6px; align-items: center; }

/* Прогресс */
.progress-box { align-self: flex-start; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px;
  font-size: 13px; min-width: 320px; }
.progress-box .bar { height: 6px; background: #eef2f7; border-radius: 3px;
  margin: 8px 0; overflow: hidden; }
.progress-box .bar div { height: 100%; background: var(--accent); transition: width .4s; }
.progress-box .pl { color: var(--muted); margin-top: 2px; }

#composer { padding: 14px 20px; background: var(--panel);
  border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; }
#composer textarea { resize: none; max-height: 140px; min-height: 42px; }
#empty-state { flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px; }

/* Админка */
.admin-body { overflow: auto; padding: 24px; height: 100vh; }
.admin-wrap { max-width: 1100px; margin: 0 auto; }
.admin-wrap h1 { font-size: 20px; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.card th, .card td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.card th { background: #f0f4f9; }
.status-ok { color: var(--green); font-weight: 600; }
.status-bad { color: var(--red); font-weight: 600; }
.status-unknown { color: var(--muted); }
.card textarea { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.form-row { display: flex; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 140px; }
.msg-note { font-size: 13px; margin-top: 8px; min-height: 16px; }
.msg-note.ok { color: var(--green); }
.msg-note.err { color: var(--red); white-space: pre-wrap; }
.shot { max-width: 100%; border: 1px solid var(--border); border-radius: 8px;
  margin-top: 10px; }
pre.log { background: #101418; color: #cfe3f5; padding: 12px; border-radius: 8px;
  font-size: 11px; overflow: auto; max-height: 400px; }
