:root {
  --bg: #000000;
  --surface: rgba(28, 28, 30, 0.86);
  --surface-solid: #1c1c1e;
  --surface-2: #2c2c2e;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --blue: #0a84ff;
  --blue-hover: #409cff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-2: #e5e5ea;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #248a3d;
  --orange: #c93400;
  --red: #d70015;
  --purple: #8944ab;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

/* 登录锁屏 */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 0%, rgba(10, 132, 255, 0.16), transparent 60%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 28px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  text-align: center;
}

.login-badge {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.login-sub { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.login-form { margin-top: 24px; text-align: left; display: flex; flex-direction: column; gap: 14px; }
.login-error { color: var(--red); font-size: 13px; text-align: center; }

.adv-details summary { font-size: 12px; color: var(--text-2); cursor: pointer; user-select: none; }

/* 表单组件 */
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field > span { font-size: 12px; font-weight: 500; color: var(--text-2); }

input[type="text"], input[type="password"], input[type="url"], input[type="number"], input[type="search"], select, textarea {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-full { width: 100%; padding: 12px; border-radius: 12px; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover { opacity: 0.88; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--surface-2); }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); }

/* 顶部导航 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; }
.muted-small { font-size: 12px; color: var(--text-2); }

.seg-nav {
  display: inline-flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

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

/* 主容器 */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 18px 60px;
}

/* 顶部统计条 */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-pill {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-val { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.c-green { color: var(--green); }
.c-blue { color: var(--blue); }
.c-purple { color: var(--purple); }
.c-orange { color: var(--orange); }
.c-red { color: var(--red); }
.c-muted { color: var(--text-2); }

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.panel-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.quick-note-wrap input { width: 280px; max-width: 100%; }

/* 刚发码高亮横幅 */
.issued-banner {
  background: rgba(48, 209, 88, 0.12);
  border: 1px solid rgba(48, 209, 88, 0.35);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.issued-banner-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.badge-green {
  background: var(--green);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.mono-big {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.04em;
  user-select: all;
}

/* 快速发码卡片网格 */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.plan-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.plan-top { display: flex; align-items: center; justify-content: space-between; }
.plan-name { font-size: 19px; font-weight: 600; }
.plan-avail { font-size: 13px; color: var(--text-2); }
.plan-avail strong { font-size: 22px; color: var(--green); margin-right: 2px; }
.plan-avail.low strong { color: var(--orange); }
.plan-avail.zero strong { color: var(--red); }

.plan-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.plan-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 999px;
  transition: width 0.3s;
}
.plan-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}

/* 通用卡片与表单 */
.card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.empty-card {
  background: var(--surface-solid);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.code-textarea { width: 100%; font-family: var(--mono); font-size: 13px; resize: vertical; }

/* 筛选条与表格 */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-2);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  cursor: pointer;
}
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.filter-right { display: flex; gap: 8px; flex-wrap: wrap; }

.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 500;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.mono-cell { font-family: var(--mono); font-weight: 500; white-space: nowrap; }
.table-footer { padding: 12px 16px; font-size: 12px; color: var(--text-2); border-top: 1px solid var(--border); }

.st-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.st-available { background: rgba(48, 209, 88, 0.16); color: var(--green); }
.st-issued { background: rgba(10, 132, 255, 0.16); color: var(--blue); }
.st-platform { background: rgba(191, 90, 242, 0.18); color: var(--purple); }
.st-used { background: var(--surface-2); color: var(--text-2); }
.st-void, .st-blocked, .st-expired { background: rgba(255, 69, 58, 0.16); color: var(--red); }
.st-permanent { background: rgba(255, 159, 10, 0.18); color: var(--orange); }
.st-active { background: rgba(48, 209, 88, 0.16); color: var(--green); }
.st-inactive { background: var(--surface-2); color: var(--text-2); }

.mini-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 4px;
}
.mini-btn:hover { background: var(--surface-2); }

/* 弹窗 */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}
.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-seg { margin-bottom: 16px; width: 100%; }
.modal-seg .seg-btn { flex: 1; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
.imp-progress {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .topbar-inner { padding: 10px 12px; }
  .seg-nav { order: 3; width: 100%; justify-content: space-between; }
  .seg-btn { flex: 1; padding: 7px 6px; font-size: 12px; }
  .quick-note-wrap, .quick-note-wrap input { width: 100%; }
}
