/* ============================================================
   控制台 — 样式
   与前台同一套浅色色板（白卡 + 细描边 + 单一绿色强调），只用于 /admin。

   布局约定：
   - 一条 --shell 宽度线贯穿顶栏与内容区，左右 padding 同为 --pad。
     顶栏贴边、内容居中会让页面看起来被切成两半，所以两者共用
     .topbar__inner / .wrap 的宽度规则。
   - .panel 是 flex column，.wrap 吃满剩余高度，底部说明用 margin-top:auto
     压到底，内容少的时候不会在中间留一大片死白。
   ============================================================ */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f7;

  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --line-soft: #eef1f4;

  --fg: #101828;
  --fg-mid: #5b6472;
  --fg-dim: #98a2b3;

  --accent: #0a7f56;
  --accent-hover: #086b48;
  --accent-soft: #e7f5ee;
  --accent-line: #b7e2cd;

  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;

  --sh-card: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-pop: 0 12px 32px rgba(16, 24, 40, .16);

  --shell: 1040px;
  --pad: 24px;
  --topbar-h: 56px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ❗ [hidden] 必须带 !important：
   作者样式里给 .card 之类写了 display:flex，同优先级下会把 hidden 顶掉 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

.mono { font-family: var(--mono); font-size: 11.5px; color: var(--fg-dim); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ---------------- 登录门 ---------------- */

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.gate__card {
  width: min(100%, 372px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 26px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 4px 16px rgba(16, 24, 40, .06);
}

.gate__brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.gate__title { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.gate__sub { font-size: 12.5px; color: var(--fg-dim); margin-top: -6px; margin-bottom: 2px; }

.gate__err {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #fecdc9;
  border-radius: var(--r-sm);
  padding: 7px 10px;
}

/* ---------------- 表单字段 ---------------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.field__label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-mid);
}

.field__input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field__input::placeholder { color: var(--fg-dim); }
.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 127, 86, .12);
}

.field__input--sm { height: 34px; font-size: 13px; width: 210px; }

/* ---------------- 按钮 ---------------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(.25);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:disabled { background: var(--accent); }

.btn--ghost { color: var(--fg-mid); border-color: var(--line); }
.btn--ghost:hover { color: var(--fg); border-color: var(--line-strong); background: var(--surface-3); }

.btn--danger { color: var(--danger); border-color: #fecdc9; }
.btn--danger:hover { background: var(--danger-soft); border-color: #fda29b; }

.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn--block { width: 100%; height: 40px; }

.iconbtn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--fg-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--surface-3); color: var(--fg); }

/* ---------------- 面板骨架 ---------------- */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.topbar {
  flex: none;
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  width: min(100%, var(--shell));
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar__left { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.topbar__left strong { font-weight: 650; letter-spacing: -.005em; }

.topbar__div {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
  margin: 0 2px;
}
.topbar__hint { font-size: 12.5px; color: var(--fg-dim); }

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

.wrap {
  flex: 1;
  width: min(100%, var(--shell));
  margin: 0 auto;
  padding: 22px var(--pad) 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.pagehead__main h1 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.pagehead__main p { font-size: 12.5px; color: var(--fg-dim); margin-top: 2px; }

/* ---------------- 指标 ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
}
.stat__k { font-size: 11.5px; color: var(--fg-dim); }
.stat__v { font-size: 14px; font-weight: 600; font-family: var(--mono); letter-spacing: -.01em; }

/* ---------------- 卡片 ---------------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card__head h2 { font-size: 13.5px; font-weight: 600; }

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

.card__foot {
  font-size: 12.5px;
  color: var(--fg-dim);
  padding-top: 2px;
}

/* ---------------- 表格 ---------------- */

.tablewrap {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

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

.tbl thead th {
  text-align: left;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-dim);
  letter-spacing: .02em;
  white-space: nowrap;
}

.tbl tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }

.tbl__act {
  text-align: right;
  white-space: nowrap;
}
.tbl td.tbl__act { display: table-cell; }
.tbl td.tbl__act > .btn + .btn { margin-left: 6px; }

.tbl__acc { min-width: 180px; }

.acc__name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg);
}
.acc__note {
  font-size: 11.5px;
  color: var(--fg-dim);
  line-height: 1.45;
  margin-top: 1px;
}

/* ---------------- 徽标 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge--ok {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}
.badge--off {
  background: var(--surface-3);
  border-color: var(--line);
  color: var(--fg-mid);
}
.badge--warn {
  background: var(--warn-soft);
  border-color: #fedf89;
  color: var(--warn);
}
.badge--err {
  background: var(--danger-soft);
  border-color: #fecdc9;
  color: var(--danger);
}
.badge--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------------- 空状态 / 说明 ---------------- */

.empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: center;
}
.empty__t { font-size: 13px; font-weight: 500; color: var(--fg-mid); }
.empty__d { font-size: 11.5px; color: var(--fg-dim); max-width: 520px; margin: 0 auto; line-height: 1.6; }

.notice {
  margin-top: auto;
  padding-top: 6px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--fg-dim);
}

/* ---------------- 弹窗 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal__mask {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, .32);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal__box {
  position: relative;
  width: min(100%, 352px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--sh-pop);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal__head h3 { font-size: 14px; font-weight: 600; }

/* ---------------- 登录方式切换 ---------------- */

.tabs {
  display: flex;
  gap: 3px;
  margin: 14px 0 2px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}

.tab {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-mid);
  font-family: inherit;
  font-size: 12.5px;
  height: 30px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover { color: var(--fg); }
.tab.is-on {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1);
}

