/* =====================================================================
   OSS 网关 · 管理后台样式
   结构：1 变量  2 重置  3 基础排版  4 布局  5 组件  6 页面  7 动效与无障碍
   业务代码只引用变量；深色模式只覆盖变量。
   ===================================================================== */

/* ---------- 1. 变量 ---------- */

:root {
  color-scheme: light dark;

  --canvas: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --elevated: #ffffff;
  --hover: rgba(17, 24, 32, 0.045);
  --press: rgba(17, 24, 32, 0.08);
  --border: #e4e6e9;
  --border-strong: #d2d6db;
  --text: #15181c;
  --text-2: #4a5059;
  --text-3: #6b727c;
  --text-4: #9aa1aa;

  /* 主色：石青 */
  --accent: #0f6e8c;
  --accent-hover: #0c5d77;
  --accent-solid: #0f6e8c;
  --accent-solid-hover: #0c5d77;
  --accent-solid-press: #0a5066;
  --accent-soft: rgba(15, 110, 140, 0.09);
  --accent-soft-2: rgba(15, 110, 140, 0.16);
  --on-accent: #ffffff;
  --focus: #0f6e8c;

  --success: #177a3d;
  --success-soft: #e7f5ec;
  --warning: #95600a;
  --warning-soft: #fcf2df;
  --danger: #c42b2b;
  --danger-soft: #fcebeb;
  --danger-solid: #c42b2b;
  --danger-solid-hover: #a92424;
  --info: #2a5fc6;
  --info-soft: #e9effc;

  --chart-ok: #2f8fb3;
  --chart-fail: #d03b3b;
  --chart-grid: #eceef1;
  --chart-axis: #cfd3d8;

  --scrim: rgba(15, 20, 26, 0.36);
  --shadow-pop: 0 12px 32px -10px rgba(20, 28, 38, 0.24), 0 2px 8px -2px rgba(20, 28, 38, 0.08);
  --shadow-sheet: 0 -10px 32px -12px rgba(20, 28, 38, 0.28);
  --pop-border: var(--border);
  --skeleton: #eef0f2;
  --skeleton-shine: #f6f7f8;

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

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 26px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-full: 999px;

  --dur-fast: 110ms;
  --dur: 170ms;
  --dur-slow: 240ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);

  --sidebar-w: 232px;
  --rail-w: 56px;
  --topbar-h: 52px;
  --control-h: 32px;
  --control-h-sm: 28px;
  --input-fs: var(--fs-md);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0e0f11;
    --surface: #15171a;
    --surface-2: #1a1c20;
    --elevated: #1e2024;
    --hover: rgba(255, 255, 255, 0.05);
    --press: rgba(255, 255, 255, 0.085);
    --border: #26292e;
    --border-strong: #363a41;
    --text: #e8eaed;
    --text-2: #b1b6bd;
    --text-3: #8a9099;
    --text-4: #5d636b;

    --accent: #5fb6d3;
    --accent-hover: #7cc4dd;
    --accent-solid: #1b7e9c;
    --accent-solid-hover: #2190b1;
    --accent-solid-press: #19738e;
    --accent-soft: rgba(95, 182, 211, 0.12);
    --accent-soft-2: rgba(95, 182, 211, 0.2);
    --on-accent: #ffffff;
    --focus: #5fb6d3;

    --success: #52c27f;
    --success-soft: rgba(82, 194, 127, 0.13);
    --warning: #e2a744;
    --warning-soft: rgba(226, 167, 68, 0.13);
    --danger: #f07272;
    --danger-soft: rgba(240, 114, 114, 0.13);
    --danger-solid: #c93a3a;
    --danger-solid-hover: #d64a4a;
    --info: #7ea6f4;
    --info-soft: rgba(126, 166, 244, 0.13);

    --chart-ok: #3299bb;
    --chart-fail: #e66767;
    --chart-grid: #23262b;
    --chart-axis: #363a41;

    --scrim: rgba(0, 0, 0, 0.56);
    --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
    --shadow-sheet: 0 -12px 40px -12px rgba(0, 0, 0, 0.7);
    --pop-border: #33363c;
    --skeleton: #1e2024;
    --skeleton-shine: #25282c;
  }
}

/* 触屏与窄屏：控件更高、输入框 16px，避免 iOS 聚焦放大 */
@media (pointer: coarse), (max-width: 760px) {
  :root {
    --control-h: 40px;
    --control-h-sm: 34px;
    --input-fs: 16px;
  }
}

/* ---------- 2. 重置 ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, pre {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
}

@media (hover: hover) {
  a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: inherit;
}

button:disabled {
  cursor: not-allowed;
}

input, textarea, select {
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

input::-ms-reveal,
input::-ms-clear {
  display: none;
}

::placeholder {
  color: var(--text-4);
  opacity: 1;
}

/* Chrome 自动填充的底色 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-out 0s;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--s-4) 0;
}

[hidden] {
  display: none !important;
}

html.scroll-locked {
  overflow: hidden;
}

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

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* 浮层容器只是焦点落点，不画焦点框 */
.dialog:focus-visible,
.drawer:focus-visible,
.action-sheet:focus-visible,
.listbox:focus-visible,
.chart svg:focus:not(:focus-visible) {
  outline: none;
}

/* 细滚动条，颜色跟随主题 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---------- 3. 基础排版 ---------- */

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
  letter-spacing: 0;
}

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

.muted {
  color: var(--text-3);
}

.subtle {
  color: var(--text-2);
}

.small {
  font-size: var(--fs-sm);
}

.xs {
  font-size: var(--fs-xs);
}

.strong {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.ellipsis {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 中间省略：首段可收缩，尾段保留 */
.mid {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
  vertical-align: bottom;
}

.mid-head {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mid-tail {
  flex: 0 0 auto;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 16px;
  color: var(--text-2);
  text-align: center;
  background: var(--surface);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}

/* ---------- 4. 布局 ---------- */

.boot {
  display: grid;
  place-items: center;
  min-height: 100dvh;
}

.boot-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-solid);
  opacity: 0.85;
  animation: boot-pulse 1.2s ease-in-out infinite;
}

@keyframes boot-pulse {
  50% {
    opacity: 0.35;
  }
}

.noscript {
  padding: var(--s-6);
  text-align: center;
  color: var(--text-2);
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  transition: grid-template-columns var(--dur-slow) var(--ease-out);
}

.app[data-rail="true"] {
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
}

/* 侧栏 */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--s-3) var(--s-2) var(--s-2);
  overflow-y: auto;
  overflow-x: hidden;
}

