/* Компоненты: кнопки, поле ввода, поиск, таблица, переключатель, подсказка,
   уведомление, листание, состояния таблицы. */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--c-accent-fill); color: var(--c-on-dark); }
@media (hover: hover) { .btn-primary:hover { background: var(--c-accent-hover); } }

.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-line); }
@media (hover: hover) { .btn-secondary:hover { background: var(--c-row-hover); } }

.btn-lg { height: var(--control-h-lg); }
.btn-block { width: 100%; }

/* ---------- Поле ввода ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--fs-small); line-height: 16px; color: var(--c-text-2); }

.input {
  width: 100%;
  height: var(--control-h-lg);
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  background: var(--c-field);
  color: var(--c-text);
  font-size: 14px;
  outline: none;
}
.input::placeholder { color: var(--c-text-3); }
.input:focus { border-color: var(--c-accent-fill); }

.field.is-error .input { border-color: var(--c-danger); background: var(--c-danger-bg); }
.field-error { font-size: var(--fs-small); line-height: 16px; color: var(--c-danger); }
.field-error:empty { display: none; }

/* ---------- Поиск ---------- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  height: var(--control-h);
  flex: none;
}
.search-icon {
  position: absolute; left: 12px; top: 50%;
  width: 16px; height: 16px;
  transform: translateY(-50%);
  color: var(--c-text-3);
  pointer-events: none;
}
.search-icon svg { width: 16px; height: 16px; }
.search-input {
  width: 100%;
  height: 100%;
  padding: 0 40px 0 36px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-control);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  outline: none;
}
.search-input::placeholder { color: var(--c-text-3); }
.search-input:focus { border-color: var(--c-accent-fill); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  padding: 0; border: 0;
  border-radius: var(--r-mini);
  background: transparent;
  color: var(--c-text-2);
}
@media (hover: hover) { .search-clear:hover { background: var(--c-field); } }
.search-clear svg { width: 16px; height: 16px; }
.search-clear[hidden] { display: none; }

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

.table-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-table);
  /* Прокрутка внутри рамки в обе стороны: шапка прилипает к верху рамки,
     первая колонка — к левому краю. Высоту ограничивает .content (см. base.css). */
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  overscroll-behavior-x: none; /* без упругого выезда вбок (тачпад macOS), прокрутка вбок работает */
}
.content > .table-wrap { flex: 0 1 auto; min-height: 160px; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.table th,
.table td {
  padding: 12px;
  text-align: left;
  vertical-align: middle;
  border-right: 1px solid var(--c-line);
  border-bottom: 1px solid var(--c-line);
  background: var(--c-surface);
}
.table th:last-child,
.table td:last-child { border-right: 0; }
.table tbody tr:last-child td { border-bottom: 0; }

.table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--c-field);
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
}
@media (hover: hover) { .table tbody tr:hover td { background: var(--c-row-hover); } }

.cell-nowrap { white-space: nowrap; }
.cell-truncate {
  display: block;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Первая колонка (ID) закреплена слева при прокрутке вбок — на любой ширине. */
.table th:first-child,
.table td:first-child { position: sticky; left: 0; z-index: 1; }
.table th:first-child { z-index: 3; }

/* Таблицы с классом table-pin-last: последняя колонка (кнопки действий) закреплена
   справа, чтобы действия были под рукой, даже когда таблица шире рамки.
   На телефоне не закрепляем — иначе между двумя закреплёнными колонками не остаётся места. */
@media (min-width: 769px) {
  .table-pin-last th:last-child,
  .table-pin-last td:last-child:not(.table-state-cell) {
    position: sticky; right: 0; z-index: 1;
    box-shadow: -1px 0 0 var(--c-line);
  }
  .table-pin-last th:last-child { z-index: 3; }
}

@media (max-width: 768px) {
  .cell-truncate { max-width: 180px; }
}

/* Под таблицей: подписи и листание */
.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 16px;
}
.table-footer[hidden] { display: none; }
.table-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  font-size: var(--fs-small);
  line-height: 16px;
  color: var(--c-text-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- Листание ---------- */

.pager { display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.pager[hidden] { display: none; }
.pager-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px;
  padding: 0 4px;
  border: 0;
  border-radius: var(--r-page-btn);
  background: transparent;
  color: var(--c-text);
  font-size: 14px;
  font-weight: 500;
}
@media (hover: hover) { .pager-btn:hover { background: var(--c-surface); } }
.pager-btn.is-current { background: var(--c-accent-fill); color: var(--c-on-dark); cursor: default; }
.pager-gap { min-width: 28px; text-align: center; color: var(--c-text-3); }
.pager-next { gap: 4px; padding: 0 8px; margin-left: 8px; }
.pager-next svg { width: 16px; height: 16px; }
.pager-btn:disabled { color: var(--c-text-3); cursor: default; background: transparent; }

/* ---------- Переключатель ---------- */

.switch {
  position: relative;
  flex: none;
  width: 36px; height: 20px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--c-switch-off);
  transition: background var(--t-fast) ease;
}
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--c-surface);
  transition: transform var(--t-fast) ease;
}
.switch[aria-checked="true"] { background: var(--c-accent-fill); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

.toggles { display: flex; align-items: center; gap: 20px; white-space: nowrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; }
.toggle-label { color: var(--c-text-2); cursor: default; }

/* ---------- Подсказка ---------- */

.hint {
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  max-width: 320px;
  padding: 6px 10px;
  border-radius: var(--r-hint);
  background: var(--c-hint);
  color: var(--c-on-dark);
  font-size: var(--fs-small);
  line-height: 16px;
  pointer-events: none;
  overflow-wrap: anywhere;
}
.hint[hidden] { display: none; }
.hint-arrow {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--c-hint);
  transform: rotate(45deg);
}
.hint.is-top .hint-arrow { bottom: -4px; }
.hint.is-bottom .hint-arrow { top: -4px; }

