* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --accent-r: 255;
  --accent-g: 103;
  --accent-b: 5;
  --accent: rgb(var(--accent-r) var(--accent-g) var(--accent-b));
  --accent-soft: rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.35);
  --outline: rgb(64 64 64);
  --window: rgba(9, 10, 13, 0.92);
  --titlebar: rgba(26, 31, 38, 0.96);
  --group: rgba(17, 19, 23, 0.86);
  --control: rgb(23 26 31);
  --text: rgb(255 159 94);
  --scroll-lane: rgba(9, 10, 13, 0.85);
  --scroll-track: rgb(31 36 41);
  --scroll-thumb-lit: rgb(255 151 42);
  --scroll-thumb-dark: rgb(185 67 0);
}

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

@supports (-moz-appearance: none) {
  * {
    scrollbar-color: var(--accent) var(--scroll-track);
    scrollbar-width: thin;
  }
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background: var(--scroll-lane);
}

*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

*::-webkit-scrollbar-track {
  background: linear-gradient(
    90deg,
    var(--scroll-lane) 0 1px,
    var(--scroll-track) 1px 5px,
    var(--scroll-lane) 5px 6px
  );
}

*::-webkit-scrollbar-track:horizontal {
  background: linear-gradient(
    180deg,
    var(--scroll-lane) 0 1px,
    var(--scroll-track) 1px 5px,
    var(--scroll-lane) 5px 6px
  );
}

*::-webkit-scrollbar-thumb {
  min-width: 22px;
  min-height: 22px;
  border-right: 1px solid var(--scroll-lane);
  border-left: 1px solid var(--scroll-lane);
  background: linear-gradient(90deg, var(--scroll-thumb-lit), var(--accent) 48%, var(--scroll-thumb-dark));
}

*::-webkit-scrollbar-thumb:horizontal {
  border-top: 1px solid var(--scroll-lane);
  border-right: 0;
  border-bottom: 1px solid var(--scroll-lane);
  border-left: 0;
  background: linear-gradient(180deg, var(--scroll-thumb-lit), var(--accent) 48%, var(--scroll-thumb-dark));
}

*::-webkit-scrollbar-corner {
  background: var(--scroll-lane);
}

body {
  overflow: hidden;
  background: #0f1014;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
}

.scene {
  position: relative;
  min-height: 100vh;
}

.menu-window {
  position: absolute;
  left: 20px;
  top: 20px;
  width: min(520px, calc(100vw - 40px));
  border: 1px solid var(--outline);
  background: var(--window);
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.24), 1px 2px 0 rgba(0, 0, 0, 0.14);
  animation: menu-open 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  will-change: left, top, opacity, transform;
}

.auth-gate {
  visibility: hidden;
}

.auth-gate.is-ready {
  visibility: visible;
}

.menu-window.dragging,
.admin-window.dragging {
  box-shadow: 5px 7px 0 rgba(0, 0, 0, 0.3), 2px 3px 0 rgba(0, 0, 0, 0.18);
}

.window-bar {
  position: relative;
  height: 28px;
  border-bottom: 0;
  background: var(--titlebar);
  cursor: move;
  user-select: none;
}

.window-bar h1 {
  position: absolute;
  left: 50%;
  top: 5px;
  margin: 0;
  transform: translateX(-50%);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.shimmer-line {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.14),
    rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.72) 66%,
    rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.14)
  );
  background-size: 160px 1px;
  animation: shimmer 1.8s linear infinite;
}

.window-content {
  position: relative;
  margin: 10px;
  overflow: visible;
}

.panel {
  position: relative;
  width: 100%;
  border: 1px solid var(--outline);
  background: var(--group);
  animation: panel-rise 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.panel::before {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  content: "";
  background: rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.55);
}

.auth-panel {
  height: 184px;
}

.register-panel {
  height: 230px;
  animation-delay: 40ms;
}

.forgot-panel {
  height: 154px;
}

.reset-panel {
  height: 188px;
}

.dashboard-panel {
  height: 186px;
  margin-bottom: 8px;
}

.friend-invites-panel {
  height: 164px;
}

.store-panel {
  height: 306px;
}

.profile-panel {
  height: 380px;
}

.panel-title {
  position: relative;
  height: 22px;
}

.panel-title::after {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 1px;
  height: 1px;
  content: "";
  background: rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.16);
}

