:root {
  --bg: #0a0716;
  --bg-soft: #120d24;
  --panel: #161029;
  --panel-2: #1c1433;
  --violet: #8b5cf6;
  --violet-deep: #6d28d9;
  --blue: #3b82f6;
  --red: #ef4444;
  --green: #34d399;
  --text: #f4f1ff;
  --muted: #9d95bd;
  --line: rgba(139, 92, 246, 0.22);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1100px 620px at 85% -10%, rgba(59, 130, 246, 0.12), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(109, 40, 217, 0.28), transparent 62%),
    radial-gradient(700px 500px at 50% 130%, rgba(139, 92, 246, 0.1), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
}

/* ---------- общие карточки и кнопки ---------- */

.card {
  background: linear-gradient(165deg, rgba(32, 24, 58, 0.92), rgba(18, 13, 36, 0.94));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 22px 48px rgba(2, 0, 10, 0.35);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.12);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.38;
  cursor: default;
  transform: none;
  filter: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.35);
}

.btn-blue {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.3);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-sm {
  padding: 8px 13px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
  padding: 12px;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.plus {
  font-size: 17px;
  line-height: 1;
  font-weight: 500;
}

/* ---------- вход ---------- */

.login-view {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: float 14s ease-in-out infinite alternate;
}

.orb-a {
  width: 420px;
  height: 420px;
  background: rgba(124, 58, 237, 0.5);
  top: -120px;
  left: -100px;
}

.orb-b {
  width: 380px;
  height: 380px;
  background: rgba(37, 99, 235, 0.38);
  bottom: -120px;
  right: -80px;
  animation-delay: -6s;
}

@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(30px, 24px, 0) scale(1.08); }
}

.login-card {
  position: relative;
  width: min(390px, 100%);
  padding: 34px 30px 30px;
  text-align: center;
  animation: rise 0.4s ease both;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  color: #a78bfa;
}

.login-logo svg {
  width: 74px;
  height: 74px;
  filter: drop-shadow(0 8px 22px rgba(139, 92, 246, 0.5));
}

.login-title {
  margin: 4px 0 2px;
  font-size: 27px;
  letter-spacing: 0.5px;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: block;
  text-align: left;
  margin-bottom: 15px;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  background: #0f0b20;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  resize: vertical;
  min-height: 90px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 16px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--violet);
}

.form-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 13px;
  text-align: left;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- каркас панели ---------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 244px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 22px;
  background: linear-gradient(180deg, rgba(22, 16, 41, 0.96), rgba(12, 8, 24, 0.98));
  border-right: 1px solid rgba(139, 92, 246, 0.16);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 6px 0 30px;
}

.brand-logo {
  color: #a78bfa;
  filter: drop-shadow(0 8px 20px rgba(139, 92, 246, 0.45));
}

.brand-logo svg {
  width: 66px;
  height: 66px;
}

.brand-name {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 1.2px;
  line-height: 1.08;
  text-align: center;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #cbc4e6;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-item:hover {
  background: rgba(139, 92, 246, 0.12);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  box-shadow: 0 10px 26px rgba(124, 58, 237, 0.42);
}

.nav-icon svg {
  width: 19px;
  height: 19px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid rgba(139, 92, 246, 0.14);
  color: var(--muted);
  font-size: 13px;
}

.admin-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #cbc4e6;
  font-weight: 600;
}

.crown svg {
  width: 17px;
  height: 17px;
  color: var(--violet);
}

.admin-ver {
  margin: 3px 0 12px 26px;
  font-size: 12px;
}

.logout-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.logout-link:hover {
  color: var(--text);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 30px 34px 44px;
  max-width: 1500px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.title-bar {
  width: 5px;
  height: 30px;
  border-radius: 4px;
  background: linear-gradient(180deg, #a78bfa, #6d28d9);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.7);
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #e4dff5;
  font-size: 15px;
}

.status-text b {
  font-weight: 700;
}

.online-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.8);
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.82); opacity: 0.7; }
}

.status-divider {
  width: 1px;
  height: 22px;
  background: rgba(139, 92, 246, 0.3);
  margin: 0 4px;
}

.clock-icon svg {
  width: 18px;
  height: 18px;
  color: #cbc4e6;
}

.clock {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
}

/* ---------- статистика ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 22px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 24px 28px;
  background:
    radial-gradient(340px 160px at 12% 0%, rgba(139, 92, 246, 0.16), transparent 70%),
    linear-gradient(165deg, rgba(36, 26, 66, 0.92), rgba(18, 13, 36, 0.94));
  transition: transform 0.2s ease, border-color 0.2s ease;
  animation: rise 0.35s ease both;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.4);
}

.stat-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.13);
}

.stat-icon svg {
  width: 38px;
  height: 38px;
}

.stat-icon.ring {
  background: transparent;
  border: 2px solid rgba(139, 92, 246, 0.7);
  box-shadow: 0 0 24px rgba(139, 92, 246, 0.28), inset 0 0 18px rgba(139, 92, 246, 0.14);
  color: #a78bfa;
}

.stat-num {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.5px;
}

.stat-label {
  margin-top: 6px;
  color: #b9b1d6;
  font-size: 15px;
}

/* ---------- карточка списка ---------- */

.list-card {
  padding: 24px 26px 10px;
  margin-bottom: 22px;
  animation: rise 0.4s ease both;
}

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

