/* ---------- 登录 ---------- */
.login { width: 400px; max-width: calc(100% - 32px); margin: 14vh auto; padding: 36px; }
.login .eyebrow { margin: 0 0 4px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.login h1 { margin: 0 0 8px; font-size: 26px; }
.login-hint { margin: 0 0 28px; font-size: 14px; }
.login label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.login input { width: 100%; }
.login .block { width: 100%; margin-top: 26px; }
.error-text { color: var(--accent); min-height: 20px; margin: 12px 0 0; font-size: 13px; }

/* ---------- 侧栏 ---------- */
aside {
  position: fixed; inset: 0 auto 0 0; width: 216px; padding: 24px 16px;
  background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 600;
}
.brand-text { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }

nav { display: grid; gap: 4px; margin-top: 16px; }
nav button {
  display: grid; gap: 1px; text-align: left; padding: 9px 12px;
  border: 1px solid transparent; background: transparent; border-radius: 8px;
}
nav button:hover { background: var(--bg); }
nav button.on { background: var(--accent-light); color: var(--accent); }
.nav-label { font-size: 14px; font-weight: 500; }
.nav-hint { font-size: 12px; color: var(--muted); }
nav button.on .nav-hint { color: inherit; opacity: .75; }

.identity { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: grid; min-width: 0; }
.who-label { font-size: 11px; color: var(--muted); }
.who-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost { padding: 6px 12px; font-size: 13px; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }

/* ---------- 主区 ---------- */
main { margin-left: 216px; padding: 28px 32px 48px; max-width: 1560px; }
header { margin-bottom: 20px; }
header h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }

/* ---------- 卡片 ---------- */
.card { padding: 22px 24px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 16px; }
.card-hint { font-size: 13px; color: var(--muted); }

/* ---------- 生成表单 ---------- */
.lottery-picker { margin-bottom: 18px; }
.picker-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.pack-state { font-weight: 400; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.pack-state.ok { background: var(--accent-light); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 14px; user-select: none;
  transition: border-color .12s, background .12s;
}
.chip:hover { border-color: #c9ced6; }
.chip input { width: auto; margin: 0; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.chip-static { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; color: var(--green); background: var(--green-light); white-space: nowrap; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }

.pack-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-mini { padding: 5px 12px; font-size: 13px; background: transparent; }
.btn-mini:hover { background: var(--bg); }

.form-grid { display: grid; grid-template-columns: 130px 110px 130px minmax(180px, 1fr) auto; gap: 14px; align-items: end; }
.field { min-width: 0; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.field input, .field select { width: 100%; }
.generate-submit { padding: 10px 28px; white-space: nowrap; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input { flex: 1 1 220px; min-width: 160px; }
.toolbar select { flex: 0 0 auto; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: 0;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfbfc; }
tbody tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; width: 64px; }
th.act-col, td.actions { text-align: right; white-space: nowrap; width: 1%; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

.code-cell { display: grid; gap: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; white-space: nowrap; }
.muted.tiny { font-size: 11px; }
.tag { font-size: 11px; color: var(--muted); }
.holder { font-size: 13px; }

.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot-on { background: var(--green); }

.status { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; }
.status-unclaimed { color: var(--muted); background: var(--bg); }
.status-claimed { color: var(--green); background: var(--green-light); }
.status-expired { color: var(--muted); background: var(--bg); }
.status-revoked { color: var(--accent); background: var(--accent-light); }

.btn-icon { padding: 4px 9px; font-size: 12px; background: transparent; border-color: transparent; color: var(--blue); }
.btn-icon:hover { background: var(--bg); }
.btn-danger { color: var(--accent); }

/* ---------- 概览数字 ---------- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.stat-num { font-size: 26px; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-warn .stat-num { color: var(--accent); }

/* ---------- 分页 ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.pager .muted { font-size: 13px; }
.pager-btns { display: flex; gap: 8px; }

/* ---------- 提示条 ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 20px; border-radius: 8px;
  max-width: calc(100% - 32px); z-index: 20; font-size: 13.5px; box-shadow: 0 6px 20px #00000022;
}
#toast.error { background: var(--accent); }
#toast.ok { background: var(--green); }

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  .form-grid { grid-template-columns: repeat(4, 1fr); }
  .generate-submit { grid-column: span 4; }
}
@media (max-width: 1000px) { .summary { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) {
  aside { position: static; width: auto; padding: 16px; }
  .brand { padding-bottom: 14px; }
  nav { grid-template-columns: repeat(2, 1fr); }
  nav button { text-align: center; }
  .nav-hint { display: none; }
  .identity { margin-top: 14px; }
  main { margin: 0; padding: 18px 14px 40px; }
  .card { padding: 18px 16px; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .generate-submit { grid-column: span 2; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .pager { flex-direction: column; align-items: stretch; }
  .pager-btns { justify-content: flex-end; }
}

/* ---------- 设备额度弹窗 ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 28, 36, .45);
  display: grid; place-items: center; padding: 24px;
}
.dialog-backdrop[hidden] { display: none; }
.dialog { width: 880px; max-width: 100%; max-height: 86vh; overflow: auto; margin: 0; }
.dialog .card-head { align-items: center; }
.dialog-footer {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.dialog-footer input { width: 90px; }
.device-quota-input { width: 90px; }
.device-id { font-family: var(--mono, monospace); font-size: 12px; white-space: nowrap; }
/* 设备描述（浏览器/系统）放在 id 下面一行，别单独占一列 —— 少一列就少挤一分。 */
.device-cell { max-width: 260px; }
.device-label {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 操作列钉在右边：表格再宽（窄屏、浏览器缩放）也不会把「解绑」挤出可视区。 */
th.act-col, td.actions { position: sticky; right: 0; }
th.act-col { background: var(--bg); z-index: 2; }
td.actions { background: var(--card); }
tbody tr:hover td.actions { background: #fbfbfc; }
/* 窄屏时表格保持自然宽度、横向滚动：压扁会把表头挤成半个字，更难看。 */
.dialog .table-wrap table { min-width: 520px; }