/* ---------- Уведомление ---------- */

.snackbars {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.snackbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  width: 360px;
  max-width: 100%;
  padding: 8px 8px 8px 16px;
  border-radius: var(--r-snack);
  color: var(--c-on-dark);
  font-size: 14px;
  line-height: 20px;
  box-shadow: 0 8px 24px var(--c-shadow);
  pointer-events: auto;
  animation: snack-in var(--t-base) ease-out;
}
.snackbar svg { width: 20px; height: 20px; flex: none; }
.snackbar-text { flex: 1; min-width: 0; }
.snackbar-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none;
  padding: 0; border: 0;
  border-radius: var(--r-mini);
  background: transparent;
  color: var(--c-on-dark);
}
.snackbar-close svg { width: 16px; height: 16px; }
.snackbar-close:focus-visible { outline-color: var(--c-on-dark); }
.snackbar.is-positive { background: var(--c-positive); }
.snackbar.is-negative { background: var(--c-danger); }
.snackbar.is-neutral { background: var(--c-neutral); }
.snackbar.is-leaving { opacity: 0; transition: opacity var(--t-fast) ease; }

@keyframes snack-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (max-width: 768px) {
  .snackbars { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .snackbar { width: auto; }
}

/* ---------- Состояния таблицы ---------- */

.table td.table-state-cell { padding: 0; }
@media (hover: hover) { .table tbody tr:hover td.table-state-cell { background: var(--c-surface); } }
.table-state {
  position: sticky;
  left: 0;
  width: min(100%, calc(100vw - 2 * var(--content-pad) - 2px));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 16px;
}
.table-state-icon { width: 40px; height: 40px; color: var(--c-text-3); margin-bottom: 12px; }
.table-state-icon svg { width: 40px; height: 40px; }
.table-state-title { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--c-text); }
.table-state-text { margin-top: 4px; color: var(--c-text-2); }
.table-state .btn { margin-top: 16px; }

.skeleton-row td { background: var(--c-surface); }
@media (hover: hover) { .table tbody tr.skeleton-row:hover td { background: var(--c-surface); } }
.skeleton {
  display: block;
  height: 12px;
  width: 70%;
  border-radius: var(--r-mini);
  background: var(--c-skeleton);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .snackbar { animation: none; }
}

/* ---------- Экран входа ---------- */

.login-page {
  min-height: calc(100vh / var(--ui-zoom, 1));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  width: 360px;
  max-width: 100%;
  padding: 32px;
  background: var(--c-surface);
  border-radius: var(--r-window);
}
.login-brand {
  text-align: center;
  font-size: var(--fs-brand);
  line-height: 24px;
  font-weight: 600;
  color: var(--c-text);
}
.login-title {
  margin-top: 8px;
  margin-bottom: 24px;
  text-align: center;
  font-size: var(--fs-title);
  line-height: 36px;
  font-weight: 600;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .btn { margin-top: 8px; }

@media (max-width: 768px) {
  .login-card { width: 100%; padding: 24px; }
}

/* ---------- Шапка: кнопка «назад» ---------- */

.page-head-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border: 1px solid var(--c-line);
  border-radius: var(--r-control);
  background: var(--c-surface);
  color: var(--c-text);
}
.back-btn svg { width: 20px; height: 20px; }
@media (hover: hover) { .back-btn:hover { background: var(--c-field); } }

/* На телефоне у страниц с кнопкой «назад» шапка остаётся: кнопка и заголовок поменьше. */
@media (max-width: 768px) {
  .page-head:has(.back-btn) { flex-wrap: wrap; margin-bottom: 16px; }
  body:not(.is-search-open) .page-head:has(.back-btn) { margin-bottom: 16px; }
  .page-head:has(.back-btn) .page-title { display: block; font-size: 18px; line-height: 24px; }
}

