:root {
  --ink: #0a0a0b;
  --surface: #17181b;
  --surface-2: #202225;
  --surface-3: #2c2e33;
  --line: #37393f;
  --text: #f5f5f6;
  --text-muted: #aaacb2;
  --text-faint: #74757b;
  /* Акцент — "полированная сталь": светлый металл на угольно-чёрном,
     как сами треугольники на лого, а не серое на сером. */
  --violet: #e3e5ea;
  --violet-dim: #e3e5ea1f;
  --on-accent: #101114;
  --signal: #5fbf8f;
  --signal-dim: #5fbf8f26;
  --amber: #d1a668;
  --danger: #e2666a;
  --danger-dim: #e2666a1f;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-lift: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --font-ui: -apple-system, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --ink: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f4f5fa;
  --surface-3: #e9ebf3;
  --line: #dde1ec;
  --text: #171b26;
  --text-muted: #626b82;
  --text-faint: #9198ab;
  /* На белом фоне светлый акцент был бы не виден — тут он тёмный. */
  --violet: #3f434b;
  --violet-dim: #3f434b14;
  --on-accent: #ffffff;
  --signal-dim: #5fbf8f1a;
  --danger-dim: #e2666a14;
  --shadow-lift: 0 12px 32px -14px rgba(23, 27, 38, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* iOS/Android автоматически зумят страницу при фокусе на поле ввода, если
   шрифт в нём меньше 16px, и не всегда корректно возвращают масштаб назад —
   это и есть причина "сайт увеличился и не открывается список". Инпуты
   получают гарантированные 16px независимо от общего масштаба текста;
   кнопки (не текстовые поля) в фокус-зум не попадают, их не трогаем. */
input,
textarea,
select {
  font-size: 16px;
}

a {
  color: inherit;
}

::selection {
  background: var(--violet-dim);
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 20px;
  border: 2px solid var(--ink);
}

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 18% 20%, rgba(140, 146, 156, 0.14), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(127, 174, 149, 0.10), transparent 40%),
    var(--ink);
}

.login-card {
  width: 380px;
  padding: 40px 36px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
}

.login-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-mark .stub-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-dim);
}

.login-mark span {
  font-weight: 600;
  letter-spacing: 0.01em;
  font-size: 16px;
}

.login-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: -18px 0 26px;
  line-height: 1.5;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.field .required {
  color: var(--danger);
}

.input,
.select-native,
textarea.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select-native:focus,
textarea.input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-dim);
}

.input::placeholder {
  color: var(--text-faint);
}

.error-text {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 8px;
  min-height: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--violet);
  color: var(--on-accent);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    filter: brightness(0.92);
  }
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover {
    background: var(--surface-2);
  }
}

.btn-danger-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--danger);
}
@media (hover: hover) and (pointer: fine) {
  .btn-danger-ghost:hover {
    background: var(--danger-dim);
    border-color: var(--danger);
  }
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
@media (hover: hover) and (pointer: fine) {
  .btn-icon:hover {
    background: var(--surface-2);
    color: var(--text);
  }
}

/* ---------- Shell layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}
.shell.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, #3a3d43, #5c6067);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 5px;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-text strong {
  font-size: 14.5px;
  letter-spacing: 0.01em;
}
.brand-text span {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-group-label {
  padding: 14px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 2px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
  }
}
.nav-item.active {
  background: var(--violet-dim);
  color: var(--violet);
}
.nav-item svg {
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px 18px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
}

.sidebar-close {
  display: none;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-backdrop {
  display: none;
}

/* ---------- Topbar ---------- */
.topbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.crumbs strong {
  color: var(--text);
  font-weight: 600;
}

.topbar-spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.menu-panel {
  position: absolute;
  top: 46px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  min-width: 180px;
  padding: 6px;
  z-index: 40;
}
.menu-panel-item {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
@media (hover: hover) and (pointer: fine) {
  .menu-panel-item:hover {
    background: var(--surface-2);
  }
}
.menu-panel-item.danger {
  color: var(--danger);
}
.menu-panel-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 4px;
}

/* ---------- Content ---------- */
.content {
  padding: 24px 28px 60px;
  max-width: 1320px;
}

.shell.sidebar-collapsed .content {
  max-width: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}
.search-input input {
  width: 100%;
  padding: 9px 34px 9px 36px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
}
.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  pointer-events: none;
  background: var(--surface-3);
}
.search-input input:focus {
  border-color: var(--violet);
}