.sb-head {
  padding: 2px var(--s-1) var(--s-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px;
  border-radius: var(--r-sm);
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  flex: none;
  width: 28px;
  height: 28px;
}

.brand-bg {
  fill: var(--accent-solid);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.brand-name {
  font-weight: 600;
  font-size: var(--fs-md);
}

.brand-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-group {
  margin: var(--s-4) var(--s-2) var(--s-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

.nav-item svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--text-3);
}

.nav-item:hover {
  text-decoration: none;
}

@media (hover: hover) {
  .nav-item:hover {
    background: var(--hover);
    color: var(--text);
  }
}

.nav-item:active {
  background: var(--press);
}

.nav-item[aria-current="page"] {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.nav-item[aria-current="page"] svg {
  color: var(--accent);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: var(--s-2);
}

.sb-version {
  padding: 2px 10px;
  font-size: 11px;
  color: var(--text-4);
  white-space: nowrap;
}

/* 图标栏 */
.app[data-rail="true"] .brand-text,
.app[data-rail="true"] .nav-label,
.app[data-rail="true"] .sb-version {
  display: none;
}

.app[data-rail="true"] .nav-group {
  height: 1px;
  margin: var(--s-3) var(--s-2);
  background: var(--border);
  font-size: 0;
}

.app[data-rail="true"] .sidebar {
  overflow: visible;
}

.app[data-rail="true"] .nav-item {
  justify-content: center;
  padding: 0;
}

.app[data-rail="true"] .sb-head {
  padding-left: 0;
  padding-right: 0;
  display: flex;
  justify-content: center;
}

/* 图标栏的悬停提示 */
@media (hover: hover) {
  .app[data-rail="true"] .nav-item[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    border-radius: var(--r-sm);
    background: var(--text);
    color: var(--surface);
    font-size: var(--fs-xs);
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 30;
  }
}

/* 主区域：嵌入式面板 */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 8px 8px 8px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
  height: var(--topbar-h);
  padding: 0 var(--s-3) 0 var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  z-index: 20;
}

.topbar-title {
  display: none;
  min-width: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--fs-md);
  color: var(--text-3);
}

.crumbs a {
  color: var(--text-3);
  white-space: nowrap;
}

.crumbs a:hover {
  color: var(--text);
  text-decoration: none;
}

.crumbs .crumb-sep {
  color: var(--text-4);
}

.crumbs .crumb-current {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

.session-chip svg {
  width: 14px;
  height: 14px;
}

.session-chip[data-level="warn"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 6px 0 4px;
  border-radius: var(--r-sm);
  max-width: 220px;
}

@media (hover: hover) {
  .user-btn:hover {
    background: var(--hover);
  }
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft-2);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.content {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-top: var(--s-4);
}

.page {
  container: page / inline-size;
  padding: var(--s-5) var(--s-6) var(--s-10);
  min-height: 100%;
}

.page--fill {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-bottom: var(--s-5);
}

.page--narrow > .page-body {
  max-width: 920px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}

.ph-main {
  flex: 1;
  min-width: 0;
}

.ph-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}

.ph-title h1 {
  font-size: var(--fs-xl);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ph-desc {
  margin-top: 4px;
  max-width: 72ch;
  color: var(--text-2);
  font-size: var(--fs-md);
}

.ph-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
}

.ph-info {
  display: none;
}

.section {
  margin-top: var(--s-8);
}

.section:first-child {
  margin-top: 0;
}

.section-head {
  display: flex;
  align-items: flex-end;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.section-head h2 {
  font-size: var(--fs-lg);
}

.section-head p {
  margin-top: 2px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.section-head .grow {
  flex: 1;
  min-width: 0;
}

.panel {
  container: panel / inline-size;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.panel-body {
  padding: var(--s-4) var(--s-5);
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-md) var(--r-md);
}

.panel-foot .grow {
  flex: 1;
  min-width: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}

.row--wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}

.toolbar .search {
  flex: 1 1 240px;
  max-width: 360px;
}

.audit-filters .search {
  flex: 1 1 260px;
}

.audit-filters .select {
  flex: 0 0 auto;
  width: 148px;
}

.drawer-scrim {
  display: none;
}

/* 平板与窄窗口：侧栏收成图标栏 */
@media (max-width: 1100px) and (min-width: 761px) {
  .app,
  .app[data-rail="false"] {
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
  }

  .app .brand-text,
  .app .nav-label,
  .app .sb-version,
  .app .collapse-btn {
    display: none;
  }

  .app .nav-group {
    height: 1px;
    margin: var(--s-3) var(--s-2);
    background: var(--border);
    font-size: 0;
  }

  .app .sidebar {
    overflow: visible;
  }

  .app .nav-item {
    justify-content: center;
    padding: 0;
  }

  .app .sb-head {
    display: flex;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .app .nav-item[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    border-radius: var(--r-sm);
    background: var(--text);
    color: var(--surface);
    font-size: var(--fs-xs);
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 30;
  }
}

/* 手机：单列，导航进抽屉，页面整体滚动 */
@media (max-width: 760px) {
  .app,
  .app[data-rail="true"],
  .app[data-rail="false"] {
    display: block;
    height: auto;
    min-height: 100dvh;
    padding: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(288px, 86vw);
    padding: calc(var(--s-3) + var(--safe-top)) var(--s-3) calc(var(--s-3) + var(--safe-bottom))
      calc(var(--s-3) + var(--safe-left));
    background: var(--canvas);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    transition: transform var(--dur-slow) var(--ease-out);
    overflow-y: auto;
  }

  .app[data-drawer="true"] .sidebar {
    transform: none;
    box-shadow: var(--shadow-pop);
  }

  .app .brand-text,
  .app .nav-label,
  .app .sb-version {
    display: flex;
  }

  .app .nav-label,
  .app .sb-version {
    display: block;
  }

  .app .nav-group {
    height: auto;
    margin: var(--s-4) var(--s-2) var(--s-1);
    background: none;
    font-size: var(--fs-xs);
  }

  .app .nav-item {
    justify-content: flex-start;
    height: 44px;
    padding: 0 12px;
    font-size: var(--fs-lg);
  }

  .app .sb-head {
    display: block;
    padding: 2px var(--s-1) var(--s-3);
  }

  .collapse-btn {
    display: none;
  }

  .drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-slow) var(--ease-out);
  }

  .app[data-drawer="true"] .drawer-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow: visible;
    min-height: 100dvh;
  }

  .topbar {
    position: sticky;
    top: 0;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) var(--s-2) 0 var(--s-2);
    transition: transform var(--dur-slow) var(--ease-out);
  }

  .topbar[data-hidden="true"] {
    transform: translateY(-100%);
  }

  .topbar .crumbs,
  .session-chip,
  .user-name {
    display: none;
  }

  .topbar-title {
    display: block;
    flex: 1;
  }

  .topbar-spacer {
    display: none;
  }

  .content {
    overflow: visible;
  }

  .page {
    padding: var(--s-3) var(--s-4) calc(var(--s-10) + var(--safe-bottom));
  }

  .page--fill {
    height: auto;
  }
}

@media (min-width: 761px) {
  .menu-btn {
    display: none !important;
  }
}

/* 页面标题区在窄容器下：标题交给顶栏，说明收进 ⓘ */
@container page (max-width: 600px) {
  .page-head {
    align-items: center;
    margin-bottom: var(--s-3);
  }

  .ph-title h1,
  .ph-desc {
    display: none;
  }

  .ph-info {
    display: inline-flex;
  }

  .page-head:not(:has(.ph-actions > *)):not(:has(.ph-info)) {
    display: none;
  }

  .section {
    margin-top: var(--s-6);
  }

  .panel-body {
    padding: var(--s-3) var(--s-4);
  }

  .panel-foot {
    padding: var(--s-3) var(--s-4);
  }

  .toolbar .search {
    max-width: none;
  }
}

/* ---------- 5. 组件 ---------- */

/* 图标 */
.icon {
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  vertical-align: -0.2em;
}

/* 按钮 */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  height: var(--control-h);
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast),
    transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
}

.btn .icon {
  width: 16px;
  height: 16px;
}

@media (hover: hover) {
  .btn:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--surface-2);
    border-color: var(--text-4);
  }
}

.btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: scale(0.97);
  background: var(--hover);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
}

.btn[aria-disabled="true"] {
  cursor: not-allowed;
}

.btn--primary {
  border-color: transparent;
  background: var(--accent-solid);
  color: var(--on-accent);
}