/* ---------- Вкладки ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
/* На телефоне вкладки стоят в одну строку и листаются вбок, не отнимая высоту у таблицы. */
@media (max-width: 768px) {
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin-left: calc(-1 * var(--content-pad));
    margin-right: calc(-1 * var(--content-pad));
    padding: 2px var(--content-pad);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex: none; }
}
.tab {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-control);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}
@media (hover: hover) { .tab:hover { background: var(--c-field); } }
.tab[aria-selected="true"] {
  background: var(--c-accent-soft);
  border-color: var(--c-accent-fill);
  color: var(--c-accent-fill);
}

/* ---------- Мини-кнопка ---------- */

.mini-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--r-mini);
  background: var(--c-mini);
  color: var(--c-text-2);
}
.mini-btn svg { width: 16px; height: 16px; }
@media (hover: hover) { .mini-btn:hover { background: var(--c-mini-hover); } }
.mini-btn-sm { width: 24px; height: 24px; }

/* Кнопки, видимые на компьютере только при наведении (на строку / на ячейку)
   и при фокусе с клавиатуры; на сенсорных экранах — всегда. */
@media (hover: hover) {
  .reveal-row, .reveal-cell { opacity: 0; }
  .table tbody tr:hover .reveal-row,
  .table tbody td:hover .reveal-cell,
  .reveal-row:focus-visible, .reveal-cell:focus-visible,
  .reveal-row[aria-expanded="true"] { opacity: 1; }
}

/* ---------- Таблица: дополнения ---------- */

.cell-muted { color: var(--c-text-3); }
.cell-truncate-sm { max-width: 200px; }
.cell-truncate-xs { max-width: 180px; }

/* Колонка, которая занимает остаток ширины таблицы и обрезает текст,
   а не раздвигает таблицу (на компьютере) */
.table td.cell-fill { width: 100%; max-width: 0; min-width: 220px; }
.cell-fill .cell-truncate { display: inline-block; max-width: 100%; vertical-align: top; }
.table td.cell-actions { width: 1%; padding-top: 8px; padding-bottom: 8px; text-align: center; }

/* Значение и кнопка ✎ рядом */
.cell-edit { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.cell-edit > :first-child { min-width: 0; }

.link { color: var(--c-accent-fill); text-decoration: none; }
@media (hover: hover) { .link:hover { text-decoration: underline; } }

.switch:disabled { opacity: .5; cursor: default; }

/* Подсвеченная строка (#row=…): бирюзовая обводка 2px вокруг всей строки */
.table tbody tr.is-highlighted td {
  background: var(--c-accent-soft);
  box-shadow: inset 0 2px 0 var(--c-accent), inset 0 -2px 0 var(--c-accent);
}
.table tbody tr.is-highlighted td:first-child {
  box-shadow: inset 2px 0 0 var(--c-accent), inset 0 2px 0 var(--c-accent), inset 0 -2px 0 var(--c-accent);
}
.table tbody tr.is-highlighted td:last-child {
  box-shadow: inset -2px 0 0 var(--c-accent), inset 0 2px 0 var(--c-accent), inset 0 -2px 0 var(--c-accent);
}
.table tbody tr.is-highlighted:last-child td:first-child { border-bottom-left-radius: var(--r-table); }
.table tbody tr.is-highlighted:last-child td:last-child { border-bottom-right-radius: var(--r-table); }

@media (max-width: 768px) {
  .cell-truncate-sm, .cell-truncate-xs { max-width: 180px; }
  .table td.cell-fill { width: auto; max-width: none; }
  .cell-fill .cell-truncate { max-width: 180px; }
}

/* ---------- Меню ---------- */

.menu {
  position: fixed;
  z-index: 80;
  min-width: 200px;
  padding: 6px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-menu);
  box-shadow: 0 8px 24px var(--c-shadow);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-menu-item);
  background: transparent;
  color: var(--c-text);
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  white-space: nowrap;
}
.menu-item svg { width: 16px; height: 16px; flex: none; }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-item:focus { background: var(--c-field); }
@media (hover: hover) { .menu-item:hover { background: var(--c-field); } }
.menu-item.is-negative { color: var(--c-danger); }
.menu-item.is-negative:focus { background: var(--c-danger-bg); }
@media (hover: hover) { .menu-item.is-negative:hover { background: var(--c-danger-bg); } }

/* ---------- Окна ---------- */

