:root {
  --background: #000000;
  --foreground: #eef6ff;
  --muted: #9bb0c4;
  --blue: #0077ff;
  --blue-glow: #00d4ff;
  --navy: #0a2744;
  --gold: #c5a059;
  --gold-deep: #d4af37;
  --card: #071018e8;
  --line: #6fb6ff22;
}

* { box-sizing: border-box; }

html {
  background: var(--background);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--background);
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  color: var(--foreground);
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  overscroll-behavior-x: none;
}

button, input { font: inherit; }

.site-shell {
  isolation: isolate;
  background:
    radial-gradient(circle at 50% -8%, #00d4ff28, #0000 42%),
    radial-gradient(circle at 80% 90%, #0077ff18, #0000 36%),
    linear-gradient(145deg, #02060c 0%, #000000 48%, #071525 100%);
  place-items: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 36px 20px;
  display: grid;
  position: relative;
  overflow-x: hidden;
  overflow-y: visible;
}

.site-shell:before {
  z-index: -2;
  content: "";
  background-image:
    linear-gradient(#ffffff05 1px, #0000 1px),
    linear-gradient(90deg, #ffffff05 1px, #0000 1px);
  background-size: 54px 54px;
  position: absolute;
  inset: 0;
  -webkit-mask-image: radial-gradient(circle, #000 12%, #0000 70%);
  mask-image: radial-gradient(circle, #000 12%, #0000 70%);
}

.ambient {
  z-index: -1;
  filter: blur(90px);
  opacity: .2;
  pointer-events: none;
  border-radius: 999px;
  position: absolute;
}

.ambient-one {
  background: var(--blue-glow);
  width: 270px;
  height: 270px;
  top: 8%;
  left: 12%;
}

.ambient-two {
  background: var(--gold-deep);
  opacity: .12;
  width: 240px;
  height: 240px;
  bottom: 5%;
  right: 10%;
}

.content-card {
  background: linear-gradient(145deg, #00d4ff12, transparent 38%), var(--card);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  border: 1px solid #00d4ff3d;
  border-radius: 30px;
  width: min(100%, 560px);
  padding: 28px 38px 26px;
  box-shadow: 0 34px 90px #00000094, inset 0 0 0 1px #ffffff08, 0 0 55px #00d4ff22;
}

.admin-card {
  width: min(100%, 920px);
}

.brand {
  justify-content: center;
  height: 210px;
  margin-bottom: 4px;
  display: flex;
}

.brand-logo {
  object-fit: contain;
  filter: drop-shadow(0 0 28px #00d4ff55);
  width: 210px;
  height: 210px;
}

.heading { text-align: center; }

.eyebrow {
  color: var(--gold);
  letter-spacing: .2em;
  align-items: center;
  gap: 7px;
  font-size: .7rem;
  font-weight: 800;
  display: inline-flex;
}

.eyebrow:before,
.eyebrow:after {
  content: "";
  background: #00d4ff8c;
  width: 18px;
  height: 1px;
}

h1 {
  letter-spacing: -.045em;
  margin: 12px 0 10px;
  font-size: clamp(2rem, 7vw, 2.8rem);
  line-height: 1.02;
}

.heading p {
  max-width: 430px;
  color: var(--muted);
  margin: 0 auto;
  font-size: .98rem;
  line-height: 1.6;
}

.device-form { margin-top: 27px; }

.device-form label {
  color: #e8f4ff;
  letter-spacing: .02em;
  margin: 0 0 9px 3px;
  font-size: .82rem;
  font-weight: 700;
  display: block;
}

.input-wrap {
  background: #02070db3;
  border: 1px solid #6fb6ff33;
  border-radius: 16px;
  align-items: center;
  min-height: 62px;
  padding: 0 18px;
  transition: border-color .16s, box-shadow .16s, transform .16s;
  display: flex;
}

.input-wrap:focus-within {
  border-color: #00d4ffb8;
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px #00d4ff24;
}

.input-wrap.has-error { border-color: #f07178; }

.key-icon {
  width: 30px;
  height: 30px;
  color: var(--blue-glow);
  border: 1px solid #00d4ff59;
  border-radius: 9px;
  flex: 0 0 30px;
  place-items: center;
  font-weight: 900;
  display: grid;
}

.input-wrap input {
  color: #fff;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: 0 0;
  border: 0;
  outline: 0;
  width: 100%;
  min-width: 0;
  padding: 18px 0 18px 13px;
  font-size: 1.05rem;
  font-weight: 650;
}

.input-wrap .link-input {
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  font-weight: 500;
}

.input-wrap input::placeholder {
  color: #6d8498;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.field-message {
  color: #7e93a6;
  min-height: 19px;
  margin: 8px 3px 14px;
  font-size: .74rem;
  line-height: 1.4;
}

.field-message.error { color: #ff9298; }
.field-message.success { color: #7be3b0; }

.device-form button {
  color: #fff;
  cursor: pointer;
  letter-spacing: .02em;
  background: linear-gradient(100deg, #003366 0%, #0077ff 52%, #00d4ff 140%);
  border: 0;
  border-radius: 16px;
  justify-content: center;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 61px;
  font-size: .94rem;
  font-weight: 850;
  transition: transform .16s, box-shadow .16s, filter .16s;
  display: flex;
  box-shadow: 0 13px 30px #0077ff4d, inset 0 1px #fff3;
}

.device-form button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 17px 38px #00d4ff6b, inset 0 1px #ffffff40;
}

.device-form button:active:not(:disabled) { transform: translateY(0); }
.device-form button:disabled { opacity: .7; cursor: wait; }

.button-arrow {
  color: var(--gold);
  font-size: 1.35rem;
  line-height: 1;
}

.steps {
  border-top: 1px solid var(--line);
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: 27px;
  padding: 19px 5px 4px;
  display: grid;
}

.step {
  align-items: flex-start;
  gap: 10px;
  display: flex;
}

.step-number {
  width: 27px;
  height: 27px;
  color: var(--blue-glow);
  background: #00d4ff12;
  border: 1px solid #00d4ff52;
  border-radius: 50%;
  flex: 0 0 27px;
  place-items: center;
  font-size: .73rem;
  font-weight: 900;
  display: grid;
}

.step p {
  gap: 4px;
  margin: 1px 0 0;
  display: grid;
}

.step strong { font-size: .74rem; }

.step p span {
  color: #7e93a6;
  font-size: .67rem;
  line-height: 1.35;
}

.step-divider {
  background: var(--line);
  width: 1px;
  height: 38px;
}

footer {
  color: #6d8498;
  letter-spacing: .035em;
  justify-content: center;
  align-items: center;
  gap: 7px;
  margin-top: 25px;
  font-size: .67rem;
  display: flex;
  flex-wrap: wrap;
}

.admin-link {
  color: #00d4ff;
  text-decoration: none;
  margin-left: 6px;
}

.admin-link:hover { color: var(--gold); }

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000000d6;
  display: grid;
  place-items: center;
  padding: 20px;
}

.loader-overlay[hidden] { display: none; }

.success-card {
  width: min(100%, 440px);
  text-align: center;
  background: linear-gradient(160deg, #00d4ff18, transparent 42%), #061018f2;
  border: 1px solid #00d4ff66;
  border-radius: 28px;
  padding: 42px 28px 28px;
  box-shadow: 0 0 80px #00d4ff33, 0 30px 80px #000000c4;
}

.success-icon {
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  filter: drop-shadow(0 0 18px #00d4ff88);
}

.success-icon circle {
  fill: #00d4ff14;
  stroke: #00d4ff;
  stroke-width: 4;
}

.success-icon path {
  fill: none;
  stroke: #7be3b0;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: check-draw .45s .15s ease forwards;
}

.success-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 5vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -.03em;
}

.success-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.success-card button {
  color: #fff;
  cursor: pointer;
  background: linear-gradient(100deg, #003366 0%, #0077ff 52%, #00d4ff 140%);
  border: 0;
  border-radius: 14px;
  width: 100%;
  min-height: 52px;
  font-size: .95rem;
  font-weight: 850;
}

.confirm-card {
  border-color: #c5a05988;
  box-shadow: 0 0 80px #c5a05922, 0 30px 80px #000000c4;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions button {
  width: auto;
  flex: 1;
}

.ghost-btn {
  background: #02070db3 !important;
  border: 1px solid #6fb6ff55 !important;
  color: #e8f4ff !important;
}

.transfer-modal-label {
  text-align: left;
  margin: 0 0 8px;
}

.transfer-modal-select {
  width: 100%;
  margin-bottom: 16px;
}

.brand-pick {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0 0 16px;
  padding-right: 2px;
}

.brand-pick-btn {
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: #e8f4ff;
  background: #02070db3;
  border: 1px solid #6fb6ff33;
  border-radius: 12px;
  min-height: 44px;
  padding: 8px 12px;
  font-size: .9rem;
  font-weight: 700;
}

.brand-pick-btn.active {
  color: #fff;
  border-color: #00d4ffb8;
  background: #0077ff24;
}

@keyframes check-draw {
  to { stroke-dashoffset: 0; }
}

.loader-card {
  width: min(100%, 360px);
  text-align: center;
  background: #061018e8;
  border: 1px solid #00d4ff55;
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: 0 24px 70px #000000a3;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border: 3px solid #00d4ff33;
  border-top-color: var(--gold-deep);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-card p {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 800;
}

.loader-card span {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.dns-list {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.dns-item {
  background: #02070db3;
  border: 1px solid #6fb6ff33;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #e8f4ff;
  font-size: .9rem;
}

.dns-remove {
  cursor: pointer;
  color: #ff9298;
  background: #f0717814;
  border: 1px solid #f0717840;
  border-radius: 10px;
  min-height: 34px;
  padding: 0 12px;
  font-size: .75rem;
  font-weight: 700;
}

.dns-remove:hover { filter: brightness(1.1); }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.transfer-btn {
  cursor: pointer;
  color: #d8e8ff;
  background: #0077ff18;
  border: 1px solid #0077ff55;
  border-radius: 10px;
  min-height: 34px;
  padding: 0 12px;
  font-size: .75rem;
  font-weight: 700;
}

.transfer-btn:hover { filter: brightness(1.1); }

.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0 18px;
}

.tab-btn {
  cursor: pointer;
  color: #c5d8ea;
  background: #02070db3;
  border: 1px solid #6fb6ff33;
  border-radius: 12px;
  min-height: 40px;
  padding: 0 16px;
  font-size: .8rem;
  font-weight: 750;
}

.tab-btn.active {
  color: #fff;
  border-color: #00d4ffb8;
  background: #0077ff24;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 8px;
}

.delay-label {
  color: #e8f4ff;
  display: grid;
  gap: 6px;
  font-size: .78rem;
  font-weight: 700;
}

.delay-input {
  color: #fff;
  background: #02070db3;
  border: 1px solid #6fb6ff33;
  border-radius: 12px;
  width: 92px;
  min-height: 42px;
  padding: 0 12px;
}

.filter-select {
  width: 210px;
}

.file-input {
  color: #c5d8ea;
  margin: 0 0 12px;
  font-size: .82rem;
}

.brand-preview {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 0 12px;
  border-radius: 16px;
  background: #000;
  border: 1px solid #6fb6ff33;
}

.dns-item .admin-link,
.dns-item .pager-btn {
  margin-right: 8px;
}

.filter-key {
  width: 140px;
  text-transform: uppercase;
}

.devices-meta {
  color: #9bb0c4;
  margin: 0 3px 10px;
  font-size: .78rem;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: #9bb0c4;
  font-size: .8rem;
}

.pager-btn {
  cursor: pointer;
  color: #e8f4ff;
  background: #02070db3;
  border: 1px solid #6fb6ff33;
  border-radius: 10px;
  min-height: 34px;
  padding: 0 12px;
  font-size: .75rem;
  font-weight: 700;
}

.pager-btn:disabled {
  opacity: .4;
  cursor: default;
}

.secondary-btn,
.text-btn {
  cursor: pointer;
  color: #fff;
  background: linear-gradient(100deg, #003366 0%, #0077ff 70%);
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  padding: 0 16px;
  font-size: .8rem;
  font-weight: 800;
}

.text-btn {
  background: transparent;
  color: #00d4ff;
  min-height: auto;
  padding: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #6fb6ff33;
  border-radius: 16px;
}

.device-table {
  border-collapse: collapse;
  width: 100%;
  font-size: .78rem;
}

.device-table th,
.device-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #ffffff14;
  vertical-align: middle;
}

.device-table th {
  color: #9bb0c4;
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.m3u-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #b9b2c5;
}

.status-dot {
  background: #00d4ff;
  border-radius: 50%;
  width: 6px;
  height: 6px;
  box-shadow: 0 0 8px #00d4ffb3;
}

.result-card {
  display: none;
  margin-top: 18px;
  padding: 16px 16px 14px;
  border-radius: 16px;
  border: 1px solid #00d4ff40;
  background: #00d4ff12;
}

.result-card.visible { display: block; }

.result-card.error {
  border-color: #f0717840;
  background: #f0717812;
}

.result-card h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.result-card p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.5;
}

@media (hover: none) {
  .device-form button:hover:not(:disabled),
  .device-form button:active:not(:disabled) {
    filter: none;
    transform: none;
    box-shadow: 0 13px 30px #0077ff4d, inset 0 1px #fff3;
  }
}

@media (max-width: 560px) {
  html,
  body {
    touch-action: manipulation;
  }

  .site-shell {
    align-items: start;
    justify-items: center;
    padding: 16px 12px calc(24px + env(safe-area-inset-bottom));
  }

  .content-card {
    border-radius: 22px;
    width: 100%;
    max-width: 100%;
    padding: 20px 16px 18px;
  }

  .brand { height: 120px; margin-bottom: 0; }
  .brand-logo { width: 120px; height: 120px; }

  h1 {
    margin: 8px 0 8px;
    font-size: 1.7rem;
  }

  .heading p { font-size: .9rem; }

  .input-wrap:focus-within { transform: none; }

  .input-wrap,
  .input-wrap input,
  .input-wrap .link-input,
  .device-form button,
  .delay-input,
  select,
  .success-card button {
    font-size: 16px;
  }

  .steps {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
  }

  .step-divider {
    width: 100%;
    height: 1px;
  }

  .ambient-one,
  .ambient-two {
    width: 140px;
    height: 140px;
  }
}