@media (hover: hover) {
  .btn--primary:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--accent-solid-hover);
    border-color: transparent;
  }
}

.btn--primary:active:not(:disabled):not([aria-disabled="true"]) {
  background: var(--accent-solid-press);
}

.btn--danger {
  border-color: transparent;
  background: var(--danger-solid);
  color: #fff;
}

@media (hover: hover) {
  .btn--danger:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--danger-solid-hover);
    border-color: transparent;
  }
}

.btn--danger:active:not(:disabled):not([aria-disabled="true"]) {
  background: var(--danger-solid-hover);
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

@media (hover: hover) {
  .btn--ghost:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--hover);
    border-color: transparent;
    color: var(--text);
  }
}

.btn--ghost:active:not(:disabled):not([aria-disabled="true"]) {
  background: var(--press);
}

.btn--danger-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--danger);
}

@media (hover: hover) {
  .btn--danger-ghost:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--danger-soft);
    border-color: transparent;
  }
}

.btn--link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 500;
}

@media (hover: hover) {
  .btn--link:hover:not(:disabled):not([aria-disabled="true"]) {
    background: none;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}

.btn--link:active:not(:disabled) {
  transform: none;
  background: none;
}

.btn--sm {
  height: var(--control-h-sm);
  padding: 0 10px;
  font-size: var(--fs-sm);
}

.btn--icon {
  width: var(--control-h);
  padding: 0;
}

.btn--icon.btn--sm {
  width: var(--control-h-sm);
}

.btn--block {
  width: 100%;
}

.btn-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn[data-loading="true"] {
  cursor: progress;
}

.btn[data-loading="true"] .btn-label {
  visibility: hidden;
}

.btn-spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.btn[data-done="true"] {
  color: var(--success);
}

.btn--primary[data-done="true"] {
  color: var(--on-accent);
}

/* 小号图标按钮（行内操作） */
.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: background-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}

.icon-btn .icon {
  width: 18px;
  height: 18px;
}

@media (hover: hover) {
  .icon-btn:hover:not(:disabled) {
    background: var(--hover);
    color: var(--text);
  }
}

.icon-btn:active:not(:disabled) {
  background: var(--press);
  transform: scale(0.94);
}

.icon-btn:disabled,
.icon-btn[aria-disabled="true"] {
  opacity: 0.4;
}

.icon-btn--sm {
  width: 26px;
  height: 26px;
}

.icon-btn--sm .icon {
  width: 16px;
  height: 16px;
}

@media (pointer: coarse) {
  .icon-btn {
    width: 40px;
    height: 40px;
  }

  .icon-btn--sm {
    width: 36px;
    height: 36px;
  }
}

/* 转圈 */
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0.75;
  animation: spin 0.7s linear infinite;
}

.spinner--sm {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

.spinner--lg {
  width: 22px;
  height: 22px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.badge .icon {
  width: 12px;
  height: 12px;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--success {
  background: var(--success-soft);
  border-color: transparent;
  color: var(--success);
}

.badge--warning {
  background: var(--warning-soft);
  border-color: transparent;
  color: var(--warning);
}

.badge--danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.badge--info {
  background: var(--info-soft);
  border-color: transparent;
  color: var(--info);
}

.badge--accent {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.badge--mono {
  font-family: var(--mono);
  font-weight: 400;
}

.badge--sq {
  border-radius: var(--r-xs);
  height: 20px;
  padding: 0 6px;
}

/* 表单 */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4) var(--s-5);
}

.form-grid > .span-2 {
  grid-column: 1 / -1;
}

@container (max-width: 560px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}

.field-label .opt {
  color: var(--text-3);
  font-weight: 400;
}

.field-hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--danger);
}

.field-error .icon {
  width: 14px;
  height: 14px;
  margin-top: 1px;
}

.input,
.textarea,
.select-trigger {
  width: 100%;
  min-width: 0;
  height: var(--control-h);
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--input-fs);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.textarea {
  height: auto;
  min-height: 76px;
  padding: 8px 10px;
  line-height: 1.5;
  resize: vertical;
}

@media (hover: hover) {
  .input:hover:not(:disabled):not(:focus),
  .textarea:hover:not(:disabled):not(:focus),
  .select-trigger:hover:not(:disabled):not([aria-expanded="true"]) {
    border-color: var(--text-4);
  }
}

.input:focus,
.textarea:focus,
.select-trigger:focus-visible,
.select-trigger[aria-expanded="true"],
.input-group:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}

