/* ============ 共用设计系统 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #07070e;
  --bg-soft: #0d0d18;
  --text: #eef0f8;
  --muted: #9aa0b5;
  --muted-2: #6f7488;
  --accent: #8b7bff;
  --accent-2: #5ee7e7;
  --accent-3: #ff8fc0;
  --card: rgba(255, 255, 255, 0.045);
  --card-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --danger: #ff6b81;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 18px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.8);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body.admin-page {
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(109, 77, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(15, 184, 184, 0.12), transparent 55%),
    var(--bg);
}

a { color: #b9b1ff; text-decoration: none; }
a:hover { color: #d9d4ff; }

h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.25; letter-spacing: -0.01em; }
h2 { font-size: 17px; line-height: 1.4; }

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px;
  background: rgba(7, 7, 14, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; color: #fff; letter-spacing: 0.02em;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 9px;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  font-size: 13px; color: #fff;
  box-shadow: 0 8px 24px -8px rgba(124, 92, 255, 0.9);
}
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-actions a.active { border-color: rgba(139, 123, 255, 0.6); color: #fff; }
.inline-form { display: inline; }

/* ============ 布局 ============ */
.wrap { max-width: 1160px; margin: 0 auto; padding: 30px 22px 80px; }
.wrap.narrow { max-width: 620px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumb:hover { color: #fff; }

.split {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px; margin-bottom: 18px;
}

.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-num {
  font-size: 26px; font-weight: 700;
  background: linear-gradient(110deg, #a08bff, #5ee7e7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { font-size: 12.5px; color: var(--muted); letter-spacing: 0.04em; }

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.section-head h2 { display: flex; align-items: center; gap: 9px; }
.section-head h2 .hint { font-weight: 400; }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.empty { color: var(--muted-2); padding: 10px 2px; }
.warn-text { color: var(--warn); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }
.btn:active { transform: scale(0.985); }
.btn.primary {
  border: none; color: #fff;
  background: linear-gradient(120deg, #7c5cff, #a855f7 45%, #22d3ee);
  background-size: 180% 100%;
  box-shadow: 0 12px 30px -12px rgba(124, 92, 255, 0.95);
}
.btn.primary:hover { background-position: 100% 0; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: #fff; }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 129, 0.35); }
.btn.danger:hover { background: rgba(255, 107, 129, 0.1); border-color: rgba(255, 107, 129, 0.6); }
.btn.sm { font-size: 13px; padding: 8px 14px; }
.btn.xs { font-size: 12.5px; padding: 6px 11px; }
.btn.block { width: 100%; }
.btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ============ 表单 ============ */
.stack { display: flex; flex-direction: column; gap: 13px; }
.stack.tight { gap: 8px; margin-top: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; align-items: end;
}
.form-submit { display: flex; align-items: end; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

.input {
  width: 100%; font-family: inherit; font-size: 15px;
  color: var(--text); background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 13px; outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  min-height: 44px;
}
.input:focus { border-color: rgba(139, 123, 255, 0.65); background: rgba(255, 255, 255, 0.06); }
.input::placeholder { color: var(--muted-2); }
textarea.input { resize: vertical; line-height: 1.6; }
select.input {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa0b5' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
select.input:focus {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa0b5' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
select.input option {
  background-color: #12121d;
  color: var(--text);
}
select.input option:disabled {
  color: var(--muted-2);
}
input[type="file"].input { padding: 8px; color: var(--muted); }

/* ============ 表格 ============ */
.table-scroll { overflow-x: auto; border-radius: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 12px; letter-spacing: 0.05em; color: var(--muted-2);
  font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table td.actions { white-space: nowrap; }
.table .hint { font-size: 12.5px; }

.code {
  display: inline-block; padding: 2px 8px; border-radius: 7px;
  background: rgba(139, 123, 255, 0.13);
  border: 1px solid rgba(139, 123, 255, 0.28);
  color: #d7d1ff; letter-spacing: 0.14em; font-size: 13px;
}
.code.big { font-size: 16px; padding: 4px 10px; }
.code.huge { font-size: 28px; letter-spacing: 0.28em; padding: 8px 16px; color: #fff; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); white-space: nowrap;
}
.badge.type-html { color: #9fe9ff; border-color: rgba(94, 231, 231, 0.35); background: rgba(94, 231, 231, 0.08); }
.badge.type-form { color: #d7c9ff; border-color: rgba(139, 123, 255, 0.4); background: rgba(139, 123, 255, 0.1); }
.badge.ok-badge { color: #b8f5c9; border-color: rgba(74, 222, 128, 0.4); background: rgba(74, 222, 128, 0.1); }

.status {
  display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.status-active { color: #b9b1ff; border-color: rgba(139, 123, 255, 0.4); }
.status-opened, .status-used { color: #9fe9ff; border-color: rgba(94, 231, 231, 0.35); }
.status-locked { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); }
.status-expired, .status-revoked, .status-missing { color: var(--danger); border-color: rgba(255, 107, 129, 0.4); }

.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.expiry-details summary { list-style: none; }
.expiry-details summary::-webkit-details-marker { display: none; }
.expiry-details[open] { flex-basis: 100%; }
.expiry-details > form { max-width: 260px; }

/* ============ 提示 ============ */
.flash {
  padding: 12px 16px; border-radius: 13px; font-size: 14px;
  margin-bottom: 16px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}
.flash-ok { color: #b8f5c9; border-color: rgba(74, 222, 128, 0.32); background: rgba(74, 222, 128, 0.08); }
.flash-error { color: #ffc4cc; border-color: rgba(255, 107, 129, 0.35); background: rgba(255, 107, 129, 0.09); }
.flash-warn { color: #ffe6a8; border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.09); }

/* ============ 生成结果卡片 ============ */
.created-card { border-color: rgba(139, 123, 255, 0.4); background: rgba(139, 123, 255, 0.07); }
.created-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px; margin: 6px 0 18px; align-items: start;
}
.created-grid .label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.copy-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy-line code { color: #dcd8ff; word-break: break-all; font-size: 13px; }

.filter-input { max-width: 240px; min-height: 38px; }

.danger-zone { border-color: rgba(255, 107, 129, 0.22); }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; }

/* ============ 登录 ============ */
.auth-page {
  display: grid; place-items: center;
  background:
    radial-gradient(800px 500px at 20% 0%, rgba(109, 77, 255, 0.22), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(15, 184, 184, 0.15), transparent 55%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 420px; padding: 24px; }
.auth-card { padding: 30px 26px; }
.auth-brand { margin-bottom: 18px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .hint { margin-bottom: 18px; }

/* ============ 验证码页 ============ */
.gate-page {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(620px 420px at 8% -10%, rgba(109, 77, 255, 0.4), transparent 62%),
    radial-gradient(560px 420px at 105% 110%, rgba(15, 184, 184, 0.24), transparent 58%),
    radial-gradient(400px 400px at 75% 45%, rgba(255, 79, 150, 0.12), transparent 60%),
    var(--bg);
  padding: 24px;
}
.gate-wrap { width: 100%; max-width: 430px; }
.gate-card {
  padding: 34px 28px 28px; text-align: center;
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.lock-mark {
  width: 46px; height: 46px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 16px;
  font-size: 22px; color: #d9d4ff;
  background: rgba(139, 123, 255, 0.14);
  border: 1px solid rgba(139, 123, 255, 0.35);
  box-shadow: 0 10px 30px -12px rgba(139, 123, 255, 0.8);
}
.lock-mark.muted { color: var(--muted); background: rgba(255, 255, 255, 0.05); border-color: var(--border); box-shadow: none; }
.gate-card h1 { font-size: 24px; margin-bottom: 8px; }
.gate-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; word-break: break-word; }
.gate-form { display: flex; flex-direction: column; gap: 18px; }
.digits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.digit {
  width: 100%; height: 62px; text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px; font-weight: 700; color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 14px;
  outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease;
  caret-color: var(--accent-2);
}
.digit:focus {
  border-color: rgba(139, 123, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(139, 123, 255, 0.16);
}
.digit:disabled { opacity: 0.55; }
.gate-hint { margin-top: 18px; font-size: 12.5px; }
.countdown { font-variant-numeric: tabular-nums; }

/* ============ 预览 ============ */
.preview-bar { position: sticky; }
.preview-page { padding: 18px 22px 60px; }
.preview-note { text-align: center; margin-bottom: 14px; }
.preview-shell {
  margin: 0 auto; background: #000;
  border: 1px solid var(--border); border-radius: 20px;
  overflow: hidden; box-shadow: var(--shadow);
  transition: max-width 0.2s ease;
}
.preview-shell.desktop { max-width: 1160px; }
.preview-shell.mobile { max-width: 390px; }
.preview-frame { display: block; width: 100%; height: calc(100vh - 170px); min-height: 560px; border: 0; background: #07070e; }

/* ============ 编辑器 ============ */
.editor-wrap { max-width: 1000px; }
.editor-page .card { padding: 20px; }
.dim-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 10px;
  align-items: end; padding: 12px; border: 1px solid var(--border);
  border-radius: 14px; background: rgba(255, 255, 255, 0.025);
}
.dim-side { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: end; }
.dim-vs { color: var(--muted-2); padding-bottom: 12px; font-size: 12px; }

.q-editor {
  border: 1px solid var(--border); border-radius: 16px;
  padding: 14px; background: rgba(255, 255, 255, 0.025);
}
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.q-head strong { font-size: 13px; color: var(--muted); }
.q-head .row { gap: 5px; }
.opt-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.opt-row {
  display: grid; grid-template-columns: 1fr 90px 70px auto;
  gap: 8px; align-items: center;
}
.opt-row .input { min-height: 38px; font-size: 13.5px; }
.editor-details { margin-top: 14px; }
.editor-details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
ol.steps {
  margin: 10px 0 0 20px; color: var(--muted);
  font-size: 13px; line-height: 1.75;
}
ol.steps li { margin-bottom: 4px; }
.json-area { min-height: 220px; font-size: 12.5px; line-height: 1.55; }
.result-editor { border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.result-editor summary { cursor: pointer; font-weight: 600; letter-spacing: 0.08em; color: #cfc8ff; }
.result-editor .form-grid { margin-top: 12px; }
.result-editor textarea.input { min-height: 70px; }
.row-actions .btn, .row-actions form { flex: none; }

/* ============ 工具 ============ */
.is-hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100;
  transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px;
  background: rgba(20, 20, 32, 0.96); color: #e8f8ef;
  border: 1px solid rgba(74, 222, 128, 0.4);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-error { color: #ffd0d6; border-color: rgba(255, 107, 129, 0.45); }

/* ============ 响应式 ============ */
@media (max-width: 760px) {
  .topbar { padding: 12px 14px; }
  .wrap { padding: 22px 14px 60px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; border-radius: 16px; }
  .dim-row { grid-template-columns: 1fr; }
  .dim-vs { padding-bottom: 0; }
  .opt-row { grid-template-columns: 1fr 80px 64px auto; }
  .table-scroll { overflow: visible; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr {
    border: 1px solid var(--border); border-radius: 14px;
    margin-bottom: 10px; padding: 6px 4px; background: rgba(255, 255, 255, 0.02);
  }
  .table td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; border: none; padding: 6px 10px; text-align: right;
  }
  .table td::before {
    content: attr(data-label); color: var(--muted-2); font-size: 12px;
    text-align: left; flex: none;
  }
  .table td.actions { display: block; text-align: left; }
  .table td.actions::before { display: block; margin-bottom: 6px; }
  .preview-bar .brand { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .filter-input { max-width: 100%; }
  .page-head { align-items: flex-start; }
  .digit { height: 56px; font-size: 24px; }
  .preview-page { padding: 12px; }
  .preview-shell.mobile { max-width: 100%; }
  .preview-frame { height: calc(100vh - 210px); }
  .form-grid { grid-template-columns: 1fr; }
  .created-grid { grid-template-columns: 1fr; }
}
