/* BIZPEOPLE VPN, админка. Цвета — только через переменные: фирменная палитра меняется здесь. */

:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-sunken: #eef0f3;
  --surface-hover: #f6f7f9;
  --border: #dadee4;
  --border-strong: #838c98;
  --text: #15181c;
  --text-muted: #555d68;
  --text-faint: #646c77;
  --accent: #1b5e7b;
  --accent-hover: #154c64;
  --accent-text: #ffffff;
  --accent-soft: #e2edf2;
  --ok: #1e7148;
  --ok-soft: #e3f2ea;
  --warn: #8a5300;
  --warn-soft: #fbefd8;
  --warn-border: #ecd3a4;
  --danger: #b3261e;
  --danger-hover: #93201a;
  --danger-soft: #fbe9e7;
  --off: #5b636e;
  --off-soft: #eceef1;
  --focus: #2b7fa6;
  --backdrop: rgb(18 22 28 / 0.42);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgb(16 24 32 / 0.06);
  --shadow: 0 1px 2px rgb(16 24 32 / 0.06), 0 4px 16px rgb(16 24 32 / 0.05);
  --shadow-lg: 0 4px 8px rgb(16 24 32 / 0.06), 0 16px 40px rgb(16 24 32 / 0.14);
  --font:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1113;
    --surface: #171a1d;
    --surface-sunken: #111416;
    --surface-hover: #1d2124;
    --border: #2a2f35;
    --border-strong: #5f6872;
    --text: #e7e9ec;
    --text-muted: #9ba3ad;
    --text-faint: #8a929c;
    --accent: #7dbad6;
    --accent-hover: #9acce2;
    --accent-text: #0a1c24;
    --accent-soft: #19303a;
    --ok: #74c99a;
    --ok-soft: #15291f;
    --warn: #e7b25c;
    --warn-soft: #2e2413;
    --warn-border: #4d3b1c;
    --danger: #f08a80;
    --danger-hover: #f6a8a0;
    --danger-soft: #3a1b18;
    --off: #a1a9b3;
    --off-soft: #22262b;
    --focus: #8cc6e0;
    --backdrop: rgb(0 0 0 / 0.6);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
    --shadow-lg: 0 4px 10px rgb(0 0 0 / 0.35), 0 18px 44px rgb(0 0 0 / 0.45);
  }
}

/* База */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 0.9375rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mark {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  font-size: 0.9375rem;
  line-height: 1;
}

.mark-name {
  font-weight: 750;
  letter-spacing: 0.06em;
}

.mark-tag {
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* Кнопки и поля */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 150ms ease-out,
    border-color 150ms ease-out,
    color 150ms ease-out;
}

.btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-ghost {
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-sunken);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: var(--accent-text);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-sm {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.btn.is-busy {
  cursor: progress;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

.field {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field-label {
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.field-optional {
  font-weight: 400;
  color: var(--text-faint);
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition:
    border-color 150ms ease-out,
    box-shadow 150ms ease-out;
}

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

.input:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Загрузка и вход */

.boot {
  min-height: 100vh;
}

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.login-form {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 22rem;
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-title {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Каркас */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 82rem;
  margin: 0 auto;
  padding: 12px 16px;
}

.main {
  max-width: 82rem;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

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

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Фильтры и поиск */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 150ms ease-out,
    color 150ms ease-out,
    border-color 150ms ease-out;
}

.chip:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.chip[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.chip-count {
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.chip[aria-pressed='true'] .chip-count {
  color: var(--accent);
}

.search {
  position: relative;
  flex: 0 1 18rem;
  min-width: 12rem;
}

.search .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  translate: 0 -50%;
  color: var(--text-faint);
  pointer-events: none;
}

.search-input {
  min-height: 36px;
  padding-left: 34px;
}

/* Таблица */

.table-box {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

.table-box:focus-visible {
  outline-offset: 3px;
}

.table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.table .num {
  text-align: right;
}

.table th:first-child,
.table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: inset -1px 0 0 var(--border);
}

.table th:first-child {
  z-index: 2;
  background: var(--surface-sunken);
}

.table tbody tr:hover td {
  background: var(--surface-hover);
}

.table tbody tr.is-off td:not(:last-child) {
  color: var(--text-muted);
}

.col-name {
  width: 15rem;
}

.cell-name {
  min-width: 11rem;
  max-width: 17rem;
}

.name-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.name-text {
  min-width: 0;
}

.pill.pill-card {
  display: none;
}

.sub.note {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.name {
  display: block;
  font-weight: 600;
  overflow-wrap: break-word;
}

.sub {
  display: block;
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.nowrap {
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.pill-active {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-expiring {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill-expired,
.pill-disabled {
  background: var(--off-soft);
  color: var(--off);
}

.pill-disabled::before {
  background: none;
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  color: var(--text-muted);
}

.live::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.live.is-on {
  color: var(--ok);
  font-weight: 600;
}

.live.is-on::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.live.is-unknown::before {
  display: none;
}

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

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.extend {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.extend button {
  min-width: 46px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.extend button + button {
  border-left: 1px solid var(--border-strong);
}

.extend button:hover:not([aria-disabled='true']) {
  background: var(--accent-soft);
}

.extend button:focus-visible {
  outline-offset: -2px;
}

.extend button[aria-disabled='true'] {
  cursor: progress;
  color: var(--text-faint);
}

.more[aria-disabled='true'] {
  cursor: progress;
  opacity: 0.55;
}

.act {
  min-height: 34px;
  font-size: 0.8125rem;
}

.more {
  width: 34px;
  height: 34px;
  border-color: var(--border-strong);
}

.more[aria-expanded='true'] {
  background: var(--surface-sunken);
  color: var(--text);
}

/* Скелет загрузки */

.skeleton td {
  height: 61px;
}

.skeleton-bar {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: var(--surface-sunken);
}

.skeleton-bar.w-60 {
  width: 60%;
}

.skeleton-bar.w-40 {
  width: 40%;
}

.skeleton-bar.w-80 {
  width: 80%;
}

/* Пустые состояния */

.load-error {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 28px 24px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
}

.load-error .empty-text {
  color: var(--text);
}

.empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  margin-top: 12px;
  padding: 28px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty-title {
  font-size: 1.0625rem;
  font-weight: 650;
}

.empty-text {
  max-width: 34rem;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.updated {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--text-faint);
}

/* Меню строки */

.menu {
  position: fixed;
  inset: auto;
  min-width: 13rem;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-sunken);
}

.menu-item:focus-visible {
  outline-offset: -2px;
}

.menu-danger {
  color: var(--danger);
}

.menu-danger:hover,
.menu-danger:focus-visible {
  background: var(--danger-soft);
}

.menu-sep {
  height: 1px;
  margin: 6px 4px;
  border: 0;
  background: var(--border);
}

/* Диалоги */

.dialog {
  width: min(30rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.dialog-narrow {
  width: min(26rem, calc(100vw - 32px));
}

.dialog::backdrop {
  background: var(--backdrop);
}

.dialog[open] {
  animation: dialog-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

.dialog-body {
  display: grid;
  gap: 18px;
  padding: 22px 22px 20px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: -4px -8px -4px 0;
}

.dialog-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

.dialog-title:focus {
  outline: none;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.confirm-text,
.result-lead {
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.result-lead strong {
  color: var(--text);
}

.term {
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.segmented label {
  position: relative;
  display: block;
}

.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  transition:
    background-color 150ms ease-out,
    border-color 150ms ease-out;
}

.segmented label:hover span {
  background: var(--surface-hover);
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.copy {
  display: flex;
  gap: 8px;
}

.btn.is-done {
  border-color: var(--ok);
  color: var(--ok);
}

.copy-field {
  flex: 1;
  min-width: 0;
  background: var(--surface-sunken);
  font-family: var(--mono);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
}

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

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  display: grid;
  justify-items: end;
  gap: 8px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 26rem;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-error {
  background: var(--danger);
  color: var(--accent-text);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 160ms ease-in,
    transform 160ms ease-in;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Узкие экраны */

@media (max-width: 720px) {
  .search {
    flex: 1 1 100%;
  }

  /* Строки — карточки: имя и статус сверху, данные сеткой, действия внизу */
  .table-box {
    overflow: visible;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    min-width: 0;
  }

  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table tbody {
    display: grid;
    gap: 10px;
  }

  .table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .table th,
  .table td,
  .table th:first-child,
  .table td:first-child {
    position: static;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .table tbody tr:hover td {
    background: none;
  }

  .table .num {
    text-align: left;
  }

  .table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-faint);
  }

  .cell-name,
  .cell-actions {
    grid-column: 1 / -1;
  }

  .cell-name {
    max-width: none;
  }

  .cell-status {
    display: none !important;
  }

  .pill.pill-card {
    display: inline-flex;
    flex: none;
  }

  .cell-actions {
    padding-top: 12px !important;
    border-top: 1px solid var(--border) !important;
  }

  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .skeleton td {
    height: 18px;
  }

  .skeleton td:first-child {
    grid-column: 1 / -1;
  }

  .page-title {
    font-size: 1.375rem;
  }
}

@media (max-width: 480px) {
  .page-head .btn-primary {
    width: 100%;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toasts {
    left: 16px;
    right: 16px;
    justify-items: stretch;
  }

  .toast {
    max-width: none;
  }

  .dialog-body {
    padding: 20px 16px 16px;
  }
}

/* Пальцы, а не мышь: цели не меньше 44px */
@media (pointer: coarse) {
  .btn,
  .btn-sm,
  .chip,
  .search-input,
  .act,
  .more,
  .icon-btn {
    min-height: 44px;
  }

  .more,
  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .extend button {
    min-height: 44px;
    min-width: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
