:root {
  color-scheme: dark;
  --bg: #050912;
  --surface: rgba(7, 14, 28, 0.92);
  --surface-2: rgba(10, 20, 40, 0.96);
  --line: rgba(38, 155, 191, 0.34);
  --line-strong: rgba(40, 215, 255, 0.58);
  --text: #e9f6ff;
  --muted: #8d9ab0;
  --cyan: #27d7ff;
  --cyan-2: #00b8f0;
  --blue: #7ba7ff;
  --purple: #d579ff;
  --green: #6ae4a1;
  --amber: #ffbb76;
  --red: #ff7584;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 0 0 1px rgba(40, 215, 255, 0.18), 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background:
    linear-gradient(rgba(5, 9, 18, 0.92), rgba(5, 9, 18, 0.92)),
    linear-gradient(90deg, rgba(39, 215, 255, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(39, 215, 255, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 48px 48px, 48px 48px, auto;
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.8;
}

.shell {
  width: min(100%, 1860px);
  margin: 0 auto;
  padding: 36px 28px 60px;
}

.admin-shell {
  max-width: 1660px;
}

.panel {
  background: linear-gradient(180deg, rgba(11, 21, 42, 0.97), rgba(6, 12, 24, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.panel-gap {
  margin-top: 34px;
  padding: 32px;
}

.hero {
  padding: 28px 34px 30px;
}

.hero-top,
.section-head,
.action-row,
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-top {
  margin-bottom: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 22px;
  border: 1px solid rgba(39, 215, 255, 0.35);
  border-radius: 999px;
  color: var(--cyan);
  letter-spacing: 0.24em;
  font-size: 0.82rem;
  text-transform: uppercase;
  background: rgba(39, 215, 255, 0.05);
}

.ghost-link {
  color: var(--muted);
}

.lang-switch {
  display: inline-flex;
  gap: 0;
  border: 1px solid rgba(39, 215, 255, 0.34);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(6, 12, 24, 0.8);
}

.lang-btn {
  min-width: 56px;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.lang-btn.active,
.tab-btn.active {
  color: var(--bg);
  background: linear-gradient(180deg, var(--cyan), #12a6d4);
  box-shadow: 0 0 0 1px rgba(39, 215, 255, 0.2), 0 0 24px rgba(39, 215, 255, 0.22);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow: 0 0 20px rgba(39, 215, 255, 0.3);
}

.hero-copy {
  margin: 18px auto 0;
  max-width: 760px;
  text-align: center;
  color: var(--muted);
}

.tab-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 30px;
}

.tab-btn,
.copy-btn,
.ghost-btn,
.primary-btn {
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid rgba(100, 130, 170, 0.4);
  background: rgba(5, 10, 22, 0.85);
  color: var(--text);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tab-btn:hover,
.copy-btn:hover,
.ghost-btn:hover,
.primary-btn:hover,
.lang-btn:hover,
.action-btn:hover,
.row-action:hover {
  transform: translateY(-1px);
}

.tab-btn.active {
  border-color: rgba(39, 215, 255, 0.8);
}

.primary-btn {
  border-color: rgba(39, 215, 255, 0.78);
  background: linear-gradient(180deg, rgba(39, 215, 255, 0.96), rgba(4, 158, 212, 0.98));
  color: #04151f;
  font-weight: 700;
}

.ghost-btn,
.ghost-link {
  color: var(--muted);
}

.copy-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.copy-btn {
  min-width: 0;
  border-color: rgba(39, 215, 255, 0.38);
  color: var(--cyan);
}

.section-head {
  align-items: end;
  margin-bottom: 10px;
}

.section-head.tight {
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--cyan);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 8px 0 0;
}

.helper,
.section-meta,
.activity-meta,
.small-muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
}

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

.field span {
  color: var(--muted);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid rgba(39, 215, 255, 0.2);
  border-radius: var(--radius);
  background: rgba(3, 8, 18, 0.92);
  color: var(--text);
  outline: none;
  padding: 14px 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(39, 215, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(39, 215, 255, 0.14);
}

textarea {
  resize: vertical;
  min-height: 180px;
}

.action-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.action-row.compact {
  justify-content: flex-end;
}

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

.stat-card {
  border-radius: 16px;
  min-height: 150px;
  padding: 22px 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(3, 8, 18, 0.65);
}

.stat-card.blue {
  border-color: rgba(103, 166, 255, 0.42);
  background: linear-gradient(180deg, rgba(16, 42, 92, 0.92), rgba(7, 18, 38, 0.94));
}

.stat-card.purple {
  border-color: rgba(211, 126, 255, 0.42);
  background: linear-gradient(180deg, rgba(64, 18, 77, 0.9), rgba(20, 6, 25, 0.94));
}

.stat-card.green {
  border-color: rgba(106, 228, 161, 0.42);
  background: linear-gradient(180deg, rgba(10, 58, 43, 0.92), rgba(6, 23, 16, 0.94));
}

.stat-card.amber {
  border-color: rgba(255, 183, 96, 0.42);
  background: linear-gradient(180deg, rgba(69, 42, 20, 0.92), rgba(29, 18, 8, 0.94));
}

.stat-label {
  color: rgba(235, 242, 255, 0.72);
  font-size: 0.98rem;
}

.stat-value {
  margin-top: 28px;
  font-size: clamp(2.6rem, 4vw, 4.1rem);
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.results-panel {
  margin-top: 30px;
  padding-top: 6px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid rgba(39, 215, 255, 0.22);
  border-radius: var(--radius-lg);
  background: rgba(3, 8, 18, 0.72);
}

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

.data-table th,
.data-table td {
  padding: 18px 18px;
  border-bottom: 1px solid rgba(39, 215, 255, 0.1);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(7, 13, 27, 0.9);
}

.data-table tr:hover td {
  background: rgba(39, 215, 255, 0.03);
}

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

.code-pill,
.status-pill,
.action-btn,
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(100, 130, 170, 0.34);
  background: rgba(5, 10, 22, 0.9);
}

.code-pill {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.status-pill {
  min-width: 92px;
}

.status-unused {
  border-color: rgba(106, 228, 161, 0.4);
  color: var(--green);
}

.status-used {
  border-color: rgba(255, 117, 132, 0.38);
  color: #ff9ca8;
}

.status-invalid {
  border-color: rgba(255, 183, 96, 0.36);
  color: var(--amber);
}

.status-unknown {
  color: var(--muted);
}

.admin-grid {
  display: grid;
  gap: 18px;
}

.pool-grid {
  grid-template-columns: 1.15fr 0.85fr;
}
.subpanel {
  border: 1px solid rgba(39, 215, 255, 0.18);
  border-radius: var(--radius-lg);
  background: rgba(3, 8, 18, 0.72);
  padding: 20px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  display: grid;
  gap: 10px;
}

.toast-item {
  max-width: min(92vw, 420px);
  border: 1px solid rgba(39, 215, 255, 0.3);
  border-radius: 14px;
  background: rgba(4, 10, 20, 0.95);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  color: var(--text);
}

.toast-item.error {
  border-color: rgba(255, 117, 132, 0.36);
}

.admin-shell .hero {
  margin-bottom: 30px;
}

.narrow {
  max-width: 520px;
  margin: 0 auto;
}

.admin-stats {
  margin-top: 0;
}

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

.filter-row {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.filter-row input,
.filter-row select {
  width: auto;
  min-width: 180px;
}

.admin-table {
  min-width: 1300px;
}

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

.delivery-block {
  display: block;
  width: 100%;
  white-space: pre-wrap;
  text-align: left;
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.45;
}

.delivery-preview {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  max-height: 220px;
  overflow: auto;
  padding-right: 6px;
}

.pool-table-wrap {
  min-height: 260px;
}

.action-btn,
.row-action {
  min-height: 34px;
  padding-inline: 12px;
  color: var(--text);
}

.action-btn.danger,
.row-action.danger {
  border-color: rgba(255, 117, 132, 0.38);
  color: #ff9ca8;
}

.action-btn.success,
.row-action.success {
  border-color: rgba(106, 228, 161, 0.38);
  color: var(--green);
}

.action-btn.warn,
.row-action.warn {
  border-color: rgba(255, 183, 96, 0.38);
  color: var(--amber);
}

.activity-list {
  display: grid;
  gap: 12px;
}

.activity-item {
  border: 1px solid rgba(39, 215, 255, 0.14);
  border-radius: 14px;
  background: rgba(3, 8, 18, 0.72);
  padding: 14px 16px;
  color: var(--muted);
}

.activity-item strong {
  color: var(--text);
}

.small-note {
  font-size: 0.92rem;
  color: var(--muted);
}

@media (max-width: 1200px) {
  .stats-grid,
  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .copy-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .shell {
    padding: 18px 14px 34px;
  }

  .hero,
  .panel-gap {
    padding: 20px 16px;
  }

  .hero h1 {
    font-size: 2.1rem;
    text-align: left;
  }

  .hero-copy {
    text-align: left;
    margin-left: 0;
  }

  .hero-top,
  .section-head,
  .action-row,
  .filter-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .tab-strip,
  .copy-bar,
  .stats-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

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

  .tab-strip {
    align-items: stretch;
  }

  .tab-btn,
  .copy-btn,
  .ghost-btn,
  .primary-btn,
  .lang-btn {
    width: 100%;
  }

  .data-table {
    min-width: 760px;
  }

  .filter-row input,
  .filter-row select {
    width: 100%;
  }
}
