/* ==========================================================================
   cdxx OCR — 面板识别服务 / 共用样式表
   识别页与后台配置页共用。浅色 + 深色两套主题，全部走 class，
   页面里不写内联 style，以便服务端下发严格 CSP（style-src 'self'）。
   ========================================================================== */

:root {
  color-scheme: light;

  /* 冷静的运维控制台色：冷灰纸面 + 墨绿点缀，避免常见「AI 蓝紫渐变」气质。 */
  --bg: #e9ecef;
  --surface: #f7f8f9;
  --surface-alt: #f1f3f5;
  --surface-sunken: #e4e7eb;

  --border: #d5d9de;
  --border-strong: #b8c0c7;

  --text: #1c2329;
  --text-muted: #4d5964;
  /* 小字对比度：在 --surface-sunken 上仍 ≥ 4.5:1 */
  --text-faint: #5c6772;

  --accent: #1f5c4d;
  --accent-hover: #17493d;
  --accent-soft: #e4efeb;
  --accent-ring: rgba(31, 92, 77, .18);

  --ok: #1b6b4a;
  --ok-soft: #e3f2eb;
  --ok-line: #b7d9c7;

  --warn: #8a5a12;
  --warn-soft: #f6eedf;
  --warn-line: #e2d0a8;

  --bad: #a3282c;
  --bad-soft: #f8eaea;
  --bad-line: #e6c4c5;

  --mark-nick: #b33b18;
  --mark-power: #8f6b12;

  --shadow-sm: 0 1px 0 rgba(28, 35, 41, .06);
  --shadow: 0 1px 0 rgba(28, 35, 41, .08);
  --shadow-lg: 0 10px 28px -18px rgba(28, 35, 41, .28);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  /* 页面左右内边距。顶栏、内容区、底部保存条共用同一个值。 */
  --gutter: clamp(16px, 1.6vw, 28px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0e1014;
    --surface: #161920;
    --surface-alt: #1b1f27;
    --surface-sunken: #12151b;

    --border: #252a34;
    --border-strong: #363d49;

    --text: #e7eaf0;
    --text-muted: #a1a9b6;
    /* 同上：原值 #757d8b 在深色底上只有 3.98–4.24:1，提亮到 5.55–5.91:1 */
    --text-faint: #8e96a5;

    --accent: #4d8dff;
    --accent-hover: #6fa2ff;
    --accent-soft: #16233c;
    --accent-ring: rgba(77, 141, 255, .24);

    --ok: #4ed0a4;
    --ok-soft: #102b25;
    --ok-line: #1f5145;

    --warn: #e3b064;
    --warn-soft: #2e2410;
    --warn-line: #55411b;

    --bad: #f38084;
    --bad-soft: #331719;
    --bad-line: #5c2a2d;

    --mark-nick: #ff8a5c;
    --mark-power: #f0c24b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 1px 3px rgba(0, 0, 0, .55), 0 10px 30px -14px rgba(0, 0, 0, .8);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .85);
  }
}

* { box-sizing: border-box; }

/* `hidden` must beat every layout rule below. Without this, `.dropzone`
   (display:flex), `.admin-shell` (display:grid) and `.gate` (display:grid)
   would keep showing an element the script had just hidden. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  min-width: 0;
}
.topbar > .badge,
.topbar > .btn,
.topbar > .nav-toggle {
  flex: 0 0 auto;
}

body.admin-skin .topbar {
  background: #f7f8f9;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
  min-width: 0;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}
.brand-text strong { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.brand-text em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 620px) {
  .brand-text em { display: none; }
}

/* ------------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 500;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}
.badge.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.badge.ok .dot { background: var(--ok); }
.badge.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.badge.warn .dot { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.badge.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.badge.bad .dot { background: var(--bad); }

@keyframes pulse { 50% { opacity: .35; } }

/* ------------------------------------------------------------------ buttons */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.btn:hover { background: var(--surface-sunken); border-color: var(--text-faint); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.ghost { border-color: transparent; color: var(--text-muted); background: transparent; }
.btn.ghost:hover { background: var(--surface-sunken); color: var(--text); border-color: transparent; }

.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }

.btn.exit {
  border-color: var(--border-strong);
  background: var(--surface-alt);
  color: var(--text-muted);
  text-decoration: none !important;
}
.btn.exit:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn.sm { padding: 4px 10px; font-size: 12.5px; }

/* Quiet link back to the public recognizer — sits after logout in the topbar. */
.topbar-back {
  flex: 0 0 auto;
  margin-left: 2px;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
  text-decoration: none !important;
  white-space: nowrap;
}
.topbar-back:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface);
}
.topbar-back:active {
  transform: translateY(.5px);
}

/* -------------------------------------------------------------------- cards */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, .95fr) minmax(420px, 1.05fr);
  gap: 16px;
  padding: 18px var(--gutter) 48px;
  align-items: start;
}
/* 宽屏上把多出来的空间优先给截图预览：面板截图看得清，
   结果列表也不必被拉成超长一行行读。 */
@media (min-width: 1700px) {
  .layout { grid-template-columns: minmax(320px, 1.2fr) minmax(420px, .8fr); gap: 20px; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
}

/* 页面主体铺满视口：左右边缘与顶栏、底部保存条对齐。
   内容本身的可读宽度由各栅格自己的列宽上限控制（见 .inline-form / .stat-grid），
   而不是靠把整页锁在一个居中的窄容器里。 */
.admin-shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  padding: 18px var(--gutter) 28px;
  align-items: start;
}
body.savebar-visible .admin-shell {
  padding-bottom: 96px;
}

