:root {
  color-scheme: light;
  --background: #f4f7ff;
  --foreground: #0f172a;
  --muted: #667085;
  --card: #ffffff;
  --border: #d9e2f3;
  --border-strong: #c7d5ef;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #e0e7ff;
  --primary-soft-2: #eef2ff;
  --success: #047857;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow-sm: 0 8px 20px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 14px 34px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--foreground);
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.1), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 24%),
    var(--background);
  overflow-x: hidden;
}

.bg-shape {
  display: none;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.hero {
  padding: 16px 22px;
  margin-bottom: 0;
  border-radius: 18px;
  border-color: rgba(217, 226, 243, 0.95);
  background:
    linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(14, 165, 233, 0.08)),
    rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 44px rgba(79, 70, 229, 0.08);
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 8px;
  font-size: clamp(24px, 3vw, 30px);
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.subline {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 13px;
}

.subline.compact {
  font-size: 12px;
}

.required-star {
  margin-left: 2px;
  color: #dc2626;
  font-weight: 700;
}

.modal-required-note {
  margin-bottom: 2px;
}

.tabs {
  margin-top: 16px;
  padding: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  border-radius: 14px;
}

.tab {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab:hover {
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.28);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.08);
}

.tab.active {
  color: var(--primary);
  background: rgba(224, 231, 255, 0.92);
  border-color: rgba(79, 70, 229, 0.24);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.1);
}

.panel {
  margin-top: 16px;
  display: none;
}

.panel.active {
  display: block;
}

.audit-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 8px;
}

.audit-form-grid {
  flex: 0 1 auto;
  grid-template-columns: minmax(180px, 220px) minmax(150px, 180px) minmax(150px, 180px);
  gap: 8px;
  margin: 0;
}

.audit-form-grid label {
  min-width: 0;
}

.audit-filter-bar .actions,
.audit-filter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  margin-left: auto;
  margin-top: 0;
  flex: 0 0 auto;
  align-items: flex-end;
}

.audit-filter-bar .actions .btn,
.audit-filter-actions .btn {
  min-width: 72px;
  height: 40px;
}

.campaign-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 12px;
}

.campaign-topbar .actions {
  margin-top: 0;
}

.module-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.module-titlebar h2 {
  margin: 0;
}

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

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

#panel-audit .grid.two {
  grid-template-columns: 1fr;
}

.module {
  padding: 18px;
}

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

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

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--foreground);
  font-size: 14px;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #9ca3af;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
  resize: vertical;
}

.actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.actions.wrap {
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--foreground);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  border-color: transparent;
  color: #fff;
  background: var(--primary);
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.ghost {
  background: #fff;
}

.ops {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.campaign-ops {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.campaign-ops .op-btn {
  flex: 0 0 auto;
}

.op-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--foreground);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.op-btn:hover {
  border-color: rgba(79, 70, 229, 0.3);
  color: var(--primary);
  background: #f8faff;
}

.op-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.op-btn.danger {
  border-color: #fecaca;
  color: var(--danger);
  background: #fff7f7;
}

.table-wrap {
  margin-top: 8px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.list-pagination {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.list-pagination-info {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

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

.pagination-btn {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.list-pagination-indicator {
  min-width: 64px;
  text-align: center;
  color: var(--foreground);
  font-size: 12px;
  font-weight: 700;
}

.pagination-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pagination-size-label select {
  min-width: 74px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

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

#panel-audit table {
  min-width: 100%;
}

#campaign-table {
  min-width: 980px;
  table-layout: fixed;
}

#campaign-table th,
#campaign-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#campaign-table td:nth-child(1) {
  white-space: normal;
  word-break: break-all;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
}

#campaign-table td:nth-child(2) {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
}

#campaign-table th:nth-child(1),
#campaign-table td:nth-child(1) {
  width: 8%;
}

#campaign-table th:nth-child(2),
#campaign-table td:nth-child(2) {
  width: 30%;
}

#campaign-table th:nth-child(3),
#campaign-table td:nth-child(3) {
  width: 8%;
}

