:root {
  --bg: #07080c;
  --surface: rgba(255,255,255,0.035);
  --surface-2: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.18);
  --text: #f3f4f8;
  --text-dim: #9aa0b4;
  --text-faint: #656b80;
  --accent: #7c93ff;
  --accent-2: #b083ff;
  --accent-3: #ff8fd8;
  --accent-4: #5ad9ff;
  --danger: #ff6b6b;
  --success: #6cffa1;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow-soft: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-lift: 0 24px 60px rgba(0,0,0,0.55);
  --gradient-main: linear-gradient(135deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  letter-spacing: -0.011em;
  background-color: var(--bg);
}

/* Animated aurora backdrop, behind everything, fixed to viewport */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(circle at 18% 20%, rgba(124,147,255,0.38), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(176,90,255,0.32), transparent 42%),
    radial-gradient(circle at 25% 85%, rgba(255,143,216,0.24), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(90,217,255,0.26), transparent 42%);
  filter: blur(70px);
  animation: auroraDrift 26s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes auroraDrift {
  0%   { transform: translate(0,0) scale(1) rotate(0deg); }
  50%  { transform: translate(-3%, 3%) scale(1.1) rotate(4deg); }
  100% { transform: translate(3%, -2%) scale(1.02) rotate(-3deg); }
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

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

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: #b9c4ff; text-decoration: none; }

::selection { background: rgba(124,147,255,0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

.gradient-text {
  background: var(--gradient-main);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradientShift 6s ease infinite;
}

/* Brand mark */
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16.5px; }
.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--gradient-main);
  background-size: 220% 220%;
  animation: gradientShift 7s ease infinite;
  color: #0a0b10;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(176,90,255,0.4);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 28px;
  background: rgba(9,10,15,0.7);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,147,255,0.7), rgba(255,143,216,0.6), transparent);
  opacity: 0.55;
}
.topbar nav { display: flex; gap: 8px; align-items: center; font-size: 14px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 550;
  padding-right: 10px;
  margin-right: 4px;
  border-right: 1px solid var(--border);
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #0a0b10;
  background: var(--gradient-main);
  background-size: 220% 220%;
  animation: gradientShift 8s ease infinite;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border-color: var(--border);
  text-decoration: none;
}
.nav-link.primary {
  background: rgba(124,147,255,0.12);
  border-color: rgba(124,147,255,0.35);
  color: #c3cdff;
}
.nav-link.primary:hover { background: rgba(124,147,255,0.2); }
.nav-link.quiet { color: var(--text-faint); }
.nav-link.quiet:hover { color: var(--danger); background: rgba(255,107,107,0.08); }

/* App grid */
.app-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
  padding: 28px 28px 80px;
  max-width: 1240px;
  margin: 0 auto;
}
.app-grid-top { padding-top: 48px; }
.app-card { flex: 1 1 340px; max-width: 380px; }

.app-card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: var(--shadow-soft);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s ease, border-color .3s ease;
  animation: fadeUp .6s cubic-bezier(.2,.8,.2,1) backwards;
  animation-delay: calc(var(--i, 0) * 80ms);
}
.app-card:hover {
  transform: translateY(-6px) scale(1.012);
  border-color: rgba(176,131,255,0.55);
  box-shadow: 0 22px 54px rgba(124,147,255,0.22), 0 10px 24px rgba(255,143,216,0.16);
}

.app-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.app-card-link:hover { text-decoration: none; color: inherit; }

.app-card-shot {
  display: block;
  width: calc(100% + 44px);
  margin: -22px -22px 16px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 1px solid var(--border);
}

.app-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.app-card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}

.app-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.app-icon-fallback {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: #0a0b10;
  background: var(--gradient-main);
  background-size: 220% 220%;
  animation: gradientShift 8s ease infinite;
}

.app-heading { min-width: 0; }
.app-heading h2 { margin: 0 0 3px; font-size: 18px; font-weight: 650; letter-spacing: -0.015em; }
.app-heading .tagline { margin: 0; color: var(--text-dim); font-size: 13.5px; }
.desc { margin: 0 0 14px; font-size: 13.5px; line-height: 1.55; color: #c9cbdb; }

.meta { display: flex; gap: 7px; margin-bottom: 14px; flex-wrap: wrap; }

.badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}

.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gradient-main);
  background-size: 220% 220%;
  animation: gradientShift 9s ease infinite;
  color: #0a0b10;
  padding: 9px 18px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 13.5px;
  border: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  box-shadow: 0 8px 22px rgba(124,147,255,0.3);
}
.btn::after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.6), transparent);
  transform: skewX(-20deg);
  transition: left .6s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); text-decoration: none; box-shadow: 0 14px 30px rgba(176,90,255,0.38); }
.btn:hover::after { left: 130%; }
.btn:active { transform: translateY(0); }

.app-card > .btn { margin-top: auto; align-self: flex-start; }