.input:disabled,
.textarea:disabled,
.select-trigger:disabled,
.input[readonly] {
  background: var(--surface-2);
  color: var(--text-3);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.select-trigger[aria-invalid="true"],
.input-group[data-invalid="true"] {
  border-color: var(--danger);
}

.input[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus,
.input-group[data-invalid="true"]:focus-within {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.input.mono,
.textarea.mono {
  font-size: calc(var(--input-fs) - 1px);
}

.input-group {
  display: flex;
  align-items: stretch;
  min-width: 0;
  height: var(--control-h);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input-group .input {
  height: 100%;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.input-group .input:focus {
  box-shadow: none;
}

.input-addon {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 0 10px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.input-addon + .input {
  padding-left: 0;
}

.input-group .unit-select,
.input-group .unit-select .select {
  display: flex;
  flex: none;
  height: 100%;
}

.input-group .unit-select {
  border-left: 1px solid var(--border);
}

.input-group .unit-select .select-trigger {
  height: 100%;
  border: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  box-shadow: none;
  background: transparent;
  padding-right: 28px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search .icon {
  position: absolute;
  left: 10px;
  color: var(--text-3);
  pointer-events: none;
}

.search .input {
  padding-left: 32px;
  padding-right: 30px;
}

.search .search-clear {
  position: absolute;
  right: 4px;
}

/* 下拉选择（自绘） */
.select {
  position: relative;
  min-width: 0;
}

.select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 30px;
  text-align: left;
  cursor: pointer;
}

.select-trigger .select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-trigger .select-placeholder {
  color: var(--text-4);
}

.select-trigger .chev {
  position: absolute;
  right: 9px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  color: var(--text-3);
  pointer-events: none;
  transition: transform var(--dur-fast);
}

.select-trigger[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.select--inline .select-trigger {
  width: auto;
}

/* 弹出层（下拉、菜单） */
.popover {
  position: fixed;
  z-index: 80;
  min-width: 160px;
  max-width: min(360px, calc(100vw - 16px));
  padding: 4px;
  border: 1px solid var(--pop-border);
  border-radius: var(--r-md);
  background: var(--elevated);
  box-shadow: var(--shadow-pop);
  transform-origin: var(--origin, top left);
  animation: pop-in var(--dur) var(--ease-out);
  overflow: hidden;
}

.popover[data-leaving="true"] {
  animation: pop-out var(--dur-fast) var(--ease-in) forwards;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

@keyframes pop-out {
  to {
    opacity: 0;
    transform: translateY(-2px) scale(0.99);
  }
}

.popover-search {
  padding: 4px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.popover-search .input {
  height: 30px;
}

.listbox {
  max-height: min(320px, 50dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.option,
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-md);
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.option[aria-selected="true"] {
  font-weight: 500;
}

.option .opt-check {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--accent);
  flex: none;
}

.option[data-active="true"],
.menu-item:focus {
  background: var(--hover);
}

.menu-item:focus-visible {
  outline: none;
  background: var(--press);
}

@media (hover: hover) {
  .menu-item:hover:not([aria-disabled="true"]) {
    background: var(--hover);
  }
}

.option[aria-disabled="true"],
.menu-item[aria-disabled="true"] {
  color: var(--text-4);
  cursor: not-allowed;
}

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

.option-hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 400;
}

.menu-item .icon {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}

.menu-item--danger {
  color: var(--danger);
}

.menu-item--danger .icon {
  color: var(--danger);
}

.menu-item .menu-hint {
  margin-left: auto;
  padding-left: 12px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}

.menu-label {
  padding: 6px 10px 2px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.empty-option {
  padding: 12px 10px;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
}

.switch input {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease-out);
}

.switch input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform var(--dur) var(--ease-out);
}

.switch input:checked {
  background: var(--accent-solid);
}

.switch input:checked::before {
  transform: translateX(14px);
}

.switch input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch:has(input:disabled) {
  cursor: not-allowed;
}

.switch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.switch-label {
  font-weight: 500;
  font-size: var(--fs-md);
}

.switch-hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* 开关行：设置项 */
.setting {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
}

.setting + .setting {
  border-top: 1px solid var(--border);
}

.setting-text {
  min-width: 0;
}

.setting-title {
  font-weight: 500;
}

.setting-desc {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: 64ch;
}

.setting-control {
  flex: none;
  padding-top: 2px;
}

/* 复选框与单选 */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
}

.cb,
.radio {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1.5px solid var(--text-4);
  border-radius: var(--r-xs);
  background: var(--surface);
  cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast);
}

.radio {
  border-radius: 50%;
}

.cb:checked,
.cb:indeterminate,
.radio:checked {
  border-color: var(--accent-solid);
  background: var(--accent-solid);
}

.cb:checked::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.cb:indeterminate::after {
  content: "";
  position: absolute;
  left: 2.5px;
  top: 5.5px;
  width: 8px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

.radio:checked::after {
  content: "";
  position: absolute;
  inset: 3.5px;
  border-radius: 50%;
  background: #fff;
}

.cb:disabled,
.radio:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.check:has(:disabled) {
  cursor: not-allowed;
  color: var(--text-3);
}

.check-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.check-hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* 大的选项卡片（如权限选择） */
.choice-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-2);
}

.choice {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--dur-fast), background-color var(--dur-fast);
}

@media (hover: hover) {
  .choice:hover {
    border-color: var(--text-4);
  }
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.choice:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.choice-title {
  display: block;
  font-weight: 500;
}

.choice-desc {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* 分段控件 */
.seg {
  display: inline-flex;
  flex: none;
  padding: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.seg button {
  height: calc(var(--control-h) - 6px);
  padding: 0 10px;
  border-radius: 4px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

@media (hover: hover) {
  .seg button:hover {
    color: var(--text);
  }
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-strong);
}

/* 标签输入 */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: var(--control-h);
  padding: 3px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: text;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.tag-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}

.tag-input[data-invalid="true"] {
  border-color: var(--danger);
}

.tag-input input:focus-visible,
.stepper input:focus-visible,
.otp-input:focus-visible {
  outline: none;
}

.tag-input input {
  flex: 1 0 120px;
  min-width: 80px;
  height: calc(var(--control-h) - 8px);
  padding: 0 4px;
  border: 0;
  background: transparent;
  font-size: var(--input-fs);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  height: 24px;
  padding: 0 2px 0 8px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip button {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  color: var(--text-3);
}

.chip button .icon {
  width: 12px;
  height: 12px;
}

@media (hover: hover) {
  .chip button:hover {
    background: var(--hover);
    color: var(--text);
  }
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip--static {
  padding-right: 8px;
}

/* 选项卡 */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--dur-fast);
}

@media (hover: hover) {
  .tab:hover {
    color: var(--text);
  }
}

.tab[aria-selected="true"] {
  color: var(--text);
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.tab .count {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* 表格（容器查询：变窄先藏次要列，再变卡片） */
.table-wrap {
  container: tbl / inline-size;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: opacity var(--dur);
}

.table-wrap[data-stale="true"] {
  opacity: 0.55;
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--r-md);
}

.tbl {
  width: 100%;
  table-layout: auto;
  font-size: var(--fs-md);
}

.tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 36px;
  padding: 0 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.tbl th:first-child {
  border-top-left-radius: var(--r-md);
}

.tbl th:last-child {
  border-top-right-radius: var(--r-md);
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}

.sort-btn .icon {
  width: 12px;
  height: 12px;
  opacity: 0.4;
}

th[aria-sort] .sort-btn {
  color: var(--text);
}

th[aria-sort] .sort-btn .icon {
  opacity: 1;
}

.tbl td {
  height: 44px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 0;
}

.tbl tr:last-child td {
  border-bottom: 0;
}

.tbl td.fit,
.tbl th.fit {
  width: 1%;
  max-width: none;
  white-space: nowrap;
}

.tbl .right {
  text-align: right;
}

.tbl .center {
  text-align: center;
}

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

.tbl tbody tr {
  transition: background-color var(--dur-fast);
}

.tbl tbody tr[data-clickable="true"] {
  cursor: pointer;
}

@media (hover: hover) {
  .tbl tbody tr:hover {
    background: var(--surface-2);
  }
}

.tbl tbody tr[aria-selected="true"] {
  background: var(--accent-soft);
}

.tbl tbody tr[data-flash="true"] {
  animation: flash 1.6s var(--ease-out);
}

@keyframes flash {
  0%, 30% {
    background: var(--accent-soft-2);
  }
}

.cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.35;
}

.cell-stack > * {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-stack > .badge {
  overflow: visible;
}

.cell-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.cell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.tbl-more {
  display: flex;
  justify-content: center;
  padding: var(--s-3);
  border-top: 1px solid var(--border);
}

.tbl-foot-note {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* 列的重要程度：p2 在中等宽度隐藏，p3 更早隐藏 */
@container tbl (max-width: 1080px) {
  .tbl .p3 {
    display: none;
  }
}

@container tbl (max-width: 860px) {
  .tbl .p2 {
    display: none;
  }
}

/* 卡片形态 */
@container tbl (max-width: 600px) {
  .table-wrap {
    border: 0;
    background: transparent;
  }

  .tbl,
  .tbl tbody {
    display: block;
  }

  .tbl thead {
    display: none;
  }

  .tbl tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .tbl tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "title status actions"
      "sub sub sub"
      "meta meta meta";
    align-items: center;
    column-gap: 8px;
    padding: 10px 6px 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
  }

  .tbl tbody tr[aria-selected="true"] {
    border-color: var(--accent);
  }

  .tbl td,
  .tbl td.fit {
    display: block;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    max-width: none;
    min-width: 0;
  }

  .tbl td.p2,
  .tbl td.p3 {
    display: none;
  }

  .tbl td[data-card="title"] {
    grid-area: title;
    font-weight: 500;
  }

  .tbl td[data-card="status"] {
    grid-area: status;
  }

  .tbl td[data-card="actions"] {
    grid-area: actions;
  }

  .tbl td[data-card="sub"] {
    grid-area: sub;
    margin-top: 2px;
    color: var(--text-2);
    font-size: var(--fs-sm);
  }

  .tbl td[data-card="meta"] {
    grid-area: meta;
    margin-top: 2px;
    color: var(--text-3);
    font-size: var(--fs-xs);
  }

  .tbl td[data-card="lead"] {
    grid-row: 1 / span 3;
    grid-column: 1;
    margin-right: 4px;
    align-self: start;
  }

  .tbl tbody tr:has(td[data-card="lead"]) {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "lead title status actions"
      "lead sub sub sub"
      "lead meta meta meta";
  }

  .tbl tbody tr:has(td[data-card="lead"]) td[data-card="lead"] {
    grid-area: lead;
  }

  .tbl td[data-card="hide"],
  .tbl td:not([data-card]) {
    display: none;
  }

  .tbl td.right {
    text-align: left;
  }

  .tbl .card-inline {
    display: inline;
  }

  .tbl .card-hide {
    display: none;
  }

  .tbl-more {
    border-top: 0;
  }

  .tbl-foot-note {
    border-top: 0;
    padding-left: 2px;
  }
}

.card-only {
  display: none;
}

@container tbl (max-width: 600px) {
  .card-only {
    display: inline;
  }
}

/* 键值列表 */
.kv {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
  gap: 10px var(--s-5);
  font-size: var(--fs-md);
}

.kv dt {
  color: var(--text-3);
  font-size: var(--fs-sm);
  padding-top: 1px;
}

.kv dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.kv dd .row {
  flex-wrap: wrap;
}

@container (max-width: 420px) {
  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .kv dd {
    margin-bottom: 8px;
  }
}

/* 复制按钮 */
.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.copy-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: var(--r-xs);
  color: var(--text-3);
  transition: color var(--dur-fast), background-color var(--dur-fast);
}

.copy-btn .icon {
  width: 14px;
  height: 14px;
}

@media (hover: hover) {
  .copy-btn:hover {
    background: var(--hover);
    color: var(--text);
  }
}

.copy-btn[data-copied="true"] {
  color: var(--success);
}

@media (pointer: coarse) {
  .copy-btn {
    width: 34px;
    height: 34px;
  }
}

/* 代码块 */
.code-block {
  position: relative;
  padding: 10px 40px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 320px;
  overflow: auto;
}

.code-block .copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-family: var(--mono);
  font-size: var(--fs-md);
  word-break: break-all;
}

.secret-box > span {
  flex: 1;
  min-width: 0;
  user-select: all;
}

/* 提示条 */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.alert > .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex: none;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  color: var(--text);
  font-weight: 500;
}

.alert-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: 8px;
  flex-wrap: wrap;
}

.alert--info {
  background: var(--info-soft);
  border-color: transparent;
}

.alert--info > .icon {
  color: var(--info);
}

.alert--warning {
  background: var(--warning-soft);
  border-color: transparent;
}

.alert--warning > .icon {
  color: var(--warning);
}

.alert--danger {
  background: var(--danger-soft);
  border-color: transparent;
}

.alert--danger > .icon {
  color: var(--danger);
}

.alert--success {
  background: var(--success-soft);
  border-color: transparent;
}

.alert--success > .icon {
  color: var(--success);
}

.alert .alert-close {
  margin: -4px -4px -4px 0;
}

/* 空状态 */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--s-10) var(--s-5);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
}