#campaign-table th:nth-child(4),
#campaign-table td:nth-child(4) {
  width: 12%;
  white-space: normal;
}

#campaign-table th:nth-child(5),
#campaign-table td:nth-child(5) {
  width: 8%;
}

#campaign-table th:nth-child(6),
#campaign-table td:nth-child(6) {
  width: 9%;
}

#campaign-table th:nth-child(7),
#campaign-table td:nth-child(7) {
  width: 25%;
}

.campaign-time-cell {
  display: grid;
  justify-items: center;
  gap: 2px;
  line-height: 1.35;
}

.campaign-time-line {
  display: block;
  width: 100%;
  text-align: center;
  white-space: nowrap;
}

#audit-table-body {
  font-size: 12px;
}

#panel-audit .module {
  min-width: 0;
}

#panel-audit .table-wrap {
  max-width: 100%;
}

#audit-table {
  width: 100%;
  min-width: 100%;
  table-layout: fixed;
}

#audit-table th,
#audit-table td {
  vertical-align: middle;
}

#audit-table th {
  white-space: nowrap;
}

#audit-table td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

#audit-table th:nth-child(1),
#audit-table td:nth-child(1) {
  width: 9%;
}

#audit-table th:nth-child(2),
#audit-table td:nth-child(2) {
  width: 10%;
}

#audit-table th:nth-child(3),
#audit-table td:nth-child(3) {
  width: 7%;
}

#audit-table th:nth-child(4),
#audit-table td:nth-child(4) {
  width: 8%;
}

#audit-table th:nth-child(5),
#audit-table td:nth-child(5) {
  width: 12%;
  white-space: normal;
  word-break: break-all;
}

#audit-table th:nth-child(6),
#audit-table td:nth-child(6) {
  width: 7%;
}

#audit-table th:nth-child(7),
#audit-table td:nth-child(7) {
  width: 7%;
}

#audit-table th:nth-child(8),
#audit-table td:nth-child(8) {
  width: 8%;
  white-space: normal;
  line-height: 1.25;
}

#audit-table th:nth-child(9),
#audit-table td:nth-child(9) {
  width: 8%;
}

#audit-table th:nth-child(10),
#audit-table td:nth-child(10) {
  width: 6%;
}

#audit-table th:nth-child(11),
#audit-table td:nth-child(11) {
  width: 9%;
}

#audit-table td:nth-child(11) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#audit-table th:nth-child(12),
#audit-table td:nth-child(12) {
  width: 9%;
  white-space: normal;
}

.audit-ops {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(217, 226, 243, 0.8);
  text-align: center;
  vertical-align: middle;
}

th {
  background: linear-gradient(180deg, #f7faff, #eef4ff);
  color: #243b63;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(239, 246, 255, 0.68);
}

.audit-link {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dashed rgba(79, 70, 229, 0.35);
}

.audit-link:hover {
  color: var(--primary-hover);
}

.result {
  margin: 10px 0 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f9fbff);
  min-height: 130px;
  max-height: 340px;
  overflow: auto;
  padding: 11px;
  line-height: 1.45;
  font-size: 12px;
  color: #30445e;
}

.result.compact {
  min-height: 70px;
}

.statusbar {
  margin-top: 16px;
  padding: 13px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

#toast {
  color: var(--primary);
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: riseIn 0.35s ease forwards;
}

.reveal:nth-of-type(2) {
  animation-delay: 0.05s;
}

.reveal:nth-of-type(3) {
  animation-delay: 0.1s;
}

.reveal:nth-of-type(4) {
  animation-delay: 0.15s;
}

@keyframes riseIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 18, 35, 0.56);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(860px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fafdff, #f5f8ff);
}

.modal-head h2 {
  margin: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.3);
}

.modal-body {
  padding: 12px 14px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.modal-body .form-grid {
  grid-template-columns: 1fr;
  gap: 8px;
}

.builder-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.builder-grid h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.modal-body section {
  border: 1px solid rgba(217, 226, 243, 0.9);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #fafcff);
  padding: 10px;
}

.reward-rule-grid {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}

#reward-rule-empty-tip {
  margin-top: 4px;
}

