:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(12, 24, 42, 0.88);
  --panel-strong: rgba(16, 32, 56, 0.96);
  --ink: #e6edf7;
  --muted: #8ea1bb;
  --line: rgba(130, 157, 193, 0.2);
  --line-strong: rgba(111, 231, 255, 0.34);
  --cyan: #45d7ff;
  --green: #36e6a4;
  --blue: #7aa7ff;
  --amber: #f8c76b;
  --danger: #ff6b7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(rgba(69, 215, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 215, 255, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(69, 215, 255, 0.1), transparent 420px),
    var(--bg);
  background-size: 34px 34px, 34px 34px, 100% 100%, auto;
}

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

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(69, 215, 255, 0.14), transparent 44%),
    linear-gradient(225deg, rgba(54, 230, 164, 0.1), transparent 36%),
    rgba(9, 20, 36, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin: 0;
  font-size: 17px;
}

.switch-row span,
label {
  color: var(--muted);
}

.login-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(14px);
}

.login-card {
  width: min(430px, 100%);
  padding: 18px;
}

.login-card .status {
  display: inline-block;
  margin-top: 12px;
}

body.logged-in .hero {
  display: none;
}

body:not(.logged-in) .grid,
body:not(.logged-in) .admin-topbar {
  display: none;
}

.admin-topbar {
  display: none;
  justify-content: flex-end;
  margin-bottom: 20px;
  position: sticky;
  top: 16px;
  z-index: 20;
}

body.logged-in .admin-topbar {
  display: flex;
}

.admin-menu-wrap {
  position: relative;
}

.admin-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(69, 215, 255, 0.28);
  border-radius: 999px;
  padding: 8px 12px 8px 8px;
  color: var(--ink);
  background: rgba(12, 24, 42, 0.9);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

.admin-avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #06111e;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-weight: 900;
}

.admin-name {
  max-width: 140px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: none;
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 24px 75px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(14px);
}

.admin-menu.open {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.96fr) minmax(420px, 1.04fr);
  gap: 20px;
  margin-top: 20px;
}

.panel {
  padding: 22px;
}

.config-board {
  padding: 22px;
}

.config-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  align-items: start;
}

.config-card {
  min-height: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 12, 24, 0.36);
}

.mini-program-card {
  grid-column: 1 / -1;
}

.config-card-head {
  margin-bottom: 16px;
}

.config-card-head h3 {
  color: var(--ink);
}

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

.config-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.config-actions .primary {
  width: min(280px, 100%);
}

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

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

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.editable-panel:not(.edit-mode) .edit-only,
.editable-panel.edit-mode .read-only {
  display: none;
}

.section-title {
  margin: 24px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(130, 157, 193, 0.26);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: rgba(4, 12, 24, 0.72);
  outline: none;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
}

input::placeholder,
textarea::placeholder {
  color: rgba(142, 161, 187, 0.62);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(69, 215, 255, 0.12);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--cyan) 50%),
    linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px;
  padding-right: 36px;
}

.field-hint {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
}

.mini-program-link-rows {
  display: grid;
  gap: 12px;
}

.mini-program-link-row {
  display: grid;
  grid-template-columns: 76px minmax(120px, 0.9fr) minmax(170px, 1.1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 12, 24, 0.52);
}

.mini-program-link-row label {
  margin-bottom: 0;
}

.link-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid rgba(130, 157, 193, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.link-switch span {
  color: var(--muted);
  font-size: 12px;
}

.mini-program-link-row .danger-btn {
  justify-self: end;
}

@media (max-width: 980px) {
  .mini-program-link-row {
    grid-template-columns: 76px repeat(2, minmax(0, 1fr)) auto;
  }

  .mini-program-link-row label:nth-of-type(4) {
    grid-column: 2 / 4;
  }
}

@media (max-width: 720px) {
  .mini-program-link-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .mini-program-link-row label:nth-of-type(4) {
    grid-column: auto;
  }
}

.add-link-btn {
  width: 100%;
  margin-top: 12px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #06111e;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  cursor: pointer;
  font-weight: 900;
}

button:hover {
  filter: brightness(1.08);
}

.mini-btn {
  min-height: 32px;
  border: 1px solid rgba(69, 215, 255, 0.28);
  padding: 0 10px;
  color: var(--ink);
  background: rgba(69, 215, 255, 0.12);
  white-space: nowrap;
  font-size: 12px;
}

.ghost-btn {
  color: var(--cyan);
  background: rgba(69, 215, 255, 0.06);
}

.danger-btn {
  border-color: rgba(255, 107, 122, 0.38);
  color: #ffd7dc;
  background: rgba(255, 107, 122, 0.13);
}

.primary {
  width: 100%;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 12, 24, 0.52);
}

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

.switch-row strong {
  color: var(--ink);
}

.switch-row span {
  margin-top: 4px;
  font-size: 13px;
}

.switch {
  margin: 0;
}

.switch input {
  display: none;
}

.switch i {
  position: relative;
  display: block;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: rgba(142, 161, 187, 0.38);
}

.switch i::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e6edf7;
  transition: transform 0.18s ease;
}

.switch input:checked + i {
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.switch input:checked + i::after {
  transform: translateX(24px);
}

.status,
.pill {
  border: 1px solid rgba(69, 215, 255, 0.24);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--cyan);
  background: rgba(69, 215, 255, 0.08);
  font-size: 12px;
  font-weight: 900;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: rgba(4, 12, 24, 0.68);
}

td {
  color: #c8d4e5;
}

.select-cell {
  width: 42px;
  text-align: center;
}

.select-cell input {
  display: inline-block;
}

tr:last-child td {
  border-bottom: 0;
}

small {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  text-align: center;
}

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

.user-cell img,
.avatar-fallback {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.user-cell img {
  object-fit: cover;
  border: 1px solid rgba(69, 215, 255, 0.28);
}

.avatar-fallback {
  display: inline-grid;
  place-items: center;
  color: #06111e;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-size: 13px;
  font-weight: 900;
}

.avatar-fallback.avatar-hidden {
  display: none;
}

.points {
  color: var(--amber);
  font-size: 18px;
}

.points-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
}

.points-input {
  width: 88px;
  min-width: 88px;
  padding: 8px 9px;
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(130, 157, 193, 0.24);
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-badge.active {
  border-color: rgba(54, 230, 164, 0.36);
  color: var(--green);
  background: rgba(54, 230, 164, 0.1);
}

.status-badge.disabled {
  border-color: rgba(255, 107, 122, 0.36);
  color: var(--danger);
  background: rgba(255, 107, 122, 0.1);
}

.mono {
  max-width: 320px;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

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