/* ============================================================================
   Админка Mini App: экраны этапа B (js/admin*.js). Примитивы - chekanka.css,
   общие карточки и чипы - screens.css (там же .adm-period, .adm-reply).

   Правила «Чеканки» здесь те же: у каждой поверхности верхний хайлайт
   (--e1/--e2), радиусы по назначению (строка списка 12, пилюля 999, чип 6),
   золото - одно на экран (ключевая сумма в шапке карточки), статусы своими
   цветами. Цели нажатия не меньше 44 px: одной рукой на телефоне.
   ========================================================================= */

/* Стек экранов: каждый экран - колонка с тем же шагом, что у .view. */
.adm-screen { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.adm-screen > * { animation: rise var(--t-mid) var(--spring) backwards; }
.adm-screen > *:nth-child(2) { animation-delay: 40ms; }
.adm-screen > *:nth-child(3) { animation-delay: 80ms; }
.adm-screen > *:nth-child(4) { animation-delay: 120ms; }
.adm-screen > *:nth-child(n+5) { animation-delay: 160ms; }
.adm-screen__body { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.adm-body { margin-top: 8px; min-width: 0; }
.adm-title { margin-bottom: -2px; }

/* Шесть периодов - сетка 3 x 2, без горизонтальной прокрутки на 320 px. */
.adm-period--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Вкладки карточки пользователя: слова длинные, на 320 px - по два в ряд. */
.adm-period--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.adm-period--2 .chip { overflow-wrap: normal; }

.adm-filters { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.adm-filters .chip,
.adm-screen > .filters .chip,
.adm-screen__body .filters .chip { height: 44px; padding: 0 13px; }
.adm-search { min-height: 48px; }

/* ---------------------------------------------------------- Сводка -- */

.adm-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.adm-metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--app-100);
  box-shadow: var(--inset);
}
.adm-metric__v {
  align-self: flex-start;
  max-width: 100%;
  font-size: 19px;
  font-weight: 650;
  color: var(--app-ink);
}
/* Оборот - строка сервера с 8 знаками: в половине сетки она не помещается
   и обрезалась прорезью одометра. Ключевая ячейка - во всю ширину. */
.adm-metric--key { grid-column: 1 / -1; order: -1; }
.adm-metric--key .adm-metric__v { color: var(--gold); }
.adm-metric__s {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--app-mute);
  overflow-wrap: anywhere;
}

.adm-badges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.adm-badges:empty { display: none; }
.adm-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
  text-align: left;
  box-shadow: var(--e1);
}
.adm-tiles .tile { min-height: 76px; justify-content: center; }

/* ------------------------------- Блоки главной: балансы и статистика -- */
/* Гильош лежит под карточкой балансов (один на экран). Холст исключён из
   общего правила: он position:absolute, и правило вернуло бы его в поток. */

.adm-home { overflow: hidden; }
.adm-home > *:not(canvas) { position: relative; z-index: 1; }
.adm-home__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.adm-bal .adm-home__head { min-height: 44px; margin: -8px 0 -6px; }
.adm-home__btn {
  flex: none;
  width: auto;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 13px;
}
.adm-home__btn:disabled { color: var(--app-mute); cursor: default; }
.adm-home__when { font-family: var(--mono); font-size: 11px; color: var(--app-mute); text-align: right; }

/* Тело с данными нажимается целиком и проседает (.press), как плитка. */
.adm-home__body.is-tap {
  margin-left: -6px;
  margin-right: -6px;
  padding: 2px 6px 4px;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.adm-home__body.is-tap:focus-visible { outline: 2px solid var(--gold-line); outline-offset: 2px; }
.adm-home__k {
  display: block;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--app-mute);
}
.adm-home__k:first-child { margin-top: 4px; }
.adm-home__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--app-300);
}
.adm-home__foot .adm-note { margin-top: 0; font-size: 12px; }
.adm-home__go { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--app-ink); white-space: nowrap; }
.adm-home__go::after { content: "\203A"; margin-left: 6px; color: var(--app-mute); }