.filters-wrap {
  position: relative;
  flex-shrink: 0;
}
.btn-filter-active {
  border-color: var(--violet);
  color: var(--text);
}
.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--violet);
  color: var(--on-accent);
  font-size: 10.5px;
  font-weight: 700;
}
.filters-panel {
  position: fixed;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  z-index: 200;
  padding: 14px;
  animation: fade-in 0.12s ease;
}
.filters-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.filters-clear {
  background: none;
  border: none;
  color: var(--violet);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.filters-panel .field {
  margin-bottom: 12px;
}
.filters-panel .field:last-child {
  margin-bottom: 0;
}
.filters-panel .field label {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 5px;
}
.search-input svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
}

/* ---------- Card / table ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  white-space: nowrap;
}
tbody td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr {
  transition: background 0.12s ease;
}
@media (hover: hover) and (pointer: fine) {
  tbody tr:hover {
    background: var(--surface-2);
  }
}

.cell-primary {
  font-weight: 600;
}
.cell-muted {
  color: var(--text-muted);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-on {
  background: var(--signal-dim);
  color: var(--signal);
}
.badge-off {
  background: var(--danger-dim);
  color: var(--danger);
}
.badge-on::before,
.badge-off::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tag {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

/* ---------- Signature: ticket-stub sub-id chip ---------- */
.stub {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 5px 10px 5px 12px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-left: 2px solid var(--violet);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stub-fake {
  border-left-color: var(--signal);
}
.stub.stub-new {
  animation: stub-pop 1.1s ease;
}
@keyframes stub-pop {
  0% {
    box-shadow: 0 0 0 0 var(--violet-dim);
    background: var(--violet-dim);
  }
  100% {
    box-shadow: 0 0 0 10px transparent;
    background: var(--surface-2);
  }
}

.empty-state {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  color: var(--text-faint);
}
.empty-state .empty-title {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}
.empty-state .empty-hint {
  font-size: 12.5px;
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

.pagination-hint {
  padding: 12px 18px;
  color: var(--text-faint);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 14, 0.62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 20px 40px;
  z-index: 100;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  animation: modal-in 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.modal.modal-wide {
  max-width: 620px;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
}
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.close-x {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (hover: hover) and (pointer: fine) {
  .close-x:hover {
    background: var(--surface-2);
    color: var(--text);
  }
}

/* ---------- Managed select (dropdown with add/delete) ---------- */
.mselect {
  position: relative;
}
.mselect-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mselect-input {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}
.mselect-input.placeholder {
  color: var(--text-faint);
}
@media (hover: hover) and (pointer: fine) {
  .mselect-input:hover {
    border-color: var(--text-faint);
  }
}
.mselect.open .mselect-input {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-dim);
}
.mselect-caret {
  color: var(--text-faint);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.mselect.open .mselect-caret {
  transform: rotate(180deg);
}

.mselect-backdrop {
  position: fixed;
  inset: 0;
  z-index: 499;
  background: transparent;
}

.mselect-panel {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  z-index: 500;
  overflow: hidden;
  animation: fade-in 0.12s ease;
}
.mselect-search {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.mselect-search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  outline: none;
  color: var(--text);
}
.mselect-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}
.mselect-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  gap: 8px;
}
@media (hover: hover) and (pointer: fine) {
  .mselect-option:hover {
    background: var(--surface-2);
  }
}
.mselect-option.selected {
  color: var(--violet);
  background: var(--violet-dim);
}
.mselect-option-delete {
  opacity: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .mselect-option:hover .mselect-option-delete {
    opacity: 1;
  }
}
@media (hover: none) {
  /* На тач-устройствах нет состояния "наведение" — если показывать корзину
     только по hover, она будет невидима и недоступна для тапа вообще.
     Показываем всегда, но приглушённо, чтобы не отвлекала от текста. */
  .mselect-option-delete {
    opacity: 0.55;
  }
}
@media (hover: hover) and (pointer: fine) {
  .mselect-option-delete:hover {
    background: var(--danger-dim);
    color: var(--danger);
  }
}
.mselect-empty {
  padding: 16px 10px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
}
.mselect-add {
  border-top: 1px solid var(--line);
  padding: 8px;
}
.mselect-add-row {
  display: flex;
  gap: 6px;
}
.mselect-add-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  outline: none;
  color: var(--text);
}
.mselect-add-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 7px;
  background: transparent;
  border: none;
  color: var(--violet);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .mselect-add-trigger:hover {
    background: var(--violet-dim);
  }
}

