/* 织流远程 · 管理员后台
 *
 * 只写后台特有的部分。颜色/字体/圆角/按钮/输入框/卡片/导航
 * 全部复用官网的 style.css，不重复定义——避免以后官网换主题时这里落单。
 * 本文件必须在 style.css 之后引入。
 */

/* ---------- 导航里的退出按钮 ---------- */
/* style.css 有 `.nav-links .btn { color: var(--text-inverse) }`，本意是给
   导航里的实心主按钮配白字。我们这里是 .btn-ghost（白底），会被它覆盖成
   白底白字，看不见。按选择器优先级补回来。 */
.nav-links .btn-ghost { color: var(--text); }
.nav-links .btn-ghost:hover { color: var(--primary-fill); }

/* ---------- 页面骨架 ---------- */
body.admin { background: var(--surface-page); }
.admin-main { padding: 28px 0 64px; }

/* 面板：官网 .card 是营销卡（hover 上浮 + 内边距 24/22），
   后台要的是静态容器，hover 会晃，所以单开一个。 */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel > header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel > header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.1px;
}
.panel > header .hint { margin: 0; }
.panel > .panel-body { padding: 20px; }

/* ---------- 概览数字 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  background: #fff;
}
.stat .k { font-size: 12px; color: var(--text-tertiary); }
.stat .v {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
}
.stat .v.pending { color: var(--border-strong); }

/* ---------- 单选卡片（注册验证方式） ---------- */
.choice-row { display: flex; flex-wrap: wrap; gap: 12px; }
.choice {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choice:hover { background: var(--surface-sunken); }
.choice input { margin: 3px 0 0; accent-color: var(--primary); flex: none; }
.choice .t { display: block; font-size: 14px; font-weight: 500; color: var(--text); }
.choice .d { display: block; font-size: 12px; color: var(--text-tertiary); line-height: 1.6; margin-top: 3px; }
.choice.checked { border-color: var(--primary); background: var(--accent-soft); }
.choice.checked .t { color: var(--primary-fill); }

.save-row {
  display: flex; align-items: center; gap: 12px;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.save-row .cur { font-size: 12px; color: var(--text-tertiary); }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.toolbar .field { margin: 0; flex: 1 1 200px; max-width: 300px; }
.toolbar .field input { padding: 9px 12px; }
.toolbar .grow { flex: 1 1 auto; }
.toolbar .count { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }

/* ---------- 表格 ---------- */
/* 窄屏靠这层横向滚动，不给 table 设 width:100% 之外的花样，
   否则表头和数据会错位。 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; min-width: 780px; }
table.grid th,
table.grid td {
  padding: 11px 16px;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.grid th {
  color: var(--text-tertiary);
  font-weight: 500;
  background: var(--surface-sunken);
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: var(--surface-page); }
table.grid td.n { font-variant-numeric: tabular-nums; }
table.grid td.m { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.grid td.act { width: 1%; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}
.tag-on { background: #E6F4ED; color: var(--success); }
.tag-off { background: #FDECEC; color: var(--danger); }
.tag-grey { background: var(--surface-sunken); color: var(--text-tertiary); }

/* 锁定中。用琥珀色，和「停用」的红色区分开 ——
 * 锁定是临时的、会自己到期，停用是管理员主动且不自动恢复，
 * 两者的严重程度不一样，颜色必须能分开。
 */
.tag-lock { background: #FEF4E2; color: #B26A00; }

/* ---------- 用户行 ---------- */
/* 整行可点击进详情，给个手型光标作为可点的暗示 */
table.grid tbody tr.user-row { cursor: pointer; }
table.grid tbody tr.user-row:hover { background: var(--surface-sunken); }

/* 被锁定的行左侧加一条琥珀竖线：扫一眼列表就知道谁被关了，
 * 不用逐个看状态列的小标签。
 *
 * 注意画在 td 上而不是 tr 上 —— 表格是 border-collapse: collapse，
 * 这种模式下 tr 的 box-shadow 根本不会被绘制（规范如此，不是浏览器 bug）。
 * 我第一版就写在 tr 上，实测 computed 是 none，白写。
 * td 是 table-cell，box-shadow 正常渲染。
 */
table.grid tbody tr.is-locked td:first-child {
  box-shadow: inset 3px 0 0 #E8A33D;
}

/* 失败次数。放在状态标签下面一行，比塞进标签里更清楚。 */
table.grid .sub-note {
  margin-top: 3px;
  font-size: 11px;
  color: #B26A00;
  line-height: 1.3;
}

.dash { color: var(--text-tertiary); }

/* ---------- 分页 ---------- */
.pager {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.pager .info { font-size: 12px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ---------- 登录遮罩 ---------- */
/* 官网 .auth-page 是整页布局，这里要的是压在内容上的弹层 */
.mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(24, 25, 25, .40);
}
.mask[hidden] { display: none; }
.mask .box {
  width: 100%;
  max-width: 396px;
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px;
}
.mask .box h1 { font-size: 20px; margin: 0 0 6px; letter-spacing: -.2px; }
.mask .box .sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.65;
}

/* ---------- toast ---------- */
#toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 340px;
  padding: 11px 15px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  background: var(--text);
  color: var(--text-inverse);
  font-size: 13px;
  line-height: 1.55;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* ============================================================
   服务器资源 / 容量估算
   ============================================================ */

.panel > header .grow { flex: 1 1 auto; }

/* 容量结论：整块灰底，数字放大。用户打开后台最想先看到的就是这个数，
   所以它比概览的三个数字还要显眼。 */
.verdict {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.verdict-main { flex: 1 1 auto; min-width: 0; }
.verdict-label { font-size: 12px; color: var(--text-tertiary); }
.verdict-num {
  font-size: 40px;
  font-weight: 600;
  line-height: 1.1;
  margin-top: 4px;
  letter-spacing: -1.4px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.verdict-num.pending { color: var(--border-strong); font-size: 28px; }
.verdict-sub { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.verdict-sub b { color: var(--text); font-weight: 600; }

/* 横向条：表示「当前用户数 vs 上限」的位置。比纯数字更能看出还有多少余量。 */
.verdict-chart { flex: 0 0 260px; max-width: 260px; }
.capbar {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--border-strong);
  overflow: hidden;
}
.capbar > i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  background: var(--primary);
  transition: width .4s;
}
.capbar-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.verdict-text {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--primary);
  background: var(--accent-soft);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
}

/* 关键指标网格 */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.metric {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 14px;
  background: #fff;
  min-width: 0;
}
.metric .k {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.metric .v {
  font-size: 19px;
  font-weight: 600;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric .v small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-left: 4px;
}
.metric .bar {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-sunken);
  margin-top: 9px;
  overflow: hidden;
}
.metric .bar > i {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width .4s;
}
.metric .bar.warn > i { background: var(--warning, #C8811A); }
.metric .bar.danger > i { background: var(--danger); }

/* 折叠明细 */
.fold { margin-top: 18px; border-top: 1px solid var(--border); }
.fold > summary {
  padding: 14px 0 2px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform .15s;
  color: var(--text-tertiary);
}
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary:hover { color: var(--text); }
.fold-body { padding-top: 14px; }

/* 明细里的两栏 */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
}
.split h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: none;
  letter-spacing: 0;
  margin: 0 0 8px;
}
.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td {
  padding: 6px 0;
  font-size: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.kv th {
  color: var(--text-tertiary);
  font-weight: 400;
  width: 46%;
  white-space: nowrap;
}
.kv td {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }

.assume-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.85;
  color: var(--text-secondary);
}
.assume-list li { margin-bottom: 1px; }

.scen {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.scen-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.scen-top .t { font-size: 13px; font-weight: 500; }
.scen-top .n {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.scen .note {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.7;
  margin-top: 5px;
}

/* ============================================================
   用户详情抽屉
   ============================================================ */

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(24, 25, 25, .36);
  display: flex;
  justify-content: flex-end;
}
.drawer-mask[hidden] { display: none; }
.drawer {
  width: 100%;
  max-width: 520px;
  height: 100%;
  background: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: drawer-in .18s ease-out;
}
@keyframes drawer-in {
  from { transform: translateX(24px); opacity: .6; }
  to { transform: translateX(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .drawer { animation: none; }
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-head .btn { margin-left: auto; }
.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.dsec { margin-bottom: 22px; }
.dsec:last-child { margin-bottom: 0; }
.dsec > h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin: 0 0 10px;
}

/* 详情里的操作按钮组 */
.act-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.act-row .btn { flex: 0 0 auto; }

/* 表单行 */
.form-row { margin-bottom: 12px; }
.form-row label {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 5px;
}
.form-row input {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
}
.form-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 设备/登录记录小列表 */
.mini-list { display: flex; flex-direction: column; gap: 7px; }
.mini {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.6;
}
.mini .r1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.mini .r1 .id {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.mini .r1 .when { margin-left: auto; color: var(--text-tertiary); white-space: nowrap; }
.mini .r2 { color: var(--text-tertiary); margin-top: 3px; }
.mini-empty {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 8px 0;
}

/* 危险操作按钮 */
.btn-danger {
  border-color: #E9B4B4;
  color: var(--danger);
}
.btn-danger:hover {
  background: #FDECEC;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:disabled { opacity: .5; }

/* ---------- 窄屏 ---------- */
@media (max-width: 720px) {
  .admin-main { padding: 18px 0 48px; }
  .stats { grid-template-columns: 1fr; }
  .stat .v { font-size: 22px; }
  .toolbar .field { max-width: none; }
  .panel > .panel-body { padding: 16px; }
  .toolbar, .pager, .panel > header { padding-left: 16px; padding-right: 16px; }

  /* 容量结论在小屏改成竖排，横排会把数字压到换行 */
  .verdict { flex-direction: column; align-items: stretch; gap: 14px; padding: 16px; }
  .verdict-num { font-size: 34px; }
  .verdict-chart { flex: 1 1 auto; max-width: none; }
  .drawer { max-width: none; }
  .drawer-body { padding: 16px; }

  /* 表格要横向滚，但触屏上滚动条不显眼，用户不知道右边还有列。
     在收窄的那一侧压一道渐变阴影提示「还有内容」。
     用 background-attachment: local 让阴影随内容滚走，不会一直挡着。 */
  .table-scroll {
    background:
      linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center,
      linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center,
      radial-gradient(farthest-side at 0 50%, rgba(24, 25, 25, .16), transparent) left center,
      radial-gradient(farthest-side at 100% 50%, rgba(24, 25, 25, .16), transparent) right center;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }

  /* 次要列在窄屏收起来，少滚一点 */
  table.grid { min-width: 520px; }
  table.grid th:nth-child(3),
  table.grid td:nth-child(3),
  table.grid th:nth-child(4),
  table.grid td:nth-child(4) { display: none; }
}

/* 手机竖屏：把「操作」列挤到滚动区外就够不到了，所以按重要性再收一轮。
   保住 ID / 手机号 / 状态 / 操作 —— 这四列是能看能点的那几列。 */
@media (max-width: 520px) {
  table.grid { min-width: 0; }
  table.grid th:nth-child(5),
  table.grid td:nth-child(5),
  table.grid th:nth-child(7),
  table.grid td:nth-child(7) { display: none; }
  table.grid th,
  table.grid td { padding: 10px 10px; }
  /* 手机号是这屏唯一能认出人的信息，不能省 */
  table.grid td.m { white-space: nowrap; }
}

/* ============================================================
   危险操作二次确认弹窗
   ============================================================ */

.confirm-mask {
  position: fixed;
  inset: 0;
  z-index: 120;            /* 比抽屉(90)高，抽屉里点删除时能盖住 */
  background: rgba(24, 25, 25, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-mask[hidden] { display: none; }

.confirm {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  animation: confirm-in .14s ease-out;
}
@keyframes confirm-in {
  from { transform: translateY(-6px) scale(.985); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .confirm { animation: none; }
}

.confirm h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.1px;
}
.confirm-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.confirm-desc b { color: var(--text); font-weight: 600; }
.cf-mini { font-size: 12px; color: var(--text-tertiary); }

/* 手打确认词 */
.confirm-check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
}
.confirm-check[hidden] { display: none; }
.confirm-check input {
  flex: none;
  width: 180px;
  padding: 6px 9px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
.confirm-check input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.confirm-check span { line-height: 1.5; }

.confirm-acts {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.confirm-acts .btn { min-width: 76px; justify-content: center; }

@media (max-width: 520px) {
  .confirm { max-width: none; }
  .confirm-check { flex-wrap: wrap; }
  .confirm-check input { width: 100%; order: 2; }
}
