/* =========================================================================
   Admin Auth · "Ink" design system（黑白双主题）
   ---------------------------------------------------------------------
   概念：黑白灰的冷淡安全控制台。墨色侧边栏 + 中性画布 + 墨色主按钮，
   彩色只留给"状态语义"（成功/失败/风险）与 client 配色 chip。
   - 主题：全部颜色用 light-dark() 成对声明；html[data-theme=light|dark]
     强制主题，缺省跟随系统（color-scheme）。切换入口在右上角。
   - 字体：Bricolage Grotesque（拉丁展示）+ Spline Sans Mono（数据）
           + 系统中文（PingFang）。
   - 动效：页面加载 stagger 上浮；hover 微反馈；尊重 reduced-motion。
   ========================================================================= */

:root {
  color-scheme: light dark;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
             "Helvetica Neue", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", -apple-system, "SF Pro Display",
                  "PingFang SC", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* ── 纸与墨（中性灰阶） ── */
  --paper:        light-dark(#f6f6f7, #101113);
  --paper-deep:   light-dark(#ebebed, #1b1d20);
  --surface:      light-dark(#ffffff, #17191c);
  --surface-alt:  light-dark(#f2f2f4, #1e2124);

  --ink:          light-dark(#17181a, #ececee);
  --ink-2:        light-dark(#3e4045, #c6c8cc);
  --text:         var(--ink);
  --text-muted:   light-dark(#6c6e74, #96999f);
  --text-faint:   light-dark(#9b9da3, #67696f);

  --border:        light-dark(#e5e5e8, #24272b);
  --border-strong: light-dark(#d1d2d6, #34373c);

  /* ── 主色 = 墨（浅色下黑、深色下白） ── */
  --primary:          light-dark(#17181a, #f0f0f1);
  --primary-hover:    light-dark(#000000, #ffffff);
  --primary-contrast: light-dark(#ffffff, #121316);
  --focus-ring:       light-dark(rgba(23, 24, 26, 0.13), rgba(240, 240, 241, 0.16));
  --accent-bg:        light-dark(rgba(23, 24, 26, 0.06), rgba(240, 240, 241, 0.08));

  /* ── 语义色（状态专用，非主题装饰） ── */
  --green:    light-dark(#188045, #56bd83);
  --green-bg: light-dark(rgba(24, 128, 69, 0.10), rgba(86, 189, 131, 0.13));
  --red:      light-dark(#cf3a31, #ef8079);
  --red-bg:   light-dark(rgba(207, 58, 49, 0.09), rgba(239, 128, 121, 0.13));
  --amber:    light-dark(#ac6106, #dda23c);
  --amber-bg: light-dark(rgba(172, 97, 6, 0.11), rgba(221, 162, 60, 0.13));
  --blue:     light-dark(#2f5fd0, #86a8ee);
  --blue-bg:  light-dark(rgba(47, 95, 208, 0.09), rgba(134, 168, 238, 0.13));

  /* ── 侧边栏（两种主题下都是墨色） ── */
  --side-bg:      light-dark(#141517, #0b0c0e);
  --side-bg-deep: light-dark(#0f1012, #08090a);
  --side-edge:    light-dark(transparent, #202327);
  --side-text:    #a6a9af;
  --side-dim:     #63666c;
  --side-line:    rgba(255, 255, 255, 0.07);
  --side-hover:   rgba(255, 255, 255, 0.05);
  --side-active:  rgba(255, 255, 255, 0.08);
  --side-bright:  #ffffff;

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

  --shadow-1: 0 1px 2px light-dark(rgba(20, 20, 22, 0.05), rgba(0, 0, 0, 0.4));
  --shadow-2: 0 1px 2px light-dark(rgba(20, 20, 22, 0.05), rgba(0, 0, 0, 0.4)),
              0 4px 14px light-dark(rgba(20, 20, 22, 0.06), rgba(0, 0, 0, 0.45));
  --shadow-3: 0 2px 6px light-dark(rgba(20, 20, 22, 0.07), rgba(0, 0, 0, 0.5)),
              0 16px 40px light-dark(rgba(20, 20, 22, 0.13), rgba(0, 0, 0, 0.6));
}

/* 强制主题：右上角切换写入 html[data-theme]；缺省跟随系统 */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"]  { color-scheme: dark; }

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(light-dark(rgba(23, 24, 26, 0.04), rgba(236, 236, 238, 0.035)) 1px, transparent 1px) 0 0 / 26px 26px,
    var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}
a:hover { text-decoration: underline; text-underline-offset: 2px; }
/* 正文里的内容链接：常显下划线，可辨识 */
.page-subtitle a, .row-body a, .modal-body a, .empty a {
  text-decoration: underline;
  text-decoration-color: var(--text-faint);
  text-underline-offset: 2px;
}
.page-subtitle a:hover, .row-body a:hover, .modal-body a:hover, .empty a:hover {
  text-decoration-color: currentColor;
}

::selection { background: light-dark(rgba(23, 24, 26, 0.14), rgba(240, 240, 241, 0.22)); }

[hidden] { display: none !important; }

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

/* =========================================================================
   进场动效 —— 页面主区块 stagger 上浮
   ========================================================================= */

@media (prefers-reduced-motion: no-preference) {
  .main > * {
    animation: rise 420ms cubic-bezier(0.18, 0.75, 0.3, 1) backwards;
  }
  .main > *:nth-child(1) { animation-delay: 20ms; }
  .main > *:nth-child(2) { animation-delay: 70ms; }
  .main > *:nth-child(3) { animation-delay: 120ms; }
  .main > *:nth-child(4) { animation-delay: 170ms; }
  .main > *:nth-child(5) { animation-delay: 220ms; }
  .main > *:nth-child(n+6) { animation-delay: 260ms; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================================
   布局骨架
   ========================================================================= */

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  width: 100%;
  max-width: 1120px;
  min-width: 0;
  padding: 34px 40px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* =========================================================================
   侧边栏 —— 墨色导航
   ========================================================================= */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px 14px;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-deep) 100%);
  border-right: 1px solid var(--side-edge);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.14) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px 16px;
  border-bottom: 1px solid var(--side-line);
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #ffffff;
  color: #141517;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.09), 0 4px 12px rgba(0,0,0,.35);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.brand-text strong {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}
.brand-text span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--side-dim);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* ── workspace switcher ── */
.workspace-switcher {
  position: relative;
  margin: 0 2px;
}
.workspace-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--side-dim);
  padding: 0 8px 6px;
}
.workspace-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: #e7e8ea;
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease;
}
.workspace-trigger:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.20);
}
.workspace-trigger[aria-expanded="true"] {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}
.workspace-trigger svg { color: var(--side-dim); flex-shrink: 0; }
.workspace-current {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.workspace-current-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--side-dim);
  box-shadow: 0 0 0 3px rgba(255,255,255,.06);
}
.workspace-current-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* 下拉面板浮在墨色上 —— 用画布色形成反差 */
.workspace-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  z-index: 100;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panel-pop 150ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes panel-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
.workspace-search { padding: 8px; border-bottom: 1px solid var(--border); }
.workspace-search .input { font-size: 12.5px; height: 30px; }
.workspace-list {
  overflow-y: auto;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.workspace-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.workspace-option:hover { background: var(--surface-alt); }
.workspace-option.is-active {
  background: var(--accent-bg);
  font-weight: 600;
}
.workspace-option .opt-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-faint);
}
.workspace-option .opt-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workspace-option .opt-id {
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.workspace-option.global {
  border-top: 1px dashed var(--border);
  margin-top: 4px;
  padding-top: 10px;
  border-radius: 0 0 6px 6px;
}
.workspace-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* tone 圆点（workspace 与选项共用） */
.workspace-current-dot[data-tone="blue"],   .opt-dot[data-tone="blue"]   { background: #5b8def; }
.workspace-current-dot[data-tone="green"],  .opt-dot[data-tone="green"]  { background: #3fae72; }
.workspace-current-dot[data-tone="orange"], .opt-dot[data-tone="orange"] { background: #e29a4d; }
.workspace-current-dot[data-tone="pink"],   .opt-dot[data-tone="pink"]   { background: #e0708a; }
.workspace-current-dot[data-tone="purple"], .opt-dot[data-tone="purple"] { background: #a184e0; }
.workspace-current-dot[data-tone="teal"],   .opt-dot[data-tone="teal"]   { background: #3fbcac; }

/* ── 导航分组 ── */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-section-title {
  padding: 2px 10px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--side-dim);
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--side-text);
  font-size: 13px;
  transition: background 120ms ease, color 120ms ease;
}
.nav-item:hover {
  background: var(--side-hover);
  color: #e8e9eb;
  text-decoration: none;
}
.nav-item.is-active {
  background: var(--side-active);
  color: var(--side-bright);
  font-weight: 500;
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: var(--side-bright);
}
.nav-icon {
  display: grid;
  place-items: center;
  width: 16px;
  color: var(--side-dim);
  flex-shrink: 0;
  transition: color 120ms ease;
}
.nav-item:hover .nav-icon { color: var(--side-text); }
.nav-item.is-active .nav-icon { color: var(--side-bright); }
.nav-item > svg { color: var(--side-dim); flex-shrink: 0; }
.nav-item.is-active > svg { color: var(--side-bright); }

/* ── 底部用户区 ── */
.sidebar-user {
  margin-top: auto;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--side-line);
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.avatar-link { text-decoration: none; display: inline-flex; border-radius: 50%; }
.avatar-link:hover { text-decoration: none; }
.avatar-link:hover .avatar { border-color: rgba(255, 255, 255, 0.55); }
.sidebar-user .who {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
  flex: 1;
}
.sidebar-user .who strong {
  font-size: 12.5px;
  font-weight: 500;
  color: #e7e8ea;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user .who span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--side-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.icon-btn {
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--side-dim);
  transition: background 120ms ease, color 120ms ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
/* modal 头部的关闭按钮复用 .icon-btn，但落在卡片上 */
.modal .icon-btn { color: var(--text-faint); }
.modal .icon-btn:hover { background: var(--surface-alt); color: var(--text); }

/* =========================================================================
   页头
   ========================================================================= */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.page-eyebrow { display: none; }
.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.page-title em {
  font-style: normal;
  color: inherit;
}
.page-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  max-width: 72ch;
}
.page-subtitle code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--paper-deep);
  padding: 1px 5px;
  border-radius: 4px;
}
.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* =========================================================================
   按钮
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: background 100ms ease, border-color 100ms ease,
              transform 80ms ease, box-shadow 100ms ease;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: none; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 1px 0 light-dark(rgba(255,255,255,0.10), rgba(255,255,255,0.25)) inset,
              0 2px 8px light-dark(rgba(23, 24, 26, 0.22), rgba(0, 0, 0, 0.5));
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--accent-bg); }

.btn-destructive {
  background: light-dark(#cf3a31, #b23730);
  border-color: light-dark(#b1332b, #9c322c);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 2px 8px rgba(160, 48, 42, 0.3);
}
.btn-destructive:hover { background: light-dark(#b6332b, #c03e36); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 38px; padding: 0 18px; font-size: 14px; }

.icon-btn-sm {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}
.icon-btn-sm:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.icon-btn-sm.destructive:hover {
  background: var(--red-bg);
  border-color: light-dark(rgba(207, 58, 49, 0.35), rgba(239, 128, 121, 0.4));
  color: var(--red);
}

/* ── segmented（筛选/页签）── */
/* .main 为纵向 flex：避免直下的页签条被拉满整行 */
.main > .segmented, .main > .hstack { align-self: flex-start; }
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--paper-deep);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  gap: 2px;
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 4px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
  transition: color 100ms ease, background 100ms ease;
  white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active {
  background: light-dark(#ffffff, #34373c);
  color: var(--text);
  box-shadow: 0 1px 2px light-dark(rgba(20, 20, 22, 0.10), rgba(0, 0, 0, 0.4));
}

/* ── 搜索框 ── */
.search {
  position: relative;
  display: inline-block;
}
.search input {
  height: 34px;
  width: 250px;
  padding: 0 12px 0 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.search::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 13px;
  height: 13px;
  transform: translateY(-50%);
  background: var(--text-faint);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M10 18a8 8 0 1 1 5.293-2.293l4.5 4.5a1 1 0 0 1-1.414 1.414l-4.5-4.5A7.96 7.96 0 0 1 10 18Zm0-2a6 6 0 1 0 0-12a6 6 0 0 0 0 12Z'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M10 18a8 8 0 1 1 5.293-2.293l4.5 4.5a1 1 0 0 1-1.414 1.414l-4.5-4.5A7.96 7.96 0 0 1 10 18Zm0-2a6 6 0 1 0 0-12a6 6 0 0 0 0 12Z'/></svg>") center / contain no-repeat;
  pointer-events: none;
}

/* =========================================================================
   卡片与列表
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.card-meta { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 16px 18px; }

/* roles / permissions 页的分组列表容器 */
.card-list-pad {
  padding: 16px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.list-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
/* 卡片内嵌套 list 时去掉重复描边 */
.card .list { border: none; border-radius: 0; box-shadow: none; }

.list-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 100ms ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-alt); }

.row-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--paper-deep);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11.5px;
  flex-shrink: 0;
  overflow: hidden;
}
.row-avatar[data-tone="blue"]   { background: light-dark(#e6ecfa, #1d2940); color: light-dark(#2d55b4, #9db9f2); }
.row-avatar[data-tone="green"]  { background: light-dark(#dff0e5, #17301f); color: light-dark(#1d7a42, #83d3a6); }
.row-avatar[data-tone="orange"] { background: light-dark(#f6ead8, #372a15); color: light-dark(#95590e, #dfb26e); }
.row-avatar[data-tone="pink"]   { background: light-dark(#f9e3e8, #3a2026); color: light-dark(#ab3652, #ec9fb1); }
.row-avatar[data-tone="purple"] { background: light-dark(#ebe4f8, #2b2340); color: light-dark(#6540ad, #bfa8ed); }
.row-avatar[data-tone="teal"]   { background: light-dark(#ddefec, #16302c); color: light-dark(#0e685c, #82ccc1); }

.row-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.row-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.005em;
}
.row-subtitle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 0;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.row-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── 徽章 ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.mono { font-family: var(--font-mono); font-size: 10.5px; }
.badge-active   { background: var(--green-bg); color: var(--green); border-color: transparent; }
.badge-disabled { background: var(--red-bg);   color: var(--red);   border-color: transparent; }
/* 超管徽章：墨色反白，黑白主题的最高对比位 */
.badge-super {
  background: var(--primary);
  color: var(--primary-contrast);
  border-color: transparent;
}
.badge-blue     { background: var(--blue-bg);  color: var(--blue);  border-color: transparent; }
.badge-orange   { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.badge-pink     { background: var(--red-bg);   color: var(--red);   border-color: transparent; }
.badge-teal     { background: light-dark(#ddefec, #16302c); color: light-dark(#0e685c, #82ccc1); border-color: transparent; }
/* client_id 的确定性配色 chip：同一 client 全 UI 同色 */
.badge[data-tone="blue"]   { background: light-dark(#e6ecfa, #1d2940); color: light-dark(#2d55b4, #9db9f2); border-color: transparent; }
.badge[data-tone="green"]  { background: light-dark(#dff0e5, #17301f); color: light-dark(#1d7a42, #83d3a6); border-color: transparent; }
.badge[data-tone="orange"] { background: light-dark(#f6ead8, #372a15); color: light-dark(#95590e, #dfb26e); border-color: transparent; }
.badge[data-tone="pink"]   { background: light-dark(#f9e3e8, #3a2026); color: light-dark(#ab3652, #ec9fb1); border-color: transparent; }
.badge[data-tone="purple"] { background: light-dark(#ebe4f8, #2b2340); color: light-dark(#6540ad, #bfa8ed); border-color: transparent; }
.badge[data-tone="teal"]   { background: light-dark(#ddefec, #16302c); color: light-dark(#0e685c, #82ccc1); border-color: transparent; }
.badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ── 统计卡 ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.stat-grid > .empty { grid-column: 1 / -1; }
.stat {
  position: relative;
  padding: 16px 18px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: inherit;
}
.stat .label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.stat .value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat .delta { font-size: 11px; color: var(--text-faint); }
a.stat { text-decoration: none; transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease; }
a.stat::after {
  content: "→";
  position: absolute;
  right: 16px;
  bottom: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  transition: color 120ms ease, transform 120ms ease;
}
a.stat:hover {
  text-decoration: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}
a.stat:hover::after { color: var(--text); transform: translateX(2px); }

/* =========================================================================
   表单
   ========================================================================= */

.form-card { padding: 24px 28px 28px; }

.form-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
}
.form-section + .form-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px dashed var(--border-strong);
  max-width: none;
}
.form-section-title {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text);
}
.field-hint {
  font-size: 11.5px;
  color: var(--text-muted);
}

.input, .select, textarea {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
textarea {
  height: auto;
  padding: 9px 11px;
  resize: vertical;
  min-height: 76px;
  line-height: 1.5;
}
.input::placeholder, textarea::placeholder { color: var(--text-faint); }

.input:focus, .select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.input:disabled, .input[readonly] {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%236c6e74' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 30px;
}

/* ── 开关 ── */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 160ms ease;
  flex-shrink: 0;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: light-dark(#ffffff, #101113);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 160ms cubic-bezier(0.3, 0.8, 0.4, 1);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); }
.switch-label { font-size: 13px; color: var(--text); }

/* ── 勾选标签（角色分配）── */
.check-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.check-tag {
  position: relative;
  cursor: pointer;
}
.check-tag input { position: absolute; opacity: 0; pointer-events: none; }
.check-tag span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  color: var(--text);
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.check-tag:hover span { background: var(--surface-alt); }
.check-tag input:checked + span {
  background: var(--accent-bg);
  border-color: var(--primary);
  font-weight: 550;
}
.check-tag input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ── 提示条 ── */
.alert {
  position: relative;
  padding: 10px 12px 10px 36px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid transparent;
  border-left: 3px solid var(--red);
}
.alert::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M8 1.5A6.5 6.5 0 1 0 14.5 8 6.508 6.508 0 0 0 8 1.5Zm.75 9.75h-1.5V7h1.5Zm0-5.25h-1.5v-1.5h1.5Z'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M8 1.5A6.5 6.5 0 1 0 14.5 8 6.508 6.508 0 0 0 8 1.5Zm.75 9.75h-1.5V7h1.5Zm0-5.25h-1.5v-1.5h1.5Z'/></svg>") center / contain no-repeat;
}
.alert-success {
  background: var(--green-bg);
  color: var(--green);
  border-left-color: var(--green);
}
.alert-success::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M13.78 4.22a.75.75 0 0 1 0 1.06l-7 7a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 1 1 1.06-1.06L6.25 10.69l6.47-6.47a.75.75 0 0 1 1.06 0Z'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M13.78 4.22a.75.75 0 0 1 0 1.06l-7 7a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 1 1 1.06-1.06L6.25 10.69l6.47-6.47a.75.75 0 0 1 1.06 0Z'/></svg>");
}

/* ── toast ── */
.toast-host {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 12.5px;
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toast-in 200ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
.toast-success { background: light-dark(#166534, #2f7d4f); color: #fff; }
.toast-error   { background: light-dark(#9c2d29, #a63a34); color: #fff; }

/* =========================================================================
   登录页 —— 墨色侧幕 + 单卡
   ========================================================================= */

body.auth-body {
  background:
    radial-gradient(light-dark(rgba(23, 24, 26, 0.04), rgba(236, 236, 238, 0.035)) 1px, transparent 1px) 0 0 / 26px 26px,
    radial-gradient(900px 620px at 108% 112%, light-dark(rgba(23, 24, 26, 0.05), rgba(236, 236, 238, 0.03)), transparent 55%),
    var(--paper);
}

.auth-stage {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(440px, 1fr);
  align-items: stretch;
}

.auth-aside {
  position: relative;
  overflow: hidden;
  padding: 56px 56px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #dfe0e2;
  background:
    radial-gradient(820px 560px at 85% -5%, rgba(255, 255, 255, 0.07), transparent 55%),
    linear-gradient(165deg, #101113 0%, #16171a 55%, #1a1c1f 100%);
}
.auth-aside::after {
  /* 工程网格 —— 与主界面点阵呼应 */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: -1px -1px;
  mask-image: radial-gradient(760px 600px at 28% 32%, #000 25%, transparent 74%);
  -webkit-mask-image: radial-gradient(760px 600px at 28% 32%, #000 25%, transparent 74%);
  pointer-events: none;
}

.auth-aside-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 44px;
  max-width: 430px;
  height: 100%;
}
.auth-aside-inner .auth-pitch { margin-top: auto; }
.auth-aside-inner .auth-bullets { margin-bottom: auto; }

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.auth-brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: #ffffff;
  color: #101113;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.10), 0 6px 18px rgba(0,0,0,.4);
}
.auth-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.auth-brand-text strong {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}
.auth-brand-text em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(223, 224, 226, 0.5);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.auth-pitch h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: #fff;
}
.auth-pitch p {
  margin: 0;
  font-size: 14px;
  color: rgba(223, 224, 226, 0.68);
  line-height: 1.65;
  max-width: 350px;
}

.auth-bullets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.auth-bullets li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(223, 224, 226, 0.78);
}
.auth-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.auth-aside-foot {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(223, 224, 226, 0.35);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── 右列：登录卡 ── */

.auth-main {
  display: grid;
  place-items: center;
  padding: 32px 24px;
}
/* 错误页等无侧幕形态：单列占满整个舞台居中 */
.auth-main:only-child { grid-column: 1 / -1; }

.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow:
    0 1px 0 light-dark(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.04)) inset,
    0 2px 6px light-dark(rgba(20, 20, 22, 0.05), rgba(0, 0, 0, 0.45)),
    0 24px 60px light-dark(rgba(20, 20, 22, 0.12), rgba(0, 0, 0, 0.55));
  padding: 38px 38px 30px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: authPop 380ms cubic-bezier(0.18, 0.75, 0.3, 1) both;
}
@keyframes authPop {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.auth-card[data-state="error"] {
  animation: authShake 360ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes authShake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.auth-card-head {
  display: none; /* 窄屏（侧幕折叠）时显示 */
  align-items: center;
  gap: 10px;
}
.auth-brand-mark-sm {
  width: 30px; height: 30px;
  border-radius: 9px;
  font-size: 14px;
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: none;
}
.auth-brand-text-sm strong { color: var(--text); font-size: 13px; }
.auth-brand-text-sm em     { color: var(--text-muted); }

.auth-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid transparent;
}
.auth-banner svg { flex-shrink: 0; }
.auth-banner-info {
  background: var(--accent-bg);
  color: var(--text-muted);
  border-color: var(--border);
}

.auth-headline { display: flex; flex-direction: column; gap: 6px; }
.auth-eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.auth-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}
.auth-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-sub code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text);
}

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.auth-input::placeholder { color: var(--text-faint); }
.auth-input:hover { border-color: light-dark(#b9bac0, #45484e); }
.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.auth-input:disabled {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.auth-eye {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 120ms ease, background 120ms ease;
}
.auth-eye:hover { color: var(--text); background: var(--surface-alt); }
.auth-eye[aria-pressed="true"] { color: var(--text); }

.auth-field-hint {
  font-size: 11px;
  color: var(--amber);
  letter-spacing: 0.02em;
}

.auth-alert {
  font-size: 12.5px;
  padding: 9px 12px;
  background: var(--red-bg);
  color: var(--red);
  border-radius: 8px;
  border: 1px solid light-dark(rgba(207, 58, 49, 0.2), rgba(239, 128, 121, 0.25));
}

.auth-submit {
  position: relative;
  height: 46px;
  border-radius: 11px;
  background: var(--primary);
  color: var(--primary-contrast);
  border: 1px solid var(--primary);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
  transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease;
  box-shadow: 0 1px 0 light-dark(rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.3)) inset,
              0 6px 18px light-dark(rgba(23, 24, 26, 0.25), rgba(0, 0, 0, 0.5));
}
.auth-submit:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring), 0 6px 18px light-dark(rgba(23, 24, 26, 0.25), rgba(0, 0, 0, 0.5));
}
.auth-submit[disabled] {
  background: light-dark(#77787c, #55575c);
  border-color: light-dark(#77787c, #55575c);
  color: light-dark(#ffffff, #1a1b1d);
  cursor: progress;
  box-shadow: none;
}
.auth-submit-spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid light-dark(rgba(255, 255, 255, 0.35), rgba(16, 17, 19, 0.35));
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}
.auth-submit[data-loading="true"] .auth-submit-spinner { display: inline-block; }
.auth-submit[data-loading="true"] .auth-submit-text   { opacity: 0.85; }

.auth-foot {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

@media (max-width: 880px) {
  .auth-stage { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main  { padding: 24px 16px; }
  .auth-card  { padding: 28px 24px 22px; }
  .auth-card-head { display: inline-flex; }
}

/* ── 错误页 ── */
.error-glyph {
  font-family: var(--font-mono);
  font-size: 88px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -4px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

/* =========================================================================
   审计 —— 筛选工具条
   ========================================================================= */

.audit-filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.filter-row-secondary {
  border-top: 1px dashed var(--border);
  padding-top: 11px;
}
.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.filter-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.filter-group .segmented { padding: 2px; }
.filter-group .segmented button {
  gap: 5px;
  padding: 3px 10px;
  font-size: 11.5px;
}
.filter-group .segmented .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }

.filter-select {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.filter-select .filter-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.select-compact,
.input-compact {
  height: 30px;
  min-width: 168px;
  padding: 0 26px 0 28px;
  font-size: 12px;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background-color: var(--surface);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.select-compact:focus,
.input-compact:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.select-compact {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%236c6e74' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 7px center;
  appearance: none;
}
.filter-search {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.filter-search > svg {
  position: absolute;
  left: 9px;
  color: var(--text-faint);
  pointer-events: none;
}
.filter-search .input-compact {
  padding-left: 28px;
  padding-right: 10px;
  min-width: 220px;
}

.filter-active-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  background: var(--accent-bg);
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
}

@media (max-width: 900px) {
  .filter-row { gap: 6px 10px; }
  .filter-select, .filter-search .input-compact { min-width: 140px; }
}

/* =========================================================================
   审计 —— 时间线（日分组 + 风险色轨）
   ========================================================================= */

.audit-day-header {
  position: sticky;
  top: 0;
  z-index: 5;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 10px 18px 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.audit-day-header:first-child { border-top: none; }

.audit-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: flex-start;
  padding: 13px 18px 13px 16px;
  border-top: 1px solid var(--border);
  position: relative;
  transition: background 100ms ease;
}
.audit-row:hover { background: var(--surface-alt); }
.audit-row:first-of-type { border-top: none; }
.audit-row::before {
  content: "";
  position: absolute;
  left: 0; top: 13px; bottom: 13px;
  width: 3px;
  border-radius: 2px;
  background: var(--border-strong);
}
.audit-row.side-normal::before    { background: var(--border-strong); }
.audit-row.side-elevated::before  { background: var(--amber); }
.audit-row.side-high::before      { background: var(--red); }
.audit-row.side-failure::before   { background: var(--red); }

.audit-time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-top: 2px;
  cursor: default;
}

.audit-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audit-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.audit-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.audit-action-code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--paper-deep);
  padding: 1px 6px;
  border-radius: 4px;
}

.risk-pill {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 4px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.risk-normal   { background: var(--surface-alt); color: var(--text-muted); }
.risk-elevated { background: var(--amber-bg);    color: var(--amber); }
.risk-high     { background: var(--red-bg);      color: var(--red); }

.audit-meta-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font: inherit;
  font-size: 11.5px;
  padding: 2px 8px 2px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: color 100ms ease, background 100ms ease;
}
.audit-meta-toggle:hover { color: var(--text); background: var(--surface-alt); }
.audit-meta-toggle.is-open svg { transform: rotate(180deg); }
.audit-meta-toggle svg { transition: transform 140ms ease; }

.audit-route {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 13px;
  color: var(--text);
}
.audit-route .audit-actor { font-weight: 550; }
.audit-route .mono {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--paper-deep);
  padding: 1px 6px;
  border-radius: 4px;
}
.audit-route .muted { color: var(--text-faint); }

.audit-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.audit-sub .audit-sep { color: var(--text-faint); }
.audit-sub .mono { font-size: 11px; }

.audit-reason { color: var(--text-muted); font-size: 12px; }
.audit-reason-fail { color: var(--red); font-weight: 550; }

.audit-meta-pane {
  margin-top: 8px;
  font-size: 11.5px;
  background: var(--paper-deep);
  padding: 10px 13px;
  border-radius: 7px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.55;
  border: 1px solid var(--border);
  color: var(--ink-2);
}

@media (max-width: 700px) {
  .audit-row { grid-template-columns: 1fr; gap: 6px; padding-left: 15px; }
  .audit-time { font-size: 11px; }
}

/* ── 旧时间线（我的账号 · 登录历史仍在用）── */
.timeline {
  display: flex;
  flex-direction: column;
}
.timeline-row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 16px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.timeline-row:last-child { border: none; }
.timeline-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.timeline-body { min-width: 0; }
.timeline-action {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}
.timeline-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-all;
}

/* =========================================================================
   我的账号（profile hero + 双栏）
   ========================================================================= */

.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
}
.profile-hero-body {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}
.profile-hero-avatar {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 650;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(140deg, #2b2d31, #131416);
  box-shadow: 0 6px 16px rgba(10, 11, 12, 0.35);
}
.profile-hero-avatar[data-tone="blue"]   { background: linear-gradient(140deg, #4a6fd8, #2b4cb0); box-shadow: 0 6px 16px rgba(43, 76, 176, 0.3); }
.profile-hero-avatar[data-tone="green"]  { background: linear-gradient(140deg, #2d9a66, #17724a); box-shadow: 0 6px 16px rgba(23, 114, 74, 0.3); }
.profile-hero-avatar[data-tone="orange"] { background: linear-gradient(140deg, #dd8a35, #b4650f); box-shadow: 0 6px 16px rgba(180, 101, 15, 0.3); }
.profile-hero-avatar[data-tone="purple"] { background: linear-gradient(140deg, #8a68d8, #6743b3); box-shadow: 0 6px 16px rgba(103, 67, 179, 0.3); }
.profile-hero-avatar[data-tone="teal"]   { background: linear-gradient(140deg, #1c9384, #0e6b5c); box-shadow: 0 6px 16px rgba(14, 107, 92, 0.3); }
.profile-hero-avatar[data-tone="indigo"] { background: linear-gradient(140deg, #5b6fd6, #3c4fb2); box-shadow: 0 6px 16px rgba(60, 79, 178, 0.3); }
.profile-hero-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.profile-hero-name {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.25;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-hero-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
}
.profile-hero-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-size: 12px;
}
.profile-hero-actions { flex-shrink: 0; }

.me-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  align-items: start;
}
.me-grid-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
@media (max-width: 960px) {
  .me-grid { grid-template-columns: 1fr; }
  .profile-hero { flex-direction: column; align-items: flex-start; }
  .profile-hero-actions { align-self: flex-end; }
}

/* =========================================================================
   空态 / 加载
   ========================================================================= */

.empty {
  padding: 44px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.empty .glyph {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--paper-deep);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 20px;
}
.empty h3 {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.empty p { margin: 0; font-size: 12.5px; }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--paper-deep) 0%, light-dark(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.07)) 50%, var(--paper-deep) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1300ms ease-in-out infinite;
  border-radius: 4px;
  display: block;
}
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-line.short { width: 40%; }
.skeleton-line.mid   { width: 65%; }
.skeleton-line.long  { width: 88%; }
.skeleton-list {
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton-list .skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.skeleton-list .skeleton-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(90deg, var(--paper-deep) 0%, light-dark(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.07)) 50%, var(--paper-deep) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1300ms ease-in-out infinite;
}
.skeleton-list .skeleton-text { flex: 1; min-width: 0; }
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =========================================================================
   工具类
   ========================================================================= */

.muted { color: var(--text-muted); }
.mono  { font-family: var(--font-mono); }
.hidden { display: none !important; }

.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* =========================================================================
   移动端：汉堡 + 抽屉
   ========================================================================= */

/* 登录/错误页没有侧边栏，任何尺寸都不显示汉堡按钮 */
body.auth-body .sidebar-toggle { display: none !important; }

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle:active { transform: scale(0.96); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 9, 10, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 220ms ease;
}
.sidebar-backdrop.is-visible {
  display: block;
  opacity: 1;
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }

  .sidebar-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: 268px;
    max-width: 84vw;
    padding: 20px 14px 14px;
    z-index: 55;
    transform: translateX(-100%);
    transition: transform 260ms cubic-bezier(0.3, 0.8, 0.3, 1);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.35);
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    overflow: auto;
  }
  .sidebar.is-open { transform: translateX(0); }
  /* 汉堡按钮固定在左上（z 更高），品牌行右移避免被盖住 */
  .sidebar-brand { padding-left: 52px; }

  .main { padding: 72px 18px 44px; }

  .top-tools { top: 14px; }

  body.is-sidebar-open { overflow: hidden; }
}

/* =========================================================================
   弹窗
   ========================================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 10, 0.5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 80;
  animation: modal-fade 150ms ease-out;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-rise 190ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.modal-wide { width: min(640px, 100%); }

@keyframes modal-rise {
  from { transform: translateY(10px) scale(0.99); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 8px;
}
.modal-header .modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 650;
  margin: 0;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.modal-header .modal-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 3px 0 0;
  line-height: 1.5;
}
.modal-header .modal-close {
  margin-left: auto;
  flex-shrink: 0;
}

.modal-body {
  padding: 10px 20px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.modal-body form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.modal-body .field { gap: 6px; }
.modal-body .field-label { font-size: 12.5px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.modal-error {
  display: none;
  position: relative;
  background: var(--red-bg);
  color: var(--red);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--red);
  padding: 10px 10px 10px 36px;
  font-size: 12.5px;
  line-height: 1.5;
}
.modal-error::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M8 1.5A6.5 6.5 0 1 0 14.5 8 6.508 6.508 0 0 0 8 1.5Zm.75 9.75h-1.5V7h1.5Zm0-5.25h-1.5v-1.5h1.5Z'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M8 1.5A6.5 6.5 0 1 0 14.5 8 6.508 6.508 0 0 0 8 1.5Zm.75 9.75h-1.5V7h1.5Zm0-5.25h-1.5v-1.5h1.5Z'/></svg>") center / contain no-repeat;
}
.modal-error.is-visible { display: block; }

.modal-readonly {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-deep);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-all;
}
.modal-readonly code {
  flex: 1;
  white-space: pre-wrap;
}
.modal-readonly .copy-btn { flex-shrink: 0; }
.modal-readonly + .modal-readonly-label { margin-top: 12px; }
.modal-readonly-label {
  margin: 2px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.modal-callout {
  padding: 10px 13px;
  border-radius: var(--r-sm);
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 12.5px;
  line-height: 1.55;
}
.modal-callout.is-info {
  background: var(--accent-bg);
  color: var(--text-muted);
}
.modal-callout.is-success {
  background: var(--green-bg);
  color: var(--green);
}

/* 多选 chips（复制角色/权限到其他接入方） */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.chip-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  background: var(--surface);
  user-select: none;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.chip-option input { display: none; }
.chip-option:hover { background: var(--surface-alt); }
.chip-option.is-checked {
  background: var(--accent-bg);
  border-color: var(--primary);
  font-weight: 550;
}
.chip-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.modal-open { overflow: hidden; }

.copy-feedback {
  font-size: 11px;
  color: var(--green);
  margin-left: 6px;
  opacity: 0;
  transition: opacity 200ms;
}
.copy-feedback.is-visible { opacity: 1; }

/* =========================================================================
   右上浮动工具（主题 + 语言）
   ========================================================================= */

.top-tools {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-switcher,
.lang-switcher {
  display: inline-flex;
  background: light-dark(rgba(255, 255, 255, 0.9), rgba(23, 25, 28, 0.9));
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px);
}
.lang-switcher button {
  border: 0;
  background: transparent;
  padding: 4px 11px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.lang-switcher button:hover { color: var(--text); }
.lang-switcher button.is-active {
  background: var(--primary);
  color: var(--primary-contrast);
}

.theme-switcher button {
  border: 0;
  background: transparent;
  width: 26px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.theme-switcher button:hover { color: var(--text); }
.theme-switcher button.is-active {
  background: var(--primary);
  color: var(--primary-contrast);
}
