:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #71808f;
  --line: #e3e8ee;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok: #157f3b;
  --err: #c0392b;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.error {
  color: var(--err);
  min-height: 1.2em;
  margin: 8px 0 0;
}
.ok {
  color: var(--ok);
}

/* Вход */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(20, 30, 50, 0.06);
}
.card h1 {
  margin: 0;
  font-size: 22px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
input,
select,
textarea {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea {
  min-height: 60px;
  resize: vertical;
}
button {
  font: inherit;
  cursor: pointer;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
button.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
}
button.small {
  padding: 5px 10px;
  font-size: 13px;
}

/* Шапка и навигация */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}
.spacer {
  flex: 1;
}
#nav button {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
}
#nav button.active {
  color: var(--accent);
}
main {
  max-width: 920px;
  margin: 24px auto;
  padding: 0 20px;
}
h2 {
  font-size: 19px;
  margin: 0 0 4px;
}
.hint {
  margin: 0 0 18px;
}

/* Таблицы-карточки */
.row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.row .key {
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  color: var(--muted);
}
.row .def {
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 8px;
  white-space: pre-wrap;
}
.row .controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row textarea,
.row input[type="text"] {
  width: 100%;
}
.pill {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
}
.pill.approved {
  background: #e7f6ec;
  color: var(--ok);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.formrow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.formrow label {
  flex: 1;
  min-width: 120px;
}
.saved {
  font-size: 13px;
}

/* Аналитика */
.row h3 {
  margin: 0 0 10px;
  font-size: 15px;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.stat {
  display: flex;
  flex-direction: column;
}
.stat b {
  font-size: 24px;
}
.stat span {
  color: var(--muted);
  font-size: 12px;
}
.barrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 5px 0;
}
.barlabel {
  width: 130px;
  font-size: 13px;
}
.bar {
  height: 10px;
  background: var(--accent);
  border-radius: 5px;
  display: inline-block;
  min-width: 2px;
}

/* Сообщения бота (CRM-4) */
.buttons-edit .controls {
  margin-top: 4px;
}
.buttons-edit .controls input[type="text"] {
  width: auto;
  flex: 1;
  min-width: 160px;
}
label.inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}

/* Строки с несколькими полями (дети, настройки-ссылки) — поля не на всю ширину */
.row .controls input[type="text"],
.row .controls input[type="number"],
.row .controls select {
  width: auto;
  flex: 1;
  min-width: 90px;
}