.panel-title strong {
  position: absolute;
  left: 50%;
  top: 1px;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  white-space: nowrap;
}

.panel-body {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 26px;
}

.check-row,
.auth-row,
.auth-actions {
  position: relative;
  width: 100%;
}

.link-actions {
  height: 24px;
  padding-top: 5px;
}

.recovery-actions {
  height: 20px;
  justify-content: center;
  padding-top: 0;
}

.check-row {
  display: block;
  height: 24px;
}

input[type="checkbox"] {
  position: absolute;
  left: 0;
  top: 4px;
  width: 14px;
  height: 14px;
  margin: 0;
  appearance: none;
  border: 1px solid var(--outline);
  background: var(--control);
  opacity: 0;
}

.check-row i {
  position: absolute;
  left: 0;
  top: 4px;
  width: 14px;
  height: 14px;
  border: 1px solid var(--outline);
  background: var(--control);
  pointer-events: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.check-row i::after {
  position: absolute;
  left: 1px;
  top: 1px;
  width: 10px;
  height: 10px;
  content: "";
  background: linear-gradient(180deg, rgb(255 151 42), var(--accent));
  opacity: 0;
  transform: scale(0.76);
  transition: opacity 150ms ease, transform 150ms ease;
}

input[type="checkbox"]:checked + i::after {
  opacity: 1;
  transform: scale(1);
}

input[type="checkbox"]:focus + i,
.check-row:hover i {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.34);
}

.check-row span {
  position: absolute;
  left: 22px;
  top: 3px;
  line-height: 14px;
}

.auth-row {
  display: block;
  height: 32px;
}

.auth-row > span {
  position: absolute;
  left: 0;
  top: 3px;
}

.auth-row input {
  position: absolute;
  left: 42%;
  top: 0;
  width: 58%;
  height: 24px;
  border: 1px solid var(--outline);
  color: var(--text);
  caret-color: var(--accent);
  background: linear-gradient(180deg, rgb(28 31 37), var(--control));
  font: inherit;
  line-height: 14px;
  padding: 0 6px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.auth-row input:-webkit-autofill,
.auth-row input:-webkit-autofill:hover,
.auth-row input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--accent);
  box-shadow: 0 0 0 1000px rgb(23 26 31) inset;
  border-color: var(--outline);
  transition: background-color 9999s ease-in-out 0s;
}

.auth-row input::placeholder {
  color: rgba(255, 159, 94, 0.82);
  opacity: 1;
}

.auth-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.55);
}

button,
.auth-actions a {
  color: var(--text);
  font: inherit;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding-top: 2px;
}

.dashboard-actions {
  width: 100%;
}

.auth-actions button,
.register-button {
  height: 24px;
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.34), rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.14));
  color: var(--text);
  cursor: pointer;
  font: inherit;
  position: relative;
  overflow: hidden;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease, background-color 120ms ease;
}

.auth-actions button {
  flex: 1;
  width: auto;
}

.dashboard-actions button {
  flex: 1;
  width: auto;
}

.auth-actions button::after,
.register-button::after {
  position: absolute;
  inset: 0;
  content: "";
  background: rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.22);
  opacity: 0;
  transition: opacity 140ms ease;
}

.auth-actions button:hover,
.register-button:hover,
.auth-actions a:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.32);
}

.auth-actions button:hover::after,
.register-button:hover::after,
.auth-actions button.is-pressed::after,
.register-button.is-pressed::after {
  opacity: 1;
}

.auth-actions button.is-pressed,
.register-button.is-pressed {
  transform: translateY(1px);
}

.auth-actions a {
  display: inline-flex;
  align-items: center;
  height: 24px;
  text-decoration: none;
  transition: color 120ms ease, text-shadow 120ms ease;
}

.auth-actions a:hover {
  color: rgb(255 184 122);
  text-shadow: 0 0 8px rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.45);
}

.remember-row {
  margin-top: 3px;
}

.register-button {
  width: 100%;
  margin-top: 8px;
}

.account-line {
  position: relative;
  height: 30px;
}

.account-line span {
  position: absolute;
  left: 0;
  top: 3px;
}

.account-line strong {
  position: absolute;
  left: 42%;
  top: 3px;
  font-weight: 700;
}

.account-line a,
td a {
  color: inherit;
  text-decoration: none;
}

.dashboard-actions {
  margin-top: 4px;
}

