/* NPChat — страницы входа/регистрации, кабинет и админка: общий фундамент.
   Стиль — как у сайта npshev.ru (тема site/1/wp-content/themes/npshev): светло-серый фон,
   белые скруглённые листы, тёмные кнопки, ярко-зелёный акцент, шрифт Onest (свой, не Google). */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --fog: #F3F4F6;          /* фон сайта */
  --sheet: #FFFFFF;
  --ink: #23262B;          /* тёмные панели и кнопки сайта */
  --ink-2: #2E3238;
  --muted: #6B7280;
  --rule: #D9DCE1;
  --rule-soft: #E8EAED;
  --accent: #2BDB7C;       /* ярко-зелёный сайта: фон, метки, точки — не для текста на белом */
  --signal: #127A45;       /* тот же зелёный, затемнённый для текста и ссылок на белом (контраст ≥ 4.5) */
  --signal-deep: #0D5C33;
  --signal-soft: #DDF8E8;
  --alarm: #B42318;
  --alarm-soft: #FBE9E7;
  --radius: 14px;          /* кнопки и поля, как на сайте */
  --radius-lg: 28px;       /* листы */
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--fog); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--fog);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.03em; }
a { color: var(--signal); text-underline-offset: 3px; }
a:hover { color: var(--signal-deep); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

/* Логотип: знак NPChat (облачко «NP» с зелёной точкой, static/brand/logo.svg) + «Chat» */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
}
.logo:hover { color: var(--ink); }
.logo img { display: block; width: 40px; height: 40px; }
.logo small { margin-left: 4px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--muted); }

/* --- Вход/регистрация: белый лист с формой + зелёная панель с окном чата --- */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 600px) 1fr;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}
.auth-form-side {
  display: flex;
  flex-direction: column;
  padding: 32px 48px;
  background: var(--sheet);
  border-radius: var(--radius-lg);
}
.auth-form {
  width: 100%;
  max-width: 420px;
  margin: auto 0;
  padding: 40px 0;
}
.auth-form h1 {
  margin: 0 0 10px;
  font-size: 38px;
  line-height: 1.1;
  font-weight: 700;
}
.lead { margin: 0 0 28px; font-size: 17px; color: var(--muted); }
/* Маркер-выделение главного обещания: зелёная заливка «прочерчивается» слева направо при открытии */
.highlight {
  padding: 1px 6px;
  margin: 0 -2px;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(var(--accent), var(--accent)) no-repeat left center / 100% 100%;
  border-radius: 6px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
@media (prefers-reduced-motion: no-preference) {
  .highlight { animation: highlight-draw .7s cubic-bezier(.2, .7, .2, 1) .4s both; }
}
@keyframes highlight-draw { from { background-size: 0 100%; } to { background-size: 100% 100%; } }
.auth-foot { margin: 0; font-size: 14px; color: var(--muted); }
.auth-foot a { color: var(--muted); }

/* --- Поля и кнопки --- */
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin-bottom: 8px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.field input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--sheet);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.field input:hover { border-color: #B8BDC5; }
.field input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px var(--signal-soft); }
.field input[aria-invalid="true"] { border-color: var(--alarm); box-shadow: 0 0 0 4px var(--alarm-soft); }
.field-error { margin: 0 0 8px; font-size: 14px; color: var(--alarm); }
.field-error a { color: var(--alarm); font-weight: 600; }
.hint { margin: 6px 0 0; font-size: 14px; color: var(--muted); }

.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 52px; }
.eye {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.eye:hover { color: var(--ink); background: var(--fog); }
.eye svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Главная кнопка — тёмная, как «Обсудить задачу» на сайте */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 0 26px;
  font: 500 17px/1 var(--font);
  color: #fff;
  background: var(--ink);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #000; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-quiet {
  width: auto;
  min-height: 44px;
  padding: 0 18px;
  font-size: 15px;
  color: var(--ink);
  background: var(--sheet);
  border-color: var(--rule);
}
.btn-quiet:hover { background: var(--sheet); border-color: var(--ink); }

.links { margin: 22px 0 0; font-size: 16px; }
.links p { margin: 8px 0; }

/* Сообщения формы */
.notice {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 15px;
}
.notice-error { color: var(--alarm); background: var(--alarm-soft); }
.notice-ok { color: var(--signal-deep); background: var(--signal-soft); }
.notice .btn-quiet { margin-top: 10px; }
/* Код из письма: 6 цифр, проверка без кнопки. Зелёная рамка — верно и входим, красная — нет */
.code-field { margin: 22px 0 0; }
.field .code-input {
  max-width: 240px;
  height: 64px;
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .35em;
  text-align: center;
}
.field .code-input.is-ok,
.field .code-input.is-ok:disabled { border: 3px solid var(--accent); box-shadow: 0 0 0 4px var(--signal-soft); opacity: 1; }
.field .code-input.is-bad { border: 3px solid var(--alarm); box-shadow: 0 0 0 4px var(--alarm-soft); }
.code-msg { margin-bottom: 14px; }
.code-msg-ok { color: var(--signal); font-weight: 600; }
.code-msg-bad { color: var(--alarm); }
@media (prefers-reduced-motion: no-preference) {
  .field .code-input.is-bad { animation: shake .3s ease-in-out; }
}
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.resend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.resend .hint { margin: 0; font-variant-numeric: tabular-nums; }
.btn-quiet:disabled { cursor: not-allowed; }
.btn-quiet:disabled:hover { border-color: var(--rule); }

/* --- Панель с окном чата: продукт объясняет страницу сам. Зелёный — только рамкой окна,
   как карточка на npshev.ru (сплошной зелёный фон панели утомлял — решение владельца) --- */
