/* 管理后台样式。设计说明见 docs/DESIGN.md。
   方向：「调度台」——深石墨侧栏 + 暖纸色工作区 + 信号橙强调色；唯一有设备外形的东西是右侧的 Telegram 预览。
   限制：页面不运行脚本、不加载外部字体（CSP 只允许本站样式表和 data: 图片），所以字体用系统自带的，
   质感靠字重、等宽数字、点阵底纹和细线。
   结构：令牌 → 基础元素 → 外框（侧栏/页头/正文）→ 版块 → 表单 → 列表与表格 → 状态 → 概览 → 聊天预览 → 登录页 → 动效 → 窄屏。 */

/* ---------- 令牌 ---------- */
:root {
  --bg: #f2eee6;
  --dot: rgba(40, 33, 20, 0.075);
  --sheet: #fffdf9;
  --field: #ffffff;
  --soft: #f7f3eb;
  --hover: #faf6ef;
  --ink: #1c1b18;
  --ink-2: #6b665c;
  --ink-3: #9a9487;
  --line: #e6dfd2;
  --line-2: #d4cbbb;

  --accent: #c8461a;
  --accent-hi: #ff6a2b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7dc;
  --ok: #2f8a5f;
  --ok-soft: #dff0e6;
  --warn: #b06f12;
  --warn-soft: #f8ead2;
  --danger: #bf271d;
  --danger-soft: #fbe3df;
  --focus: #e2541c;

  /* 侧栏在浅色和深色下都是深的 */
  --rail: #17181c;
  --rail-2: #23252b;
  --rail-line: #2c2e34;
  --rail-ink: #ece9e2;
  --rail-ink-2: #9a978f;
  --rail-ink-3: #66645f;

  /* Telegram 聊天预览用它自己的配色 */
  --tg-wall-a: #cfdcb8;
  --tg-wall-b: #9cc4a7;
  --tg-bubble: #ffffff;
  --tg-ink: #111417;
  --tg-link: #2481cc;
  --tg-btn: rgba(42, 62, 50, 0.46);
  --bezel: #101113;

  --sans: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei",
    "Noto Sans CJK SC", "Source Han Sans SC", -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --rail-w: 264px;
  --form-w: 760px;
  --r: 8px;
  --r-lg: 14px;
  --shadow: 0 1px 0 rgba(28, 27, 24, 0.04), 0 10px 28px -16px rgba(28, 27, 24, 0.22);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012;
    --dot: rgba(255, 255, 255, 0.045);
    --sheet: #17181b;
    --field: #111215;
    --soft: #1c1d21;
    --hover: #1d1e22;
    --ink: #ece8df;
    --ink-2: #a39e93;
    --ink-3: #716c63;
    --line: #27292e;
    --line-2: #363940;

    --accent: #ff7a3d;
    --accent-hi: #ff8c55;
    --accent-ink: #1b0c03;
    --accent-soft: #3a1d10;
    --ok: #5ec493;
    --ok-soft: #14301f;
    --warn: #e3a649;
    --warn-soft: #33260f;
    --danger: #ff8a7d;
    --danger-soft: #3b1714;
    --focus: #ff7a3d;

    --rail: #0a0b0d;
    --rail-2: #17181c;
    --rail-line: #1f2125;

    --tg-wall-a: #1d2a22;
    --tg-wall-b: #15201b;
    --tg-bubble: #212d3b;
    --tg-ink: #f1f3f4;
    --tg-link: #6ab3f3;
    --tg-btn: rgba(255, 255, 255, 0.14);
    --bezel: #000000;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 12px 30px -18px rgba(0, 0, 0, 0.8);
  }
}

/* ---------- 基础元素 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 0);
  background-size: 18px 18px;
  font: 15.5px/1.75 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 36px; line-height: 1.2; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 19px; line-height: 1.4; font-weight: 700; margin: 52px 0 18px; padding-top: 36px; border-top: 1px solid var(--line); }
h3 { font-size: 15px; font-weight: 700; margin: 30px 0 10px; color: var(--ink-2); }
p { margin: 0 0 16px; max-width: 70ch; }
a { color: var(--accent); text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
small { display: block; color: var(--ink-2); font-size: 13.5px; font-weight: 400; }
code { font: 13.5px/1.5 var(--mono); padding: 1px 5px; border-radius: 4px; background: var(--soft); border: 1px solid var(--line); overflow-wrap: anywhere; }
b { font-weight: 700; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--sheet); padding: 6px 12px; z-index: 20; }
.skip:focus { left: 8px; }
.hint { color: var(--ink-2); font-size: 14px; }
.bad { color: var(--danger); }
.break { word-break: break-all; }
.empty { color: var(--ink-2); }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ---------- 外框 ---------- */
body.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
/* 侧栏那一列一直铺到页面底部（侧栏本身只有一屏高，跟着滚动固定在顶部） */
body.app {
  background-image: linear-gradient(90deg, var(--rail) var(--rail-w), transparent var(--rail-w)), radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 0);
  background-size: 100% 100%, 18px 18px;
}

