:root {
  --bg: #f6f4ef;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --accent: #0f6b5c;
  --err: #b42318;
  --ok: #067647;
  --border: #e4e0d8;
  --font: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: linear-gradient(160deg, #f6f4ef 0%, #e8f0ee 100%);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(255,255,255,.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.top nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--muted); }
.wrap { max-width: 880px; margin: 0 auto; padding: 24px 16px 64px; }
.card, .auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin: 16px 0;
}
.auth-card { max-width: 420px; margin: 48px auto; }
label { display: block; margin: 12px 0; font-size: 14px; }
input[type=text], input[type=email], input[type=password], textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit;
}
button, .btn {
  display: inline-block;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.secondary { background: #445; }
button.danger { background: var(--err); }
button.linkish, .linkish {
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; margin: 0; font: inherit;
}
.muted { color: var(--muted); font-size: 14px; }
.err { color: var(--err); }
.ok { color: var(--ok); }
.snippet {
  background: #111; color: #e8e8e8; padding: 12px; border-radius: 10px;
  overflow-x: auto; font-size: 13px;
}
.list { list-style: none; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.chk { display: flex; gap: 8px; align-items: center; }
.chk input { width: auto; margin: 0; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--border); }
.bubble.in { align-self: flex-start; }
.bubble.out { align-self: flex-end; background: #e7f5f1; }
.bubble.owner { align-self: flex-end; background: #dbeafe; }
.bubble .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.table th, .table td { border: 1px solid var(--border); padding: 8px; vertical-align: top; }
.actions form { display: inline-block; margin: 2px; }
.actions button { margin-top: 0; padding: 6px 8px; font-size: 12px; }
.inline { display: inline; }
.mt { margin-top: 24px; }
.row-form label.chk { margin: 8px 0; }

/* Внутренний Помощник */
.sa-asst {
  position: fixed; right: 20px; bottom: 20px; z-index: 1200;
  font-family: var(--font);
}
.sa-asst__launcher {
  border: 0; border-radius: 999px; padding: 14px 20px;
  background: var(--accent); color: #fff; font-weight: 600;
  cursor: pointer; box-shadow: 0 10px 28px rgba(15,107,92,.28);
}
.sa-asst.is-open .sa-asst__launcher { display: none; }
.sa-asst__panel {
  display: none; flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 40px));
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15,23,42,.16); overflow: hidden; margin-bottom: 10px;
}
.sa-asst.is-open .sa-asst__panel { display: flex; }
.sa-asst__header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: #f8faf9;
}
.sa-asst__title { font-weight: 700; }
.sa-asst__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sa-asst__close { border: 0; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; }
.sa-asst__progress {
  padding: 8px 14px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--border); background: #fafafa;
}
.sa-asst__messages {
  flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px;
  background: #fbfbfa;
}
.sa-asst__msg {
  max-width: 88%; padding: 10px 12px; border-radius: 12px;
  white-space: pre-wrap; word-break: break-word; font-size: 14px;
}
.sa-asst__msg--bot { align-self: flex-start; background: #eef5f2; }
.sa-asst__msg--user { align-self: flex-end; background: var(--accent); color: #fff; }
.sa-asst__finish { padding: 8px 12px; border-top: 1px solid var(--border); }
.sa-asst__finish button { margin-top: 0; width: 100%; }
.sa-asst__form {
  display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: #fff;
}
.sa-asst__form textarea {
  flex: 1; resize: none; min-height: 40px; margin: 0;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font: inherit;
}
.sa-asst__form button {
  margin: 0; width: 40px; height: 40px; border-radius: 10px; padding: 0;
}
.card--onboarding { border-color: #b7d9d0; background: #f3faf7; }

/* Админка */
.admin-shell { display: flex; min-height: 100vh; }
.admin-nav {
  width: 220px; background: #fff; border-right: 1px solid var(--border);
  padding: 20px 14px; flex-shrink: 0;
}
.admin-nav a {
  display: block; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: var(--text); margin-bottom: 4px;
}
.admin-nav a:hover, .admin-nav a.is-active { background: #eef5f2; color: var(--accent); }
.admin-nav .brand { font-weight: 700; margin-bottom: 18px; display: block; color: var(--text); text-decoration: none; }
.admin-main { flex: 1; padding: 24px; max-width: 1100px; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: #eef5f2; color: var(--accent);
}
.pill--warn { background: #fff4e5; color: #9a6700; }
.pill--err { background: #fdecea; color: var(--err); }
.pill--ok { background: #e8f6ee; color: var(--ok); }
@media (max-width: 720px) {
  .admin-shell { flex-direction: column; }
  .admin-nav { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
}

/* Страница настроек админки */
.field { display: block; margin-bottom: 12px; }
.field input { width: 100%; max-width: 420px; margin-top: 4px; }
.field .muted { display: block; }
.err-box { background: var(--err-bg, #fdecea); border: 1px solid var(--err, #c0392b); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.env-only { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; }
.env-only dt { color: var(--muted, #666); }
.env-only dd { margin: 0; overflow-wrap: anywhere; }
button.primary { background: var(--accent, #0f6b5c); color: #fff; }