.adm-bal__sum {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
  margin-top: 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--app-ink);
}
.adm-bal__sum .odo { max-width: 100%; }
.adm-bal__unit { font-size: 14px; font-weight: 600; letter-spacing: .02em; opacity: .72; }
.adm-bal__list { margin-top: 4px; }
.adm-bal .adm-big { margin-top: 4px; }

.adm-per__types { margin-top: 8px; }
.adm-per__types .adm-metric { padding: 9px 11px; gap: 4px; }
.adm-per__types .adm-metric__v { font-size: 17px; }
.adm-per__st { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.adm-per__list { margin-top: 6px; }

/* --------------------------------------------------- Строки списков -- */

.adm-list { display: flex; flex-direction: column; gap: 8px; }
.adm-listbox { min-height: 120px; }
.adm-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 11px 12px;
  border-radius: 12px;
  text-align: left;
  box-shadow: var(--e1);
}
.adm-item__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.adm-item__t { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.adm-item__m {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--app-mute);
  overflow-wrap: anywhere;
}
.adm-item__p {
  font-size: 13px;
  line-height: 1.35;
  color: var(--app-ink);
  opacity: .82;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.adm-item__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  max-width: 48vw;
}
.adm-item__sum {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.adm-foot { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.adm-foot:empty { display: none; }
.adm-foot__n { margin-top: 0; text-align: center; }
.adm-foot__err { display: flex; flex-direction: column; gap: 8px; }
.adm-more:disabled { color: var(--app-mute); cursor: default; }
.adm-empty__go { width: auto; min-height: 44px; margin-top: 4px; }
.adm-trace { font-size: 12px; }
.adm-sub { display: block; margin-top: 2px; font-size: 12px; }
.adm-sublabel { display: block; margin: 14px 0 2px; }
.adm-head { margin-bottom: 10px; }

.adm-star {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--app-ink);
  background: rgba(233,235,238,.08);
  box-shadow: var(--e1);
}
.adm-star::before { content: "\2605"; margin-right: 4px; color: var(--app-mute); }

/* ------------------------------------------------------ Карточки ---- */

.adm-hero { display: flex; flex-direction: column; gap: 4px; }
.adm-hero__sum {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.adm-hero__sub { font-size: 13px; color: var(--app-mute); overflow-wrap: anywhere; }
.adm-hero__name { font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.adm-marks { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }

.adm-kv .list__val { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.adm-kv { flex-wrap: wrap; }
.adm-kv > span:first-child { flex: 1 1 40%; min-width: 0; }
.adm-kv__sub {
  flex-basis: 100%;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--app-mute);
  text-align: right;
}
.adm-who { padding: 12px; border-radius: 12px; box-shadow: var(--e1); min-height: 56px; }
.adm-link { margin-top: 12px; text-decoration: none; min-height: 46px; }
.adm-menu { padding-top: 4px; padding-bottom: 4px; }
.adm-menu .list__item, .adm-user { min-height: 48px; }

.adm-warn {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: var(--inset);
  overflow-wrap: anywhere;
}
.adm-warn--bad { color: #E7BCB2; background: rgba(196,97,79,.14); }
.adm-warn--wait { color: #C9D6E3; background: rgba(110,138,166,.14); }
.adm-warn--idle { color: var(--app-mute); background: rgba(142,149,157,.10); }

.adm-plan { margin-top: 4px; font-size: 14px; }
.adm-plan__sum { font-weight: 650; }

.adm-big { margin-top: 6px; font-size: 20px; font-weight: 650; color: var(--ok); overflow-wrap: anywhere; }
.adm-big--bad { color: var(--bad); }
.adm-big--idle { color: var(--app-mute); }

.adm-pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.adm-screen > .adm-pager { grid-template-columns: 1fr; margin-top: 0; }
.adm-pager .btn { min-height: 44px; }
.adm-pager .btn:disabled { color: var(--app-mute); opacity: .55; cursor: default; }
.adm-pager__n { font-size: 12px; color: var(--app-mute); }
.adm-open { min-height: 44px; }
.adm-pane { margin-top: 10px; min-height: 60px; }

/* -------------------------------------------------------- Переписка -- */

.adm-chat { min-height: 0; justify-content: flex-start; }
.adm-older:empty { display: none; }
.adm-bub--out {
  align-self: flex-end;
  background-color: #1D2126;
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.014) 0 1px, transparent 1px 4px);
  border: 1px solid var(--gold-line);
}
.adm-file { min-height: 44px; }

.adm-tpl {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--app-100);
  box-shadow: var(--inset);
}

/* -------------------------------------------------------- Настройки -- */

.adm-set {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 0;
  border-bottom: 1px solid var(--app-300);
}
.adm-set:last-child { border-bottom: 0; }
.adm-set__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.adm-set__t { font-size: 14px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.adm-set__tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.adm-set__v { font-size: 13.5px; overflow-wrap: anywhere; }
.adm-set__h { font-size: 12px; line-height: 1.4; color: var(--app-mute); overflow-wrap: anywhere; }
.adm-set .pill { align-self: flex-start; }
.adm-pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--app-100);
  box-shadow: var(--inset);
}

/* ---------------------------------------------- Действия (этап E1) -- */

/* Строка итога действия: «Проверяем результат», текст 409. */
.adm-notice[hidden] { display: none; }
.adm-notice .adm-warn { margin-top: 0; }

.adm-acts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.adm-acts--col { grid-template-columns: minmax(0, 1fr); margin-top: 14px; }
.adm-screen > .adm-acts { margin-top: 0; }
.adm-act { min-height: 48px; padding: 0 10px; font-size: 14px; }
.adm-act:disabled, .adm-sheet__acts .btn:disabled { opacity: .55; cursor: default; }

/* Необратимое действие: графит с красной кромкой, не сплошная заливка -
   красное пятно спорило бы со статусами «отклонено». */
.btn--bad {
  background-color: #211719;
  background-image:
    repeating-linear-gradient(115deg, rgba(255,255,255,.014) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, rgba(196,97,79,.16), rgba(196,97,79,0) 62%);
  border: 1px solid rgba(196,97,79,.52);
  color: #E7BCB2;
}

/* Ряд «название - значение - изменить» в шапке тикета. */
.adm-pick { width: 100%; min-height: 48px; text-align: left; }
.adm-pick .list__val { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; }
.adm-pick__go {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--app-mute);
}