.dashboard-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  margin-bottom: 10px;
  border: 1px solid var(--outline);
  background: rgba(17, 19, 23, 0.72);
  color: inherit;
  padding: 6px;
  text-decoration: none;
}

.dashboard-profile-card img {
  width: 62px;
  height: 62px;
  border: 1px solid var(--outline);
  object-fit: cover;
  background: var(--control);
}

.dashboard-profile-card strong,
.dashboard-profile-card span {
  display: block;
}

.dashboard-profile-card span {
  margin-top: 5px;
  color: rgba(255, 159, 94, 0.78);
}

.invite-list {
  max-height: 56px;
  overflow: auto;
  margin-top: 8px;
}

.invite-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--outline);
  background: rgba(17, 19, 23, 0.72);
  margin-bottom: 4px;
  padding: 4px;
}

.plans-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.profile-head img {
  width: 64px;
  height: 64px;
  border: 1px solid var(--outline);
  object-fit: cover;
  background: var(--control);
}

.profile-head strong,
.profile-head span {
  display: block;
}

.profile-head span {
  margin-top: 5px;
  color: rgba(255, 159, 94, 0.78);
}

.profile-bio {
  min-height: 48px;
  margin: 0 0 10px;
  border: 1px solid var(--outline);
  background: rgba(17, 19, 23, 0.72);
  padding: 8px;
  line-height: 16px;
}

.plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--outline);
  background: rgba(17, 19, 23, 0.72);
  padding: 6px;
}

.plan-row strong,
.plan-row span {
  display: block;
}

.plan-row span {
  margin-top: 3px;
  color: rgba(255, 159, 94, 0.78);
}

.status-line {
  position: relative;
  z-index: 10000;
  min-height: 18px;
  margin: 6px 0 0;
  color: rgba(255, 159, 94, 0.82);
  line-height: 14px;
}

.status-line:empty {
  display: none;
}

.session-label {
  height: 18px;
  margin: -2px 0 6px;
  color: rgb(255 184 122);
  line-height: 14px;
}

.status-line.is-error {
  color: rgb(255 91 64);
}

.status-line.is-success {
  color: rgb(255 184 122);
}

@media (max-width: 560px), (max-height: 540px) {
  body {
    overflow: auto;
  }

  .scene {
    min-height: 540px;
  }

  .menu-window {
    transform-origin: top left;
    transform: scale(calc((100vw - 24px) / 520));
    left: 12px;
    top: 20px;
    width: 520px;
    animation: menu-open-mobile 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
}

@keyframes menu-open {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes shimmer {
  from {
    background-position: -80px 0;
  }
  to {
    background-position: calc(100% + 80px) 0;
  }
}

@keyframes menu-open-mobile {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(calc((100vw - 24px) / 520));
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(calc((100vw - 24px) / 520));
  }
}

.admin-scene {
  min-height: 100vh;
  padding: 20px;
}

.admin-window {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1120px, calc(100vw - 40px));
  height: calc(100vh - 40px);
  border: 1px solid var(--outline);
  background: var(--window);
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.24), 1px 2px 0 rgba(0, 0, 0, 0.14);
  animation: menu-open 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.admin-content {
  flex: 1;
  overflow: auto;
  padding: 10px;
}

.admin-login {
  width: 520px;
  max-width: 100%;
  height: 178px;
}

.login-window {
  width: min(560px, calc(100vw - 40px));
  min-height: 236px;
}

.denied-copy {
  margin: 0 0 14px;
  line-height: 16px;
}

.denied-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 42%;
}

.admin-dashboard {
  display: grid;
  gap: 8px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--outline);
  background: rgba(17, 19, 23, 0.72);
  padding: 8px;
}

.admin-identity strong,
.admin-identity span {
  display: block;
}

.admin-identity strong {
  color: rgb(255 184 122);
}

.admin-identity span {
  margin-top: 3px;
  color: rgba(255, 159, 94, 0.72);
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 8px;
}

.stat-panel,
.invite-panel {
  min-height: 164px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 30px 12px 12px;
}

.metric {
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, rgba(28, 31, 37, 0.88), rgba(17, 19, 23, 0.88));
  padding: 8px;
  min-height: 70px;
}

.metric span,
.metric strong {
  display: block;
}

.metric strong {
  margin-top: 8px;
  font-size: 18px;
}

.table-panel {
  min-height: 192px;
}

.admin-table-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 0;
}

