:root {
  --bg: #0b1016;
  --bg-elevated: rgba(16, 22, 31, 0.55);
  --ink: #e8eef6;
  --ink-soft: #8b9aab;
  --line: rgba(184, 210, 235, 0.12);
  --line-strong: rgba(184, 210, 235, 0.22);
  --accent: #9ec9ff;
  --accent-soft: rgba(158, 201, 255, 0.14);
  --accent-press: #b8d8ff;
  --ok: #7dcea0;
  --err: #f0a0a0;
  --radius: 8px;
  --font-display: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-auth: "Barlow", "IBM Plex Sans", sans-serif;
  --font-phone: "Barlow", "IBM Plex Sans", sans-serif;
}

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

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

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.stage {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
  overflow: hidden;
}

.atmosphere {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% -10%, rgba(158, 201, 255, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 80%, rgba(158, 201, 255, 0.05), transparent 50%),
    linear-gradient(180deg, #0d131b 0%, #0b1016 55%, #090d12 100%);
  z-index: 0;
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background-image:
    linear-gradient(rgba(158, 201, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(158, 201, 255, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 15%, transparent 70%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    transparent 70%,
    rgba(11, 16, 22, 0.55) 100%
  );
}

.auth {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  font-family: var(--font-auth);
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand {
  margin-bottom: 2.5rem;
}

.brand__mark {
  margin: 0;
  font-family: var(--font-auth);
  font-size: clamp(1.7rem, 6.5vw, 2.35rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--ink);
}

.form {
  display: grid;
  gap: 1.1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.phone {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: stretch;
  min-height: 3.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.phone:hover {
  border-color: var(--line-strong);
}

.phone:focus-within {
  border-color: var(--accent);
  background: rgba(158, 201, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(158, 201, 255, 0.35);
}

.phone__prefix {
  display: grid;
  place-items: center;
  min-width: 3.4rem;
  padding: 0 0.85rem;
  border-right: 1px solid var(--line);
  font-family: var(--font-phone);
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  user-select: none;
}

.phone__track {
  position: relative;
  display: grid;
  align-items: center;
  min-width: 0;
}

.phone__ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 1.05rem;
  font-family: var(--font-phone);
  font-size: clamp(1.25rem, 4.8vw, 1.55rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  line-height: 1;
  pointer-events: none;
  white-space: pre;
}

.phone__ghost .is-empty {
  color: rgba(139, 154, 171, 0.38);
}

.phone__ghost .is-filled {
  color: transparent;
}

.phone__ghost .is-sep {
  color: rgba(139, 154, 171, 0.28);
}

.phone__ghost .is-sep.is-active {
  color: transparent;
}

.field__label {
  font-family: var(--font-auth);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field__input {
  width: 100%;
  min-height: 3rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink);
  font: inherit;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  outline: none;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.phone__input {
  position: relative;
  z-index: 1;
  min-height: 3.75rem;
  padding: 0 1.05rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  caret-color: var(--accent);
  font-family: var(--font-phone);
  font-size: clamp(1.25rem, 4.8vw, 1.55rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  line-height: 1;
}

.phone__input:hover,
.phone__input:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.field__input::placeholder {
  color: rgba(139, 154, 171, 0.55);
}

.field__input:hover {
  border-color: var(--line-strong);
}

.field__input:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(158, 201, 255, 0.35);
}

.form__status {
  min-height: 1.2rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}

.form__status.is-ok {
  color: var(--ok);
}

.form__status.is-err {
  color: var(--err);
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  margin-top: 0.15rem;
  padding: 0 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #0b1016;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

.btn:hover:not(:disabled) {
  background: var(--accent-press);
  box-shadow: 0 8px 24px rgba(158, 201, 255, 0.18);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.is-loading {
  cursor: wait;
  pointer-events: none;
}

.btn.is-loading .btn__label {
  opacity: 0;
}

.btn.is-loading .btn__spinner {
  opacity: 1;
}

.btn.is-success {
  background: rgba(125, 206, 160, 0.18);
  border-color: rgba(125, 206, 160, 0.45);
  color: var(--ok);
}

.btn.is-error {
  background: rgba(240, 160, 160, 0.12);
  border-color: rgba(240, 160, 160, 0.35);
  color: var(--err);
}

.btn__label {
  transition: opacity 0.18s ease;
}

.btn__spinner {
  position: absolute;
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.7s linear infinite;
  transition: opacity 0.18s ease;
}

.btn--ghost {
  margin-top: 0;
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
  box-shadow: none;
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn--small {
  min-height: 2.35rem;
  padding: 0 0.9rem;
  font-size: 0.84rem;
}

.stage--cabinet {
  align-items: stretch;
  place-items: stretch;
}

.cabinet {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 0.5rem 0 1.5rem;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.cabinet__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.cabinet__brand {
  margin: 0 0 0.65rem;
  font-family: var(--font-auth);
  font-size: clamp(1.45rem, 5.5vw, 2rem);
  letter-spacing: 0.01em;
}

.cabinet__phone {
  margin: 0;
  min-height: 1.2rem;
  font-family: var(--font-phone);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(var(--tabs-count, 3), minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.tabs[data-count="1"] {
  --tabs-count: 1;
}

.tabs[data-count="2"] {
  --tabs-count: 2;
}

.tabs[data-count="3"] {
  --tabs-count: 3;
}

.tabs__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease;
}

.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #2dff8a;
  box-shadow:
    0 0 0 3px rgba(45, 255, 138, 0.22),
    0 0 12px rgba(45, 255, 138, 0.7);
  transition:
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.status-dot.is-on {
  background: #2dff8a;
  box-shadow:
    0 0 0 3px rgba(45, 255, 138, 0.22),
    0 0 12px rgba(45, 255, 138, 0.7);
}

.status-dot.is-off {
  background: #ff4d4d;
  box-shadow:
    0 0 0 3px rgba(255, 77, 77, 0.25),
    0 0 12px rgba(255, 77, 77, 0.75);
}

.tabs__btn .status-dot {
  width: 0.62rem;
  height: 0.62rem;
}

.server-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  width: fit-content;
  margin: 0;
  padding: 0.4rem 0.7rem 0.4rem 0.55rem;
  border: 1px solid rgba(45, 255, 138, 0.28);
  border-radius: 999px;
  background: rgba(45, 255, 138, 0.1);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #7dffb2;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease;
}

.server-status.is-off {
  border-color: rgba(255, 77, 77, 0.32);
  background: rgba(255, 77, 77, 0.12);
  color: #ff8f8f;
}

.server-status .status-dot {
  width: 0.72rem;
  height: 0.72rem;
}

.server-status.is-off .status-dot {
  background: #ff4d4d;
  box-shadow:
    0 0 0 3px rgba(255, 77, 77, 0.25),
    0 0 12px rgba(255, 77, 77, 0.75);
}

.server-status.is-on .status-dot {
  background: #2dff8a;
  box-shadow:
    0 0 0 3px rgba(45, 255, 138, 0.22),
    0 0 12px rgba(45, 255, 138, 0.7);
}

.tabs__btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.tabs__btn.is-active,
.tabs__btn[aria-selected="true"] {
  color: #0b1016;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(158, 201, 255, 0.16);
}

.tabs__btn-full {
  display: none;
}

.tabs__btn-label {
  display: inline;
}

.panel {
  position: relative;
  min-height: 18rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.loader {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.85rem;
  min-height: 18rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.loader[hidden],
.panel__empty[hidden],
.link-view[hidden],
.tabs[hidden] {
  display: none !important;
}

.loader__spin {
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid rgba(158, 201, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.panel__empty {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 18rem;
  padding: 1.5rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  text-align: center;
}

.link-view {
  display: grid;
  gap: 1.25rem;
  padding: 1.25rem;
}

.link-view.is-enter {
  animation: fade-swap 0.28s ease both;
}

.link-view__qr {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  width: fit-content;
  margin: 0 auto;
  padding: 0.75rem;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  cursor: zoom-in;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.link-view__qr:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.link-view__qr:active {
  transform: scale(0.99);
}

.link-view__qr img {
  display: block;
  width: min(220px, 62vw);
  height: auto;
  pointer-events: none;
}

.link-view__qr img[hidden],
.link-view__qr[hidden] {
  display: none;
}

.link-view__qr-hint {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: rgba(11, 16, 22, 0.55);
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
}

.modal[hidden] {
  display: none !important;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  padding: 1rem 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #101821;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.modal.is-open .modal__backdrop {
  opacity: 1;
}

.modal.is-open .modal__dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal__close {
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-strong);
}

.modal__qr {
  display: grid;
  place-items: center;
  padding: 1rem;
  border-radius: 14px;
  background: #fff;
}

.modal__qr img {
  display: block;
  width: min(320px, 78vw);
  height: auto;
}

.link-view__content {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.link-view__heading {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.link-view__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.link-view__content {
  gap: 0.75rem;
}

.link-view__updated {
  margin: -0.35rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.link-view__value {
  margin: 0;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-soft);
  word-break: break-all;
  max-height: 8.5rem;
  overflow: auto;
}

.link-view__content .btn {
  margin-top: 0;
  width: 100%;
}

.skeleton {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(158, 201, 255, 0.08),
    rgba(158, 201, 255, 0.18),
    rgba(158, 201, 255, 0.08)
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}

.skeleton--text {
  width: 10rem;
  height: 0.9rem;
}

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

@keyframes fade-swap {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@media (min-width: 640px) {
  .tabs__btn-label {
    display: none;
  }

  .tabs__btn-full {
    display: inline;
  }

  .link-view {
    grid-template-columns: auto 1fr;
    align-items: start;
    padding: 1.45rem;
  }

  .link-view__qr {
    margin: 0;
  }

  .link-view__content .btn {
    width: auto;
    justify-self: start;
    min-width: 12rem;
  }
}

@media (min-width: 768px) {
  .auth {
    width: min(100%, 420px);
    padding: 2.25rem 2.25rem 2.35rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-elevated);
  }

  .brand {
    margin-bottom: 2.6rem;
  }
}

@media (max-width: 767px) {
  .stage {
    align-items: flex-start;
    padding-top: max(2.75rem, env(safe-area-inset-top));
  }

  .auth {
    width: 100%;
  }

  .cabinet__top {
    flex-direction: column;
  }

  .cabinet__top .btn {
    width: 100%;
  }

  .brand__mark {
    animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .form {
    animation: rise 0.65s 0.06s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth,
  .brand__mark,
  .form,
  .cabinet,
  .link-view.is-enter,
  .skeleton,
  .btn__spinner,
  .loader__spin {
    animation: none;
  }

  .btn,
  .tabs__btn,
  .field__input,
  .phone,
  .link-view__qr,
  .modal__backdrop,
  .modal__dialog,
  .modal__close {
    transition: none;
  }

  .btn:hover:not(:disabled),
  .link-view__qr:hover {
    transform: none;
  }

  .modal.is-open .modal__dialog {
    transform: none;
  }
}
