:root {
  --background: #f7f8fc;
  --foreground: #171a24;
  --muted-foreground: #646b7d;
  --card: #ffffff;
  --border: #e6e9f2;
  --input: #eceff7;
  --primary: #4353e8;
  --primary-hover: #3543ce;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(67, 83, 232, 0.1);
  --success: #12805c;
  --success-soft: rgba(18, 128, 92, 0.12);
  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, 0.12);
  --shadow-card: 0 28px 70px -28px rgba(25, 32, 72, 0.28);
  --shadow-soft: 0 12px 28px -16px rgba(25, 32, 72, 0.22);
  --radius-xl: 2rem;
  --radius-lg: 1.35rem;
  --radius-md: 1rem;
  --font-sans:
    "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--foreground);
  background-color: var(--background);
  background-image:
    radial-gradient(circle at 12% 0%, rgba(67, 83, 232, 0.12), transparent 32%),
    radial-gradient(circle at 88% 6%, rgba(107, 92, 231, 0.1), transparent 30%),
    radial-gradient(
      circle at 50% 100%,
      rgba(67, 83, 232, 0.07),
      transparent 36%
    );
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p,
dl,
dd,
dt {
  margin: 0;
}

.app-header {
  width: 100%;
  padding: 1rem 1rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.8rem;
  color: var(--primary-foreground);
  background: linear-gradient(145deg, #5666ff, #3543ce);
  box-shadow: 0 10px 20px -12px rgba(53, 67, 206, 0.9);
}

.brand-mark svg {
  width: 1.15rem;
  height: 1.15rem;
}

.app-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 2rem 1rem 2.5rem;
}

.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.25rem 1rem 1.75rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
}

.card {
  width: 100%;
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(230, 233, 242, 0.9);
  padding: 2rem 1.5rem;
  animation: card-in 0.5s ease both;
}

.card-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-align: center;
}

.card-head h1 {
  font-size: clamp(1.75rem, 5vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 700;
}

.subtitle {
  max-width: 28rem;
  color: var(--muted-foreground);
  font-size: 0.95rem;
  line-height: 1.55;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.chip-success {
  background: var(--success-soft);
  color: var(--success);
}

.chip-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

.chip-icon {
  flex: 0 0 auto;
  width: 0.9rem;
  height: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.75rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.2;
  transition:
    transform 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible,
.input:focus-visible,
.link-button:focus-visible,
.modal-close:focus-visible,
.qr-modal-close:focus-visible {
  outline: 3px solid rgba(67, 83, 232, 0.32);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: progress;
  opacity: 0.72;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 14px 26px -14px rgba(67, 83, 232, 0.9);
}

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

.btn-secondary {
  background: #ffffff;
  border-color: var(--border);
  color: var(--foreground);
  box-shadow: 0 8px 18px -14px rgba(25, 32, 72, 0.4);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(67, 83, 232, 0.35);
  color: var(--primary);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--foreground);
}

.input {
  width: 100%;
  min-height: 3.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--input);
  padding: 0.75rem 1rem;
  color: var(--foreground);
  font-size: 1rem;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.input:hover {
  background: #e7ebf5;
}

.input:focus {
  outline: none;
  border-color: rgba(67, 83, 232, 0.55);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(67, 83, 232, 0.12);
}

.input::-webkit-outer-spin-button,
.input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2rem 0.55rem;
  font-size: 0.83rem;
}

.link-separator {
  color: #aeb4c6;
}

.link-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--muted-foreground);
  font-size: inherit;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.22em;
  transition:
    color 0.15s ease,
    text-decoration-color 0.15s ease;
}

.link-button:hover {
  color: var(--foreground);
  text-decoration-color: currentColor;
}

.spinner {
  display: inline-block;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 3px solid rgba(67, 83, 232, 0.18);
  border-top-color: var(--primary);
  animation: spin 0.85s linear infinite;
}

.spinner-small {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

body.is-preloading {
  overflow: hidden;
}

body.is-preloading .app-header,
body.is-preloading .app-main,
body.is-preloading .app-footer {
  opacity: 0.75;
  pointer-events: none;
  user-select: none;
}

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(247, 248, 252, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: progress;
}

.loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-width: min(18rem, 100%);
  padding: 2rem;
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(230, 233, 242, 0.9);
  text-align: center;
}

.loader-card p {
  color: var(--muted-foreground);
  font-size: 0.95rem;
}

.preloader-card {
  width: min(21rem, 100%);
  gap: 0.85rem;
  padding: 1.75rem 1.75rem 1.5rem;
}

.preloader-title {
  color: var(--foreground);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.preloader-subtitle {
  max-width: 16rem;
  font-size: 0.82rem;
  line-height: 1.5;
}

.auth-error {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(192, 57, 43, 0.25);
  background: #fff8f7;
  text-align: left;
}

.auth-error-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--danger);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
}

.auth-error-title {
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-error-text {
  margin-top: 0.15rem;
  color: var(--muted-foreground);
  font-size: 0.83rem;
  line-height: 1.45;
}

.auth-error.is-network {
  border-color: rgba(183, 121, 31, 0.28);
  background: #fffaf0;
}

.auth-error.is-network .auth-error-icon {
  background: #b7791f;
}

.auth-error.is-network .auth-error-title {
  color: #b7791f;
}

.modal-body.policy-text {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-body.policy-text::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.notifications {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
}

.notification {
  width: min(26rem, 100%);
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  color: var(--foreground);
  font-size: 0.9rem;
  line-height: 1.4;
  pointer-events: auto;
  animation: notification-in 0.25s ease both;
}

.notification::before {
  content: "";
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: var(--primary);
}

.notification-error {
  border-color: rgba(192, 57, 43, 0.25);
  background: #fff8f7;
}

.notification-error::before {
  background: var(--danger);
}

.notification-success {
  border-color: rgba(18, 128, 92, 0.25);
  background: #f5fdfa;
}

.notification-success::before {
  background: var(--success);
}

.notification.is-hiding {
  animation: notification-out 0.3s ease both;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(20, 24, 40, 0.42);
  backdrop-filter: blur(4px);
}

.modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 32rem;
  max-height: min(85vh, 44rem);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: 0 30px 80px -30px rgba(20, 24, 40, 0.55);
  overflow: hidden;
  animation: modal-in 0.25s ease both;
}

.modal-content-wide {
  max-width: 44rem;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.35rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.15rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.modal-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: var(--input);
  color: var(--muted-foreground);
  font-size: 1.15rem;
  line-height: 1;
}

.modal-close:hover {
  background: #e1e6f2;
  color: var(--foreground);
}

.modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.15rem 1.35rem 1.5rem;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-body p + p {
  margin-top: 0.7rem;
}

.policy-text p {
  text-align: left;
}

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

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

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

@keyframes notification-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 640px) {
  .app-header {
    padding: 1.15rem 1.5rem 0;
  }

  .app-main {
    padding: 2.5rem 1.5rem 3rem;
  }

  .card {
    padding: 2.5rem 2.25rem;
  }
}