.admin-table-tools label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 210px;
}

.admin-table-tools label:first-child {
  flex: 1;
}

.admin-table-tools span,
.table-muted {
  color: rgba(255, 159, 94, 0.72);
}

.admin-table-tools input,
.admin-table-tools select,
.auth-row select {
  height: 24px;
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, rgb(28 31 37), var(--control));
  color: var(--text);
  caret-color: var(--accent);
  font: inherit;
  outline: none;
}

.admin-table-tools input {
  flex: 1;
  min-width: 140px;
  padding: 0 6px;
}

.admin-table-tools input[readonly] {
  cursor: text;
  color: rgb(255 184 122);
}

.admin-table-tools select {
  width: 120px;
  padding: 0 4px;
}

.admin-table-tools input:focus,
.admin-table-tools select:focus,
.mini-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.55);
}

.audit-tools {
  justify-content: flex-end;
}

.reset-tools {
  align-items: center;
}

.reset-tools input {
  min-width: min(560px, 100%);
}

.table-wrap {
  overflow: auto;
  padding: 8px;
  max-height: 34vh;
}

.compact-table-wrap {
  max-height: 240px;
}

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

th,
td {
  border: 1px solid var(--outline);
  padding: 6px;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--titlebar);
  font-weight: 700;
}

td {
  background: rgba(17, 19, 23, 0.72);
}

code {
  color: rgb(255 184 122);
}

.admin-user-link {
  display: inline-block;
  color: rgb(255 184 122);
  font-weight: 700;
}

.table-muted {
  display: block;
  margin-top: 4px;
  line-height: 14px;
}

.uid-cell {
  width: 64px;
  white-space: nowrap;
}

.email-cell {
  max-width: 220px;
  word-break: break-word;
}

.invite-limit-cell {
  min-width: 148px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 18px;
  border: 1px solid rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.35);
  background: rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.1);
  color: rgb(255 184 122);
  padding: 0 6px;
  text-transform: lowercase;
}

.status-pill.is-active,
.status-pill.role-admin {
  border-color: rgba(74, 181, 114, 0.7);
  color: rgb(126 235 165);
}

.status-pill.is-inactive,
.status-pill.is-requested {
  border-color: rgba(255, 159, 94, 0.45);
}

.status-pill.is-link_ready {
  border-color: rgba(76, 148, 255, 0.7);
  color: rgb(132 185 255);
}

.status-pill.is-banned,
.status-pill.is-expired {
  border-color: rgb(120 38 30);
  color: rgb(255 91 64);
}

.status-pill.is-used {
  border-color: rgba(90, 96, 105, 0.9);
  color: rgba(255, 159, 94, 0.62);
}

.admin-form-grid {
  display: grid;
  gap: 2px;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 5px;
}

.admin-action-stack {
  display: grid;
  gap: 5px;
  min-width: 170px;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 22px;
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.34), rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.14));
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}

.mini-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.32);
}

.mini-button:active {
  transform: translateY(1px);
}

.admin-nav-button {
  min-width: 88px;
}

.danger-button {
  border-color: rgb(120 38 30);
  color: rgb(255 91 64);
}

.mini-input {
  width: 58px;
  height: 22px;
  border: 1px solid var(--outline);
  background: var(--control);
  color: var(--text);
  font: inherit;
  outline: none;
  padding: 0 5px;
}

.days-input {
  width: 64px;
}

.empty-cell {
  height: 62px;
  text-align: center;
  color: rgba(255, 159, 94, 0.72);
}

.reset-requests-panel .status-line {
  margin: 0 8px 8px;
}

.audit-log {
  max-height: 190px;
  overflow: auto;
  padding: 8px;
}

.audit-log div {
  border: 1px solid var(--outline);
  background: rgba(17, 19, 23, 0.72);
  margin-bottom: 4px;
  padding: 6px;
}

.audit-log span {
  display: inline-block;
  min-width: 180px;
  color: rgba(255, 159, 94, 0.72);
}

.audit-log strong {
  margin-right: 6px;
}

.audit-log em {
  color: rgb(255 184 122);
  font-style: normal;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .admin-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .admin-window {
    height: auto;
    min-height: calc(100vh - 40px);
  }

  .admin-toolbar,
  .admin-table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-toolbar-actions,
  .admin-table-tools label {
    width: 100%;
  }

  .admin-table-tools select {
    flex: 1;
  }
}