.card-title {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.section-icon {
  color: #a78bfa;
  display: inline-flex;
}

.section-icon svg {
  width: 24px;
  height: 24px;
}

.card-title h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.latest-badge {
  margin-left: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

.subs-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.subs-table th {
  padding: 16px 10px;
  text-align: left;
  color: #b3abce;
  font-size: 14px;
  font-weight: 600;
}

.subs-table td {
  padding: 14px 10px;
  border-top: 1px solid rgba(139, 92, 246, 0.13);
  vertical-align: middle;
}

.subs-table tbody tr {
  transition: background 0.15s ease;
}

.subs-table tbody tr:hover {
  background: rgba(139, 92, 246, 0.06);
}

.hwid-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hwid-cell svg {
  width: 21px;
  height: 21px;
  color: #a78bfa;
  flex: none;
}

.hwid-text {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13.5px;
  letter-spacing: 0.4px;
  color: #e7e2fa;
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.hwid-text:hover {
  color: #c4b5fd;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.time-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 15px;
  color: #eee9ff;
  white-space: nowrap;
}

.time-cell.expired {
  color: #f87171;
}

.frozen-tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #93c5fd;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.name-cell {
  font-size: 15px;
  color: #f4f1ff;
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.empty {
  padding: 26px 6px 30px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ---------- обновления ---------- */

.updates-list {
  display: flex;
  flex-direction: column;
}

.update-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 4px;
  border-top: 1px solid rgba(139, 92, 246, 0.13);
  flex-wrap: wrap;
}

.update-row:first-child {
  border-top: 0;
}

.update-main {
  min-width: 0;
  flex: 1 1 320px;
}

.update-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.update-version {
  font-size: 17px;
  font-weight: 700;
}

.badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.required {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.badge.optional {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #93c5fd;
}

.badge.latest {
  background: rgba(52, 211, 153, 0.13);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}

.update-date {
  color: var(--muted);
  font-size: 12.5px;
}

.update-desc {
  margin-top: 8px;
  color: #cfc9e8;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.update-desc.empty-desc {
  color: #6f6790;
  font-style: italic;
}

.update-meta {
  margin-top: 8px;
  color: #7f77a2;
  font-size: 12px;
  font-family: Consolas, "Cascadia Mono", monospace;
  overflow-wrap: anywhere;
}

.update-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.update-actions .btn {
  padding: 7px 12px;
  font-size: 12.5px;
}

.page-foot {
  margin-top: 8px;
  color: #6f6790;
  font-size: 12px;
  text-align: center;
}

/* ---------- модальные окна ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 2, 10, 0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.16s ease both;
  overflow-y: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(470px, 100%);
  padding: 24px 24px 20px;
  animation: pop 0.2s ease both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-head h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(139, 92, 246, 0.14);
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.confirm-text {
  margin: 0 0 18px;
  color: #d6d0ec;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.progress-wrap {
  margin: 4px 0 14px;
}

.progress {
  height: 9px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.16);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #8b5cf6, #3b82f6);
  transition: width 0.2s ease;
}

.progress-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

/* ---------- уведомления ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(380px, calc(100vw - 48px));
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(30, 22, 54, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(46, 16, 24, 0.96);
  color: #fecaca;
}

/* ---------- адаптивность ---------- */

@media (max-width: 1000px) {
  .main {
    padding: 24px 20px 36px;
  }

  .sidebar {
    width: 214px;
    padding: 22px 14px 18px;
  }
}

@media (max-width: 820px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid rgba(139, 92, 246, 0.16);
  }

  .brand {
    flex-direction: row;
    gap: 8px;
    padding: 0;
  }

  .brand-logo svg {
    width: 34px;
    height: 34px;
  }

  .brand-name {
    font-size: 15px;
    line-height: 1.1;
    text-align: left;
  }

  .brand-name br {
    display: none;
  }

  .nav {
    margin-left: auto;
  }

  .nav-item {
    padding: 9px 14px;
    font-size: 14px;
  }

  .sidebar-foot {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .admin-line,
  .admin-ver {
    display: none;
  }

  .main {
    padding: 20px 16px 34px;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .stat-num {
    font-size: 36px;
  }

  .stat-card {
    padding: 18px 20px;
  }

  .subs-table {
    min-width: 0;
  }

  .subs-table thead {
    display: none;
  }

  .subs-table,
  .subs-table tbody,
  .subs-table tr,
  .subs-table td {
    display: block;
    width: 100%;
  }

  .subs-table tr {
    margin: 10px 0;
    padding: 8px 14px;
    border: 1px solid rgba(139, 92, 246, 0.16);
    border-radius: 14px;
    background: rgba(19, 14, 38, 0.6);
  }

  .subs-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    padding: 7px 0;
    white-space: normal;
  }

  .subs-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    flex: none;
  }

  .actions-cell {
    justify-content: flex-end;
    padding-top: 10px !important;
  }

  .actions-cell::before {
    display: none;
  }

  .update-row {
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .topbar h1 {
    font-size: 21px;
  }

  .status {
    width: 100%;
    justify-content: space-between;
  }

  .card-head {
    align-items: flex-start;
  }

  .card-head .btn {
    width: 100%;
  }

  .list-card {
    padding: 18px 14px 8px;
  }
}
