:root {
  color-scheme: dark;
  --bg: #050607;
  --black: #08090c;
  --gray-900: #0c0f14;
  --gray-800: #121722;
  --gray-700: #1c2330;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.24);
  --text: #f7f9fc;
  --muted: #a9b3c3;
  --blue: #59a7ff;
  --blue-soft: rgba(89, 167, 255, 0.18);
  --danger: #ff788d;
  --success: #9ef0b9;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(89, 167, 255, 0.16), transparent 28rem),
    linear-gradient(135deg, #050607, #10141b 54%, #07080b);
  overflow-x: hidden;
}

.auth-bg-page {
  background:
    radial-gradient(circle at 50% 10%, rgba(89, 167, 255, 0.12), transparent 24rem),
    #050607;
}

.auth-bg-page::before,
.account-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 6, 7, 0.28), rgba(5, 6, 7, 0.02) 46%, rgba(5, 6, 7, 0.3)),
    linear-gradient(180deg, rgba(5, 6, 7, 0), rgba(5, 6, 7, 0.4)),
    url("../img/auth-background.png") center center / cover no-repeat;
  filter: saturate(1.12) contrast(1.02) brightness(1.62);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

.page-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 84%);
}

.icon {
  width: 1.08em;
  height: 1.08em;
  flex: 0 0 auto;
}

.site-footer {
  position: relative;
  z-index: 2;
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-main {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 28px));
  min-height: calc(100vh - 68px);
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: clamp(24px, 5vw, 58px) 0;
}

.surface-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.035)),
    rgba(8, 10, 14, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(130%);
}

.auth-card {
  width: min(100%, 540px);
  padding: clamp(24px, 3.4vw, 38px);
}

.auth-card.wide {
  width: min(100%, 760px);
}

.dashboard-card,
.status-card,
.content-card {
  width: min(100%, 760px);
  padding: clamp(26px, 4vw, 44px);
}

.auth-copy {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 13ch;
  font-size: clamp(1.9rem, 4vw, 3.15rem);
  line-height: 0.98;
}

h2 {
  font-size: 1.12rem;
  margin-bottom: 16px;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(4, 6, 9, 0.72);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  resize: vertical;
}

select {
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(89, 167, 255, 0.88);
  box-shadow: 0 0 0 4px rgba(89, 167, 255, 0.14);
  background: rgba(7, 10, 15, 0.92);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle.is-visible {
  border-color: rgba(89, 167, 255, 0.55);
  background: rgba(89, 167, 255, 0.18);
}

.help-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--blue);
  background: rgba(89, 167, 255, 0.14);
  font-size: 0.78rem;
  font-weight: 900;
  cursor: help;
}

.help-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 5;
  width: min(310px, 82vw);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(8, 10, 14, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.help-icon:hover::after,
.help-icon:focus::after {
  opacity: 1;
  transform: translateX(-50%);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.check-row span {
  color: var(--muted);
}

.align-end {
  align-self: end;
  min-height: 50px;
}

.privacy-row a {
  color: var(--blue);
  font-weight: 850;
}

.optional-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.optional-box summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  cursor: pointer;
  color: var(--text);
  font-weight: 850;
}

.optional-box summary::-webkit-details-marker {
  display: none;
}

.optional-box[open] summary .icon {
  transform: rotate(180deg);
}

.optional-grid {
  padding: 0 14px 14px;
}

.btn,
.icon-btn {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 18px;
  color: var(--text);
  font-weight: 880;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #05101d;
  background: linear-gradient(135deg, #8fc5ff, var(--blue));
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.075);
  border-color: var(--line);
}

.icon-btn {
  min-height: 34px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.075);
  border-color: var(--line);
  font-size: 0.78rem;
}

.icon-btn.danger {
  color: #ffd8de;
  border-color: rgba(255, 120, 141, 0.42);
}

.auth-links,
.action-stack {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.auth-links {
  justify-content: space-between;
  color: var(--muted);
  font-weight: 780;
}

.auth-links a:hover {
  color: var(--blue);
}

.action-stack {
  flex-direction: column;
}

.action-stack.horizontal {
  flex-direction: row;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.support-option {
  min-height: 106px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(89, 167, 255, 0.12), rgba(255, 255, 255, 0.035)),
    rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-weight: 850;
}

.support-option .icon {
  width: 26px;
  height: 26px;
  color: var(--blue);
}

.support-option span {
  display: grid;
  gap: 4px;
}

.support-option small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.support-option:hover {
  border-color: rgba(89, 167, 255, 0.58);
  background: var(--blue-soft);
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 18px;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  color: var(--text);
}

.alert-success {
  background: rgba(158, 240, 185, 0.13);
}

.alert-error {
  background: rgba(255, 120, 141, 0.13);
}

.alert-info {
  background: rgba(89, 167, 255, 0.13);
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 20px;
}

.profile-card .action-stack {
  grid-column: 1 / -1;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
  image-rendering: pixelated;
}

.status-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--danger);
  background: rgba(255, 120, 141, 0.12);
}