.empty-icon .icon {
  width: 22px;
  height: 22px;
}

.empty-title {
  font-weight: 600;
  font-size: var(--fs-md);
}

.empty-desc {
  max-width: 44ch;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.empty-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-3);
  flex-wrap: wrap;
  justify-content: center;
}

.empty--compact {
  padding: var(--s-6) var(--s-4);
}

/* 骨架屏 */
.sk {
  display: block;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-shine) 50%, var(--skeleton) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.sk--text {
  height: 12px;
  margin: 4px 0;
}

.sk--title {
  height: 18px;
  width: 40%;
}

.sk--block {
  height: 100%;
  border-radius: var(--r-md);
}

.sk-rows {
  display: flex;
  flex-direction: column;
}

.sk-row {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}

.sk-row:last-child {
  border-bottom: 0;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

.fade-in {
  animation: fade-in var(--dur-slow) var(--ease-out);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* 对话框 / 底部面板 / 抽屉 */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: max(24px, var(--safe-top));
  padding-bottom: max(24px, var(--safe-bottom));
}

.scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: fade-in var(--dur) var(--ease-out);
}

.overlay[data-leaving="true"] .scrim {
  animation: fade-out var(--dur-fast) var(--ease-in) forwards;
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

.dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: min(760px, calc(100dvh - 48px));
  border-radius: var(--r-lg);
  background: var(--elevated);
  border: 1px solid var(--pop-border);
  box-shadow: var(--shadow-pop);
  animation: dialog-in var(--dur-slow) var(--ease-out);
  container: dialog / inline-size;
}

.dialog--wide {
  max-width: 640px;
}

.dialog--xl {
  max-width: 820px;
}

.overlay[data-leaving="true"] .dialog {
  animation: dialog-out var(--dur-fast) var(--ease-in) forwards;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes dialog-out {
  to {
    opacity: 0;
    transform: translateY(4px) scale(0.99);
  }
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-5) 0;
}

.dialog-head h2 {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-lg);
}

.dialog-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 400;
}

.dialog-close {
  margin: -6px -8px 0 0;
}

.dialog-body {
  flex: 1;
  min-height: 0;
  padding: var(--s-4) var(--s-5) var(--s-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.confirm-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}

.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5) var(--s-4);
  border-top: 1px solid var(--border);
}

.dialog-foot .grow {
  flex: 1;
}

.sheet-handle {
  display: none;
}

/* 手机上对话框变成底部面板 */
@media (max-width: 760px) {
  .overlay {
    align-items: flex-end;
    padding: 0;
    padding-top: calc(var(--safe-top) + 24px);
  }

  .dialog,
  .dialog--wide,
  .dialog--xl {
    max-width: none;
    max-height: calc(100dvh - var(--safe-top) - 24px);
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    padding-bottom: var(--safe-bottom);
    box-shadow: var(--shadow-sheet);
    animation: sheet-in var(--dur-slow) var(--ease-out);
  }

  .overlay[data-leaving="true"] .dialog {
    animation: sheet-out var(--dur) var(--ease-in) forwards;
  }

  .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    margin: 8px auto -8px;
    border-radius: 2px;
    background: var(--border-strong);
  }

  .dialog-head {
    padding: var(--s-4) var(--s-4) 0;
  }

  .dialog-body {
    padding: var(--s-3) var(--s-4) var(--s-4);
  }

  .dialog-foot {
    padding: var(--s-3) var(--s-4);
    flex-wrap: wrap-reverse;
  }

  .dialog-foot .btn {
    flex: 1 1 auto;
  }

  .dialog-foot .grow {
    display: none;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}

/* 右侧抽屉（详情） */
.overlay--drawer {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}

.drawer {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(520px, 100vw);
  height: 100%;
  background: var(--elevated);
  border-left: 1px solid var(--pop-border);
  box-shadow: var(--shadow-pop);
  animation: drawer-in var(--dur-slow) var(--ease-out);
  container: drawer / inline-size;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.drawer--wide {
  width: min(680px, 100vw);
}

.overlay[data-leaving="true"] .drawer {
  animation: drawer-out var(--dur) var(--ease-in) forwards;
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}

@keyframes drawer-out {
  to {
    transform: translateX(100%);
  }
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  font-size: var(--fs-lg);
  min-width: 0;
  overflow-wrap: anywhere;
}

.drawer-head .grow {
  min-width: 0;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  padding: var(--s-4) var(--s-5) var(--s-6);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer-foot {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
  .overlay--drawer {
    align-items: flex-end;
    padding-top: calc(var(--safe-top) + 24px);
  }

  .drawer,
  .drawer--wide {
    width: 100%;
    height: auto;
    max-height: calc(100dvh - var(--safe-top) - 24px);
    border-left: 0;
    border-radius: 16px 16px 0 0;
    padding-top: 0;
    animation: sheet-in var(--dur-slow) var(--ease-out);
  }

  .overlay[data-leaving="true"] .drawer {
    animation: sheet-out var(--dur) var(--ease-in) forwards;
  }

  .drawer-head {
    padding: var(--s-4);
  }

  .drawer-body {
    padding: var(--s-4);
  }

  .drawer-foot {
    padding: var(--s-3) var(--s-4);
  }

  .drawer-foot .btn {
    flex: 1 1 auto;
  }
}

/* 动作面板（手机上的“⋯”菜单与下拉） */
.action-sheet {
  position: relative;
  width: 100%;
  max-height: calc(100dvh - var(--safe-top) - 48px);
  display: flex;
  flex-direction: column;
  padding: 6px 8px calc(8px + var(--safe-bottom));
  border-radius: 16px 16px 0 0;
  background: var(--elevated);
  box-shadow: var(--shadow-sheet);
  animation: sheet-in var(--dur-slow) var(--ease-out);
}

.overlay[data-leaving="true"] .action-sheet {
  animation: sheet-out var(--dur) var(--ease-in) forwards;
}

.action-sheet .sheet-handle {
  display: block;
  margin: 2px auto 8px;
}

.action-sheet-title {
  padding: 4px 12px 8px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-sheet .listbox {
  max-height: none;
  flex: 1;
  min-height: 0;
}

.action-sheet .menu-item,
.action-sheet .option {
  min-height: 48px;
  padding: 10px 12px;
  font-size: var(--fs-lg);
}

.action-sheet .menu-item .icon {
  width: 20px;
  height: 20px;
}

.action-sheet .popover-search .input {
  height: 40px;
}

.action-sheet-cancel {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.action-sheet-cancel .btn {
  width: 100%;
  height: 46px;
  font-size: var(--fs-lg);
}

/* 轻提示 */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 10px 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--pop-border);
  background: var(--elevated);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-md);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-out);
}

.toast[data-leaving="true"] {
  animation: toast-out var(--dur) var(--ease-in) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(4px);
  }
}

.toast > .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: none;
}

.toast--success > .icon {
  color: var(--success);
}

.toast--error > .icon {
  color: var(--danger);
}

.toast--info > .icon {
  color: var(--info);
}

.toast-body {
  min-width: 0;
  flex: 1;
  padding-top: 1px;
}

.toast-msg {
  overflow-wrap: anywhere;
}

.toast-detail {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.toast-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin: -2px 0;
}

/* 上传面板占着右下角时，提示移到左下角（手机上移到顶部） */
.has-uploads .toasts {
  right: auto;
  left: 16px;
  align-items: flex-start;
}

@media (max-width: 760px) {
  .toasts,
  .has-uploads .toasts {
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--safe-bottom));
    align-items: stretch;
  }

  .has-uploads .toasts {
    top: calc(12px + var(--safe-top));
    bottom: auto;
  }

  .toast {
    width: auto;
    max-width: none;
  }
}

/* 气泡说明（ⓘ） */
.tip-pop {
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.55;
}

/* 进度条 */
.progress {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  border: 0;
  overflow: hidden;
}

.progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 2px;
  background: var(--accent-solid);
  transition: width var(--dur) linear;
}

.progress[data-tone="danger"] > span {
  background: var(--danger);
}

.progress[data-tone="success"] > span {
  background: var(--success);
}

/* 计量条 */
.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent-solid);
}

.meter[data-tone="warning"] > span {
  background: var(--warning);
}

.meter[data-tone="danger"] > span {
  background: var(--danger);
}

/* 检查清单 */
.checks {
  display: flex;
  flex-direction: column;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.check-item:first-child {
  border-top: 0;
}

.check-item > .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.check-item[data-status="pass"] > .icon {
  color: var(--success);
}

.check-item[data-status="fail"][data-level="error"] > .icon {
  color: var(--danger);
}

.check-item[data-status="fail"][data-level="warn"] > .icon {
  color: var(--warning);
}

.check-item[data-status="skip"] > .icon {
  color: var(--text-4);
}

.check-name {
  font-weight: 500;
}

.check-msg {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* 统计带：一个面板内的多项指标 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 14px 16px;
  border-left: 1px solid var(--border);
  margin-left: -1px;
  border-top: 1px solid var(--border);
  margin-top: -1px;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.stat-label .icon {
  width: 14px;
  height: 14px;
}

.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value--text {
  font-size: var(--fs-lg);
  line-height: 1.45;
}

.stat-value small {
  margin-left: 4px;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0;
}

.stat-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 6px;
  min-width: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.stat-foot > * {
  white-space: nowrap;
}

.stat a {
  color: inherit;
}

/* 两栏 */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-5);
}

@container page (max-width: 900px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 排行条 */
.rank {
  display: flex;
  flex-direction: column;
}

.rank-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}

.rank-item:first-child {
  border-top: 0;
}

a.rank-item {
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: var(--r-sm);
  color: inherit;
}

a.rank-item:hover {
  text-decoration: none;
}

@media (hover: hover) {
  a.rank-item:hover {
    background: var(--hover);
  }
}

.rank-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.rank-bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.rank-bar > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--text-4);
}

.rank-bar[data-tone="danger"] > span {
  background: var(--chart-fail);
}

/* ---------- 6. 页面 ---------- */

/* 登录 */
.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-brand .brand-mark {
  width: 36px;
  height: 36px;
}

.login-brand-name {
  font-weight: 600;
  font-size: var(--fs-lg);
}

.login-brand-host {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow-wrap: anywhere;
}

.login h1 {
  font-size: var(--fs-xl);
}

.login-desc {
  margin-top: 6px;
  color: var(--text-2);
}

.login-desc b {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 0.95em;
}

.otp {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 24px;
}

.otp-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  letter-spacing: 0;
  opacity: 0.01;
  z-index: 2;
}

.otp-cell {
  display: grid;
  place-items: center;
  height: 52px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 22px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}

