:root {
  --bg: #0b1020;
  --panel: #141b34;
  --panel-2: #1b2445;
  --text: #eef2ff;
  --muted: #a5b0d6;
  --primary: #6d7cff;
  --primary-2: #8190ff;
  --danger: #ff6b81;
  --warning: #ffb84d;
  --success: #39d98a;
  --line: rgba(255,255,255,0.08);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top, #17214b, var(--bg) 50%);
  color: var(--text);
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.topbar-actions form {
  margin: 0;
}

.topbar-actions .btn {
  min-width: 108px;
}

.brand {
  font-size: 28px;
  font-weight: 800;
}

.subbrand {
  color: var(--muted);
  margin-top: 4px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero-grid,
.grid.two-cols {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

.hero-grid.single {
  align-items: stretch;
}

.narrow {
  max-width: 480px;
}

h1, h2, h3 {
  margin: 0 0 12px;
}

p { line-height: 1.65; }
.muted { color: var(--muted); }
.tiny { font-size: 13px; }
.mono { font-family: Consolas, Monaco, monospace; word-break: break-all; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(109,124,255,0.16);
  color: #cfd5ff;
  font-size: 13px;
  margin-bottom: 16px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form.compact {
  background: var(--panel-2);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--line);
}

label {
  display: grid;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  outline: none;
}

select,
option {
  background: #121936;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: rgba(129,144,255,0.8);
  box-shadow: 0 0 0 4px rgba(109,124,255,0.15);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  min-height: 42px;
  white-space: nowrap;
  transition: 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
}
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-danger {
  background: rgba(255,107,129,0.18);
  color: #ffd7de;
  border: 1px solid rgba(255,107,129,0.25);
}
.btn-small {
  padding: 9px 12px;
  font-size: 13px;
  min-height: 36px;
}

.alert {
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}
.alert-success { background: rgba(57,217,138,0.14); }
.alert-warning { background: rgba(255,184,77,0.14); }
.alert-danger { background: rgba(255,107,129,0.14); }

.feature-list {
  margin: 18px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}
.feature-list.slim { gap: 8px; }

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

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

.info-item {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.admin-log-item {
  grid-column: 1 / -1;
}

.admin-log-panel {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(180deg, rgba(7, 12, 28, 0.92), rgba(12, 18, 38, 0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  color: #dfe7ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}

.admin-log-panel.is-danger {
  border-color: rgba(255,107,129,0.28);
  background:
    linear-gradient(180deg, rgba(48, 15, 25, 0.92), rgba(22, 12, 23, 0.96));
}

.admin-log-panel.is-success {
  border-color: rgba(57,217,138,0.24);
  background:
    linear-gradient(180deg, rgba(11, 35, 28, 0.92), rgba(10, 20, 22, 0.96));
}

.admin-log-panel::-webkit-scrollbar {
  width: 10px;
}

.admin-log-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.eligibility {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
}
.eligibility-title { font-weight: 800; margin-bottom: 6px; }
.eligibility-success { background: rgba(57,217,138,0.10); }
.eligibility-warning { background: rgba(255,184,77,0.10); }
.eligibility-danger { background: rgba(255,107,129,0.10); }
.eligibility-celebration {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.22), transparent 30%),
    linear-gradient(135deg, rgba(255, 193, 7, 0.22), rgba(255, 107, 129, 0.18) 38%, rgba(109, 124, 255, 0.22) 100%);
  border-color: rgba(255, 220, 120, 0.35);
  box-shadow: 0 12px 28px rgba(255, 184, 77, 0.15);
}

.eligibility-celebration .eligibility-title {
  position: relative;
  z-index: 1;
  margin-bottom: 0;
  font-size: 18px;
}

.celebration-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.celebration-confetti span {
  position: absolute;
  top: -18px;
  width: 10px;
  height: 18px;
  border-radius: 999px;
  opacity: 0.95;
  animation: confetti-fall 4.2s linear infinite;
}

.celebration-confetti span:nth-child(1) { left: 7%; background: #ffd166; animation-delay: 0s; }
.celebration-confetti span:nth-child(2) { left: 18%; background: #ff6b81; animation-delay: 0.5s; }
.celebration-confetti span:nth-child(3) { left: 31%; background: #39d98a; animation-delay: 1.1s; }
.celebration-confetti span:nth-child(4) { left: 44%; background: #6d7cff; animation-delay: 1.6s; }
.celebration-confetti span:nth-child(5) { left: 58%; background: #ffd166; animation-delay: 0.9s; }
.celebration-confetti span:nth-child(6) { left: 70%; background: #ff8fab; animation-delay: 2s; }
.celebration-confetti span:nth-child(7) { left: 82%; background: #7bdff2; animation-delay: 1.3s; }
.celebration-confetti span:nth-child(8) { left: 92%; background: #b8f2e6; animation-delay: 2.4s; }

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(-8px, 96px, 0) rotate(300deg);
  }
}

.callout,
.line-box,
.empty-state,
.tips {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.line-info-box {
  border-color: rgba(109,124,255,0.25);
  background: linear-gradient(180deg, rgba(109,124,255,0.10), rgba(109,124,255,0.04));
}

.line-info-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 10px;
}

.line-content {
  margin-top: 10px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  white-space: pre-wrap;
  line-height: 1.8;
  color: #e8ecff;
}

.usage-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.usage-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(109,124,255,0.14);
  border: 1px solid rgba(109,124,255,0.26);
  color: #dbe0ff;
  text-decoration: none;
  font-weight: 600;
}

.usage-link:hover {
  background: rgba(109,124,255,0.22);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.toggle-row {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.multi-checks {
  display: grid;
  gap: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.admin-table-card {
  margin-top: 20px;
}

.admin-filter-head {
  align-items: end;
}

.admin-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(150px, 0.7fr) auto;
  gap: 10px;
  align-items: center;
}

.admin-main-row {
  cursor: pointer;
}

.admin-main-row:hover {
  background: rgba(255,255,255,0.03);
}

.admin-expand-row {
  display: none;
}

.admin-expand-row.open {
  display: table-row;
}

.admin-expand-box {
  padding: 8px 0;
}

.admin-actions-inline {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 4px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  margin: 0;
}

.expire-form input[type="datetime-local"] {
  min-width: 180px;
  padding: 9px 12px;
}

.expand-hint {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table.data-table-admin {
  min-width: 980px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

.admin-pagination-summary {
  margin-bottom: 12px;
}

.admin-pagination {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-page-jump {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-page-jump input {
  width: 90px;
  padding: 9px 12px;
}

.btn:disabled,
.btn-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.link-row {
  margin-top: 18px;
}

@media (max-width: 920px) {
  .hero-grid,
  .grid.two-cols,
  .action-grid,
  .info-grid,
  .stats-grid,
  .admin-filters {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    width: 100%;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .section-head > form {
    width: 100%;
  }

  .section-head > form .btn {
    width: 100%;
  }

  .narrow { max-width: none; }

  .admin-pagination {
    justify-content: stretch;
  }

  .admin-pagination > * {
    width: 100%;
  }

  .admin-page-jump {
    width: 100%;
  }

  .admin-page-jump input {
    width: 100%;
  }
}
