:root {
  --accent: #2aabee;
  --accent-dark: #1c8cc7;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1c2733;
  --text-dim: #6b7785;
  --border: #e1e6eb;
  --sidebar: #17212b;
  --sidebar-text: #aebacc;
  --sidebar-active: #2b5278;
  --green: #2ea043;
  --yellow: #d29922;
  --red: #d1383d;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- экран во весь экран (активация, мастер настройки) ---------- */
.full-screen {
  width: 100%; min-height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #17212b, #223549);
  padding: 24px 16px; box-sizing: border-box;
}
.full-card {
  background: var(--card); border-radius: 14px; padding: 36px 40px;
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.full-card h1 { margin: 0 0 6px; font-size: 20px; }
.full-card p.hint { color: var(--text-dim); margin: 0 0 20px; font-size: 13px; }
.logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.logo-dot {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff;
}
.logo-row b { font-size: 17px; }

/* ---------- сайдбар + контент ---------- */
.sidebar {
  width: 220px; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .brand { padding: 18px 16px; display: flex; align-items: center; gap: 10px; font-weight: 600; color: #fff; }
.sidebar nav { flex: 1; padding: 6px; }
.sidebar nav .item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 2px 0;
  border-radius: 8px; cursor: pointer; font-size: 13.5px; user-select: none;
}
.sidebar nav .item:hover { background: rgba(255,255,255,.06); }
.sidebar nav .item.active { background: var(--sidebar-active); color: #fff; }
.sidebar .sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 0 6px;
  border-radius: 8px; font-size: 13.5px; color: var(--sidebar-text); text-decoration: none;
}
.sidebar .sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .engine-box { margin: 10px; padding: 12px; border-radius: 10px; background: rgba(255,255,255,.05); }
.sidebar .engine-box .state { font-size: 12px; color: var(--sidebar-text); margin-bottom: 8px; }
.sidebar .engine-box .state b { color: #fff; }

.content { flex: 1; overflow-y: auto; padding: 28px 32px; }
.content h2 { margin: 0 0 4px; font-size: 20px; }
.content .subtitle { color: var(--text-dim); margin: 0 0 20px; font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; background: #fff; color: var(--text); font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 14px; }
.field .help { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }

button {
  font-family: inherit; font-size: 13.5px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; background: var(--accent); color: #fff;
  font-weight: 500;
}
button:hover { background: var(--accent-dark); }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: #fff; color: var(--text); border-color: var(--border); }
button.secondary:hover { background: #f5f6f8; }
button.danger { background: var(--red); }
button.danger:hover { background: #b02f34; }
button.small { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 6px; }

.error-text { color: var(--red); font-size: 12.5px; margin-top: 8px; }
.ok-text { color: var(--green); font-size: 12.5px; margin-top: 8px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: #d9f4e0; color: #1a7a34; }
.badge.yellow { background: #fdf1d6; color: #93690a; }
.badge.red { background: #fbdadb; color: #a3272b; }
.badge.gray { background: #eceff2; color: var(--text-dim); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table tr:last-child td { border-bottom: none; }

.console {
  background: #0e1621; color: #b9c6d4; font-family: Consolas, "Courier New", monospace;
  font-size: 12px; padding: 12px; border-radius: 8px; height: 240px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}

.lead-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.lead-card .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.lead-card .summary { font-weight: 600; margin-bottom: 6px; }
.lead-card .quote { background: #f7f8fa; border-left: 3px solid var(--accent); padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 8px; }
.lead-card .meta { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.lead-card .links a { color: var(--accent-dark); text-decoration: none; font-size: 12.5px; margin-right: 14px; }

.stat-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 120px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; }
.stat-box .num { font-size: 24px; font-weight: 700; }
.stat-box .label { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.hidden { display: none !important; }
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.instructions h4 { margin: 18px 0 6px; }
.instructions ol, .instructions ul { margin: 4px 0 4px 18px; padding: 0; }
.instructions code { background: #eceff2; padding: 1px 5px; border-radius: 4px; }

/* ---------- веб-специфика ---------- */
.banner {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.banner.warn { background: #fdf1d6; color: #93690a; border: 1px solid #f3dfa8; }
.banner.info { background: #e3f2fb; color: #1c6a91; border: 1px solid #bfe0f2; }

.pool-list { display: flex; flex-direction: column; gap: 10px; }
.pool-row {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer;
}
.pool-row:hover { border-color: var(--accent); }
.pool-row .name { font-weight: 600; }
.pool-row .meta { color: var(--text-dim); font-size: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border); font-size: 12.5px; cursor: pointer; user-select: none; margin: 3px;
}
.chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

.back-link { color: var(--accent-dark); text-decoration: none; font-size: 13px; display: inline-block; margin-bottom: 12px; cursor: pointer; }

.admin-wrap { max-width: 900px; margin: 0 auto; padding: 32px; }

/* ---------- виджет связи с админом ---------- */
#contact-widget { position: fixed; right: 22px; bottom: 22px; z-index: 40; }
#contact-toggle {
  width: 48px; height: 48px; border-radius: 50%; padding: 0; font-size: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
#contact-panel {
  position: absolute; right: 0; bottom: 60px; width: 300px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
#contact-panel .contact-head { font-weight: 600; margin-bottom: 6px; }
#contact-panel textarea { min-height: 90px; }
@media (max-width: 480px) {
  #contact-widget { right: 12px; bottom: 12px; }
  #contact-panel { width: calc(100vw - 24px); right: -12px; }
}

#telegram-login-widget {
  display: flex; justify-content: center; align-items: center;
  margin-top: 22px; min-height: 44px;
}

/* ---------- адаптив: мобильные экраны ---------- */
@media (max-width: 720px) {
  #app { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 4px 8px; }
  .sidebar .brand { padding: 10px 8px; }
  .sidebar nav { display: flex; flex: 1 1 auto; overflow-x: auto; padding: 0; gap: 2px; }
  .sidebar nav .item { flex: 0 0 auto; white-space: nowrap; margin: 4px 2px; }
  .sidebar .engine-box { margin: 6px; padding: 8px 10px; }
  .content { padding: 16px; overflow-y: visible; }
  .row > * { min-width: 100%; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .admin-wrap { padding: 16px !important; }
}
