:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dbe3ef;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 24px 28px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.status {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

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

.auth-layout {
  min-height: calc(100vh - 89px);
  display: grid;
  place-items: start center;
  padding: 56px 24px;
}

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

.dashboard-layout {
  max-width: 1280px;
  margin: 0 auto;
}

.layout {
  padding: 20px 28px 32px;
  display: grid;
  gap: 16px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.tab {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.admin-page {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

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

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

.span-3 {
  grid-column: 1 / -1;
}

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

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

input, textarea {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

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

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 9px 14px;
  cursor: pointer;
}

button.ghost {
  background: #fff;
  color: var(--accent);
}

button.danger {
  background: #fff;
  border-color: var(--danger);
  color: var(--danger);
}

button.compact {
  padding: 6px 10px;
  font-size: 12px;
}

.message {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.generated-codes {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.generated-codes[hidden] {
  display: none;
}

.code-box {
  min-height: 92px;
  resize: vertical;
  font-family: Consolas, "Microsoft YaHei", monospace;
  line-height: 1.5;
}

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

.section-header h2,
.section-header h3 {
  margin: 0;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar input {
  min-width: 220px;
}

.table-wrap {
  overflow: auto;
}

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

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #e2e8f0;
  color: #334155;
}

.tag.active { background: #dbeafe; color: #1d4ed8; }
.tag.used { background: #dcfce7; color: #166534; }
.tag.revoked { background: #fee2e2; color: #b91c1c; }
.tag.completed { background: #dcfce7; color: #166534; }
.tag.draft { background: #fef3c7; color: #92400e; }

.link-button {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.link-button:hover {
  text-decoration: underline;
}

.detail-panel {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.detail-panel[hidden] {
  display: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-grid > div {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: #f8fafc;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.detail-grid strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}

.detail-block {
  margin: 14px 0;
}

.detail-block h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.detail-block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.table-wrap.nested {
  max-width: 720px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .layout {
    padding: 16px;
  }

  .auth-layout {
    min-height: calc(100vh - 121px);
    padding: 28px 16px;
  }

  .header-actions,
  .tabs {
    width: 100%;
  }

  .tabs {
    justify-content: stretch;
  }

  .tab {
    flex: 1;
  }

  .grid.three,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .toolbar,
  .toolbar input {
    width: 100%;
  }
}