.empty {
  padding: 70px 20px;
  text-align: center;
  color: var(--text-faint);
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* App detail page */
.app-detail {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 28px 80px;
  animation: fadeUp .5s cubic-bezier(.2,.8,.2,1);
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 24px 0 20px;
}
.app-icon-lg {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
}
.detail-header h1 { margin: 0 0 4px; font-size: 26px; font-weight: 760; letter-spacing: -0.02em; }
.tagline-lg { margin: 0 0 10px; color: var(--text-dim); font-size: 15px; }

.btn-lg { padding: 12px 26px; font-size: 14.5px; margin-bottom: 8px; }

.detail-section { margin-top: 36px; }
.detail-section h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin: 0 0 14px;
}
.desc-full { font-size: 15px; line-height: 1.7; color: #d4d6e4; margin: 0; white-space: pre-line; }

.shots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.shots-grid img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: block;
  transition: transform .2s ease, border-color .2s ease;
}
.shots-grid a:hover img {
  transform: scale(1.02);
  border-color: rgba(176,131,255,0.5);
}

/* Auth */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 38px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lift);
  text-align: center;
  animation: fadeUp .6s cubic-bezier(.2,.8,.2,1);
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  padding: 1.5px;
  background: var(--gradient-main);
  background-size: 220% 220%;
  animation: gradientShift 6s ease infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: .55;
  z-index: -1;
}
.auth-card .brand-mark { margin: 0 auto 18px; width: 44px; height: 44px; border-radius: 14px; font-size: 19px; }
.auth-card h1 { margin: 0 0 4px; font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card .subtitle { color: var(--text-dim); margin: 0 0 28px; font-size: 13.5px; }
.auth-card form { text-align: left; }

form label {
  display: block;
  margin-bottom: 15px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
form input[type=text],
form input[type=email],
form input[type=password],
form input[type=number],
form textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 11px 13px;
  background: rgba(255,255,255,0.065);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
form input:focus, form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(124,147,255,0.07);
  box-shadow: 0 0 0 3px rgba(124,147,255,0.18);
}
form textarea { resize: vertical; }
form input[type=file] {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 9px 11px;
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12.5px;
  font-family: inherit;
}
.field-preview-icon {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  margin: 7px 0;
}
.field-preview-shots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 7px 0;
}
.field-preview-shots img {
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
form button[type=submit] {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 12px;
  background: var(--gradient-main);
  background-size: 220% 220%;
  animation: gradientShift 8s ease infinite;
  border: none;
  border-radius: var(--radius-sm);
  color: #0a0b10;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  margin-top: 6px;
  transition: transform .18s ease, filter .18s ease;
  box-shadow: 0 10px 26px rgba(124,147,255,0.32);
}
form button[type=submit]:hover { transform: translateY(-2px); filter: brightness(1.08); }
form .checkbox { display: flex; align-items: center; gap: 8px; text-transform: none; font-weight: 500; }
form .checkbox input { width: auto; margin-top: 0; }

.alert {
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.4);
  color: #ffb3b3;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 13.5px;
}
.alert.success {
  background: rgba(108,255,161,0.1);
  border-color: rgba(108,255,161,0.4);
  color: #b3ffcf;
}

.form-main {
  max-width: 540px;
  margin: 48px auto;
  padding: 0 20px;
  animation: fadeUp .5s cubic-bezier(.2,.8,.2,1);
}
.form-main h1 { margin-bottom: 24px; font-size: 24px; font-weight: 680; letter-spacing: -0.02em; }
.form-main form {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-soft);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
}
.user-avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #0a0b10;
  background: var(--gradient-main);
  background-size: 220% 220%;
  animation: gradientShift 7s ease infinite;
}
.profile-name { font-size: 17px; font-weight: 680; letter-spacing: -0.01em; }
.profile-email { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.profile-role {
  display: inline-block;
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #c3cdff;
  background: rgba(124,147,255,0.14);
  border: 1px solid rgba(124,147,255,0.3);
  padding: 2px 9px;
  border-radius: 999px;
}

.admin-main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 24px 60px;
  animation: fadeUp .5s cubic-bezier(.2,.8,.2,1);
}

.page-eyebrow {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 4px;
}
.page-title {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.025em;
  margin: 0 0 28px;
}

.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.stat-card {
  flex: 1 1 150px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
}
.stat-value {
  font-size: 30px;
  font-weight: 780;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: var(--gradient-main);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradientShift 6s ease infinite;
}
.stat-label {
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
  font-weight: 650;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-head h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 36px;
  box-shadow: var(--shadow-soft);
}
.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.admin-table th {
  color: var(--text-faint);
  font-weight: 650;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.02);
}
.admin-table tbody tr { transition: background .15s ease; }
.admin-table tbody tr:hover { background: rgba(124,147,255,0.05); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 14px; align-items: center; }
.row-actions form { display: inline; }
.link-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13.5px;
  padding: 0;
  font-family: inherit;
  transition: color .15s ease;
}
.link-btn:hover { color: #ff9494; text-decoration: underline; }
.muted { color: var(--text-faint); }
.hint { color: var(--text-faint); font-size: 12.5px; margin-top: 14px; }
