:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --indigo: #4f46e5;
  --indigo-bg: #eef2ff;
  --emerald: #10b981;
  --emerald-bg: #ecfdf5;
  --rose: #e11d48;
  --rose-bg: #fff1f2;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.pg-shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-bottom: 40px;
  overflow-x: hidden;
}

.pg-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.pg-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pg-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pg-logo-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.25);
  flex-shrink: 0;
}
.pg-brand-title {
  font-size: 17px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.2;
}
.pg-brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.pg-quick-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pg-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.pg-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 260px;
}
.pg-select, .pg-input {
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  outline: none;
  transition: all 0.15s;
}
.pg-select:focus, .pg-input:focus {
  background: #fff;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.pg-select {
  min-width: 190px;
  max-width: 280px;
}
.pg-search-wrap {
  flex: 1;
  min-width: 150px;
}
.pg-search-wrap .pg-input {
  width: 100%;
}

.pg-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  padding: 0 13px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.pg-btn:active { transform: scale(0.97); }
.pg-btn-outline {
  background: #fff;
  border-color: #cbd5e1;
  color: #334155;
}
.pg-btn-outline:hover { background: #f1f5f9; }
.pg-btn-soft {
  background: #f1f5f9;
  color: #334155;
}
.pg-btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.pg-btn-indigo {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.pg-btn-warning {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #b45309;
}
.pg-btn-danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #e11d48;
}
.pg-badge-count {
  background: #e11d48;
  color: #fff;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.pg-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.pg-tabs::-webkit-scrollbar { display: none; }
.pg-tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.pg-tab.active {
  background: var(--indigo-bg);
  color: var(--indigo);
}
.pg-tab-dot {
  background: #e11d48;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
}

.pg-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px 16px 4px;
}
.pg-stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.pg-stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.pg-stat-val {
  font-size: 20px;
  font-weight: 900;
  margin-top: 2px;
}
.pg-stat-icon {
  font-size: 22px;
  opacity: 0.9;
}

.pg-main {
  padding: 12px 16px;
}

/* 班级神兽网格：电脑端 4-5 列，平板 3 列，手机端 2 列紧凑卡片（严格不超出宽度） */
.pg-pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  width: 100%;
}

.pg-stu-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, border-color 0.15s;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.pg-stu-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.pg-stu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  width: 100%;
}
.pg-stu-head > div {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.pg-stu-name {
  font-size: 15px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-stu-cls {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pg-lv-pill {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  flex-shrink: 0;
}

.pg-pet-stage-box {
  height: 116px;
  margin: 8px 0;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 45%, #ffffff 0%, #fffbeb 65%, #f1f5f9 100%);
  border: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.pg-pet-stage-box img {
  max-width: 96px;
  max-height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08));
  transition: transform 0.2s;
}
.pg-pet-stage-box:hover img {
  transform: scale(1.06);
}
.pg-pet-species-tag {
  position: absolute;
  bottom: 5px;
  right: 7px;
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 6px;
  border-radius: 6px;
  max-width: calc(100% - 14px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pg-prog-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0;
}
.pg-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #4f46e5);
  border-radius: 999px;
}

.pg-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 7px 0;
  background: #f8fafc;
  padding: 6px 4px;
  border-radius: 11px;
  border: 1px solid #f1f5f9;
  text-align: center;
  min-width: 0;
}
.pg-metric-lbl {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-metric-num {
  font-size: 14px;
  font-weight: 900;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pg-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 4px;
  width: 100%;
  min-width: 0;
}
.pg-act-btn {
  height: 32px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-act-plus {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.pg-act-minus {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}
.pg-act-redeem {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

/* 兑换记录与商城面板 */
.pg-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.pg-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.pg-redemption-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pg-red-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
}
.pg-red-item.pending {
  background: #fffbeb;
  border-color: #fde68a;
}
.pg-red-item.claimed {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.pg-red-item.cancelled {
  background: #f8fafc;
  opacity: 0.65;
}

.pg-shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.pg-gift-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

/* 弹窗样式 */
.pg-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.pg-modal-card {
  background: #fff;
  border-radius: 22px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.pg-modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pg-modal-kicker {
  font-size: 10px;
  font-weight: 900;
  color: var(--indigo);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.pg-modal-title {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 900;
}
.pg-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #f8fafc;
  font-weight: 800;
}
.pg-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}
.pg-modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.pg-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pg-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pg-field.full { grid-column: 1 / -1; }
.pg-field label {
  font-size: 12px;
  font-weight: 800;
  color: #334155;
}

.pg-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 200;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.pg-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 手机端自适应优化：严格双列等宽不溢出 */
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .pg-header { padding: 10px 10px 0; }
  .pg-brand-title { font-size: 15px; }
  .pg-brand-sub { display: none; }
  .pg-toolbar { gap: 8px; }
  .pg-filter-group {
    min-width: 0;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .pg-select {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    flex: none;
  }
  .pg-search-wrap {
    min-width: 0;
    width: 100%;
    flex: none;
  }
  .pg-action-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .pg-action-group .pg-btn {
    min-width: 0;
    width: 100%;
    padding: 0 4px;
    font-size: 11px;
  }
  .pg-stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 10px 2px;
  }
  .pg-stat-card { padding: 8px 10px; min-width: 0; }
  .pg-stat-val { font-size: 15px; }
  .pg-main { padding: 10px; width: 100%; overflow-x: hidden; }
  .pg-pet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }
  .pg-stu-card {
    padding: 8px;
    border-radius: 14px;
    min-width: 0;
    max-width: 100%;
  }
  .pg-stu-name { font-size: 13px; }
  .pg-stu-cls { font-size: 10px; }
  .pg-lv-pill { padding: 1px 5px; font-size: 10px; }
  .pg-pet-stage-box { height: 84px; margin: 5px 0; border-radius: 11px; }
  .pg-pet-stage-box img { max-width: 68px; max-height: 68px; }
  .pg-pet-species-tag { font-size: 9px; padding: 1px 4px; right: 4px; bottom: 4px; }
  .pg-metrics-row { padding: 4px 2px; gap: 2px; margin: 5px 0; border-radius: 9px; }
  .pg-metric-lbl { font-size: 9px; }
  .pg-metric-num { font-size: 11px; }
  .pg-card-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }
  .pg-act-btn {
    height: 27px;
    font-size: 10px;
    padding: 0 2px;
    border-radius: 7px;
  }
  .pg-shop-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .pg-form-grid { grid-template-columns: 1fr; }
}