.site-footer {
  min-height: 54px;
  margin-bottom: 16px;
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-weight: 760;
}

.site-footer a:hover {
  color: var(--blue);
}

.admin-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  gap: 24px;
  padding: 24px;
}

.admin-nav {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-nav a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 780;
}

.admin-nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.admin-nav a.is-active {
  color: var(--text);
  background: rgba(89, 167, 255, 0.16);
  border: 1px solid rgba(89, 167, 255, 0.28);
}

.admin-brand {
  min-height: 58px;
  margin-bottom: 8px;
}

.admin-brand .icon {
  width: 28px;
  height: 28px;
}

.admin-brand .icon {
  color: var(--blue);
}

.admin-brand span {
  display: grid;
}

.admin-brand strong {
  color: var(--text);
}

.admin-brand small {
  color: var(--muted);
  font-size: 0.76rem;
}

.nav-separator {
  height: 1px;
  margin: 10px 0;
  background: var(--line);
}

.nav-profile {
  margin-top: auto;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.nav-profile img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  grid-row: span 2;
}

.nav-profile strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-profile small {
  color: var(--muted);
}

.admin-nav .nav-profile .nav-logout,
.nav-profile .nav-logout {
  min-height: 36px;
  margin-top: 6px;
  padding: 0 10px;
  justify-content: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--line);
  grid-column: 1 / -1;
}

.admin-content {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 20px;
}

.admin-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}

.admin-title h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  max-width: none;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card,
.admin-form-panel,
.table-panel {
  padding: 20px;
}

.stat-card {
  display: grid;
  gap: 12px;
}

.stat-card span,
.muted {
  color: var(--muted);
}

.stat-card strong {
  font-size: 2.2rem;
}

.inline-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

td code {
  color: #b7d8ff;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  image-rendering: pixelated;
}

.table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-actions form {
  margin: 0;
}

.permission-toggle {
  margin: 0;
}

.switch {
  display: inline-flex;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.switch input:checked + span {
  background: rgba(89, 167, 255, 0.25);
  border-color: rgba(89, 167, 255, 0.58);
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: var(--blue);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.66);
}

.modal.is-open {
  display: grid;
}

.modal-panel {
  width: min(920px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 22px;
}

.modal-panel.small-modal {
  width: min(640px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 0;
}

.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.search-bar input {
  max-width: 420px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions form {
  margin: 0;
}

.account-card {
  width: min(100%, 940px);
}

.account-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  gap: 24px;
  padding: 24px;
}

.account-content {
  min-width: 0;
}

.account-nav {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
}

.account-head {
  margin-bottom: 24px;
}

.data-summary {
  margin: 22px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.data-summary dl {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

.data-summary.compact {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 16px;
}

.data-summary.compact dt {
  color: var(--muted);
  font-weight: 800;
}

.data-summary.compact dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.data-summary dt {
  color: var(--muted);
  font-weight: 800;
}

.data-summary dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.account-form {
  margin-top: 20px;
}

.account-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.mini-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.045);
}

.danger-zone {
  border-color: rgba(255, 120, 141, 0.34);
}

@media (max-width: 900px) {
  .admin-shell,
  .account-shell {
    grid-template-columns: 1fr;
  }

  .admin-nav,
  .account-nav {
    position: relative;
    top: auto;
    height: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
  }

  .admin-brand,
  .nav-separator,
  .nav-profile {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .form-grid.two-col,
  .stats-grid,
  .profile-card,
  .support-grid,
  .account-actions,
  .data-summary dl {
    grid-template-columns: 1fr;
  }

  .site-footer,
  .site-main {
    width: min(100% - 18px, 1120px);
  }

  .auth-links,
  .action-stack.horizontal,
  .site-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-shell,
  .account-shell {
    padding: 10px;
    gap: 12px;
  }

  .admin-nav {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .admin-title {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-title h1 {
    white-space: normal;
  }

  .table-panel,
  .stat-card,
  .modal-panel {
    padding: 14px;
  }

  .search-bar input {
    max-width: none;
  }

  .row-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .row-actions .icon-btn,
  .row-actions button {
    width: 100%;
  }
}