/* 大屏：侧边导航加宽、间距放宽，正文继续占满剩余宽度 */
@media (min-width: 1500px) {
  .admin-shell { grid-template-columns: 236px minmax(0, 1fr); gap: 22px; }
}
@media (min-width: 2000px) {
  .admin-shell {
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 26px;
  }
  body.savebar-visible .admin-shell { padding-bottom: 104px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.card-head > .btn,
.card-head > .badge {
  flex: 0 0 auto;
}
.card-titles { min-width: 0; flex: 1 1 auto; }
.card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.015em;
}
.card-head .card-sub,
.card-head .sub {
  margin: 5px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 0; }

/* ---------------------------------------------------------------- dropzone */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 40px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.dragging { transform: scale(.995); }

.dz-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.dz-icon svg { width: 22px; height: 22px; }

.dropzone strong { font-size: 14px; font-weight: 600; color: var(--text); }
.dropzone .dz-sub { font-size: 12.5px; }
.dropzone .dz-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

/* ----------------------------------------------------------------- preview */

/* 预览按图自身宽高比排布，覆盖框的百分比坐标才能与像素严格对齐 */
.preview-wrap {
  position: relative;
  display: block;
  width: min(100%, calc(64vh * var(--preview-aspect, 1.6)));
  aspect-ratio: var(--preview-aspect, 1.6);
  margin: 0 auto;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}
.preview-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }

.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay .box {
  position: absolute;
  border: 1px solid rgba(22, 93, 255, .5);
  border-radius: 2px;
  transition: background .1s, border-color .1s, box-shadow .1s;
  pointer-events: auto;
  cursor: pointer;
}
.overlay .box.title { border-color: rgba(13, 115, 85, .7); }
.overlay .box.value {
  border-color: rgba(139, 110, 216, .75);
  background: color-mix(in srgb, rgba(139, 110, 216, .75) 10%, transparent);
}
.overlay .box.nickname {
  border: 2px solid var(--mark-nick);
  background: color-mix(in srgb, var(--mark-nick) 12%, transparent);
}
.overlay .box.power {
  border: 2px solid var(--mark-power);
  background: color-mix(in srgb, var(--mark-power) 14%, transparent);
}
.overlay .box.active {
  background: var(--accent-ring);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
  z-index: 2;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.legend .lg::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(22, 93, 255, .5);
}
.legend .lg-nick::before { border: 2px solid var(--mark-nick); }
.legend .lg-power::before { border: 2px solid var(--mark-power); }
.legend .lg-title::before { border-color: rgba(13, 115, 85, .7); }
.legend .lg-value::before {
  border-color: rgba(139, 110, 216, .75);
  background: color-mix(in srgb, rgba(139, 110, 216, .75) 14%, transparent);
}

/* ------------------------------------------------------------------ progress */

/* Sits inside .preview-wrap, so the wait is attached to the image being
   processed and survives the dropzone being hidden. */
.progress-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.po-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: min(300px, 100%);
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.po-head { display: flex; align-items: center; gap: 8px; }
.po-card strong { font-size: 13.5px; font-weight: 600; color: var(--text); }

.po-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.po-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .25s ease;
}
/* No measurable progress once the bytes are on the server, so the bar slides
   instead of filling -- an honest "still working" rather than a fake percent. */
.po-bar.indeterminate { animation: slide 1.15s ease-in-out infinite; }
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.po-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  max-width: 100%;
}
.po-timer {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.po-detail { font-size: 11.5px; color: var(--text-faint); line-height: 1.45; }

/* ---------------------------------------------------------------- skeleton */

.skeleton { display: flex; flex-direction: column; gap: 14px; }
.skeleton-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.skeleton-cols { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.skeleton-col { display: flex; flex-direction: column; gap: 6px; }

.skeleton-cell,
.skeleton-line {
  background: var(--surface-sunken);
  border-radius: var(--radius-xs);
  animation: pulse 1.4s ease-in-out infinite;
}
.skeleton-cell { height: 46px; }
.skeleton-line { height: 27px; }
.skeleton-line:nth-child(2n) { animation-delay: .18s; }
.skeleton-line:nth-child(3n) { animation-delay: .36s; }

@media (max-width: 640px) {
  .skeleton-strip { grid-template-columns: repeat(2, 1fr); }
  .skeleton-cols { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ metrics */

.metric-strip {
  display: grid;
  /* 28 项面板属性；126px 放不下「2851.58阿僧祇」这类长值会折行，给到 140px。
     宽屏下会自然多排几列，正好一屏看全所有属性。 */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.metric[data-link] { cursor: pointer; }
.metric.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-ring);
}
.metric .label {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .3px;
  margin-bottom: 3px;
}
.metric .value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
  /* 等宽数字：28 项属性竖着排下来时，各位数字能对齐，方便竖向扫读比大小 */
  font-variant-numeric: tabular-nums;
}
.metric .value.sm { font-size: 13.5px; font-weight: 500; }
.metric .value.dim { color: var(--text-faint); font-weight: 500; }
.metric .value.warn { color: var(--warn); }
.metric .value.bad { color: var(--bad); }
.metric.accent { border-color: var(--ok-line); background: var(--ok-soft); }

/* -------------------------------------------------------------- field grid */

.field-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) {
  .field-columns { grid-template-columns: 1fr; }
}

.field-col {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.field-col-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  letter-spacing: .3px;
}

.field {
  display: grid;
  grid-template-columns: minmax(70px, auto) 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 6px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.field-col > .field:last-child { border-bottom: 0; }
.field:hover,
.field.active {
  background: var(--accent-soft);
}
.field.active {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  position: relative;
  z-index: 1;
}

.field .k {
  color: var(--text-muted);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.field .k .tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 500;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-line);
}
.field .v {
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  font-feature-settings: "tnum";
}
.field .v.empty { color: var(--text-faint); }
.field .v .num { font-weight: 500; }
.field .v .unit { color: var(--text-muted); font-size: 12px; margin-left: 1px; }
/* Prefix tier ("无敌:1.95E+76") sits before the figure, so it needs the gap on
   the other side. */
.field .v .unit.pre { margin-left: 0; margin-right: 3px; }
.field.is-missing { opacity: .5; }
.field.is-inferred .k { color: var(--text-faint); }
/* A cell whose value was fused with a neighbour's by a stale payload: only the
   cell's own readout is shown, and the marker says the rest was dropped rather
   than letting two attributes share one number. */
.field.is-truncated { box-shadow: inset 2px 0 0 var(--warn); }
.field .v.has-spill { cursor: help; }

/* ------------------------------------------------------------------ notices */

.notice {
  display: flex;
  gap: 8px 10px;
  align-items: flex-start;
  /* Multi-part notices (a bold lead-in followed by a sentence and maybe a
     link) must wrap onto a new line rather than each being squeezed to a
     sliver, which is what made "关于被锁定的版本" render as three stacked
     characters. */
  flex-wrap: wrap;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.65;
  border: 1px solid transparent;
  margin-bottom: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.notice > b { flex: none; }
.notice > a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.notice.info { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--text); }
.notice.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.notice.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.notice.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }

.empty-hint {
  margin: 0;
  padding: 26px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- raw boxes */

.raw-box {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.raw-box summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--surface-alt);
  user-select: none;
}
.raw-box summary:hover { color: var(--text); }
.raw-box pre {
  margin: 0;
  padding: 12px;
  font: 12px/1.7 var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 320px;
  overflow: auto;
  color: var(--text-muted);
  background: var(--surface);
}

.timing {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
}
.timing b { font-weight: 500; color: var(--text-muted); }

/* -------------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 35, 41, .42);
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  background: #f7f8f9;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 40px -24px rgba(28, 35, 41, .45);
  overflow: hidden;
}
.modal-card.wide { max-width: 560px; }
.modal-card .card-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #f1f3f5;
}
.modal-card .card-head h2 {
  font-size: 15px;
  font-weight: 650;
}
.modal-body {
  padding: 16px !important;
  overflow: auto;
  display: grid;
  gap: 12px;
}
.modal-body > .desc { margin: 0; }
.modal-body .inline-form,
.modal-body .form-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------- token bar */

.token-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.token-bar input {
  flex: 1 1 200px;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
}
.token-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.token-bar input[readonly] { background: var(--surface-sunken); color: var(--text-muted); font-family: var(--mono); font-size: 12.5px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ---------------------------------------------------------------- admin bits */

/* 列宽下限同时也决定了「最多几列」：auto-fit 会尽量多排，
   所以列宽不会被拉得比下限大太多（上限约 2×下限）。
   页面铺满视口后，靠这个下限保证统计块/表单字段仍是可读宽度，
   而不是一列撑满整个 2560px 屏幕。 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.stat {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.stat .label { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 3px; }
.stat .value { display: block; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .value.sm { font-size: 13px; font-weight: 500; }

/* `.panel` 与 `.form-section` 外观一致，但不会被 renderPatchForms 的
   「清空本模块表单」逻辑抹掉 —— 识别记录模块里既有可保存的配置表单，也有
   实时列表，两者必须能共存。 */
.form-section, .panel { margin-bottom: 16px; }
.form-section:last-child, .panel:last-child { margin-bottom: 0; }

/* 面板自带边框，因为同一个模块里常常「可保存的表单」与「实时数据」并排出现。 */
.form-section,
.panel {
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
details.panel,
details.settings-drawer { padding: 0; }

.form-section h3, .panel h3 {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  color: var(--text);
}
.form-section p.desc, .panel p.desc {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
  align-items: start;
}
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.field-row label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.35;
  min-width: 0;
}
.field-row label .restart {
  flex: 0 0 auto;
  margin-left: 0;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-ring);
}
.field-row input,
.field-row select,
.field-row textarea {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.field-row textarea {
  resize: vertical;
  min-height: 62px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}
.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: none;
}
.field-row .help {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.smart-tune {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: var(--radius-sm);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    var(--surface);
}
.smart-tune-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}
.smart-tune-head strong { font-size: 13.5px; }
.smart-tune-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.smart-tune-reasons {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.smart-tune-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.gate {
  display: grid;
  place-items: center;
  padding: 72px 20px;
}
.gate-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
  text-align: left;
}
.gate-card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.gate-card p { margin: 0 0 18px; font-size: 12.5px; color: var(--text-muted); line-height: 1.7; }
.gate-card .token-bar { margin-bottom: 12px; }
.gate-card .check { justify-content: flex-start; }
.gate-card #connect-note:not(:empty) { margin-top: 16px; }

.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  box-shadow: none;
}
.savebar .state {
  font-size: 12.5px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.savebar .state.dirty { color: var(--warn); font-weight: 600; }

/* --------------------------------------------------------------- feedback */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 90;
  max-width: min(92vw, 520px);
  padding: 9px 14px;
  border-radius: 4px;
  background: var(--text);
  color: #f7f8f9;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent-ring);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  /* The blanket rule above freezes the sliding bar at its 40% resting width,
     which reads as "stuck". A uniform translucent bar says "working" instead.
     The elapsed-time readout still ticks, so the wait is never silent. */
  .po-bar.indeterminate {
    animation: none !important;
    width: 100%;
    opacity: .45;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================== login page */

body.login-skin {
  color-scheme: light;
  --bg: #dfe6e2;
  --surface: #f7f8f9;
  --surface-alt: #eef3f0;
  --surface-sunken: #e2e8e4;
  --border: #c9d2cc;
  --border-strong: #9aaca3;
  --text: #15231f;
  --text-muted: #3f524b;
  --text-faint: #5a6b64;
  --accent: #1a5244;
  --accent-hover: #123c32;
  --accent-soft: #dceae4;
  --accent-ring: rgba(26, 82, 68, .22);
  min-height: 100vh;
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI",
    "Noto Sans SC", sans-serif;
  background:
    radial-gradient(1200px 560px at 12% -8%, rgba(36, 110, 90, .28), transparent 58%),
    radial-gradient(900px 480px at 88% 110%, rgba(20, 58, 48, .18), transparent 55%),
    linear-gradient(155deg, #d7e2dc 0%, #e8ece9 42%, #d3ddd7 100%);
  color: var(--text);
}

body.login-skin::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image:
    linear-gradient(rgba(21, 35, 31, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 35, 31, .035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, #000 35%, transparent 78%);
}

.login-stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 40px);
}

.login-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 400px);
  border: 1px solid rgba(26, 82, 68, .18);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(247, 248, 249, .92);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .55) inset,
    0 24px 48px -28px rgba(18, 40, 34, .55);
  animation: login-rise .55s ease both;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  padding: 44px 40px 48px;
  color: #eef6f2;
  background:
    linear-gradient(160deg, #123c32 0%, #1a5244 46%, #245f50 100%);
  overflow: hidden;
}

