/* ===========================================================
   激活码中心 · 后台管理台
   设计取向：中性灰阶、细边框、小圆角、等宽数字。
   不使用渐变、彩色大数字与图标装饰。
   =========================================================== */

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --surface-muted: #f4f4f5;

  --line: #ebebee;
  --line-strong: #e4e4e7;

  --ink: #18181b;
  --ink-2: #3f3f46;
  --ink-3: #71717a;
  --ink-4: #a1a1aa;

  --accent: #18181b;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --violet: #7c3aed;
  --violet-bg: #f5f3ff;

  --r-sm: 5px;
  --r-md: 7px;
  --r-lg: 10px;

  --sidebar-w: 212px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', Helvetica, sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body,
input,
button,
select,
textarea {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* ============================ 登录 ============================ */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  border-top: 3px solid var(--ink);
}

.login-card {
  width: 344px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px 28px 24px;
}

.login-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.2px;
}

.login-sub {
  margin: 4px 0 26px;
  color: var(--ink-4);
  font-size: 12.5px;
}

/* ============================ 表单 ============================ */
.field {
  margin-bottom: 15px;
}

.field__label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.input,
.select {
  width: 100%;
  height: 34px;
  /* 显式行高，保证输入文字垂直居中（内容区高度 = 总高 - 上下边框） */
  line-height: 32px;
  padding: 0 10px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input::placeholder {
  color: var(--ink-4);
}

.input:focus,
.select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06);
}

.select {
  height: 32px;
  line-height: 30px;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #a1a1aa 50%),
    linear-gradient(135deg, #a1a1aa 50%, transparent 50%);
  background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .field {
  flex: 1;
  min-width: 0;
}

.form-hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-4);
  line-height: 1.5;
}

/* ============================ 按钮 ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 13px;
  font-size: 13px;
  line-height: 1;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover {
  background: var(--surface-muted);
  border-color: #d4d4d8;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn--primary:hover {
  background: #27272a;
  border-color: #27272a;
}

.btn--block {
  width: 100%;
  height: 36px;
}

.btn--plain {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
}

.btn--plain:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.btn--danger {
  color: var(--red);
  background: var(--surface);
  border-color: var(--line-strong);
}

.btn--danger:hover {
  background: var(--red-bg);
  border-color: #fecaca;
  color: var(--red);
}

.btn--sm {
  height: 27px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn--link {
  height: auto;
  padding: 0;
  border: none;
  background: none;
  color: var(--blue);
}

.btn--link:hover {
  background: none;
  text-decoration: underline;
}

.btn--danger-text {
  color: var(--red);
}

.btn--danger-text:hover {
  background: none;
  color: var(--red);
  text-decoration: underline;
}

/* ============================ 布局 ============================ */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  padding: 18px 18px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.sidebar__brand span {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-4);
}

.sidebar__nav {
  flex: 1;
  padding: 12px 10px;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  margin-bottom: 2px;
  font-size: 13.5px;
  color: var(--ink-3);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.nav-item--active {
  background: var(--accent);
  color: #ffffff;
}

.nav-item--active:hover {
  background: #27272a;
  color: #ffffff;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.topbar__divider {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
}

.view {
  flex: 1;
  padding: 24px 28px 48px;
  overflow: auto;
}

/* ============================ 卡片 ============================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card__title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

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

/* ============================ 统计 ============================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  padding: 16px 18px;
}

.stat__value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.4px;
  color: var(--ink);
}

.stat__label {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--ink-4);
}

.stat--green .stat__value {
  color: var(--green);
}
.stat--orange .stat__value {
  color: var(--amber);
}
.stat--purple .stat__value {
  color: var(--violet);
}

/* ============================ 表格 ============================ */
.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-4);
  border-bottom: 1px solid var(--line);
}

td {
  color: var(--ink-2);
  border-bottom: 1px solid #f1f1f3;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--surface-hover);
}

td.code {
  font-family: 'SF Mono', 'DIN Alternate', Menlo, Consolas, monospace;
  font-size: 12.5px;
  letter-spacing: 0.3px;
  color: var(--ink);
}

td.num {
  font-variant-numeric: tabular-nums;
}

.table-empty {
  text-align: center;
  color: var(--ink-4);
  padding: 38px 0;
}

/* ============================ 标签 ============================ */
.tag {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11.5px;
  line-height: 18px;
  border-radius: 4px;
  color: var(--ink-3);
  background: var(--surface-muted);
}

.tag--unused {
  background: var(--amber-bg);
  color: var(--amber);
}

.tag--activated {
  background: var(--green-bg);
  color: var(--green);
}

.tag--admin {
  background: var(--violet-bg);
  color: var(--violet);
}

.tag--agent {
  background: var(--blue-bg);
  color: var(--blue);
}

.tag--user {
  background: var(--surface-muted);
  color: var(--ink-3);
}

.tag--off {
  background: var(--red-bg);
  color: var(--red);
}

/* ============================ 工具栏 ============================ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar .input,
.toolbar .select {
  width: auto;
  min-width: 148px;
}

.toolbar__spacer {
  flex: 1;
}

/* ============================ 分页 ============================ */
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-4);
}

/* ============================ 弹窗 ============================ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow: auto;
  box-shadow: 0 16px 48px rgba(24, 24, 27, 0.18);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.modal__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.modal__close {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-4);
  cursor: pointer;
  padding: 0 2px;
}

.modal__close:hover {
  color: var(--ink);
}

.modal__body {
  padding: 20px;
}

.modal__foot {
  padding: 0 20px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hint {
  font-size: 12px;
  color: var(--ink-4);
  line-height: 1.55;
}

/* ============================ 提示 ============================ */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(24, 24, 27, 0.18);
  max-width: 76vw;
}

.toast--error {
  background: var(--red);
}

.toast--success {
  background: var(--green);
}

/* ============================ 趋势图 ============================ */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 170px;
  padding-top: 10px;
}

.chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.chart__count {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 5px;
}

.chart__track {
  width: 100%;
  max-width: 26px;
  flex: 1;
  background: var(--surface-muted);
  border-radius: 3px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.chart__fill {
  width: 100%;
  background: var(--ink);
  border-radius: 3px;
  min-height: 2px;
}

.chart__label {
  margin-top: 7px;
  font-size: 11px;
  color: var(--ink-4);
}

/* ============================ 条目列表 ============================ */
.rows {
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f1f3;
}

.row:last-child {
  border-bottom: none;
}

.row__name {
  font-size: 13.5px;
  color: var(--ink);
}

.row__sub {
  font-size: 12px;
  color: var(--ink-4);
  margin-top: 2px;
}

.row__value {
  font-size: 13px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ============================ 响应式 ============================ */
@media (max-width: 860px) {
  :root {
    --sidebar-w: 150px;
  }
  .view {
    padding: 16px;
  }
  .topbar {
    padding: 0 16px;
  }
}