/* Переключатель с явным состоянием: шайба в утопленном треке. */
.adm-sw {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px 0;
  text-align: left;
  color: var(--app-ink);
}
.adm-sw__t { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.adm-sw__s { display: block; margin-top: 3px; font-size: 12px; font-weight: 400; line-height: 1.4; color: var(--app-mute); }
.adm-sw__v { flex: none; font-family: var(--mono); font-size: 11px; color: var(--app-mute); }
.adm-sw__box {
  flex: none;
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: rgba(0,0,0,.34);
  box-shadow: var(--inset);
  transition: background var(--t-fast) var(--snap);
}
.adm-sw__box::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--app-400);
  box-shadow: var(--e1);
  transition: transform var(--t-fast) var(--snap), background var(--t-fast) var(--snap);
}
.adm-sw.is-on .adm-sw__box { background: var(--gold-dim); box-shadow: var(--inset), inset 0 0 0 1px var(--gold-line); }
.adm-sw.is-on .adm-sw__box::after { transform: translateX(18px); background: var(--gold); }
.adm-sw.is-on .adm-sw__v { color: var(--app-ink); }
.adm-sw:disabled { opacity: .55; cursor: default; }
.list > .adm-sw { border-bottom: 1px solid var(--app-300); }

.adm-reply__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.adm-reply__tpl { width: auto; padding: 0 16px; }

.adm-set__edit { align-self: flex-start; width: auto; min-height: 44px; padding: 0 18px; margin-top: 4px; font-size: 14px; }
.adm-set__lock { font-size: 12px; line-height: 1.4; color: var(--app-mute); }
.adm-set > .adm-sw { padding: 0; }

/* Чипы, которые переносятся, а не уезжают вбок (выбор в листе). */
.adm-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-wrap .chip { height: 44px; padding: 0 13px; }

/* -------------------------------------------------------------- Лист -- */

/* Лист поднимается над клавиатурой: --kb ставит admin.js по visualViewport
   (viewportStableHeight при клавиатуре не меняется). */