/* ---------- Toggle switch ---------- */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.toggle {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
  border: none;
}
.toggle.on {
  background: var(--signal);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.toggle.on::after {
  transform: translateX(18px);
}
.toggle-label {
  font-size: 13.5px;
  font-weight: 500;
}
.toggle-hint {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lift);
  font-size: 13px;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.18s ease;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast-ok .toast-dot {
  background: var(--signal);
}
.toast-err .toast-dot {
  background: var(--danger);
}

/* ---------- Buyer detail drawer ---------- */
.detail-section {
  margin-bottom: 22px;
}
.detail-section:last-child {
  margin-bottom: 0;
}
.detail-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 10px;
  font-weight: 600;
}
.fake-sub-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sub-mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--surface-2);
  border-radius: 9px;
  border: 1px solid var(--line);
  font-size: 12.5px;
  margin-bottom: 6px;
}
.sub-mini-row .meta {
  color: var(--text-muted);
}
.sub-mini-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.spinner-dark {
  border: 2px solid var(--surface-3);
  border-top-color: var(--violet);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.scroll-top-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.15s ease;
  z-index: 150;
}
.scroll-top-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
@media (hover: hover) and (pointer: fine) {
  .scroll-top-btn:hover {
    background: var(--violet);
    color: var(--on-accent);
    border-color: var(--violet);
  }
}
@media (max-width: 860px) {
  .scroll-top-btn {
    right: 14px;
    bottom: 14px;
  }
}

.helper-text {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 6px;
  line-height: 1.5;
}

.stat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  min-width: 150px;
  flex: 1;
}
.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 860px) {
  .login-screen {
    align-items: flex-start;
    padding-top: 12vh;
  }

  .stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card {
    min-width: 0;
    padding: 14px;
  }
  .stat-card .stat-value {
    font-size: 20px;
  }

  .shell {
    grid-template-columns: 1fr;
  }
  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 300px);
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lift);
  }
  .shell:not(.sidebar-collapsed) .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 14, 0.6);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }
  .shell:not(.sidebar-collapsed) .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .crumbs-root {
    display: none;
  }
  .crumbs strong {
    font-size: 14.5px;
  }

  .topbar {
    padding: 0 14px;
    gap: 8px;
    height: 58px;
  }
  .content {
    padding: 16px 14px 50px;
  }
  .page-head {
    align-items: flex-start;
  }
  .page-title {
    font-size: 18px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    position: sticky;
    top: 58px;
    z-index: 15;
    background: var(--ink);
    margin: 0 -14px 16px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
  }
  .search-input {
    max-width: none;
    min-width: 0;
  }
  .search-kbd {
    display: none;
  }
  .filters-wrap,
  #filters-btn {
    width: 100%;
  }
  .filters-panel {
    left: 14px !important;
    right: 14px;
    width: auto;
  }

  /* Таблицы превращаются в карточки: заголовок скрыт, каждая строка — карточка
     с парами "лейбл — значение" (лейбл берётся из data-label ячейки). */
  .card {
    background: transparent;
    border: none;
    border-radius: 0;
  }
  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }
  thead {
    display: none;
  }
  tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
  }
  tbody tr:last-child {
    margin-bottom: 0;
  }
  tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    font-size: 13px;
  }
  tbody td:last-child {
    border-bottom: none;
  }
  tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    font-weight: 600;
    text-align: left;
    flex-shrink: 0;
  }
  tbody td.cell-actions {
    padding: 8px 10px;
  }
  tbody td.cell-actions::before {
    content: none;
  }
  tbody tr:hover {
    background: var(--surface);
  }
  .row-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .empty-state {
    padding: 44px 18px;
  }

  /* Модалки на весь экран — удобнее набирать текст на маленьком экране */
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .modal,
  .modal.modal-wide {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }

  .stat-row {
    flex-direction: column;
  }
}