.login-brand-mark {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-weight: 700;
  color: #9fd0bf;
}

.login-brand h1 {
  margin: 0 0 14px;
  max-width: 8em;
  font-size: clamp(28px, 3.4vw, 36px);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -.03em;
  color: #f4faf7;
}

.login-brand-lead {
  margin: 0 0 22px;
  max-width: 28em;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(238, 246, 242, .78);
}

.login-brand-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.login-brand-points li {
  position: relative;
  padding-left: 16px;
  font-size: 13px;
  color: rgba(238, 246, 242, .88);
}

.login-brand-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: #7fbfaa;
}

.login-brand-art {
  position: absolute;
  right: -18px;
  bottom: -28px;
  width: 210px;
  height: 160px;
  opacity: .55;
  pointer-events: none;
}

.login-brand-art .scan-frame {
  position: absolute;
  inset: 24px 28px 36px 18px;
  border: 1.5px solid rgba(159, 208, 191, .55);
  border-radius: 4px;
  box-shadow: 0 0 0 12px rgba(159, 208, 191, .08);
}

.login-brand-art .scan-frame::before,
.login-brand-art .scan-frame::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid #9fd0bf;
}
.login-brand-art .scan-frame::before {
  top: -2px; left: -2px;
  border-right: 0; border-bottom: 0;
}
.login-brand-art .scan-frame::after {
  right: -2px; bottom: -2px;
  border-left: 0; border-top: 0;
}

.login-brand-art .scan-line {
  position: absolute;
  left: 28px;
  right: 38px;
  top: 42%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #9fd0bf, transparent);
  animation: login-scan 2.8s ease-in-out infinite;
}

@keyframes login-scan {
  0%, 100% { transform: translateY(-18px); opacity: .35; }
  50% { transform: translateY(28px); opacity: .9; }
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 36px 40px 40px;
  background: #f7f8f9;
}

.login-panel-head { margin-bottom: 22px; }
.login-panel-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.login-panel-head p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.login-form { display: grid; gap: 14px; }
.login-form .field-row label { font-weight: 600; color: var(--text); }
.login-form .field-row input {
  border-color: var(--border-strong);
  background: #fff;
  padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-form .field-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.login-form .btn {
  width: 100%;
  padding: 11px 14px;
  margin-top: 4px;
  font-weight: 650;
  letter-spacing: .02em;
}
.login-form .check {
  justify-content: flex-start;
  color: var(--text-muted);
  font-size: 13px;
}

.login-back {
  margin: 22px 0 0;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
}
.login-back a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.login-back a:hover {
  color: var(--text);
  border-bottom-color: var(--border-strong);
}

@media (max-width: 820px) {
  .login-card {
    grid-template-columns: 1fr;
  }
  .login-brand {
    padding: 28px 24px 26px;
    min-height: auto;
  }
  .login-brand h1 {
    max-width: none;
    font-size: 26px;
  }
  .login-brand-art { display: none; }
  .login-brand-points { display: none; }
  .login-panel { padding: 28px 22px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-card,
  .login-brand-art .scan-line { animation: none; }
}

/* ============================================================== admin shell */

/* 布局定义见上方 `.admin-shell`（与 `.layout` 放在一起，便于对照）。
   这里只补窄屏下的单列切换。 */
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; padding-bottom: 28px; }
  body.savebar-visible .admin-shell { padding-bottom: 110px; }
}

.side-nav {
  position: sticky;
  top: 62px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.nav-label {
  margin: 2px 10px 8px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}

/* 窄屏下的折叠规则在文件末尾的响应式区（与其它断点放在一起） */

.nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-sunken); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item .n-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 500;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-line);
}

.admin-main { display: grid; gap: 16px; min-width: 0; }

.module-head { margin: 0 0 4px; }
.module-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.module-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.7; }

.overview-board,
.admin-board {
  display: grid;
  gap: 14px;
}

.overview-board {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.overview-notes {
  display: grid;
  gap: 10px;
  margin-top: 2px;
}
.overview-notes .notice { margin: 0; }

.overview-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
  min-width: 0;
  height: 100%;
}

.overview-group h3 {
  margin: 0;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat-grid.compact {
  grid-template-columns: 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--surface-alt);
  flex: 1;
}

.stat-grid.compact .stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 14px;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-width: 0;
}

.stat-grid.compact .stat:last-child { border-bottom: 0; }