.pane { padding-top: 12px; }

/* 弹窗里的表单 */
.fld { margin-bottom: 10px; }
.fld > label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-mid);
}
.fld input,
.pane textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
/* 手机号/验证码要等宽，避免 6 位数字左右跳 */
.fld input[type="tel"] { font-family: var(--mono); letter-spacing: .1em; font-size: 15px; }
.fld input:focus,
.pane textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 127, 86, .12);
}
.fld input::placeholder,
.pane textarea::placeholder { color: var(--fg-dim); letter-spacing: normal; font-size: 13px; }

.pane textarea {
  min-height: 136px;
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 10px;
}

.pane .btn--block + .btn--block { margin-top: 8px; }

.pane__hint {
  font-size: 12px;
  line-height: 1.65;
  color: var(--fg-dim);
  margin-bottom: 10px;
}
.pane__hint b { color: var(--fg-mid); font-weight: 600; }
.pane__hint code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--fg-mid);
}

/* ---------------- 二维码 ---------------- */

.qr {
  position: relative;
  margin: 8px auto 0;
  width: 258px;
  height: 258px;
  border-radius: var(--r-md);
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.qr img { width: 100%; height: 100%; object-fit: contain; display: block; }

.qr__loading { display: grid; place-items: center; width: 100%; height: 100%; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.qr__tip {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--fg-mid);
  min-height: 18px;
  line-height: 1.5;
}

.qr__count {
  margin-top: 4px;
  text-align: center;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--fg-dim);
}
.qr__count.is-warn { color: var(--warn); }

.modal__foot { margin-top: 14px; }

/* ---------------- 提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 10px);
  z-index: 60;
  max-width: min(90vw, 520px);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  font-size: 13px;
  box-shadow: var(--sh-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] {
  background: var(--danger-soft);
  border-color: #fecdc9;
  color: var(--danger);
}
.toast[data-type="ok"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 860px) {
  :root { --pad: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field__input--sm { width: 150px; }
}

@media (max-width: 680px) {
  :root { --pad: 12px; }
  .wrap { padding: 16px var(--pad) 22px; gap: 12px; }

  .topbar__hint, .topbar__div { display: none; }

  /* 表格转卡片：每行一块，字段名靠 data-label 回显 */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }

  .tbl tbody tr {
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }
  .tbl tbody tr:last-child { border-bottom: 0; }
  .tbl tbody tr:hover { background: transparent; }

  .tbl tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
    padding: 4px 0;
    border: 0;
    text-align: left;
  }
  .tbl tbody td::before {
    content: attr(data-label);
    flex: none;
    width: 62px;
    font-size: 11.5px;
    color: var(--fg-dim);
    line-height: 1.7;
  }

  .tbl td.tbl__act {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
  }
  .tbl td.tbl__act::before { content: none; }
  .tbl td.tbl__act > .btn + .btn { margin-left: 0; }

  .tbl__acc { min-width: 0; }
  .acc__name { font-size: 14px; }

  .card { padding: 14px 13px 15px; }
  .card__head { align-items: flex-start; }
  .card__tools { width: 100%; }
  .field__input--sm { flex: 1; width: auto; }

  .gate__card { padding: 22px 18px 20px; }
  .btn { height: 40px; }
  .btn--sm { height: 32px; }
  .btn--block { height: 44px; }

  .qr { width: min(72vw, 250px); height: min(72vw, 250px); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
