:root {
  --ink: #1f2433;
  --muted: #6b7280;
  --line: #e8eaf2;
  --panel: #ffffff;
  --soft: #f6f7fb;
  --primary: #7657f2;
  --primary-2: #25b7a6;
  --accent: #ffb84d;
  --danger: #e14f62;
  --ok: #22a06b;
  --shadow: 0 18px 46px rgba(31, 36, 51, 0.14);
  --small-shadow: 0 8px 24px rgba(31, 36, 51, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(37, 183, 166, 0.34), transparent 28%),
    linear-gradient(135deg, #684cf6 0%, #9366f0 48%, #35c2b4 100%);
  letter-spacing: 0;
}

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

button {
  border: 0;
}

.shell {
  min-height: 100vh;
  padding: 22px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 18px;
}

.sidebar,
.card,
.modal-box,
.public-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 22px;
  height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  font-weight: 800;
}

.brand h1,
.brand p,
.section-title h2,
.section-title p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.section-title p,
.muted {
  color: var(--muted);
}

.brand p {
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: #3d4354;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, background 0.15s ease;
}

.nav button:hover,
.nav button.active {
  background: #f0edff;
  color: var(--primary);
}

.nav button:active,
.btn:active,
.icon-btn:active {
  transform: translateY(1px) scale(0.99);
}

.sidebar-footer {
  margin-top: auto;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: #fff;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 4px 0 0;
  opacity: 0.82;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.card {
  padding: 18px;
}

.metric {
  min-height: 112px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2 {
  font-size: 22px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(118, 87, 242, 0.26);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(118, 87, 242, 0.3);
}

.btn.secondary {
  color: var(--ink);
  background: #eef1f8;
  box-shadow: none;
}

.btn.ghost {
  color: var(--primary);
  background: #f0edff;
  box-shadow: none;
}

.btn.success {
  background: var(--ok);
  box-shadow: 0 8px 18px rgba(34, 160, 107, 0.22);
}

.btn.danger {
  background: var(--danger);
  box-shadow: 0 8px 18px rgba(225, 79, 98, 0.22);
}

.icon-btn {
  width: 38px;
  min-height: 38px;
  padding: 0;
  box-shadow: none;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.textarea {
  min-height: 98px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(118, 87, 242, 0.12);
}

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

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #4b5263;
  font-size: 13px;
  font-weight: 700;
}

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

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

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  position: sticky;
  top: 0;
  background: #fafbfe;
  color: #4b5263;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #4d3bb7;
  background: #f0edff;
  font-size: 12px;
  font-weight: 700;
}

.pill.green {
  color: #13795b;
  background: #e8f7f1;
}

.pill.orange {
  color: #9a5b00;
  background: #fff3d8;
}

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

.login-wrap,
.public-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

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

.public-card {
  width: min(860px, 100%);
  padding: 24px;
}

.public-head {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.public-head h1 {
  margin: 0;
  font-size: 30px;
}

.cover {
  min-height: 152px;
  padding: 20px;
  color: #fff;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 36, 51, 0.58), rgba(31, 36, 51, 0.08)),
    var(--cover, linear-gradient(135deg, #7657f2, #25b7a6));
  background-size: cover;
  background-position: center;
}

.cover h1 {
  max-width: 720px;
  margin: 0;
  font-size: 34px;
}

.cover p {
  max-width: 720px;
  margin: 10px 0 0;
  opacity: 0.9;
}

.question-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-title {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 800;
}

.options {
  display: grid;
  gap: 9px;
}

.option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  cursor: pointer;
}

.option input {
  margin-top: 3px;
}

.answer-good {
  border-color: rgba(34, 160, 107, 0.5);
  background: #eaf8f2;
}

.answer-bad {
  border-color: rgba(225, 79, 98, 0.52);
  background: #fff0f2;
}

.progress {
  height: 10px;
  overflow: hidden;
  background: #eef1f8;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.25s ease;
}

.timer {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  color: #fff;
  background: rgba(31, 36, 51, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(31, 36, 51, 0.44);
}

.modal.show {
  display: flex;
}

.modal-box {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 18px;
}

.share-box {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.qr {
  display: grid;
  place-items: center;
  width: 280px;
  min-height: 280px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr canvas,
.qr img {
  width: 260px;
  max-width: 100%;
  height: auto;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  border: 1px dashed #ccd2df;
  border-radius: 8px;
  background: #fbfcff;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: none;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #fff;
  background: rgba(31, 36, 51, 0.92);
  border-radius: 8px;
  box-shadow: var(--small-shadow);
}

.toast.show {
  display: block;
  animation: rise 0.2s ease;
}

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  background: var(--c);
  animation: fall var(--d) linear forwards;
}

.badge {
  display: inline-grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 4px auto 12px;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: 0 16px 34px rgba(118, 87, 242, 0.28);
  font-size: 28px;
  font-weight: 900;
  animation: pop 0.42s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes fall {
  to {
    transform: translate3d(var(--x), 105vh, 0) rotate(720deg);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.7);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .grid.stats,
  .grid.two,
  .grid.three,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .share-box {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 12px;
  }

  .public-card,
  .card {
    padding: 14px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .cover h1,
  .public-head h1 {
    font-size: 25px;
  }

  .toolbar .input,
  .toolbar .select {
    min-width: 100%;
  }
}