.stat-grid.compact .stat .label {
  display: block;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-grid.compact .stat .value {
  display: block;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Horizontal KPI strip — list pages use this instead of a tall vertical stack. */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0;
  margin-bottom: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.stat-strip .stat {
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.stat-strip .stat .label {
  margin: 0 0 4px;
  font-size: 11.5px;
  color: var(--text-faint);
}
.stat-strip .stat .value {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.stat-strip .stat .value.sm { font-size: 16px; }

@media (max-width: 1100px) {
  .overview-board { grid-template-columns: 1fr; }
}
@media (min-width: 1101px) and (max-width: 1280px) {
  .overview-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ================================================================== tables */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .2px;
  color: var(--text-muted);
  padding: 8px 10px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-alt); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table .muted { color: var(--text-faint); }

/* =================================================================== pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.pill.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.pill.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.pill.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.pill.info { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent); }

/* ============================================================= credentials */

.key-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.key-box .key-label { font-size: 11.5px; color: var(--text-muted); flex: none; }
.key-box code {
  flex: 1 1 240px;
  min-width: 0;
  font: 12.5px/1.6 var(--mono);
  word-break: break-all;
  color: var(--text);
}

/* ==================================================================== logs */

.log-view {
  margin: 0;
  max-height: 300px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font: 12px/1.65 var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-muted);
}

/* ============================================================= inline form */

.inline-form {
  display: grid;
  /* 下限 220px：宽屏下让配置项自动多排几列（而不是每行只放两个、输入框拉到 800px 宽）。
     输入框过宽反而难扫读，因此这里不追求「铺满」。 */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}
.inline-form .btn { height: 34px; }

/* ============================================================= code sample */

.code-sample {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font: 12px/1.7 var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-muted);
  overflow-x: auto;
}

/* A module is hidden until its nav item is selected; `[hidden]` at the top of
   this file is what makes that work, since `.card` would otherwise win. */
.card.module[hidden] { display: none !important; }

/* ========================================================== admin extras */

.stack { display: grid; gap: 14px; }

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.card-sub { font-size: 12.5px; color: var(--text-muted); }

.muted { color: var(--text-faint); }

/* 表格单元格里纵向叠放：操作按钮一行，展开详情一行。 */
.row-stack { display: grid; gap: 8px; min-width: 0; }
.row-stack details.row-detail pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-sunken);
  font: 11.5px/1.6 var(--mono);
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* 可折叠的面板：默认收起，只有摘要那一行可见。 */
details.panel,
details.settings-drawer {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 14px;
}
details.panel > summary,
details.settings-drawer > summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
details.panel > summary::-webkit-details-marker,
details.settings-drawer > summary::-webkit-details-marker { display: none; }
details.panel > summary::before,
details.settings-drawer > summary::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}
details.panel > summary::after,
details.settings-drawer > summary::after {
  content: "展开";
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
}
details.panel[open] > summary::after,
details.settings-drawer[open] > summary::after { content: "收起"; }
details.panel[open] > summary,
details.settings-drawer[open] > summary { border-bottom: 1px solid var(--border); }
details.settings-drawer > summary .muted {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-faint);
}
.details-body { display: grid; gap: 14px; padding: 14px 16px 16px; }
.settings-drawer .settings-block + .settings-block {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.settings-drawer .settings-block h3 {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 650;
}
.settings-drawer .settings-block .desc {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* 面板词表：表头名称两列对齐 */
.panel-label-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 4px 0 14px;
}
.panel-label-grid .field-row {
  margin: 0;
  gap: 6px;
}
.panel-label-grid .field-row label {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* 面板词表编辑：左右列 + 「新版才有」勾选 */
.panel-schema-editor .panel-quiet-input,
.panel-title-row .panel-quiet-input,
.propose-title-input {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  outline: none;
  transition: border-color .12s ease, background .12s ease;
}
.panel-schema-editor textarea.panel-quiet-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-alt);
  padding: 8px 10px;
  resize: vertical;
  min-height: 56px;
  line-height: 1.55;
}
.panel-schema-editor .panel-quiet-input:hover,
.panel-title-row .panel-quiet-input:hover,
.propose-title-input:hover {
  border-bottom-color: var(--border-strong);
  background: rgba(28, 35, 41, .03);
}
.panel-schema-editor .panel-quiet-input:focus,
.panel-title-row .panel-quiet-input:focus,
.propose-title-input:focus,
.panel-schema-editor textarea.panel-quiet-input:focus {
  outline: none !important;
  box-shadow: none !important;
  border-color: transparent;
  border-bottom-color: var(--accent);
  background: rgba(28, 35, 41, .04);
}
.panel-schema-editor .field-row input.panel-quiet-input:focus,
.panel-schema-editor .field-row textarea.panel-quiet-input:focus {
  outline: none !important;
  box-shadow: none !important;
}

.panel-title-grid {
  display: grid;
  gap: 2px;
  margin: 12px 0 14px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.panel-title-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 4px 2px;
}
.panel-title-row:hover {
  background: rgba(28, 35, 41, .025);
}
.panel-title-row.head {
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 600;
  padding-bottom: 6px;
}
.panel-title-row .check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  margin: 0;
}
@media (max-width: 720px) {
  .panel-title-row {
    grid-template-columns: 24px 1fr;
  }
  .panel-title-row > :nth-child(3),
  .panel-title-row > :nth-child(4) {
    grid-column: 2;
  }
}