.reward-rule-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
}

.reward-rule-row strong {
  grid-column: 1 / -1;
  color: var(--foreground);
  font-size: 13px;
}

.rule-editor-toolbar {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rule-editor-toolbar .btn {
  min-height: 34px;
  padding: 8px 12px;
}

.rule-block-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.rule-block-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 8px;
  display: grid;
  gap: 8px;
}

.rule-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.rule-block-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  border-radius: 999px;
  border: 1px solid rgba(79, 70, 229, 0.24);
  background: rgba(224, 231, 255, 0.7);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
}

.rule-block-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rule-block-textarea {
  min-height: 90px;
  resize: vertical;
}

.rule-image-empty {
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  padding: 14px 10px;
  font-size: 12px;
}

.rule-image-preview {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.rule-image-preview img {
  width: 100%;
  max-height: 210px;
  object-fit: contain;
  display: block;
}

.rule-image-meta {
  display: block;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid rgba(217, 226, 243, 0.8);
}

.uploader {
  border: 1.5px dashed rgba(79, 70, 229, 0.45);
  border-radius: 12px;
  background: #f8f9ff;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.uploader p {
  margin: 0;
}

.uploader small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.uploader.dragover {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.image-preview,
.detail-list {
  margin-top: 8px;
}

.preview-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.preview-card img {
  width: 100%;
  height: 124px;
  object-fit: cover;
  display: block;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
}

.empty-tip {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  background: #fff;
}

.detail-list {
  display: grid;
  gap: 6px;
}

.detail-item {
  display: grid;
  grid-template-columns: auto 48px 1fr auto;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.detail-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(217, 226, 243, 0.8);
}

.detail-item.dragging {
  opacity: 0.65;
}

.detail-item.over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.drag-handle {
  font-size: 16px;
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

.detail-meta {
  overflow: hidden;
}

.detail-meta strong,
.detail-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-meta strong {
  font-size: 13px;
}

.detail-meta small {
  color: var(--muted);
  font-size: 12px;
}

.detail-item.prize-item .detail-meta {
  overflow: visible;
  display: grid;
  gap: 4px;
}

.prize-name-input,
.prize-level-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--foreground);
  background: #fff;
}

.prize-name-input:focus,
.prize-level-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.mini-required-label {
  font-size: 12px;
  line-height: 1.2;
  color: var(--muted);
  font-weight: 700;
}

.mini-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn.danger {
  border-color: #fecaca;
  color: var(--danger);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
  background: #fff;
}

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

.screenshot-modal-body {
  min-height: 280px;
  display: grid;
  place-items: center;
  gap: 10px;
}

#screenshot-modal-image {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(217, 226, 243, 0.8);
  background: #fff;
}

.screenshot-modal-error {
  color: #b45309;
}

@media (max-width: 1080px) {
  .grid.two {
    grid-template-columns: 1fr;
  }

  .campaign-topbar {
    justify-content: flex-start;
  }

  .audit-filter-bar {
    flex-direction: row;
    align-items: flex-end;
    overflow-x: auto;
  }

  .audit-form-grid {
    grid-template-columns: minmax(160px, 200px) minmax(140px, 170px) minmax(140px, 170px);
  }

  .audit-filter-bar .actions .btn,
  .audit-filter-actions .btn {
    width: auto;
  }

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

  .list-pagination {
    align-items: stretch;
  }

  .list-pagination-actions {
    width: 100%;
  }

  .reward-rule-row {
    grid-template-columns: 1fr;
  }

  .reward-rule-row strong {
    grid-column: 1;
  }

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

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

  .hero {
    padding: 14px;
    border-radius: 14px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 17px;
  }

  .tab {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }

  .modal {
    padding: 10px;
  }

  .modal-card {
    max-height: 95vh;
  }

  .modal-head,
  .modal-body,
  .modal-actions {
    padding-left: 12px;
    padding-right: 12px;
  }

  .detail-item {
    grid-template-columns: auto 42px 1fr;
  }

  .detail-item .mini-btn {
    grid-column: 1 / -1;
    justify-self: end;
  }
}