html.is-modal-open,
html.is-modal-open body { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--c-overlay);
}
.modal {
  width: 400px;
  max-width: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 24px;
  background: var(--c-surface);
  border-radius: var(--r-window);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-title { flex: 1; min-width: 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.modal-close { margin: -6px -10px 0 0; flex: none; }
.modal-text { font-size: 14px; line-height: 20px; color: var(--c-text-2); }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-actions .btn { flex: 1 1 0; min-width: 0; }
.modal-form { display: flex; flex-direction: column; gap: 24px; }
.modal .btn { height: 44px; }

.btn-cancel { background: var(--c-field); color: var(--c-text); }
.btn-negative { background: var(--c-danger-bg); color: var(--c-danger); }
.btn-positive { background: var(--c-mini-positive); color: var(--c-positive); }
@media (hover: hover) { .btn-positive:hover { background: var(--c-mini-positive-hover); } }

.input-textarea {
  height: 96px;
  padding: 12px 14px;
  font: inherit;
  line-height: 20px;
  resize: none;
}

@media (max-width: 768px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: calc(100% - 24px); border-radius: var(--r-window) var(--r-window) 0 0; }
}

/* ---------- Плашка статуса ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
}
.badge svg { width: 16px; height: 16px; flex: none; }
.badge-violet { background: var(--c-badge-violet-bg); color: var(--c-badge-violet); }
.badge-yellow { background: var(--c-badge-yellow-bg); color: var(--c-badge-yellow); }
.badge-gray   { background: var(--c-badge-gray-bg);   color: var(--c-badge-gray); }
.badge-green  { background: var(--c-badge-green-bg);  color: var(--c-badge-green); }
.badge-red    { background: var(--c-badge-red-bg);    color: var(--c-badge-red); }

/* ---------- Цветные мини-кнопки ---------- */

.mini-btn-positive { background: var(--c-mini-positive); color: var(--c-positive); }
.mini-btn-negative { background: var(--c-mini-negative); color: var(--c-danger); }
.mini-btn-accent   { background: var(--c-mini-accent);   color: var(--c-accent-fill); }
@media (hover: hover) {
  .mini-btn-positive:hover { background: var(--c-mini-positive-hover); }
  .mini-btn-negative:hover { background: var(--c-mini-negative-hover); }
  .mini-btn-accent:hover   { background: var(--c-mini-accent-hover); }
}

/* Ряд мини-кнопок в ячейке */
.mini-row { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }

/* ---------- Сумма со старым значением ---------- */

.amount { display: inline-flex; flex-direction: column; }
.amount-prev {
  font-size: var(--fs-small);
  line-height: 16px;
  color: var(--c-text-3);
  text-decoration: line-through;
}

/* ---------- Значение со второй строкой (комментарий) ---------- */

.cell-stack { display: flex; flex-direction: column; min-width: 0; }
.cell-sub { font-size: var(--fs-small); line-height: 16px; color: var(--c-text-2); }

/* ---------- Окно «подпись — значение» ---------- */

.info-table-wrap {
  border: 1px solid var(--c-line);
  border-radius: var(--r-table);
  overflow: hidden;
}
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.info-table th,
.info-table td {
  padding: 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--c-line);
}
.info-table tr:last-child th,
.info-table tr:last-child td { border-bottom: 0; }
.info-table th { width: 45%; font-weight: 400; color: var(--c-text-2); }
.info-table td { color: var(--c-text); overflow-wrap: anywhere; }

/* ---------- Счетчик знаков под полем ---------- */

.field-foot { display: flex; align-items: flex-start; gap: 12px; }
.field-foot .field-error { flex: 1; min-width: 0; }
.field-counter {
  margin-left: auto;
  font-size: var(--fs-small);
  line-height: 16px;
  color: var(--c-text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Меню: пустой список ---------- */

.menu-empty {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  color: var(--c-text-3);
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  cursor: default;
}

/* ---------- Поле для файла ---------- */

.file-drop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border: 1px dashed var(--c-line);
  border-radius: var(--r-control);
  background: var(--c-field);
  color: var(--c-text);
  font-size: 14px;
  line-height: 20px;
  text-align: left;
}
.file-drop svg { width: 20px; height: 20px; flex: none; color: var(--c-text-2); }
.file-drop-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop-muted { color: var(--c-text-3); }
@media (hover: hover) { .file-drop:hover { border-color: var(--c-accent-fill); } }
.file-drop.is-drag { border-color: var(--c-accent-fill); }
.field.is-error .file-drop { border-color: var(--c-danger); background: var(--c-danger-bg); }
.field-note { font-size: var(--fs-small); line-height: 16px; color: var(--c-text-3); }

.file-chosen { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.file-chosen[hidden], .file-drop[hidden] { display: none; }
.file-chosen-icon { width: 20px; height: 20px; flex: none; color: var(--c-accent-fill); }
.file-chosen-icon svg { width: 20px; height: 20px; }
.file-chosen-info { flex: 1; min-width: 0; }
.file-chosen-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chosen-size { font-size: var(--fs-small); line-height: 16px; color: var(--c-text-3); }

/* ---------- Просмотр чека ---------- */

.receipt-img { display: block; width: 100%; max-height: calc(60vh / var(--ui-zoom, 1)); object-fit: contain; }
.receipt-frame { display: block; width: 100%; height: calc(60vh / var(--ui-zoom, 1)); border: 0; }
.receipt-video { display: block; width: 100%; max-height: calc(60vh / var(--ui-zoom, 1)); }
.receipt-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--c-line);
  border-radius: var(--r-control);
  background: var(--c-field);
  color: var(--c-text-3);
}
.receipt-placeholder svg { width: 40px; height: 40px; }
.receipt-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; }
.receipt-link svg { width: 16px; height: 16px; }
.receipt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 0;
  color: var(--c-text-3);
  text-align: center;
}
.receipt-empty svg { width: 40px; height: 40px; }