/* 样张核对弹窗 */
.modal-card.propose-modal {
  max-width: min(1440px, 98vw);
  max-height: min(96vh, 1080px);
  display: flex;
  flex-direction: column;
}
.modal-card.propose-modal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 10px !important;
}
.modal-card.propose-modal .propose-review {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px !important;
  overflow: hidden;
}
.modal-card.propose-modal .modal-actions {
  flex: 0 0 auto;
  position: relative;
  z-index: 3;
  margin-top: 0;
  padding: 12px 0 2px;
  background: #f7f8f9;
  border-top: 1px solid var(--border);
}
.propose-tools,
.propose-boxing-banner,
.propose-legend,
.propose-review > .desc {
  flex: 0 0 auto;
}
.propose-tools { margin: 0; }
.propose-boxing-banner {
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12.5px;
  line-height: 1.45;
}
.propose-boxing-banner.is-ok {
  border-color: rgba(60, 175, 102, .45);
  background: rgba(60, 175, 102, .08);
}
.propose-boxing-banner.is-warn {
  border-color: rgba(180, 83, 9, .45);
  background: rgba(255, 196, 0, .12);
}
.propose-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.propose-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 500;
  border: 1px solid transparent;
}
.propose-chip.is-nick { color: #0b6e99; background: #e6f5fb; border-color: #9ad3ea; }
.propose-chip.is-power { color: #9a5b00; background: #fff4e0; border-color: #f0c57a; }
.propose-chip.is-title { color: #1f6b3a; background: #e7f6ec; border-color: #95d0ab; }
.propose-chip.is-value { color: #5b3d9a; background: #f1eaff; border-color: #c3b0ea; }

.propose-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(360px, 1fr);
  gap: 14px;
  min-height: 0;
  flex: 1 1 auto;
  align-items: stretch;
  overflow: hidden;
}
@media (max-width: 900px) {
  .propose-layout {
    grid-template-columns: 1fr;
    overflow: auto;
  }
}
.propose-stage {
  position: relative;
  background: #1c2329;
  border-radius: var(--radius-xs);
  overflow: auto;
  min-height: 360px;
  max-height: min(72vh, 760px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.propose-stage.is-draw {
  cursor: crosshair;
}
.propose-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  vertical-align: top;
}
.propose-frame.is-draw {
  cursor: crosshair;
}
.propose-image {
  display: block;
  max-width: 100%;
  max-height: min(78vh, 820px);
  width: auto;
  height: auto;
  user-select: none;
}
.propose-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.propose-draw-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  cursor: crosshair;
  touch-action: none;
  pointer-events: auto;
}
/* Empty space draws rubber-band; existing boxes stay clickable above the layer. */
.propose-frame.is-draw .propose-overlay { z-index: 5; pointer-events: none; }
.propose-frame.is-draw .propose-box { pointer-events: auto; z-index: 6; }
.propose-draw-rect {
  position: absolute;
  box-sizing: border-box;
  border: 2px dashed #7c5cff;
  background: rgba(124, 92, 255, .18);
  pointer-events: none;
}
.propose-box {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid;
  border-radius: 2px;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  transition: box-shadow .12s ease, background .12s ease, border-width .12s ease;
}
.propose-box.is-editable { cursor: move; }
.propose-frame.is-correct .propose-box.is-active { cursor: move; }
.propose-box.is-nickname,
.propose-box.is-nick { border-color: #3db7e6; box-shadow: inset 0 0 0 1px rgba(61,183,230,.25); }
.propose-box.is-power { border-color: #e2a23a; box-shadow: inset 0 0 0 1px rgba(226,162,58,.25); }
.propose-box.is-title { border-color: #3caf66; box-shadow: inset 0 0 0 1px rgba(60,175,102,.22); }
.propose-box.is-value { border-color: #8b6ed8; box-shadow: inset 0 0 0 1px rgba(139,110,216,.22); }
.propose-box.is-active {
  border-width: 2.5px;
  background: rgba(255, 214, 64, .28);
  box-shadow: 0 0 0 2px rgba(255, 196, 0, .55);
  z-index: 7;
}
.propose-box-handle {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #fff;
  border: 1.5px solid #6c5ce7;
  border-radius: 2px;
  box-sizing: border-box;
  pointer-events: auto;
  z-index: 8;
}
.propose-box-handle.is-n { top: -5px; left: 50%; margin-left: -4px; cursor: ns-resize; }
.propose-box-handle.is-s { bottom: -5px; left: 50%; margin-left: -4px; cursor: ns-resize; }
.propose-box-handle.is-e { right: -5px; top: 50%; margin-top: -4px; cursor: ew-resize; }
.propose-box-handle.is-w { left: -5px; top: 50%; margin-top: -4px; cursor: ew-resize; }
.propose-box-handle.is-ne { right: -5px; top: -5px; cursor: nesw-resize; }
.propose-box-handle.is-nw { left: -5px; top: -5px; cursor: nwse-resize; }
.propose-box-handle.is-se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.propose-box-handle.is-sw { left: -5px; bottom: -5px; cursor: nesw-resize; }

.propose-crop-rect {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #f0a202;
  background: rgba(240, 162, 2, .12);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35);
  cursor: move;
  touch-action: none;
  z-index: 3;
}
.propose-crop-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1.5px solid #f0a202;
  border-radius: 2px;
  box-sizing: border-box;
}
.propose-crop-handle.is-n { top: -6px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.propose-crop-handle.is-s { bottom: -6px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.propose-crop-handle.is-e { right: -6px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.propose-crop-handle.is-w { left: -6px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.propose-crop-handle.is-ne { right: -6px; top: -6px; cursor: nesw-resize; }
.propose-crop-handle.is-nw { left: -6px; top: -6px; cursor: nwse-resize; }
.propose-crop-handle.is-se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.propose-crop-handle.is-sw { left: -6px; bottom: -6px; cursor: nesw-resize; }

.propose-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  max-height: min(72vh, 760px);
  overflow: hidden;
}
.propose-type-summary {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-alt);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted);
  word-break: break-word;
}
.propose-side h4 {
  margin: 2px 0 0;
  font-size: 12.5px;
  font-weight: 650;
  flex: 0 0 auto;
}
.propose-header-card {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-alt);
  flex: 0 0 auto;
}
.propose-header-tip {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
}
.propose-header-row {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  cursor: pointer;
}
.propose-header-row.is-active,
.propose-header-row.is-link-target {
  border-color: rgba(240, 162, 2, .65);
  box-shadow: 0 0 0 2px rgba(255, 196, 0, .28);
  background: rgba(255, 214, 64, .14);
}
.propose-header-row.is-missing-value .propose-value-meta {
  color: #b45309;
}
.propose-cells {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px;
  background: var(--surface);
}
.propose-cell-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr;
  gap: 8px;
  align-items: start;
}
.propose-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  cursor: pointer;
}
.propose-cell.is-active,
.propose-cell.is-link-target {
  background: rgba(255, 214, 64, .16);
  border-color: rgba(240, 162, 2, .55);
}
.propose-cell.is-missing-value,
.propose-cell.is-missing-title {
  border-color: rgba(180, 83, 9, .35);
}
.propose-col-label {
  font-size: 10.5px;
  color: var(--text-faint);
}
.propose-value-input,
.propose-side .panel-quiet-input,
.propose-side input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  min-height: 30px;
  font-size: 12px;
  line-height: 1.35;
  background: var(--surface);
  color: var(--text);
}
.propose-value-input:focus {
  outline: none;
  border-color: rgba(124, 92, 255, .65);
  box-shadow: 0 0 0 2px rgba(124, 92, 255, .18);
}
.propose-value-meta {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
  word-break: break-all;
}
.propose-cell.is-missing-value .propose-value-meta {
  color: #b45309;
}

.api-doc {
  gap: 16px;
}
.api-doc h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 650;
}
.api-doc .desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.65;
}