.otp[data-focus="true"] .otp-cell[data-active="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}

.otp-cell[data-active="true"]::after {
  content: "";
  width: 1.5px;
  height: 22px;
  background: var(--accent);
  animation: caret 1s steps(1) infinite;
}

.otp[data-focus="false"] .otp-cell[data-active="true"]::after {
  display: none;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

.otp[data-state="error"] .otp-cell {
  border-color: var(--danger);
}

.otp[data-state="error"] {
  animation: shake 0.32s var(--ease-out);
}

.otp[data-state="busy"] .otp-cell {
  color: var(--text-3);
}

.otp[data-disabled="true"] .otp-cell {
  background: var(--surface-2);
  color: var(--text-4);
}

@keyframes shake {
  20% {
    transform: translateX(-6px);
  }

  45% {
    transform: translateX(5px);
  }

  70% {
    transform: translateX(-3px);
  }
}

.login-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 44px;
  margin-top: 14px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.login-status .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex: none;
}

.login-status[data-tone="error"] {
  color: var(--danger);
}

.login-status[data-tone="warn"] {
  color: var(--warning);
}

.login-foot {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.login-foot p + p {
  margin-top: 4px;
}

/* 重新登录对话框中的输入 */
.dialog .otp {
  margin-top: 8px;
}

/* 概览图表 */
.chart {
  position: relative;
  user-select: none;
}

.chart svg {
  width: 100%;
  overflow: visible;
}

.chart .grid line {
  stroke: var(--chart-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart .baseline {
  stroke: var(--chart-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart .tick {
  fill: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .bar-ok {
  fill: var(--chart-ok);
}

.chart .bar-fail {
  fill: var(--chart-fail);
}

.chart .col-hit {
  fill: transparent;
  cursor: default;
}

.chart .col-hit:focus-visible {
  outline: none;
  stroke: var(--focus);
  stroke-width: 2;
}

.chart .col[data-dim="true"] .bar-ok,
.chart .col[data-dim="true"] .bar-fail {
  opacity: 0.45;
}

.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 132px;
  padding: 8px 10px;
  border: 1px solid var(--pop-border);
  border-radius: var(--r-sm);
  background: var(--elevated);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-xs);
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}

.chart-tip-title {
  color: var(--text-3);
  margin-bottom: 4px;
}

.chart-tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-tip-row b {
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}

.key-line {
  width: 10px;
  height: 3px;
  border-radius: 2px;
  flex: none;
}

.key-line--ok {
  background: var(--chart-ok);
}

.key-line--fail {
  background: var(--chart-fail);
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-swatch--ok {
  background: var(--chart-ok);
}

.legend-swatch--fail {
  background: var(--chart-fail);
}

.chart-panel-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}

.chart-figure {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.chart-figure-value {
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.1;
}

.chart-figure-sub {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* 引导步骤 */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3);
  counter-reset: step;
}

.step {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.step-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
}

.step[data-done="true"] .step-num {
  border-color: transparent;
  background: var(--success-soft);
  color: var(--success);
}

.step-title {
  font-weight: 500;
}

.step-desc {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.step .btn {
  margin-top: 10px;
}

/* 文件浏览器 */
.files-alert {
  margin-bottom: var(--s-3);
}

.explorer {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  flex: 1;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.explorer[data-tree="false"] {
  grid-template-columns: minmax(0, 1fr);
}

.tree-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.tree-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 6px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* Bucket 切换：桌面在目录树顶部，手机在文件列表上方 */
.bucket-switch {
  flex: 1;
  min-width: 0;
}

.bucket-switch .select-trigger,
.bucket-switch--static {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 28px 0 8px;
  border-color: transparent;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--text);
}

.bucket-switch--static {
  padding-right: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
}

.bucket-switch .select-value {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bucket-switch .icon {
  color: var(--text-3);
}

.bucket-switch-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.bucket-switch-region {
  flex: none;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

@media (hover: hover) {
  .bucket-switch .select-trigger:hover:not(:disabled):not([aria-expanded="true"]) {
    border-color: transparent;
    background: var(--hover);
  }
}

.files-bucket {
  display: flex;
  padding: 6px 8px 0;
}

.tree {
  flex: 1;
  min-height: 0;
  padding: 6px;
  overflow: auto;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  padding-right: 6px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}

@media (hover: hover) {
  .tree-row:hover {
    background: var(--hover);
    color: var(--text);
  }
}

.tree-row[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--text);
}

.tree-row[aria-selected="true"] .tree-icon {
  color: var(--accent);
}

.tree-row:focus-visible {
  outline-offset: -2px;
}

.tree-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  color: var(--text-3);
}

.tree-toggle .icon {
  width: 14px;
  height: 14px;
  transition: transform var(--dur-fast);
}

.tree-toggle[data-open="true"] .icon {
  transform: rotate(90deg);
}

@media (hover: hover) {
  .tree-toggle:hover {
    background: var(--press);
    color: var(--text);
  }
}

.tree-toggle[data-empty="true"] {
  visibility: hidden;
}

.tree-icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  color: var(--text-3);
  flex: none;
}

.tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--fs-md);
}

.tree-ns {
  margin-left: auto;
  padding-left: 6px;
}

.tree-children {
  display: flex;
  flex-direction: column;
}

.tree-note {
  height: 26px;
  padding-left: 30px;
  display: flex;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.files-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.files-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid var(--border);
}

.pathbar {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  cursor: text;
  overflow: hidden;
}

@media (hover: hover) {
  .pathbar:hover {
    border-color: var(--border);
  }
}

.pathbar-segs {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.pathbar-segs::-webkit-scrollbar {
  display: none;
}

.pathbar-seg {
  flex: none;
  min-width: 0;
  max-width: 220px;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.pathbar-seg:last-child {
  color: var(--text);
  font-weight: 500;
}

@media (hover: hover) {
  .pathbar-seg:hover {
    background: var(--hover);
    color: var(--text);
  }
}

.pathbar-seg--root {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pathbar-seg--root .icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

.pathbar-sep {
  flex: none;
  color: var(--text-4);
  padding: 0 1px;
}

.pathbar-ellipsis {
  flex: none;
  color: var(--text-3);
  padding: 0 4px;
}

.pathbar .input {
  height: 30px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.files-filter {
  width: 200px;
  flex: none;
}

.files-filter .input {
  height: 30px;
}

.ns-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
  min-width: 0;
}

.ns-strip a {
  font-weight: 500;
}

.files-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  container: files / inline-size;
}

.ftable {
  width: 100%;
  font-size: var(--fs-md);
}

.ftable th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  padding: 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.ftable td {
  height: 40px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  max-width: 0;
  white-space: nowrap;
}

.ftable .c-check {
  width: 40px;
  max-width: none;
  padding-right: 0;
  padding-left: 14px;
}

.ftable .c-size {
  width: 104px;
  max-width: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.ftable .c-time {
  width: 132px;
  max-width: none;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.ftable .c-act {
  width: 84px;
  max-width: none;
  padding-right: 8px;
}

.ftable tbody tr {
  transition: background-color var(--dur-fast);
}

@media (hover: hover) {
  .ftable tbody tr:hover {
    background: var(--surface-2);
  }

  .ftable tbody tr:hover .row-quick {
    opacity: 1;
  }
}

.ftable tbody tr[aria-selected="true"] {
  background: var(--accent-soft);
}

.ftable tbody tr[data-pending="true"] {
  color: var(--text-3);
}

.ftable tbody tr[data-flash="true"] {
  animation: flash 1.6s var(--ease-out);
}

.fname {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fname .ficon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--text-3);
}

.fname .ficon--folder {
  color: var(--accent);
}

.fname .ficon--virtual {
  color: var(--text-4);
}

.fname-btn {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  text-align: left;
}

@media (hover: hover) {
  .fname-btn:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}

.fname .input {
  height: 28px;
  font-size: var(--fs-md);
}

.row-quick {
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.ftable tbody tr:focus-within .row-quick,
.ftable tbody tr[aria-selected="true"] .row-quick {
  opacity: 1;
}

@media (hover: none) {
  .row-quick {
    display: none;
  }
}

.files-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  animation: rise-in var(--dur) var(--ease-out);
}

.selection-bar .count {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}

@keyframes rise-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

.drop-hint {
  position: absolute;
  inset: 6px;
  z-index: 10;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--accent);
  font-weight: 500;
  pointer-events: none;
  animation: fade-in var(--dur-fast);
}

.drop-hint-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.drop-hint .icon {
  width: 28px;
  height: 28px;
}

/* 文件列表在窄容器下 */
@container files (max-width: 640px) {
  .ftable thead {
    display: none;
  }

  .ftable .c-time,
  .ftable .c-size {
    display: none;
  }

  .ftable td {
    height: 56px;
  }

  .ftable .c-check {
    width: 36px;
    padding-left: 12px;
  }

  .fmeta {
    display: block !important;
  }

  .ftable .c-act {
    width: 48px;
  }
}

.fmeta {
  display: none;
  margin-top: 1px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.fname-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.explorer-mobile-bar {
  display: none;
}

@container page (max-width: 760px) {
  .explorer {
    grid-template-columns: minmax(0, 1fr);
    border: 0;
    border-radius: 0;
    margin: 0 calc(var(--s-4) * -1);
    min-height: 0;
    overflow: visible;
  }

  .tree-pane {
    display: none;
  }

  .files-filter {
    display: none;
  }

  .files-pane {
    overflow: visible;
  }

  .files-scroll {
    overflow: visible;
  }

  .ftable th {
    position: static;
  }

  .selection-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding-bottom: calc(8px + var(--safe-bottom));
    box-shadow: var(--shadow-sheet);
  }
}

/* 上传面板 */
.uploads {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 65;
  width: min(380px, calc(100vw - 32px));
  border: 1px solid var(--pop-border);
  border-radius: var(--r-lg);
  background: var(--elevated);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: rise-in var(--dur-slow) var(--ease-out);
}

.uploads-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 14px;
}

.uploads-head .grow {
  min-width: 0;
}

.uploads-title {
  font-weight: 600;
  font-size: var(--fs-md);
}

.uploads-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.uploads-overall {
  margin: 0 14px 10px;
}

.uploads-bulk {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--warning-soft);
  font-size: var(--fs-xs);
  align-items: center;
}

.uploads-bulk .grow {
  color: var(--warning);
  font-weight: 500;
}

.uploads-list {
  max-height: min(320px, 46dvh);
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.up-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid var(--border);
}

.up-item:last-child {
  border-bottom: 0;
}

.up-item > .icon {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}

.up-item[data-status="done"] > .icon {
  color: var(--success);
}

.up-item[data-status="error"] > .icon,
.up-item[data-status="conflict"] > .icon {
  color: var(--danger);
}

.up-item[data-status="conflict"] > .icon {
  color: var(--warning);
}

.up-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm);
}

.up-bucket {
  color: var(--text-3);
}

.up-meta {
  grid-column: 2;
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-item[data-status="error"] .up-meta {
  color: var(--danger);
  white-space: normal;
}

.up-item .progress {
  grid-column: 2;
  margin-top: 4px;
}

.up-actions {
  grid-row: 1 / span 3;
  grid-column: 3;
  display: flex;
  gap: 2px;
}

.up-conflict {
  grid-column: 2 / -1;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.uploads[data-collapsed="true"] .uploads-list,
.uploads[data-collapsed="true"] .uploads-bulk {
  display: none;
}

/* 保存条出现时，上传面板让出底部 */
html:has(.save-bar) .uploads {
  bottom: 88px;
}

@media (max-width: 760px) {
  html:has(.save-bar) .uploads {
    bottom: calc(120px + var(--safe-bottom));
  }

  .uploads {
    left: 8px;
    right: 8px;
    bottom: calc(8px + var(--safe-bottom));
    width: auto;
  }
}

/* 命名空间详情 */
.ns-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: -8px 0 var(--s-5);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.ns-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ns-meta b {
  color: var(--text-2);
  font-weight: 500;
}

/* 策略表单 */
.policy-section {
  padding: var(--s-5) 0;
  border-top: 1px solid var(--border);
}

.policy-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.policy-section > h3 {
  font-size: var(--fs-md);
  margin-bottom: 4px;
}

.policy-section > p {
  margin-bottom: var(--s-4);
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: 72ch;
}

.override {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 8px var(--s-5);
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.override:first-of-type {
  border-top: 0;
}

.override-label {
  font-weight: 500;
  font-size: var(--fs-md);
}

.override-global {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
}

.override-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

@container (max-width: 620px) {
  .override {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 保存条（有未保存修改时出现） */
.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: var(--s-5);
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--pop-border);
  border-radius: var(--r-lg);
  background: var(--elevated);
  box-shadow: var(--shadow-pop);
  animation: rise-in var(--dur) var(--ease-out);
}

.save-bar .grow {
  font-size: var(--fs-sm);
  color: var(--text-2);
}

@media (max-width: 760px) {
  .save-bar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + var(--safe-bottom));
    margin: 0;
    flex-wrap: wrap;
  }

  .save-bar .grow {
    flex-basis: 100%;
  }

  .save-bar .btn {
    flex: 1;
  }
}

/* 运行状态 */
.thread-viz {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.thread-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent-soft-2);
}

.thread-dot[data-busy="true"] {
  background: var(--accent-solid);
}

.stepper {
  display: inline-flex;
  align-items: center;
  height: var(--control-h);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.stepper button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 100%;
  color: var(--text-2);
}

.stepper button:disabled {
  color: var(--text-4);
}

@media (hover: hover) {
  .stepper button:hover:not(:disabled) {
    background: var(--hover);
    color: var(--text);
  }
}

.stepper input {
  width: 48px;
  height: 100%;
  border: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: transparent;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: var(--input-fs);
}

.stepper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}

@media (pointer: coarse) {
  .stepper button {
    width: 40px;
  }
}

/* 文件详情 */
.preview {
  display: grid;
  place-items: center;
  min-height: 120px;
  max-height: 360px;
  margin-bottom: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
}

.preview img,
.preview video {
  max-height: 358px;
  width: auto;
  object-fit: contain;
}

.preview audio {
  width: calc(100% - 24px);
}

.meta-table {
  width: 100%;
  font-size: var(--fs-sm);
}

.meta-table td {
  padding: 6px 0;
  border-top: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.meta-table td:first-child {
  width: 40%;
  padding-right: 12px;
  color: var(--text-3);
  font-family: var(--mono);
}

/* 审计详情里的 JSON */
.json {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 新记录提示 */
.new-pill {
  position: sticky;
  top: 8px;
  z-index: 4;
  display: flex;
  justify-content: center;
  height: 0;
  overflow: visible;
}

.new-pill button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-full);
  background: var(--accent-solid);
  color: var(--on-accent);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: rise-in var(--dur) var(--ease-out);
}

.new-pill .icon {
  width: 14px;
  height: 14px;
}

/* 未找到 */
.notfound {
  display: grid;
  place-items: center;
  min-height: 60vh;
}

/* ---------- 7. 动效与无障碍 ---------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 160ms;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .btn:active:not(:disabled),
  .icon-btn:active:not(:disabled) {
    transform: none !important;
  }

  .dialog,
  .drawer,
  .action-sheet,
  .popover,
  .toast,
  .uploads,
  .selection-bar,
  .save-bar,
  .new-pill button {
    animation-name: fade-in !important;
  }

  .overlay[data-leaving="true"] .dialog,
  .overlay[data-leaving="true"] .drawer,
  .overlay[data-leaving="true"] .action-sheet,
  .popover[data-leaving="true"],
  .toast[data-leaving="true"] {
    animation-name: fade-out !important;
  }

  .sidebar,
  .topbar,
  .app {
    transition: none !important;
  }

  .otp[data-state="error"] {
    animation: none;
  }

  .sk {
    animation: none;
  }

  .spinner {
    animation-duration: 1.4s;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

@media (forced-colors: active) {
  .btn,
  .input,
  .select-trigger,
  .badge,
  .cb,
  .radio,
  .switch input {
    border: 1px solid CanvasText;
  }

  .chart .bar-ok {
    fill: Highlight;
  }

  .chart .bar-fail {
    fill: Mark;
  }
}