/* ---------- Ссылка-кнопка и плашка-фильтр клиента («Платежи») ---------- */

button.link { padding: 0; border: 0; background: none; cursor: pointer; }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-row[hidden] { display: none; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--c-accent-soft);
  color: var(--c-accent-fill);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}
.filter-chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
}
.filter-chip-close svg { width: 16px; height: 16px; }
@media (hover: hover) { .filter-chip-close:hover { background: var(--c-mini-hover); } }

/* ---------- Малая кнопка на светло-серой подложке («Завершить» в «Настройках») ---------- */

.btn-sm { height: 32px; padding: 0 12px; }
.btn-soft { background: var(--c-field); color: var(--c-text); }
@media (hover: hover) { .btn-soft:hover { background: var(--c-mini); } }

/* ---------- Настройки: поле только для чтения ---------- */

.settings-panel[hidden] { display: none; }
.settings-field { width: 360px; max-width: 100%; }
.input[readonly] { cursor: default; }

@media (max-width: 768px) {
  .settings-field { width: 100%; }
}

/* ---------- Курс в шапке («Площадки») ---------- */

.rate {
  display: block;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--c-text);
  white-space: nowrap;
}
.rate-label { color: var(--c-text-2); }

/* ---------- Плотная таблица («Выплаты», «Платежи») ---------- */
/* Отступы 10px, длинные заголовки переносятся, дата в две строки, узкие колонки с многоточием. */

.table-dense th,
.table-dense td { padding: 10px; }
.table-dense th { white-space: normal; }
.date-stack { display: inline-flex; flex-direction: column; white-space: nowrap; }
/* ---------- Таблицы стоят на месте (класс table-fixed: все пять таблиц) ---------- */
/* Ширины колонок заданы жёстко и не зависят от строк: вкладка статуса, «Нужна рука», фильтр колонки, пустая
   таблица, одна строка либо полная страница, обновление данных — колонки те же. Узкие колонки — в px (с отступами
   и рамкой, box-sizing: border-box), «резиновые» колонки без ширины делят остаток рамки поровну.
   Наименьшая ширина таблицы — 976px: рамка при окне 1280 — 994px (с постоянной полосой прокрутки — около 977px);
   таблица шире рамки — прокрутка внутри рамки. ID заказа площадки — 8 знаков и «…» (App.shortId); на «Платежах» —
   весь ID в одну строку, сколько помещается, и «…».
   Два размера текста: главный — 13px (ID, сумма, реквизит, способ, название площадки, шапка), второстепенный —
   --fs-small вторичным цветом (банк, дата и время, номер счёта под площадкой, подстрочные пояснения). */