.adm-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: var(--kb, 0px);
}
.adm-sheet__shade {
  position: absolute;
  inset: 0;
  background: rgba(6,7,8,.64);
  touch-action: none;
  animation: adm-fade var(--t-mid) var(--snap) backwards;
}
.adm-sheet__panel {
  position: relative;
  max-height: calc(var(--vvh, var(--vh)) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px var(--pad) calc(16px + var(--safe-b));
  border-radius: 22px 22px 0 0;
  border-bottom: 0;
  box-shadow: var(--e3);
  animation: adm-sheet-up var(--t-mid) var(--spring) backwards;
}
.adm-sheet__grip {
  display: block;
  width: 40px;
  height: 4px;
  margin: 2px auto 10px;
  border-radius: 999px;
  background: var(--app-400);
  box-shadow: var(--inset);
}
.adm-sheet__t {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.adm-sheet__lead {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--app-ink);
  overflow-wrap: anywhere;
}
.adm-sheet__body { min-width: 0; }
.adm-sheet__err[hidden] { display: none; }
.adm-sheet__acts { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.adm-sheet__now { margin-top: 10px; font-size: 13px; overflow-wrap: anywhere; }
.adm-del { margin-top: 16px; color: #E7BCB2; }
.adm-tplpick .adm-list { margin-top: 10px; }

@keyframes adm-sheet-up { from { opacity: 0; transform: translateY(28px); } }
@keyframes adm-fade { from { opacity: 0; } }

/* Поле листа: утоплено, как прорезь; 16 px - iOS не увеличивает экран. */
.adm-fld { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; min-width: 0; }
.adm-fld__l {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--app-mute);
}
.adm-fld__i {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  color: var(--app-ink);
  background: var(--app-100);
  border: 1px solid var(--app-400);
  border-top-color: #191D22;
  box-shadow: var(--inset);
}
textarea.adm-fld__i { resize: vertical; }
.adm-fld__i.num { font-family: var(--mono); font-size: 14px; }
.adm-fld__i::placeholder { color: var(--app-mute); }
.adm-fld__i:focus-visible { outline: none; border-color: var(--gold-line); }
.adm-fld__f { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--app-mute); }
.adm-fld__e { font-size: 13px; line-height: 1.4; color: #E7BCB2; }

/* Выбор из вариантов в листе: крупные строки, не мелкие чипы - ошибочный
   выбор статуса тикета на телефоне не нужен никому. */
.adm-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.adm-choices--wrap { flex-direction: row; flex-wrap: wrap; }
.adm-choice {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 15px;
  text-align: left;
  color: var(--app-ink);
  background: var(--app-100);
  border: 1px solid var(--app-300);
  box-shadow: var(--e1);
}
.adm-choice[aria-pressed="true"] { color: var(--gold); border-color: var(--gold-line); background: var(--gold-dim); }
.adm-choice:disabled { opacity: .55; }
.adm-choices--wrap .adm-choice { min-height: 44px; border-radius: 6px; font-family: var(--mono); font-size: 13px; }

@media (max-width: 340px) {
  .adm-bal__sum { font-size: 22px; }
  .adm-acts { grid-template-columns: minmax(0, 1fr); }
  .adm-item { grid-template-columns: minmax(0, 1fr); }
  .adm-item__side { flex-direction: row; flex-wrap: wrap; align-items: center; max-width: none; }
  .adm-badges { grid-template-columns: minmax(0, 1fr); }
  .adm-hero__sum { font-size: 21px; }
}

/* Карточка заявки: значение с кнопкой «копировать» и готовый ответ клиенту.
   Тап-зона не меньше 44 px; длинный кошелёк или хеш переносится, не режется. */
.adm-copy { min-height: 44px; min-width: 44px; margin: -8px -8px -8px 0; padding: 8px;
  border: 0; font: inherit; color: inherit; text-align: right; justify-content: flex-end; max-width: 100%; }
.adm-copy__t { font-family: var(--mono); min-width: 0; overflow-wrap: anywhere; word-break: break-all; }
.adm-answer { color: var(--app-ink); line-height: 1.45; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }
