:root {
  --bg-0: #07131f;
  --bg-1: #0b1f33;
  --bg-2: #12304a;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(186, 214, 236, 0.18);
  --text: #e8f1f8;
  --muted: #9bb4c7;
  --accent: #2ec4b6;
  --accent-2: #3d8bfd;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(46, 196, 182, 0.22), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(61, 139, 253, 0.2), transparent 50%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1) 45%, #0a2438);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body.is-webview {
  user-select: none;
  -webkit-user-select: none;
}
body.is-webview input,
body.is-webview textarea,
body.is-webview [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}

.app-shell {
  min-height: 100%;
  min-height: 100dvh;
  width: min(480px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(46, 196, 182, 0.35);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 11px;
  border: 2px solid rgba(7, 19, 31, 0.85);
  border-radius: 4px;
}
.brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.brand-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.hero-title {
  font-size: clamp(1.8rem, 6vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin: 0 0 12px;
}
.lead {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.steps {
  display: grid;
  gap: 12px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(10px);
  animation: rise 0.55s ease both;
}
.steps li:nth-child(2) { animation-delay: 0.08s; }
.steps li:nth-child(3) { animation-delay: 0.16s; }
.steps li:nth-child(4) { animation-delay: 0.24s; }
.steps li::before {
  content: counter(step);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--mono);
  background: linear-gradient(160deg, rgba(46, 196, 182, 0.25), rgba(61, 139, 253, 0.2));
  border: 1px solid var(--line);
}
.steps h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
}
.steps p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.panel {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  backdrop-filter: blur(12px);
  padding: 20px;
  box-shadow: var(--shadow);
}

.btn {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  color: #041018;
  background: linear-gradient(135deg, var(--accent), #5eead4);
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}
.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #ff6b6b, #e03131);
}

.stack { display: grid; gap: 14px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.form-group { display: grid; gap: 8px; }
.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #cfe0ee;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="file"] {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(4, 16, 24, 0.45);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  outline: none;
}
.form-group input:focus {
  border-color: rgba(46, 196, 182, 0.7);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.18);
}
.form-group input[type="file"] {
  padding: 10px;
  font-size: 0.9rem;
}
.hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
  line-height: 1.4;
}
.alert-error {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.12);
  color: #ffd4d4;
}
.alert-ok {
  border-color: rgba(61, 220, 151, 0.4);
  background: rgba(61, 220, 151, 0.12);
  color: #c9ffe6;
}

.download-box {
  margin-top: 8px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px dashed rgba(46, 196, 182, 0.45);
  background: rgba(46, 196, 182, 0.08);
}
.download-box code {
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-all;
  color: #b8f3ea;
}

.qr-wrap {
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 20px;
  background: #fff;
  margin: 8px auto 18px;
  width: fit-content;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}
.pass-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
}
.pass-email {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 18px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(61, 220, 151, 0.12);
  border: 1px solid rgba(61, 220, 151, 0.35);
  color: var(--ok);
  font-size: 0.82rem;
  font-weight: 700;
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.2);
  animation: pulse 1.8s ease infinite;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }

.app-shell.admin-shell { width: min(960px, 100%); }
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.admin-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
}

.status-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
}
.status-available { color: #9ae6b4; }
.status-assigned { color: #90cdf4; }
.status-downloaded { color: #f6e05e; }
.status-installed { color: #b794f4; }
.status-full { color: #fc8181; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.85); opacity: 0.7; }
}

@media (min-width: 768px) {
  .app-shell:not(.admin-shell) {
    padding-top: 48px;
  }
}