.table-fixed { font-size: 13px; line-height: 18px; }
.table-fixed .date-stack { font-size: var(--fs-small); line-height: 16px; color: var(--c-text-2); }
.table-fixed .timer { font-size: var(--fs-small); }
/* Плашка статуса в таблице — по строке текста (в окне «Информация» — 22px) */
.table-fixed .badge { height: 20px; padding: 0 7px; font-size: var(--fs-small); line-height: 16px; border-radius: 6px; }
@media (min-width: 769px) {
  .table-fixed { table-layout: fixed; min-width: 976px; }
  .table-fixed th { white-space: normal; overflow-wrap: anywhere; }
  .table-fixed td.cell-flex .cell-truncate { max-width: 100%; }
  .table-fixed td.cell-flex .cell-edit { min-width: 0; }
  .table-fixed td.cell-flex .cell-stack { min-width: 0; flex: 1 1 auto; }
  .table-fixed td.cell-fill { width: auto; max-width: none; min-width: 0; }
  .table-fixed td.cell-fill .cell-truncate,
  .table-fixed td .cell-truncate-sm,
  .table-fixed td .cell-truncate-xs { max-width: 100%; }
  .table-fixed td.cell-actions { width: auto; }
  /* «Инфо»: кнопки в один ряд, 24px — строка от них не выше */
  .table-fixed .cell-actions .mini-row { gap: 4px; }
  .table-fixed .cell-actions .mini-btn { width: 24px; height: 24px; }
  .table-fixed .cell-actions .mini-btn svg { width: 14px; height: 14px; }
  .table-fixed td.cell-actions { padding-left: 6px; padding-right: 6px; }
  .table-dense .cell-edit { gap: 4px; }
  /* Название площадки, способ, метод: до двух строк по словам (cell-clamp), полное — в подсказке;
     банк под способом — целиком, переносится по словам */
  .table-fixed td .cell-clamp { white-space: normal; overflow-wrap: anywhere; }
  .table-fixed td .cell-stack .cell-sub:not(.cell-truncate) { white-space: normal; }

  /* «Выплаты»: «Площадка», «Сумма» и «Способ выплаты» без ширины — делят остаток рамки поровну; каждой не меньше
     128px (сумма с копейками и ✎): узкие колонки 722px + 3 × 128px */
  #payouts-table { min-width: 1106px; }
  #payouts-table th:nth-child(1) { width: 78px; }
  #payouts-table th:nth-child(2) { width: 106px; }
  #payouts-table th:nth-child(6) { width: 186px; }
  #payouts-table th:nth-child(7) { width: 112px; }
  #payouts-table th:nth-child(8) { width: 90px; }
  #payouts-table th:nth-child(9) { width: 150px; }

  /* «Платежи»: «ID заказа площадки» и «Площадка» без ширины — делят остаток рамки поровну; «Сумма» — по
     «9 999 999,99 ₽» с лупой, «Метод» — по «Банковская» (способ в две строки по словам): узкие колонки 948px */
  #payments-table { min-width: 1174px; }
  #payments-table th:nth-child(1) { width: 76px; }
  #payments-table th:nth-child(4) { width: 120px; }
  #payments-table th:nth-child(5) { width: 96px; }
  #payments-table td .copy-btn { max-width: 100%; }
  #payments-table th:nth-child(6) { width: 168px; }
  #payments-table th:nth-child(7) { width: 102px; }
  #payments-table th:nth-child(8) { width: 90px; }
  #payments-table th:nth-child(9) { width: 174px; }
  #payments-table th:nth-child(10) { width: 122px; }

  #requisites-table th:nth-child(1) { width: 100px; }
  /* «Реквизиты»: «Площадка», «Название», «Реквизит» и «Лимит» делят остаток поровну (не меньше 172px при 976px) */
  #requisites-table th:nth-child(6) { width: 76px; }
  #requisites-table th:nth-child(7) { width: 52px; }

  #autopayments-table th:nth-child(1) { width: 110px; }
  #autopayments-table th:nth-child(2) { width: 140px; }
  #autopayments-table th:nth-child(3) { width: 138px; }
  #autopayments-table th:nth-child(4) { width: 92px; }
  #autopayments-table th:nth-child(5) { width: 98px; }
  #autopayments-table th:nth-child(6) { width: 106px; }
  #autopayments-table th:nth-child(7) { width: 96px; }

  #platforms-table th:nth-child(1) { width: 100px; }
  #platforms-table th:nth-child(3) { width: 200px; }
  #platforms-table th:nth-child(4) { width: 220px; }

}

/* ---------- Окно «Информация»: значение с кнопкой и область под таблицей ---------- */

.info-value-act { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal .btn-sm { height: 32px; }

.info-after {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--c-line);
}
.info-after-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

/* ---------- Окно «Информация»: компактный вид, чтобы помещалось без прокрутки ---------- */