.auth-chat-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 48px;
  background: var(--sheet);
  border-radius: var(--radius-lg);
}
/* Окно — копия виджета для посетителей (app/static/widget.js): тот же размер 370 × 536 внутри
   рамки, тёмная шапка, серая переписка, посетитель справа тёмным, оператор слева белым.
   Размер фиксирован — окно не «едет», пока появляются реплики (решение владельца 2026-11-04) */
.chat-window {
  display: flex;
  flex-direction: column;
  flex: none;
  width: 394px;
  max-width: 100%;
  height: 560px;
  overflow: hidden;
  background: var(--sheet);
  border: 12px solid var(--accent);
  border-radius: 36px;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  color: #fff;
  background: var(--ink);
}
.chat-head .avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: var(--ink);
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
}
.chat-head .avatar::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--accent);
}
.chat-title { font-size: 16px; font-weight: 600; }
.chat-head .status { display: block; font-size: 13px; font-weight: 400; opacity: .7; }
.chat-x { margin-left: auto; padding: 0 6px; font-size: 22px; line-height: 1; }
.chat-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 16px; overflow: hidden; background: var(--fog); }
.msg {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.45;
  border-radius: 18px;
}
.msg-operator { align-self: flex-start; color: var(--ink); background: var(--sheet); border-bottom-left-radius: 6px; }
.msg-visitor { align-self: flex-end; color: #fff; background: var(--ink); border-bottom-right-radius: 6px; }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 14px 16px; border-radius: 18px; background: var(--sheet); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); opacity: .35; }
.chat-foot { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--rule-soft); }
.chat-input {
  flex: 1;
  min-height: 44px;
  padding: 11px 14px;
  font-size: 15px;
  color: var(--muted);
  border: 1.5px solid var(--rule);
  border-radius: 14px;
}
.chat-send { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px; color: var(--ink); background: var(--accent); }
.chat-send svg { width: 20px; height: 20px; }
.chat-brand { margin: 0; padding: 0 0 10px; text-align: center; font-size: 12px; color: var(--muted); }
.chat-caption { max-width: 400px; margin: 0; text-align: center; font-size: 16px; color: var(--ink); }

/* Единственная анимация: приветствие уже есть → реплика посетителя → оператор печатает → ответ */
@media (prefers-reduced-motion: no-preference) {
  .chat-body > * { animation: msg-in .35s ease-out both; }
  .chat-body > .msg-greet { animation: none; }
  .chat-body > .msg-greet + * { animation-delay: .4s; }
  .chat-body > .typing { animation: typing-life 1.4s ease-out 1s both; }
  .chat-body > .typing i { animation: blink 1s infinite; }
  .chat-body > .typing i:nth-child(2) { animation-delay: .15s; }
  .chat-body > .typing i:nth-child(3) { animation-delay: .3s; }
  .chat-body > .typing + .msg-operator { animation-delay: 2.4s; }
  .chat-body > .typing ~ .msg-visitor { animation-delay: 3.4s; }
}
@media (prefers-reduced-motion: reduce) { .chat-body > .typing { display: none; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 1; } }
@keyframes typing-life {
  0% { opacity: 0; transform: translateY(8px); }
  15%, 85% { opacity: 1; transform: none; }
  100% { opacity: 0; height: 0; padding: 0; margin: -4px 0; }
}

/* --- Служебные страницы после входа (временно до шага 4) --- */
.shell { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.shell-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 32px; }
.shell h1 { margin: 0 0 8px; font-size: 32px; }
.panel { padding: 28px; background: var(--sheet); border-radius: var(--radius-lg); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 20px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.badge-trial { color: var(--signal-deep); background: var(--signal-soft); }
.badge-active { color: var(--ink); background: var(--accent); }
.badge-suspended { color: var(--alarm); background: var(--alarm-soft); }
.page-admin.auth { grid-template-columns: minmax(0, 600px); justify-content: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); }
td.name { white-space: normal; font-weight: 600; }
.muted { color: var(--muted); }
.empty { padding: 32px 0; text-align: center; color: var(--muted); }

/* --- Телефон: только форма --- */
@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; padding: 10px; }
  .auth-chat-side { display: none; }
  .auth-form-side { padding: 24px 16px 28px; border-radius: 22px; }
  .auth-form { padding: 32px 0; }
  .auth-form h1 { font-size: 30px; }
}

/* Подключение 2FA супер-админа */
.step { display: flex; align-items: center; gap: 10px; margin: 28px 0 6px; font-size: 18px; }
.step span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 14px; font-weight: 700; color: var(--ink); background: var(--accent); }
.step-hint { margin: 0 0 14px; }
.qr-box { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 8px; }
.qr-box img { flex: none; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }
.qr-box .hint { flex: 1 1 180px; margin: 0; }
.secret { font: 600 14px/1.6 ui-monospace, Menlo, monospace; letter-spacing: .04em; word-break: break-all; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px; margin: 0 0 16px; padding: 16px 16px 16px 40px; border: 1px dashed var(--rule); border-radius: var(--radius); background: var(--fog); font: 600 15px/1.6 ui-monospace, Menlo, monospace; }
.actions { display: flex; gap: 10px; margin: 0 0 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--signal); }
@media (max-width: 420px) { .recovery-codes { grid-template-columns: 1fr; } }
#to-panel:disabled { cursor: not-allowed; }
.link-btn { padding: 0; font: inherit; color: var(--signal); background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--signal-deep); }
#code-step .notice { margin-bottom: 18px; }