.rail {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 24px 16px 20px; background: var(--rail); color: var(--rail-ink);
  border-right: 1px solid var(--rail-line);
  scrollbar-width: thin; scrollbar-color: var(--rail-2) transparent;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: var(--rail-ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: 0.01em; line-height: 1.25; }
.brand-name small { margin-top: 2px; color: var(--rail-ink-3); font: 11.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
/* 标志：一架纸飞机（Telegram）放在橙色方块里，纯 CSS 画 */
.mark {
  position: relative; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(140deg, var(--accent-hi), #d9431a 70%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 16px -8px rgba(255, 106, 43, 0.9);
}
.mark::after {
  content: ""; position: absolute; inset: 10px 10px 10px 8px; background: #fff;
  clip-path: polygon(0 46%, 100% 0, 74% 100%, 47% 66%, 86% 14%, 38% 60%);
}

.rail nav { display: flex; flex-direction: column; }
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.rail .group {
  margin: 22px 0 6px; padding: 0 14px; color: var(--rail-ink-3);
  font: 600 12px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
}
.rail nav a, .me a {
  position: relative; display: block; padding: 9px 14px; border-radius: var(--r); line-height: 1.5;
  color: var(--rail-ink-2); text-decoration: none; font-size: 15.5px;
}
.rail nav a:hover, .me a:hover { color: var(--rail-ink); background: var(--rail-2); }
.rail a[aria-current="page"] { color: #fff; background: var(--rail-2); font-weight: 600; }
.rail nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-hi);
}
.me { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 8px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--rail-line); }
.me a small { display: inline; margin-left: 8px; color: var(--rail-ink-3); font-size: 13px; }
.me form { padding: 0; }
.me button.quiet { padding: 6px 12px; color: var(--rail-ink-2); background: transparent; border-color: var(--rail-line); font-size: 14px; }
.me button.quiet:hover { color: var(--rail-ink); border-color: var(--rail-ink-3); box-shadow: none; }
.ver { grid-column: 1 / -1; margin: 6px 14px 0; color: var(--rail-ink-3); font: 12px/1.4 var(--mono); }

body.app > main { padding: 48px 56px 112px; min-width: 0; counter-reset: sec; }
.pagehead { margin: 0 0 32px; }
.eyebrow {
  display: flex; align-items: center; gap: 10px; margin: 0 0 10px; color: var(--accent);
  font: 600 12.5px/1.4 var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
.intro { font-size: 16px; color: var(--ink-2); margin-bottom: 28px; }
.crumb { color: var(--ink-3); margin: -8px 0 24px; font-size: 14px; }
.crumb a { color: var(--ink-2); }

/* 表单 + 预览 两栏 */
.split { display: grid; grid-template-columns: minmax(0, 840px) 380px; gap: 48px; align-items: start; }
.split > :first-child { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.stack > .hint, .stack > .toolbar { margin: 0; }
.narrow { max-width: 840px; }

/* ---------- 版块 ---------- */
.sheet {
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 36px 44px; box-shadow: var(--shadow);
}
.sheet + .sheet { margin-top: 28px; }
.stack > .sheet + .sheet { margin-top: 0; }
.sheet > :last-child { margin-bottom: 0; }
.sheet > .submit:last-child { margin-bottom: -36px; }
.sheet > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
/* 版块标题前面带一个两位编号，整页连续计数，像调度单上的栏目号 */
.sheet h2::before {
  counter-increment: sec; content: counter(sec, decimal-leading-zero);
  display: inline-block; min-width: 34px; margin-right: 6px; color: var(--accent);
  font: 600 13px/1 var(--mono); letter-spacing: 0.06em; vertical-align: 1px;
}
.flow h2::before { content: none; }
/* 表格直接贴边的版块 */
.sheet.flush { padding: 0; }
/* 不用 overflow: hidden 裁圆角，否则行内展开的「管理」菜单会被裁掉；改为给四个角上的格子单独加圆角 */
.sheet.flush > table > tbody > tr:first-child > th:first-child,
.sheet.flush > table > tbody > tr:first-child > td:first-child { border-top-left-radius: var(--r-lg); }
.sheet.flush > table > tbody > tr:first-child > th:last-child,
.sheet.flush > table > tbody > tr:first-child > td:last-child { border-top-right-radius: var(--r-lg); }
.sheet.flush > table > tbody > tr:last-child > td:first-child { border-bottom-left-radius: var(--r-lg); }
.sheet.flush > table > tbody > tr:last-child > td:last-child { border-bottom-right-radius: var(--r-lg); }
.sheet.flush > h2 + table > tbody > tr:first-child > th { border-radius: 0; }
.sheet.flush > h2 { margin: 0; padding: 28px 32px 10px; border: 0; }
.sheet.flush table { margin: 0; }
.sheet.flush th:first-child, .sheet.flush td:first-child { padding-left: 32px; }
.sheet.flush th:last-child, .sheet.flush td:last-child { padding-right: 32px; }
.sheet + .hint { margin-top: 16px; }
.aside-sheet { margin-top: 36px; background: var(--soft); box-shadow: none; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.danger-zone h2::before { color: var(--danger); }

/* ---------- 提示条 ---------- */
.notice, .error {
  position: relative; max-width: none; margin: 0 0 28px; padding: 14px 20px 14px 50px;
  border-radius: var(--r); border: 1px solid; font-weight: 500;
}
.notice::before, .error::before {
  content: "✓"; position: absolute; left: 16px; top: 15px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font: 700 12px/1 var(--sans); color: #fff; background: var(--ok);
}
.notice { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.error::before { content: "!"; background: var(--danger); }
.error p { margin: 0; max-width: none; }
.error ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }
.sheet .error, .sheet .notice { margin: 18px 0 0; }

/* ---------- 表单 ---------- */
.form { max-width: var(--form-w); }
.split > .form, .stack > .form { max-width: none; }
label { display: block; margin: 0 0 8px; font-weight: 600; font-size: 15px; }
label small { display: inline; margin-left: 8px; }
label + .hint, .l10n + .hint, .check + .hint { margin-top: -6px; margin-bottom: 28px; }
input, select, textarea {
  display: block; width: 100%; margin: 8px 0 20px; padding: 12px 15px;
  font: inherit; font-size: 15.5px; font-weight: 400; color: var(--ink);
  background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 150px; line-height: 1.65; font-family: var(--mono); font-size: 14.5px; }
input[type="number"] { width: 120px; font-family: var(--mono); }
input[type="datetime-local"] { width: 280px; font-family: var(--mono); }
input.code { width: 200px; font: 600 24px/1.3 var(--mono); letter-spacing: 0.32em; text-align: center; }
select { width: auto; min-width: 220px; padding-right: 36px; }

/* 勾选项画成开关 */
label.check { display: flex; align-items: center; gap: 12px; font-weight: 500; margin-bottom: 16px; cursor: pointer; }
label.check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; position: relative;
  width: 40px; height: 24px; margin: 0; padding: 0; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--line-2); transition: background-color 0.15s;
}
label.check input[type="checkbox"]::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
label.check input[type="checkbox"]:checked { background: var(--accent); }
label.check input[type="checkbox"]:checked::before { transform: translateX(16px); }
label.check input[type="checkbox"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: none; }
input[type="checkbox"] { display: inline-block; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px; font: inherit; font-size: 15.5px; font-weight: 700; line-height: 1.4; cursor: pointer;
  color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r); text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 0 rgba(0, 0, 0, 0.06);
}
button:hover, a.button:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 18px -10px var(--accent); }
button:active, a.button:active { transform: none; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { box-shadow: 0 8px 18px -10px var(--danger); }
button.quiet, a.button.quiet { background: var(--sheet); color: var(--ink); border-color: var(--line-2); font-weight: 600; box-shadow: none; }
button.quiet:hover, a.button.quiet:hover { border-color: var(--ink-2); box-shadow: 0 6px 14px -10px rgba(0, 0, 0, 0.4); }
button.quiet.danger { color: var(--danger); }
button.quiet.add { border-style: dashed; color: var(--ink-2); width: 100%; padding: 13px; }
button.quiet.add:hover { color: var(--accent); border-color: var(--accent); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; box-shadow: none; }
button.link:hover { text-decoration: underline; text-underline-offset: 3px; transform: none; box-shadow: none; }
button.link.danger { color: var(--danger); background: none; }
button:disabled { color: var(--ink-3); opacity: 0.5; cursor: default; text-decoration: none; transform: none; box-shadow: none; }
a.cancel { margin-left: 8px; color: var(--ink-2); }
.form > button, .confirm > button { margin-top: 10px; }
.submit {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin: 36px -44px -36px; padding: 22px 44px; border-top: 1px solid var(--line);
  background: var(--soft); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
/* 保存栏不在版块底部时（例如在提示框里）不要贴边 */
:not(.sheet) > .submit, .confirm .submit, .sheet > .submit:not(:last-child) { margin: 18px 0 0; padding: 0; border: 0; background: none; }

/* 多语言字段：一次只显示「正在编辑」的那种语言 */
.langswitch { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 28px 0 24px; color: var(--ink-2); font-size: 14px; }
.langswitch > span, .langswitch label { white-space: nowrap; }
.langswitch > span { font: 600 12px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); }
.langswitch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.langswitch label { margin: 0; padding: 6px 18px; font-weight: 500; color: var(--ink-2); cursor: pointer; border-radius: 999px; }
.langswitch label:hover { color: var(--ink); }
.langswitch input:checked + label { background: var(--ink); color: var(--sheet); }
.langswitch input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }

.l10n { margin-bottom: 6px; }
.l10n-label { margin: 0 0 4px; font-weight: 600; font-size: 15px; }
.l10n .hint { margin: 0 0 4px; }
.l10n label { margin: 0; font-weight: 400; }
.l10n .which { display: none; }
.l10n [data-lang] { display: none; }
form:has(#lang-zh-CN:checked) .l10n [data-lang="zh-CN"],
form:has(#lang-zh-TW:checked) .l10n [data-lang="zh-TW"],
form:has(#lang-en-US:checked) .l10n [data-lang="en-US"] { display: block; }
.l10n input, .l10n textarea { margin-bottom: 8px; }
.filled { display: flex; gap: 16px; margin: 0 0 28px; font-size: 13px; color: var(--ink-3); }
.filled span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; border: 1px solid var(--ink-3); vertical-align: 1px; }
.filled span.on { color: var(--ink-2); }
.filled span.on::before { background: var(--ok); border-color: var(--ok); }
/* 旧浏览器不支持 :has() 时退回全部摊开 */
@supports not selector(:has(*)) {
  .langswitch { display: none; }
  .l10n [data-lang] { display: block; }
  .l10n .which { display: block; color: var(--ink-2); font-size: 14px; font-weight: 400; }
}

/* 一个按钮一组：一行选「做什么」和目标，下面是按钮文字 */
.btnrow { padding: 16px 20px 6px; margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--soft); }
.btnhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.btnhead strong { font: 600 13px/1.4 var(--mono); letter-spacing: 0.08em; color: var(--ink-2); }
.btnops { display: flex; gap: 16px; font-size: 14px; }
.btnline { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.btnline > * { margin: 0; }
.btnline .btn-type { width: auto; flex: 0 0 auto; min-width: 150px; }
.btnline .f-url, .btnline .f-product, .btnline .f-feature { flex: 1 1 220px; min-width: 0; width: auto; align-self: center; }
.btnrow .l10n { margin-bottom: 0; }
/* 只显示当前类型要填的那一项。不支持 :has() 的旧浏览器三项都显示，服务端只读取当前类型的那一项 */
@supports selector(:has(*)) {
  .btnline .f-url, .btnline .f-product, .btnline .f-feature { display: none; }
  .btnline:has(.btn-type option[value="url"]:checked) .f-url,
  .btnline:has(.btn-type option[value="product"]:checked) .f-product,
  .btnline:has(.btn-type option[value="feature"]:checked) .f-feature { display: block; }
}
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.filters.sheet { padding: 18px 22px; }
.filters input, .filters select { width: auto; min-width: 150px; margin: 0; }
.filters #q { flex: 1 1 240px; }
.filters input[type="number"] { min-width: 0; width: 80px; display: inline-block; margin: 0 6px; }
.filters label { margin: 0; font-weight: 500; display: flex; align-items: center; }
.filters label.check { margin: 0; }
.confirm {
  margin-top: 28px; padding: 20px 24px; border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: var(--r);
}
.confirm p { margin-bottom: 10px; }
/* 筛选链接：一行文字链接，当前项加粗并带下划线 */
.tabs { display: flex; flex-wrap: wrap; gap: 4px 28px; margin: 0 0 20px; max-width: none; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 0 11px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
.tabs .n { margin-left: 8px; padding: 0 8px; border-radius: 999px; background: var(--soft); font: 500 12.5px/1.7 var(--mono); color: var(--ink-2); }
/* 一排操作 */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 20px; max-width: none; }
.toolbar form { margin: 0; }
.toolbar .filters { margin: 0; flex: 1 1 320px; }
.toolbar .count { font: 600 13px/1 var(--mono); color: var(--ink-2); letter-spacing: 0.04em; margin-right: 6px; }
/* 表格里的分类小标题 */
tr.group th {
  padding-top: 24px; background: none; color: var(--ink); font: 700 14.5px/1.4 var(--sans); letter-spacing: 0; text-transform: none;
}
.tag { margin-left: 8px; padding: 1px 9px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
/* 基础设置：头像 */
.avatar { display: flex; gap: 28px; align-items: flex-start; margin: 0 0 28px; }
.avatar img, .avatar-none { width: 112px; height: 112px; border-radius: 50%; flex: 0 0 auto; }
.avatar img { object-fit: cover; border: 3px solid var(--sheet); box-shadow: 0 0 0 1px var(--line-2), 0 10px 20px -12px rgba(0, 0, 0, 0.5); }
.avatar-none { display: flex; align-items: center; justify-content: center; background: var(--soft); border: 1.5px dashed var(--line-2); color: var(--ink-3); font-size: 13.5px; }
.avatar input[type="file"] { padding: 6px 0; border: 0; background: none; width: 100%; box-shadow: none; }
.avatar .submit { margin: 6px 0 12px; padding: 0; border: 0; background: none; }
/* 基础设置：命令列表 */
table.cmds td { vertical-align: middle; }
table.cmds td:first-child, table.cmds th:first-child { width: 48px; }
table.cmds input[type="checkbox"] { margin: 0; }
table.cmds .l10n { margin: 0; width: 60%; }
table.cmds .l10n input { margin: 0; }
/* 基础设置：菜单按钮。只有「打开一个网页」才显示文字和地址 */
@supports selector(:has(*)) {
  .mbtn .f-webapp { display: none; }
  .mbtn:has(.mb-type option[value="web_app"]:checked) .f-webapp { display: block; }
}
/* 下单流程：步骤编号、并排的小选项 */
.step {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin-right: 12px;
  border-radius: 9px; background: var(--ink); color: var(--sheet); font: 700 13.5px/1 var(--mono); vertical-align: 1px;
}
.row2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; }
.row2 label { margin-bottom: 10px; }
.row2 select, .row2 input { width: 100%; min-width: 0; }
/* 下单流程分步：所有步骤都在同一个表单里一起保存，一次只显示正在设置的那一步（做法同语言开关）。
   画成一条带编号的进度线，七步排成一行 */
.stepper {
  position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin: 0;
  padding: 16px 8px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--soft);
}
.stepper::before {
  content: ""; position: absolute; top: 31px; left: calc(8px + (100% - 16px) / 14); right: calc(8px + (100% - 16px) / 14);
  height: 2px; background: var(--line-2);
}
.stepper input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.stepper label {
  display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0; padding: 0 2px;
  color: var(--ink-2); font-weight: 500; font-size: 13.5px; line-height: 1.3; text-align: center; cursor: pointer;
}
.stepper label:hover { color: var(--ink); }
.stepper .step {
  position: relative; width: 32px; height: 32px; margin: 0; border-radius: 50%; font-size: 13px;
  background: var(--sheet); color: var(--ink-2); box-shadow: 0 0 0 2px var(--line-2);
}
.stepper label:hover .step { box-shadow: 0 0 0 2px var(--ink-3); }
.stepper input:checked + label { color: var(--ink); font-weight: 700; }
.stepper input:checked + label .step { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper input:focus-visible + label .step { outline: 2px solid var(--focus); outline-offset: 4px; }
fieldset.flowstep { min-width: 0; margin: 0; padding: 0; border: 0; }
.flowstep > h2:first-child { margin-top: 8px; padding-top: 0; border-top: 0; }
.stepnav { display: flex; gap: 12px; margin: 36px 0 0; max-width: none; }
.stepnav .next { margin-left: auto; }
label.stepbtn {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 10px 18px; cursor: pointer;
  font-size: 14.5px; font-weight: 600; background: var(--sheet); border: 1px solid var(--line-2); border-radius: var(--r);
}
label.stepbtn:hover { border-color: var(--ink-2); }
label.stepbtn::before { content: "←"; }
label.stepbtn.next { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2)); }
label.stepbtn.next::before { content: none; }
label.stepbtn.next::after { content: "→"; }
@supports selector(:has(*)) {
  .flowstep { display: none; }
  .flow:has(#step-1:checked) .flowstep[data-step="1"],
  .flow:has(#step-2:checked) .flowstep[data-step="2"],
  .flow:has(#step-3:checked) .flowstep[data-step="3"],
  .flow:has(#step-4:checked) .flowstep[data-step="4"],
  .flow:has(#step-5:checked) .flowstep[data-step="5"],
  .flow:has(#step-6:checked) .flowstep[data-step="6"],
  .flow:has(#step-7:checked) .flowstep[data-step="7"] { display: block; }
  /* 预览只画正在设置的这一步；最后一步「聊天整洁」画整个过程 */
  .split:has(#step-1:checked) .part[data-step]:not([data-step="1"]),
  .split:has(#step-2:checked) .part[data-step]:not([data-step="2"]),
  .split:has(#step-3:checked) .part[data-step]:not([data-step="3"]),
  .split:has(#step-4:checked) .part[data-step]:not([data-step="4"]),
  .split:has(#step-5:checked) .part[data-step]:not([data-step="5"]),
  .split:has(#step-6:checked) .part[data-step]:not([data-step="6"]) { display: none; }
  /* 整个过程很长，让预览跟着页面一起滚动，而不是固定在窗口里 */
  .split:has(#step-7:checked) .phone { position: static; }
}
/* 旧浏览器不支持 :has() 时退回全部摊开 */
@supports not selector(:has(*)) {
  .stepper, .stepnav { display: none; }
}
/* 选了「不让选数量」时，收起只对「可以选」有意义的两项 */
@supports selector(:has(*)) {
  .qtyopts:has(.qty-mode option[value="fixed"]:checked) .f-ask { display: none; }
}
/* 单个收件人的发送结果 */
td.res { min-width: 180px; }
.dv-failed { color: var(--danger); font-weight: 600; }
.dv-blocked, .dv-pending { color: var(--ink-2); }
/* 行内的「管理」展开区 */
details.more { display: inline-block; position: relative; text-align: left; }
details.more > summary { cursor: pointer; color: var(--accent); list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: " ▾"; font-size: 12px; }
details.more[open] > summary { color: var(--ink); margin: 0; font-weight: 400; }
.more-body {
  position: absolute; right: 0; z-index: 3; margin-top: 8px; padding: 8px 18px; min-width: 140px;
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.more-body > * { margin: 0; padding: 8px 0; white-space: nowrap; }
.more-body form { display: block; border: 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--ink-2); max-width: none; }
a.chip { padding: 5px 14px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--ink); background: var(--sheet); text-decoration: none; }
a.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; margin: 0 0 20px; }
th, td { text-align: left; padding: 16px 20px 16px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  color: var(--ink-3); font: 600 12.5px/1.4 var(--mono); letter-spacing: 0.03em; text-transform: uppercase;
  padding-top: 15px; padding-bottom: 12px; white-space: nowrap; background: var(--soft);
}
tr:last-child > td { border-bottom: 0; }
tr:hover > td { background: var(--hover); }
th.num, td.num { text-align: right; padding-right: 28px; font-family: var(--mono); font-size: 14.5px; }
td small { margin-top: 2px; word-break: break-all; }
tr.off td { color: var(--ink-3); }
/* 列表里正在预览的那一行 */
tr.sel td { background: var(--accent-soft); }
tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.actions { white-space: nowrap; text-align: right; padding-right: 0; }
td.actions > * { margin-left: 18px; }
td.actions form { display: inline; }
td.actions button + button { margin-left: 18px; }
td.preview { max-width: 420px; white-space: pre-wrap; word-break: break-word; }
td.manage { width: 340px; padding-right: 0; }

/* 状态：信号灯 + 文字 */
.st { white-space: nowrap; font-weight: 500; }
.st::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 10px; border-radius: 50%;
  background: var(--ink-3); vertical-align: 1px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink-3) 18%, transparent);
}
.st-on::before, .st-done::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.st-running::before, .st-queued::before, .st-scheduled::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.st-off::before, .st-cancelled::before { background: transparent; border: 1.5px solid var(--ink-3); box-shadow: none; }
.st-failed { color: var(--danger); }
.st-failed::before { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
/* 用户列表：状态一列，下面一行小字写到什么时候、为什么 */
table.users td.state { white-space: nowrap; }
table.users td.state small { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 行被标成灰色（拉黑、屏蔽）时，状态和操作仍然用正常的颜色，一眼看得出来 */
table.users tr.off td.state, table.users tr.off td.actions { color: var(--ink); }
.more-label { color: var(--ink-3); font: 600 11.5px/1.4 var(--mono); letter-spacing: 0.08em; }
.more-body form.sep, .more-body .more-label.sep { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
/* 顾客消息：谁能收到，收不到时下面一行小字写原因 */
table.staff { margin: 16px 0 4px; }
/* 我的账号：登录中的设备 */
table.sessions { margin: 4px 0 16px; }
table.sessions td small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 13px; }
table.sessions td small.ok { color: var(--ok); }
table.staff td small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 13px; }
/* 审计日志：操作的中文说法不换行，下面一行小字是代码 */
table.audit td.act { white-space: nowrap; }
table.audit td.act small { display: block; margin-top: 2px; }

.pager { display: flex; gap: 24px; align-items: center; justify-content: center; color: var(--ink-2); max-width: none; margin-top: 24px; font-size: 14px; }
.pager a { padding: 6px 18px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--sheet); text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--accent); color: var(--accent); }

/* 状态清单（概览、用户详情） */
.status { list-style: none; margin: 0 0 8px; padding: 0; max-width: none; }
.sheet.status { padding: 8px 36px; margin: 0; }
.status li { position: relative; padding: 18px 0 18px 30px; border-bottom: 1px solid var(--line); }
.status li:last-child { border-bottom: 0; }
.status li::before {
  content: ""; position: absolute; left: 3px; top: 28px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-2);
}
.status li.ok::before { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.status li.down::before { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.status li.paused::before { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.status li a { margin-left: 14px; font-size: 14px; }
.lead { font-size: 17.5px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 14px 36px; margin: 0 0 4px; max-width: var(--form-w); }
.facts dt { color: var(--ink-2); font-size: 14.5px; }
.facts dd { margin: 0; }
.status + .facts { margin-top: 16px; padding-top: 22px; border-top: 1px solid var(--line); }

pre.code {
  margin: 0 0 20px; padding: 16px 18px; background: var(--soft); border: 1px solid var(--line); border-radius: var(--r);
  overflow: auto; white-space: pre-wrap; word-break: break-word; font: 13.5px/1.65 var(--mono);
}

/* 管理员行里的展开区 */
details summary { cursor: pointer; color: var(--accent); width: max-content; font-weight: 500; }
details[open] summary { margin-bottom: 16px; color: var(--ink); font-weight: 700; }
details form { padding: 16px 0; border-top: 1px solid var(--line); }
details form label { font-size: 14.5px; }
details form input, details form select { margin: 6px 0 14px; }
details form button + button { margin-left: 8px; }

/* ---------- 概览的数字 ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 6px 0 20px; }
.tiles > div { padding: 14px 18px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--soft); }
.tiles dt { color: var(--ink-2); font-size: 14px; }
.tiles dd { margin: 4px 0 0; font: 700 40px/1.15 var(--mono); letter-spacing: -0.03em; }
.tiles > div:first-child dd { color: var(--accent); }
/* 最近 14 天：数字旁边一条细条，长度分 10 格（页面不能写行内样式，所以用固定的几档宽度） */
table.trend { max-width: none; }
table.trend th, table.trend td { background: none; }
table.trend td { padding-top: 9px; padding-bottom: 9px; border-bottom-style: dashed; }
table.trend th:first-child, table.trend td:first-child { width: 1%; padding-right: 24px; white-space: nowrap; font-family: var(--mono); font-size: 14.5px; color: var(--ink-2); }
table.trend tr:nth-child(2) td:first-child { color: var(--ink); font-weight: 700; }
table.trend th.num, table.trend td.num { width: 1%; padding-right: 12px; white-space: nowrap; }
table.trend .barcol { width: 38%; min-width: 96px; padding-right: 28px; vertical-align: middle; }
table.trend td.barcol { background: linear-gradient(var(--soft), var(--soft)) no-repeat 0 50% / calc(100% - 28px) 10px; }
.bar { display: block; width: 0; height: 10px; border-radius: 2px; background: var(--accent); }
.bar.alt { background: var(--ink); }
.bar-1 { width: 10%; } .bar-2 { width: 20%; } .bar-3 { width: 30%; } .bar-4 { width: 40%; } .bar-5 { width: 50%; } .bar-6 { width: 60%; } .bar-7 { width: 70%; } .bar-8 { width: 80%; } .bar-9 { width: 90%; } .bar-10 { width: 100%; }

/* ---------- 运行维护 ---------- */
/* 运行状态：一格一个仪表，左边一道色条表示正常 / 要注意 / 出问题 */
.gauges { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 4px 0 18px; }
.gauge {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px 13px 20px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--soft);
}
.gauge::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
/* 四格的状态（顾客消息页）宽屏时排成一行 */
.gauges.four { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.gauge.is-ok::before { background: var(--ok); }
.gauge.is-warn::before { background: var(--warn); }
.gauge.is-bad::before { background: var(--danger); }
.gauge dt { color: var(--ink-2); font: 600 12px/1.4 var(--mono); letter-spacing: 0.06em; }
.gauge dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; line-height: 1.3; letter-spacing: -0.01em; }
.gauge.is-warn dd { color: var(--warn); }
.gauge.is-bad dd { color: var(--danger); }
.gauge small { margin: 0; font-size: 13px; color: var(--ink-3); }
.health > .hint { margin: 0; }
/* 状态和设置一样宽，内容是长段说明，太宽了反而不好读 */
.health, .sysform { max-width: 940px; }
.health { margin-bottom: 28px; }
/* 每个版块：标题和总开关在一行，开关关掉时下面跟着它的设置变淡 */
.syshead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 6px; }
.syshead h2 { margin: 0; padding: 0; border: 0; }
label.check.master { margin: 0; padding: 6px 12px 6px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); font-size: 14px; white-space: nowrap; }
.lead-in { margin: 0 0 18px; color: var(--ink-2); }
.dep { transition: opacity 0.15s; }
@supports selector(:has(*)) {
  .sys:has(.master input:not(:checked)) .dep { opacity: 0.45; }
  .sys:has(.master input:not(:checked)) label.check.master { color: var(--ink-3); }
}
/* 版块里马上执行的操作，和上面要保存的设置用虚线隔开 */
.sysops {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 24px 0 0; padding-top: 20px;
  border-top: 1px dashed var(--line-2);
}
.sysops .hint { flex: 1 1 260px; margin: 0; }
.sysops button { flex: 0 0 auto; }
table.backups { margin-top: 8px; }
table.backups td.actions { width: 1%; }
.sys .facts { margin-bottom: 0; }
/* 保存栏贴在窗口底部，长页面里随时能点 */
.dock {
  position: sticky; bottom: 16px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 14px 18px 14px 22px; border: 1px solid var(--line-2); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--sheet) 92%, transparent); box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.dock > p { margin: 0; color: var(--ink-2); font-size: 14px; flex: 1 1 280px; }
.dock .submit { margin: 0; }

/* ---------- 聊天预览：顾客看到的样子 ---------- */
.phone { position: sticky; top: 32px; }
.phone-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 14px; color: var(--ink-3);
  font: 600 12.5px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
}
.phone-title .draft {
  padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font: 700 12px/1.4 var(--sans); letter-spacing: 0.04em;
}
.phone-what { margin: 0 0 10px; font-weight: 700; }
.phone-langs { display: flex; gap: 6px; margin: 0 0 16px; font-size: 13.5px; }
.phone-langs a { padding: 4px 13px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--ink-2); background: var(--sheet); text-decoration: none; }
.phone-langs a:hover { border-color: var(--ink-2); }
.phone-langs a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
/* 手机外形：深色边框、顶部听筒、底部横条 */
.device {
  position: relative; padding: 10px; border-radius: 36px; background: var(--bezel);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 0 rgba(0, 0, 0, 0.04), 0 34px 60px -30px rgba(20, 14, 6, 0.55);
}
.device::before {
  content: ""; position: absolute; z-index: 2; top: 18px; left: 50%; width: 76px; height: 20px; margin-left: -38px;
  border-radius: 999px; background: var(--bezel);
}
.device::after {
  content: ""; position: absolute; z-index: 2; bottom: 18px; left: 50%; width: 104px; height: 4px; margin-left: -52px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.55);
}
.device.empty {
  display: grid; place-items: center; min-height: 300px; padding: 32px 28px; text-align: center;
  background: transparent; border: 1.5px dashed var(--line-2); box-shadow: none;
}
.device.empty::before, .device.empty::after { content: none; }
.device.empty .hint { margin: 0; }
.chat .note {
  width: fit-content; max-width: 92%; margin: 12px auto 8px; padding: 2px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.3); color: #fff; font-size: 13px; line-height: 1.5; text-align: center; word-break: break-word;
}
.chat .note:first-child { margin-top: 0; }
/* 预览里的一段（一步）。前面被隐藏的段落也算「前一个」，所以顶部可能多出这一点间距 */
.part + .part { margin-top: 10px; }
.chat {
  min-height: 480px; padding: 54px 14px 38px; border-radius: 27px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.18) 0 2px, transparent 3px) 0 0 / 46px 46px,
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.12) 0 1.5px, transparent 2.5px) 0 0 / 38px 38px,
    linear-gradient(165deg, var(--tg-wall-a), var(--tg-wall-b));
  font: 15.5px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
}
.bubble {
  max-width: 100%; overflow: hidden; color: var(--tg-ink); background: var(--tg-bubble);
  border-radius: 15px 15px 15px 5px; box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.14);
}
.bubble .img {
  display: grid; place-items: center; height: 132px; color: #fff; font-size: 13px;
  background: repeating-linear-gradient(135deg, #7d8f86, #7d8f86 12px, #889a91 12px, #889a91 24px);
}
.bubble .msg { padding: 9px 13px 11px; white-space: pre-wrap; word-break: break-word; }
.bubble .tg-a { color: var(--tg-link); }
.bubble .tg-spoiler { background: currentColor; border-radius: 3px; opacity: 0.35; }
.bubble blockquote { margin: 4px 0; padding: 2px 8px; border-left: 3px solid var(--tg-link); background: rgba(36, 129, 204, 0.1); border-radius: 4px; }
.bubble pre, .bubble code { font: 13px/1.5 var(--mono); padding: 0; border: 0; background: none; }
.bubble pre { margin: 4px 0; padding: 6px 8px; background: rgba(0, 0, 0, 0.06); border-radius: 6px; white-space: pre-wrap; }
.kb-row { display: flex; gap: 4px; margin-top: 4px; }
.kb-btn {
  position: relative; flex: 1 1 0; min-width: 0; padding: 10px 8px; text-align: center; color: #fff; font-weight: 500;
  background: var(--tg-btn); border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.kb-btn.current { outline: 2px solid var(--accent-hi); outline-offset: -2px; background: rgba(200, 70, 26, 0.85); }
.kb-btn.link::after { content: "↗"; position: absolute; top: 1px; right: 5px; font-size: 10px; opacity: 0.85; }
.phone .hint { margin-top: 16px; }
/* 底部导航（回复键盘）：贴在对话底部，上面一条输入框，下面是常驻的按钮 */
.replykb { margin: 18px -14px -38px; padding: 8px 8px 34px; border-radius: 0 0 27px 27px; background: rgba(255, 255, 255, 0.94); }
.replykb .inputbar { margin: 0 0 6px; padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid rgba(0, 0, 0, 0.08); color: #98a2ab; font-size: 14px; }
.kb-btn.reply { color: var(--tg-ink); background: #e3e8ed; -webkit-backdrop-filter: none; backdrop-filter: none; }

/* ---------- 登录页 ---------- */
body.gate {
  display: grid; place-items: start center; min-height: 100vh; padding: 0 16px;
  background:
    radial-gradient(ellipse at 15% -10%, rgba(255, 106, 43, 0.22), transparent 50%),
    radial-gradient(ellipse at 100% 110%, rgba(255, 106, 43, 0.1), transparent 45%),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 36px 36px,
    var(--rail);
}
body.gate main {
  position: relative; width: 100%; max-width: 460px; margin: 12vh 0 48px; padding: 38px 40px 34px;
  background: var(--sheet); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.8);
}
body.gate main::before {
  content: ""; position: absolute; left: 40px; right: 40px; top: -1px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent-hi);
}
.gate-brand {
  display: flex; align-items: center; gap: 10px; margin: 0 0 26px; color: var(--ink-3);
  font: 600 12.5px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
}
.gate-brand .mark { width: 30px; height: 30px; border-radius: 9px; }
.gate-brand .mark::after { inset: 8px 8px 8px 6px; }
body.gate h1 { font-size: 28px; margin-bottom: 22px; }
body.gate button { width: 100%; margin-top: 8px; padding: 13px 20px; }
body.gate .hint { margin: 16px 0 0; }
.steps { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 6px; }
.steps li::marker { color: var(--accent); font-family: var(--mono); font-weight: 700; }
img.qr { display: block; max-width: 100%; image-rendering: pixelated; margin: 0 auto 12px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
code.secret { font-size: 14px; letter-spacing: 0.08em; word-break: break-all; }

/* ---------- 动效：进入页面时内容自上而下依次浮现 ---------- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px var(--ok-soft); } 50% { box-shadow: 0 0 0 7px transparent; } }
  body.app > main > *, body.gate main { animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  body.app > main > :nth-child(2) { animation-delay: 0.04s; }
  body.app > main > :nth-child(3) { animation-delay: 0.08s; }
  body.app > main > :nth-child(4) { animation-delay: 0.12s; }
  body.app > main > :nth-child(n + 5) { animation-delay: 0.16s; }
  .status li.ok::before { animation: pulse 2.4s ease-in-out infinite; }
  a, button, input, select, textarea, .kb-btn { transition: border-color 0.15s, background-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s; }
}

/* ---------- 窄屏 ---------- */
/* 左边是列表的页面，表格需要更宽，预览更早挪到下面 */
@media (max-width: 1640px) {
  .split:has(> .stack > .sheet.flush > table) { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .split:has(> .stack > .sheet.flush > table) .phone { position: static; max-width: 400px; }
}
@media (max-width: 1320px) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .phone { position: static; max-width: 400px; }
}
@media (max-width: 760px) {
  body.app { display: block; background-image: radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 0); background-size: 18px 18px; }
  /* 侧栏变成顶栏：第一行标志和账号，第二行导航横向滑动 */
  .rail {
    position: sticky; top: 0; z-index: 10; height: auto; overflow: visible;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 12px 0;
    border-right: 0; border-bottom: 1px solid var(--rail-line);
  }
  .brand { padding: 0 4px; }
  .brand-name small { display: none; }
  .mark { width: 28px; height: 28px; }
  .rail nav {
    order: 3; flex: 1 0 100%; min-width: 0; flex-direction: row; gap: 2px; padding: 4px 0 8px;
    overflow-x: auto; scrollbar-width: none;
  }
  .rail nav::-webkit-scrollbar { display: none; }
  .navgroup { display: contents; }
  .rail .group { display: none; }
  .rail nav a { white-space: nowrap; padding: 7px 12px; font-size: 15px; }
  .rail nav a[aria-current="page"]::before { left: 12px; right: 12px; top: auto; bottom: 0; width: auto; height: 2px; border-radius: 2px; }
  .me { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 4px; }
  .me a small { display: none; }
  .me form { padding: 0; }
  .me button.quiet { width: auto; padding: 4px 10px; }
  .ver { display: none; }
  body.app > main { padding: 26px 16px 72px; }
  h1 { font-size: 28px; }
  h2 { margin-top: 40px; padding-top: 28px; }
  .sheet { padding: 22px 18px; border-radius: 12px; }
  .sheet > .submit:last-child { margin-bottom: -22px; }
  .submit { margin: 26px -18px -22px; padding: 16px 18px; }
  .sheet.status { padding: 4px 18px; }
  .sheet.flush > h2 { padding: 20px 18px 6px; }
  .sheet.flush th:first-child, .sheet.flush td:first-child { padding-left: 18px; }
  .sheet.flush th:last-child, .sheet.flush td:last-child { padding-right: 18px; }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  /* 筛选栏：搜索框一行，下拉框平分一行，按钮一行 */
  .filters select { flex: 1 1 130px; min-width: 0; }
  .filters > button { flex: 1 1 100%; }
  .langswitch label { padding: 6px 13px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
  .tiles { gap: 10px; }
  .tiles > div { padding: 12px 14px 10px; }
  .tiles dd { font-size: 30px; }
  .gauges.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gauges.four .gauge dd { font-size: 19px; }
  /* 窄屏下表格横向滚动，不把文字挤成一列 */
  /* position 让表头里给读屏软件的隐藏文字（.sr）也跟着表格一起被裁剪，不撑宽页面 */
  table { display: block; overflow-x: auto; position: relative; }
  th, td { min-width: 84px; }
  td:first-child { min-width: 132px; }
  td.actions { text-align: left; }
  td.manage { width: auto; min-width: 240px; }
  /* 14 天趋势五列都很窄，不需要横向滚动 */
  table.trend { display: table; }
  table.trend th, table.trend td { min-width: 0; }
  table.trend td:first-child { min-width: 0; padding-right: 10px; }
  table.trend .barcol { width: 30%; min-width: 0; padding-right: 10px; }
  table.trend td.barcol { background-size: calc(100% - 10px) 8px; }
  /* 表格横向滚动时浮层会被裁掉，改成在行内展开 */
  details.more { display: block; margin: 6px 0 0; }
  .more-body { position: static; border: 0; padding: 0; margin: 0; flex-direction: row; gap: 16px; background: none; box-shadow: none; }
  /* 用户列表在手机上每人一张小卡片：名字和状态一行，下面是 ID、订单、最近活跃，「管理」不用横向滑动就能点到 */
  table.users, table.users tbody { display: block; overflow: visible; }
  table.users tr:first-child { display: none; }
  table.users tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
  table.users tr:last-child { border-bottom: 0; }
  table.users tr::after { content: ""; order: 3; flex-basis: 100%; height: 0; }
  .sheet.flush table.users td { display: block; min-width: 0; padding: 0; border: 0; }
  table.users td:first-child { flex: 1 1 auto; }
  table.users td.state { flex: 0 1 auto; white-space: normal; text-align: right; }
  table.users td.num, table.users td.lang, table.users td.nowrap { order: 4; font-size: 13px; color: var(--ink-2); text-align: left; }
  table.users td[data-label]::before { content: attr(data-label) " "; color: var(--ink-3); }
  table.users td.lang:empty { display: none; }
  table.users td.actions, table.users td.empty { order: 5; flex-basis: 100%; }
  table.users .more-body { flex-wrap: wrap; gap: 4px 20px; }
  table.users .more-body .more-label { flex-basis: 100%; }
  table.users .more-body .sep { margin: 0; padding: 8px 0; border: 0; }
  /* 审计日志同样一条一张卡片：做了什么和时间一行，谁、对象、IP 一行，详情单独一行 */
  table.audit, table.audit tbody { display: block; overflow: visible; }
  table.audit tr:first-child { display: none; }
  table.audit tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
  table.audit tr:last-child { border-bottom: 0; }
  table.audit tr::after { content: ""; order: 3; flex-basis: 100%; height: 0; }
  .sheet.flush table.audit td { display: block; min-width: 0; padding: 0; border: 0; }
  table.audit td.act { order: 1; flex: 1 1 auto; font-weight: 600; }
  table.audit td.act small { display: none; }
  table.audit td.when { order: 2; font-size: 13px; color: var(--ink-2); }
  table.audit td.who, table.audit td.target, table.audit td.ip { order: 4; font-size: 13px; color: var(--ink-2); text-align: left; }
  table.audit td[data-label]::before { content: attr(data-label) " "; color: var(--ink-3); }
  table.audit td.detail { order: 5; flex-basis: 100%; font-size: 14px; }
  table.audit td:empty { display: none; }
  body.gate main { margin-top: 8vh; padding: 30px 24px 28px; }
  body.gate main::before { left: 24px; right: 24px; }
}