.modal-info { padding: 20px; }
.modal-info .modal-head { margin-bottom: 12px; }
.modal-info .modal-title { font-size: 18px; line-height: 24px; }
.modal-info .info-table { font-size: 13px; line-height: 20px; }
.modal-info .info-table th,
.modal-info .info-table td { padding: 6px 12px; }
.modal-info .info-table .badge { height: 22px; padding: 0 8px; font-size: 12px; }
.modal-info .info-table .badge svg { width: 14px; height: 14px; }
.modal-info .info-table .btn-sm { height: 24px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.modal-info .info-table td { overflow-wrap: normal; }
.modal-info .info-after { margin-top: 12px; padding-top: 12px; }
.modal-info .info-after .input { height: 40px; }
.modal-info .info-after .btn { height: 40px; padding: 0 8px; }
.modal-info .info-after-actions { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
@media (max-width: 480px) {
  .modal-info .info-after .btn { font-size: 13px; }
}

/* ---------- Реквизит, который копируется по нажатию ---------- */

.copy-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0; border: 0; background: none;
  font: inherit; color: inherit; white-space: nowrap; cursor: pointer;
}
.copy-btn svg { width: 14px; height: 14px; flex: none; color: var(--c-text-3); }
@media (hover: hover) {
  .copy-btn:hover { color: var(--c-accent-fill); }
  .copy-btn:hover svg { color: var(--c-accent-fill); }
}

/* ---------- Таймер таймаута под плашкой статуса ---------- */

.timer {
  display: flex; align-items: center;
  margin-top: 6px;
  font-size: 13px; line-height: 16px; font-weight: 500;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  color: var(--c-text);
}
.timer svg { width: 14px; height: 14px; flex: none; margin-right: 6px; }
.timer-sec { color: var(--c-text-3); }
.timer.is-danger,
.timer.is-danger .timer-sec { color: var(--c-danger); }
.info-table .timer { margin-top: 0; }

/* Сенсорные экраны: рамка таблицы не прокручивается сама (см. css/base.css). */
@media (hover: none) and (min-width: 769px) {
  /* Высота не ограничена, поэтому вниз рамка не прокручивается. Вбок — только если
     таблица вдруг окажется шире страницы (тогда данные не обрежутся). */
  .content > .table-wrap { overflow: auto; min-height: 0; overscroll-behavior: auto; }
}

/* Сенсорные экраны: окно и уведомления стоят на видимой части экрана и увеличены (см. pinToVisual в js/ui.js). */
.modal-backdrop.is-touch .modal { zoom: var(--touch-zoom, 1); }
.snackbars.is-touch { box-sizing: border-box; padding: 20px; justify-content: flex-end; }
.snackbars.is-touch .snackbar { zoom: var(--touch-zoom, 1); }


/* ---------- Окна с файлом: строка под заголовком, неактивная кнопка ---------- */

.modal-sub {
  margin: -12px 0 20px;
  font-size: var(--fs-small);
  line-height: 16px;
  color: var(--c-text-3);
}
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }

/* ---------- «Нужна рука» — точка у плашки статуса; пометка площадки под ней ---------- */

/* Точка справа от плашки через 6px, в отступе ячейки (под неё — 4px справа у строки статуса у каждой строки):
   ширину колонки не меняет; причина — в подсказке. */
.status-line { position: relative; display: flex; align-items: center; width: fit-content; margin-right: 4px; }
.hand-dot {
  position: absolute;
  left: 100%; top: 50%;
  margin-top: -10px;
  width: 14px; height: 20px;
  border-radius: var(--r-mini);
  cursor: default;
}
.hand-dot::before {
  content: "";
  position: absolute;
  top: 6px; left: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-danger);
}
.hand-dot:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 0; }

/* Пометка площадки: серым мелким, одной строкой с многоточием, обрезанная — целиком в подсказке */
.cell-note {
  max-width: 120px;
  margin-top: 2px;
  font-size: var(--fs-small);
  line-height: 14px;
  color: var(--c-text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* «Площадка»: название обычным, за ним « · номер счёта» мелким, одной строкой; не влезает — сначала уходит номер */
.cell-plat { display: flex; align-items: baseline; min-width: 0; white-space: nowrap; }
.cell-plat > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cell-plat-name { flex: 0 1 auto; }
.cell-plat-id { flex: 0 1000 auto; }
.cell-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* ---------- Поиск по колонкам: лупа в заголовке и поле поверх него ---------- */

.table th.th-filter { padding-right: 4px; }
.th-head { display: inline-flex; align-items: center; }
.th-search,
.th-clear {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  width: 18px; height: 22px;
  padding: 0; border: 0;
  border-radius: var(--r-mini);
  background: none;
  color: var(--c-text-3);
  cursor: pointer;
}
.th-search svg, .th-clear svg { width: 14px; height: 14px; }
@media (hover: hover) {
  .th-search:hover, .th-clear:hover { background: var(--c-mini); color: var(--c-text); }
}
.th-filter.is-filtered .th-search { color: var(--c-accent-fill); }
/* Плотные таблицы («Выплаты», «Платежи»): лупа в правом верхнем углу заголовка, рядом с первой
   строкой подписи, — колонка не шире, чем без неё */
.table-dense th.th-filter { padding-right: 10px; }
.table-dense .th-head { display: inline; }
.table-dense .th-search { position: absolute; top: 9px; right: 0; width: 16px; }
/* Остальные таблицы с жёсткими колонками: подпись переносится по словам, лупа — так же в правом верхнем углу */
.table-fixed:not(.table-dense) th.th-filter { padding-right: 20px; }
.table-fixed:not(.table-dense) .th-head { display: inline; }
.table-fixed:not(.table-dense) .th-search { position: absolute; top: 11px; right: 2px; width: 16px; }
/* Поле занимает место заголовка: ширина колонки не меняется */
.th-filter.is-open .th-head { visibility: hidden; }
.th-field {
  position: absolute;
  top: 50%; left: 4px; right: 4px;
  transform: translateY(-50%);
  display: flex; align-items: center;
  height: 30px;
  padding: 0 2px 0 6px;
  border: 1px solid var(--c-accent-fill);
  border-radius: var(--r-mini);
  background: var(--c-surface);
}
.th-field[hidden] { display: none; }
.th-field-icon { display: inline-flex; flex: none; margin-right: 4px; color: var(--c-text-3); }
.th-field-icon svg { width: 14px; height: 14px; }
.th-filter.is-filtered .th-field-icon { color: var(--c-accent-fill); }
.th-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-weight: 400;
  font-size: 13px;
  color: var(--c-text);
}

/* ---------- Плашка-вопрос у кнопки строки (App.confirm с anchor) ---------- */

.popconfirm {
  position: fixed;
  top: 0; left: 0;
  z-index: 80;
  width: 320px;
  max-width: calc(100vw - 16px);
  padding: 16px;
  border-radius: var(--r-menu);
  background: var(--c-surface);
  box-shadow: 0 8px 24px var(--c-shadow);
}
.popconfirm-title { margin: 0; font-size: 16px; line-height: 22px; font-weight: 600; color: var(--c-text); }
.popconfirm-text { margin: 6px 0 0; font-size: 14px; line-height: 20px; color: var(--c-text-2); }
.popconfirm-actions { display: flex; gap: 8px; margin-top: 16px; }
.popconfirm-actions .btn { flex: 1 1 0; min-width: 0; height: 36px; }

/* Ряд над таблицей: вкладки статусов и переключатель «Нужна рука» */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; margin-bottom: 16px; }
.filter-bar .tabs { margin-bottom: 0; }
.hand-filter .toggle-label { cursor: pointer; }
@media (max-width: 768px) {
  .filter-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .filter-bar .tabs { align-self: stretch; }
}

/* ---------- Несколько чеков ---------- */

/* Список выбранных файлов под зоной (окно «Прикрепление чека») */
.file-chosen-list:empty { display: none; }
.file-chosen-list .file-chosen { min-height: 48px; }

/* Цифра с количеством чеков в углу кнопки «Чек»; ширину кнопки не меняет */
.mini-btn { position: relative; }
.mini-btn-count {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--c-accent-fill);
  color: var(--c-on-dark);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

/* Окно «Чеки по …»: ряд маленьких картинок, крупный вид выбранного, имя и размер под ним */
.receipt-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.receipt-thumb {
  display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; flex: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--c-line);
  border-radius: var(--r-page-btn);
  background: var(--c-field);
  color: var(--c-text-2);
}
.receipt-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.receipt-thumb.is-current { border-color: var(--c-accent-fill); box-shadow: 0 0 0 1px var(--c-accent-fill); }
@media (hover: hover) { .receipt-thumb:hover { border-color: var(--c-accent-fill); } }
.receipt-thumb-file { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 0 4px; }
.receipt-thumb-file svg { width: 20px; height: 20px; flex: none; }
.receipt-thumb-name {
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10px; line-height: 12px;
}
.receipt-meta { display: flex; gap: 8px; margin-top: 12px; font-size: var(--fs-small); line-height: 16px; }
.receipt-meta-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-text); }
.receipt-meta-size { flex: none; color: var(--c-text-3); }

/* ---------- «Автоплатежи»: окно «Добавить запись» ---------- */

.modal-form.form-compact { gap: 14px; }
.form-compact .input:not(.input-textarea) { height: var(--control-h); }
.form-compact .input-textarea { height: 72px; }
.form-compact .btn-block { margin-top: 6px; }
.field-static { font-size: 14px; line-height: 20px; color: var(--c-text-2); }

/* ---------- Живой режим (данные сервера панели, DATA.live) ---------- */

/* «Обновлено N сек назад» рядом с заголовком */
.live-age { font-size: var(--fs-small); line-height: 16px; color: var(--c-text-3); white-space: nowrap; }

/* Полоса «Данные устарели» над таблицей */
.live-stale {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
  padding: 10px 16px;
  border-radius: var(--r-control);
  background: var(--c-badge-yellow-bg);
  color: var(--c-badge-yellow);
  font-weight: 500;
}
.live-stale[hidden] { display: none; }
.live-stale svg { width: 16px; height: 16px; flex: none; }

/* Кнопки, которые пока работают только в Telegram: на местах, неактивны, с подсказкой */
.mini-btn[data-locked],
.btn[data-locked] { background: var(--c-field); color: var(--c-text-3); border-color: transparent; cursor: default; }
.switch[data-locked] { opacity: .5; cursor: default; }
.menu-item[data-locked] { color: var(--c-text-3); cursor: default; }
@media (hover: hover) {
  .mini-btn[data-locked]:hover,
  .btn[data-locked]:hover { background: var(--c-field); }
  .menu-item[data-locked]:hover { background: transparent; }
}
.menu-item[data-locked]:focus { background: var(--c-field); }

/* Действие ушло на сервер: кнопка недоступна, значок загрузки вращается */
.mini-btn[aria-busy="true"] svg { animation: busy-spin 1s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