.api-hero {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.api-hero-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 650;
}

.api-sync {
  display: grid;
  gap: 10px;
}
.api-sync-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.api-sync-item {
  display: grid;
  gap: 6px;
  padding: 12px 12px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
}
.api-sync-item strong { font-size: 12.5px; }
.api-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface-alt);
}
.api-tag.ok {
  color: #166534;
  border-color: color-mix(in srgb, #16a34a 35%, var(--border));
  background: color-mix(in srgb, #22c55e 12%, var(--surface));
}
.api-tag.mute {
  color: var(--text-faint);
}

.api-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}
.api-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 11px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.api-tab:hover { color: var(--text); background: var(--surface); }
.api-tab.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
  font-weight: 600;
}
.api-tab-panels { min-height: 120px; }
.api-tab-panel {
  display: grid;
  gap: 10px;
  padding: 4px 0 0;
}

.api-tree {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.api-node {
  padding: 6px 8px 6px 4px;
  border-radius: var(--radius-xs);
}
.api-node.is-object > .api-node-head {
  cursor: pointer;
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0;
  color: inherit;
}
.api-node-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.api-node-mark {
  width: 12px;
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 11px;
}
.api-node-name {
  font: 12px/1.4 var(--mono);
  color: var(--accent);
}
.api-node-type {
  font: 11px/1.4 var(--mono);
  color: var(--text-faint);
}
.api-node-zh {
  margin: 2px 0 0 20px;
  font-size: 12px;
  line-height: 1.45;
}
.api-node-en {
  margin: 0 0 0 20px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.api-node-kids {
  margin: 6px 0 0 12px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  display: grid;
  gap: 2px;
}
.api-node.is-open {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.api-ex-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.api-ex-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.api-ex-btn:hover { color: var(--text); border-color: var(--border-strong); }
.api-ex-btn.is-active {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.panel-scope-card .scope-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}
.panel-scope-card .scope-list li::marker { color: var(--accent); }

.legacy-panel { padding: 16px 16px 14px; }
.legacy-panel .desc { margin-bottom: 12px; }
.legacy-note { margin: 0 0 12px; }
.legacy-note:empty { display: none; margin: 0; }
.legacy-panel .token-bar { margin-top: 2px; }

/* ========================================================== 数据表（列表页）
   列表页统一用「工具条 + 表格 + 分页」。窄屏不再靠横向滚动，而是把每行折成
   一张卡片：表头隐藏，单元格用自带的 data-label 当字段名。
   ========================================================================== */

.data-table { display: grid; gap: 10px; }
.data-table .table-body.loading { opacity: .55; }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.table-search { flex: 1 1 200px; min-width: 160px; }
.table-search input { width: 100%; }

.table-search input,
.table-filter select,
.table-size select,
.pager-jump input {
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
.table-search input:focus,
.table-filter select:focus,
.table-size select:focus,
.pager-jump input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.table-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }

.table-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-alt);
}
.table-summary {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.table-size { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.pager-jump { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.pager-jump input { width: 52px; text-align: center; }

/* 单元格里的次要信息（IP、UA、时间）不好放长文本 */
.table .mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }

.secret-field { display: grid; gap: 6px; min-width: 0; }
.secret-field code {
  display: block;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-sunken);
  font: 12px/1.6 var(--mono);
  color: var(--text);
  word-break: break-all;
  min-height: 26px;
}

/* 键盘/读屏可用的折叠区（接入方详情） */
.table details.row-detail { margin: 0; }
.table details.row-detail > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================================================== 多端适配（手机/平板）
   目标不是「能挤下」，而是：
   - 手机上表格变卡片、按钮达到 44px 左右的触控尺寸；
   - iOS 上底部保存条避开 home indicator，页面不会被状态栏缩字；
   - 安卓上关掉点击高亮，避免整块闪蓝。
   ========================================================================== */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: rgba(22, 93, 255, .12); }

@media (max-width: 720px) {
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand-text em { display: none; }
  .card-body { padding: 13px; }
  .card-head { padding: 10px 13px; flex-wrap: wrap; }
  .admin-shell, .layout { padding: 12px 12px 28px; }
  body.savebar-visible .admin-shell { padding-bottom: 120px; }
  /* 底部保存条要避开 iPhone 的 home indicator */
  .savebar {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .btn { padding: 8px 13px; }
  .btn.sm { padding: 7px 11px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .table-toolbar { gap: 6px; }
  .table-search { flex-basis: 100%; }
  .table-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .table-footer { gap: 8px; }
  .table-pager { width: 100%; justify-content: flex-end; }
  .module-head h2 { font-size: 14px; }
}

@media (max-width: 620px) {
  /* 表格 → 卡片。thead 藏起来，每格前面用 data-label 补出字段名。 */
  .data-table .table,
  .table-wrap.auto-cards .table,
  .table-wrap.auto-cards .table tbody,
  .table-wrap.auto-cards .table tr,
  .table-wrap.auto-cards .table td { display: block; width: 100%; }
  .data-table .table thead,
  .table-wrap.auto-cards .table thead { display: none; }
  .data-table .table tr,
  .table-wrap.auto-cards .table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--surface);
    overflow: hidden;
  }
  .data-table .table td,
  .table-wrap.auto-cards .table td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 11px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    word-break: break-word;
  }
  .data-table .table td:last-child,
  .table-wrap.auto-cards .table td:last-child { border-bottom: 0; }
  .data-table .table td::before,
  .table-wrap.auto-cards .table td::before {
    content: attr(data-label);
    color: var(--text-faint);
    font-size: 11.5px;
  }
  .data-table .table td:empty { display: none; }
  .secret-field { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  /* 8 个模块平铺在手机上要占掉整整一屏（每行两个也有 4 行），内容被推到很
     下面。折叠成顶栏上的一条按钮：收起时侧栏 display:none，展开是两列网格。
     当前模块名写在按钮上，不展开也知道自己在哪一页。

     用「收起即 display:none」而不是浮层抽屉：不跟 sticky 顶栏抢 z-index，
     不用锁滚动，而且收起的导航项天然不可聚焦——键盘用户不会 Tab 进一排
     看不见的按钮里，也就不需要 inert 之类的额外处理。 */
  .side-nav {
    display: none;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: visible;
    /* 展开后会被 scrollIntoView 拉进视野，得给 sticky 顶栏让出位置，
       否则侧栏第一行会正好藏在顶栏底下。 */
    scroll-margin-top: 62px;
  }
  body.nav-open .side-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  .nav-item { justify-content: flex-start; }
}

/* ---------------------------------------------------------- 折叠导航按钮
   只在窄屏出现。`hidden` 属性（登录前）优先级高于这里的 display，
   所以未登录时按钮不会露出来。 */
.nav-toggle {
  display: none;
  align-items: center;
  gap: 7px;
  flex: none;
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .brand-text em { display: none; }
}

/* 触屏设备把可点元素抬高到接近 44px 的最小触控尺寸 */
@media (hover: none) and (pointer: coarse) {
  .btn, .nav-item, .table-pager .btn { min-height: 40px; }
  .table-search input, .table-filter select, .table-size select, .pager-jump input { height: 38px; }
  .row-actions .btn { min-height: 36px; }
}

/* ======================================================== accounts / security
   账号与安全：顶部身份条 + 下方全宽列表，新增/改密走弹窗。 */

.security-page {
  display: grid;
  gap: 16px;
}

.security-tile {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 16px 18px 16px;
  min-width: 0;
}

.security-header .security-me {
  margin-bottom: 8px;
}

.security-header .desc {
  margin-bottom: 12px;
}

.security-header .tile-actions {
  margin-top: 0;
}

.security-tile.wide .btn-row {
  margin: 0 0 12px;
  justify-content: flex-end;
}

.security-tile .tile-kicker {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.security-tile h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -.01em;
}

.security-tile h3::before { display: none; }

.security-tile .desc {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.65;
}

.security-tile .inline-form {
  grid-template-columns: 1fr;
  gap: 10px;
}

.security-tile .tile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.security-tile .tile-actions .btn { height: 34px; }

.security-me {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.security-me strong {
  font-size: 14px;
  font-weight: 650;
}

.security-me span {
  font-size: 12px;
  color: var(--text-faint);
}

.security-page .table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.security-page .table th {
  background: var(--surface-alt);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}

/* 后台固定浅色：不跟系统深色走，排版气质更稳。 */
body.admin-skin {
  color-scheme: light;
  --bg: #e9ecef;
  --surface: #f7f8f9;
  --surface-alt: #f1f3f5;
  --surface-sunken: #e4e7eb;
  --border: #d5d9de;
  --border-strong: #b8c0c7;
  --text: #1c2329;
  --text-muted: #4d5964;
  --text-faint: #5c6772;
  --accent: #1f5c4d;
  --accent-hover: #17493d;
  --accent-soft: #e4efeb;
  --accent-ring: rgba(31, 92, 77, .18);
  --ok: #1b6b4a;
  --ok-soft: #e3f2eb;
  --ok-line: #b7d9c7;
  --warn: #8a5a12;
  --warn-soft: #f6eedf;
  --warn-line: #e2d0a8;
  --bad: #a3282c;
  --bad-soft: #f8eaea;
  --bad-line: #e6c4c5;
  background:
    linear-gradient(180deg, #f3f4f6 0%, var(--bg) 120px),
    var(--bg);
}

body.admin-skin .side-nav {
  border-radius: var(--radius-sm);
  box-shadow: none;
}

body.admin-skin .card {
  border-radius: var(--radius-sm);
  box-shadow: none;
}

body.admin-skin .card-head {
  background: transparent;
}

body.admin-skin .nav-item.active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

body.admin-skin .key-box {
  border-style: solid;
  border-color: var(--border);
  background: var(--surface-alt);
}

body.admin-skin .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
}

body.admin-skin .btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* 登录页与后台共用的 notice：少一点「彩色胶囊」感 */
body.admin-skin .notice,
body.login-skin .notice {
  border-radius: var(--radius-xs);
}

