/* ЛК для ЛПК — оформление интерфейса.
   Плотная сетка: оператор работает за компьютером, экран должен вмещать много. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dde3e9;
  --text: #1c2530;
  --muted: #6b7684;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Шапка --------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav a.active { background: #eff4ff; color: var(--accent); }

.user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-name { font-weight: 500; }

/* --- Каркас страницы ------------------------------------------------ */

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-head h1 { font-size: 22px; margin: 0; }
.page-actions { display: flex; gap: 8px; }

/* --- Карточки и формы ----------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.card h3 { font-size: 14px; margin: 18px 0 8px; }

.form label { display: block; margin-bottom: 14px; font-weight: 500; }
.form label small { display: block; font-weight: 400; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=date], input[type=datetime-local], input[type=number], input[type=tel],
input:not([type]), select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }

label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  margin-bottom: 8px;
}
label.checkbox input { width: auto; margin: 0; }

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.inline-form input, .inline-form select { width: auto; min-width: 180px; margin: 0; }

.form-actions { display: flex; gap: 8px; margin: 20px 0; }

/* Форма второго плана: нужна редко (подключить телефонию, завести кабинет),
   но должна быть под рукой — поэтому свёрнута, а не спрятана на другой экран. */
.subform { margin-top: 16px; }
.subform > summary { cursor: pointer; color: var(--accent); width: fit-content; }
.subform > summary:hover { text-decoration: underline; }
.subform > p { margin-top: 10px; }

/* --- Кнопки --------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #eff4ff; color: var(--accent); border-color: #cddbfd; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
/* Кнопка внутри поля формы: рядом с подписью, а не вровень с «Сохранить». */
.btn-small { padding: 4px 10px; font-size: 13px; margin-top: 6px; align-self: flex-start; }
.btn-ghost:hover { background: var(--bg); }
.btn-wide { width: 100%; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

form.inline { display: inline; }

/* --- Таблицы -------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th {
  background: #fafbfc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  font-weight: 600;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table-compact th, .table-compact td { padding: 6px 12px; }
.table .right { text-align: right; }

.row-archived { opacity: .55; }

/* --- Мелочи --------------------------------------------------------- */

.muted { color: var(--muted); }
.strong { font-weight: 600; }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.danger { color: var(--danger); }
.note { margin-top: 12px; font-size: 13px; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.badge-role { background: #eff4ff; border-color: #cddbfd; color: var(--accent); }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-ok { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
/* Третье состояние: не отказ и не успех. Красным красить нельзя — ничего не
   сломано; зелёным тоже — от человека всё-таки ждут, что он сверит глазами. */
.alert-warn { background: #fffbeb; color: var(--warn); border: 1px solid #fde68a; }

code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.setting-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.secret-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.secret-revealed {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 4px 10px;
  border-radius: 4px;
}

.stub-list { margin: 8px 0 16px; padding-left: 20px; color: var(--muted); }
.stub-list li { margin-bottom: 4px; }

/* --- Лиды ------------------------------------------------------------ */

.filters { padding: 14px 16px; margin-bottom: 16px; }
.filter-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filter-row label { margin: 0; font-size: 12px; color: var(--muted); font-weight: 500; }
.filter-row input, .filter-row select { min-width: 150px; }
.filter-row .grow { flex: 1; min-width: 220px; }
.filter-row .grow input { width: 100%; }
.filter-actions { display: flex; gap: 8px; }

.nowrap { white-space: nowrap; }

.badge-new { background: #eff4ff; border-color: #cddbfd; color: var(--accent); }
.badge-moderation { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.badge-ok { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.badge-rejected { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
/* Подпись всегда над значением: иначе «Проект» и название слипаются в строку. */
.meta-grid span { display: block; font-size: 12px; margin-bottom: 2px; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 16px; }

/* --- Вход и ошибки --------------------------------------------------- */

.login-page, .error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card, .error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, .08);
}
.login-card h1, .error-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .muted { margin: 0 0 20px; }
.login-card label { display: block; margin-bottom: 14px; font-weight: 500; }
.error-card { text-align: center; }
.error-card p { color: var(--muted); margin-bottom: 20px; }

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 12px; }
  .container { padding: 16px; }
}

/* Подпись «Спрашиваю Google…» видна только пока запрос идёт. Без этого
   правила она висит на экране всегда и превращается в ложное «грузится».
   Класс ставит и снимает htmx, поэтому имя менять нельзя. */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Длинный текст отказа доставки переносится, а не растягивает таблицу
   на два экрана вширь. */
.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
