/* 文件中心 · 样式
   设计取向：纸质感、低饱和、控件图标化固定在角落，避免方块列表的呆板。 */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --line: #e6e3dd;
  --line-strong: #d4d0c8;
  --tx: #2c2a26;
  --tx-2: #6b6862;
  --tx-3: #9c988f;
  --accent: #3f7d6e;
  --accent-soft: #e8f1ee;
  --warn: #b4703a;
  --danger: #b0483f;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(44, 42, 38, .05);
  --shadow-2: 0 4px 16px rgba(44, 42, 38, .1);
  --shadow-3: 0 12px 40px rgba(44, 42, 38, .16);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --surface: #1e2124;
    --surface-2: #232629;
    --line: #2e3236;
    --line-strong: #3d4247;
    --tx: #e6e4e1;
    --tx-2: #a5a49f;
    --tx-3: #75746f;
    --accent: #5ca08e;
    --accent-soft: #1e312c;
    --warn: #c98a52;
    --danger: #c96a60;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-3: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

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

body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
}

svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 加载态 ---------- */
/* 注意：.boot 用了 position:fixed，hidden 属性不会让它消失，
   必须显式声明 [hidden] 的 display:none，否则它会一直盖在界面上拦截点击。 */
[hidden] { display: none !important; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 99; }
.boot-inner { text-align: center; }
.boot-mark {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-text { color: var(--tx-3); font-size: 13px; }

/* ---------- 布局 ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.brand { font-weight: 600; font-size: 15px; letter-spacing: .01em; }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 4px; margin-left: 4px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; font-size: 13px; color: var(--tx-2);
}
.user-chip::before {
  content: ''; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 500;
}

.body { display: flex; flex: 1; min-height: 0; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: width .18s ease, opacity .18s ease;
}
.sidebar.collapsed { width: 0; overflow: hidden; opacity: 0; border-right: none; }

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 8px; font-size: 12px; color: var(--tx-3);
  letter-spacing: .04em;
}

.tree { flex: 1; overflow-y: auto; padding: 0 8px 12px; }

.tree-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; margin: 1px 0;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--tx-2); font-size: 13px;
  transition: background .12s, color .12s;
  user-select: none;
}
.tree-item:hover { background: var(--surface-2); color: var(--tx); }
.tree-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
/* 展开箭头：外层 span 控制旋转状态，内层 svg 只画形状 */
.tree-item .caret {
  width: 14px; height: 14px; flex-shrink: 0;
  display: grid; place-items: center;
  color: var(--tx-3); transition: transform .15s;
}
.tree-item .caret-icon {
  width: 12px; height: 12px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.tree-item .caret.open { transform: rotate(90deg); }
.tree-item .caret.leaf { visibility: hidden; }
.tree-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-children { margin-left: 14px; }

.sidebar-foot { padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.quota-bar { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.quota-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.quota-text { display: block; margin-top: 6px; font-size: 11.5px; color: var(--tx-3); }

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: var(--surface); flex-shrink: 0;
}
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.crumb {
  padding: 3px 7px; border-radius: 5px; cursor: pointer;
  font-size: 13px; color: var(--tx-2); white-space: nowrap;
}
.crumb:hover { background: var(--surface-2); color: var(--tx); }
.crumb.last { color: var(--tx); font-weight: 500; }
.crumb-sep { color: var(--tx-3); flex-shrink: 0; }

.tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.divider { width: 1px; height: 16px; background: var(--line); margin: 0 5px; }

/* 图标按钮 */
.icon-btn {
  width: 32px; height: 32px; padding: 7px;
  border: none; background: none; cursor: pointer;
  color: var(--tx-2); border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--tx); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.sm { width: 28px; height: 28px; padding: 6px; }
.icon-btn.accent { color: var(--accent); }
.icon-btn.accent:hover { background: var(--accent-soft); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: none; color: var(--tx-2); }

/* 列表头 */
.list-head {
  display: grid;
  grid-template-columns: 1fr 90px 110px 140px 96px;
  gap: 12px; align-items: center;
  padding: 8px 18px; font-size: 11.5px; color: var(--tx-3);
  letter-spacing: .04em; border-bottom: 1px solid var(--line);
  background: var(--surface-2); flex-shrink: 0;
}

/* 列表 */
.list { flex: 1; overflow-y: auto; padding: 4px 10px 24px; }

.item {
  display: grid;
  grid-template-columns: 1fr 90px 110px 140px 96px;
  gap: 12px; align-items: center;
  padding: 9px 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .1s;
  border-bottom: 1px solid transparent;
}
.item:hover { background: var(--surface); border-bottom-color: var(--line); }
.item.menu-open { background: var(--accent-soft); }

.item-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.item-icon {
  width: 28px; height: 28px; flex-shrink: 0; padding: 6px;
  border-radius: 7px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--tx-3);
  display: grid; place-items: center;
}
.item.dir .item-icon { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
/* item-text 必须是块级纵向布局：标题与元信息各占一行，
   否则会挤成「xxx文件夹」连在一起（第一版实际出现过的问题）。 */
.item-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item-title {
  display: block; font-size: 13.5px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-meta { display: block; font-size: 11.5px; line-height: 1.4; color: var(--tx-3); }
.item-meta .ext-tag {
  display: inline-block; padding: 0 4px; margin-right: 6px;
  border: 1px solid var(--line); border-radius: 3px;
  font-size: 10px; text-transform: uppercase; color: var(--tx-3);
}

.col-size, .col-uploader, .col-time {
  font-size: 12.5px; color: var(--tx-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.col-ops { display: flex; gap: 1px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
.item:hover .col-ops, .item.menu-open .col-ops { opacity: 1; }
.col-ops .icon-btn { width: 26px; height: 26px; padding: 5px; }

/* 视图切换：网格 */
.list.grid-view {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 12px; padding: 16px 18px 24px; align-content: start;
}
.list.grid-view .list-head { display: none; }
.list.grid-view .item {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 14px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.list.grid-view .item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.list.grid-view .item-name { flex-direction: column; align-items: flex-start; gap: 8px; }
.list.grid-view .item-icon { width: 40px; height: 40px; padding: 10px; border-radius: 9px; }
.list.grid-view .col-size, .list.grid-view .col-uploader, .list.grid-view .col-time { display: none; }
.list.grid-view .col-ops { opacity: 1; justify-content: flex-start; padding-top: 4px; border-top: 1px solid var(--line); margin-top: 2px; }
.list.grid-view .item-title { white-space: normal; word-break: break-all; font-size: 13px; }

/* 空状态 */
.empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; padding-bottom: 60px;
}
.empty-mark {
  width: 54px; height: 54px; margin-bottom: 14px;
  border: 2px dashed var(--line-strong); border-radius: 12px;
}
.empty-mark.lock { border-radius: 50%; border-style: solid; }
/* 搜索无结果：放大镜轮廓，区别于"空文件夹"的虚线框 */
.empty-mark.search { border: none; position: relative; }
.empty-mark.search::before {
  content: ''; position: absolute; inset: 4px;
  border: 2px dashed var(--line-strong); border-radius: 50%;
}
.empty-mark.search::after {
  content: ''; position: absolute; right: -2px; bottom: -2px;
  width: 18px; height: 2px; border-radius: 2px;
  background: var(--line-strong); transform: rotate(45deg);
}
.empty-text { color: var(--tx-2); font-size: 14px; }
.empty-sub { color: var(--tx-3); font-size: 12.5px; }

/* ---------- 拖放区 ---------- */
.dropzone {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(2px);
  display: none; place-items: center;
}
.dropzone.on { display: grid; }
.dropzone-inner {
  border: 2px dashed var(--accent); border-radius: 16px;
  padding: 46px 74px; color: var(--accent);
  background: var(--surface); box-shadow: var(--shadow-2);
}
.dropzone-mark {
  width: 44px; height: 44px; margin: 0 auto 12px;
  border: 2px solid var(--accent); border-radius: 50%;
  border-top-color: transparent; animation: spin .9s linear infinite;
}
.dropzone-inner p { font-size: 15px; font-weight: 500; }

/* ---------- 上传队列 ---------- */
.upload-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 55;
  width: 320px; max-height: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; overflow: hidden;
}
.upload-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 500;
}
.upload-list { overflow-y: auto; padding: 6px; }
.up-item { padding: 8px 10px; border-radius: var(--radius-sm); }
.up-item:hover { background: var(--surface-2); }
.up-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.up-pct { color: var(--tx-3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.up-bar { height: 3px; background: var(--line); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.up-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s; }
.up-item.done .up-bar i { background: var(--accent); }
.up-item.error .up-bar i { background: var(--danger); }
.up-item.done .up-name { color: var(--tx-3); }
.up-item.error .up-name { color: var(--danger); }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(30, 28, 25, .35);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: 12px;
  box-shadow: var(--shadow-3); overflow: hidden;
  animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal-head { padding: 16px 18px 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 14px 18px; color: var(--tx-2); font-size: 13.5px; max-height: 60vh; overflow-y: auto; }
/* 管理后台内容多：弹窗本身放宽，正文独占剩余高度并独立滚动，
   否则底部的「保存」会被模态框按钮栏盖住 —— 这是上一版实际发生的。
   做法：弹窗用 flex 纵向布局，正文 flex:1 + min-height:0，
   min-height:0 是关键，否则 flex 子项不会收缩、内容会顶破容器。 */
.modal.wide {
  max-width: 860px;
  display: flex; flex-direction: column;
  max-height: 86vh;
}
.modal.wide .modal-body {
  max-height: none; flex: 1; min-height: 0; overflow-y: auto;
}
.modal.wide .modal-foot { flex-shrink: 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px 16px;
}
.btn {
  padding: 7px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--tx); font-size: 13px; cursor: pointer; font-family: inherit;
  transition: background .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.06); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--tx-2); margin-bottom: 5px; }
.field input[type=text], .field input[type=password] {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--tx);
  font-size: 13.5px; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--accent); }

/* ---------- 搜索框 ---------- */
.search-box {
  position: relative; display: flex; align-items: center;
  margin-right: 6px;
}
.search-icon {
  position: absolute; left: 8px; width: 15px; height: 15px;
  color: var(--tx-3); pointer-events: none;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.search-box input {
  width: 190px; padding: 6px 28px 6px 28px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--tx);
  font-size: 13px; font-family: inherit;
  transition: width .18s, border-color .12s;
}
.search-box input::placeholder { color: var(--tx-3); }
.search-box input:focus {
  outline: none; width: 250px; border-color: var(--accent);
  background: var(--surface);
}
.search-clear { position: absolute; right: 2px; width: 24px; height: 24px; padding: 5px; }

/* 结果分类切换 */
.seg {
  display: flex; gap: 1px; padding: 2px;
  background: var(--surface-2); border-radius: 7px;
  border: 1px solid var(--line);
}
.seg-btn {
  padding: 4px 11px; border: none; background: none; cursor: pointer;
  border-radius: 5px; font-size: 12px; font-family: inherit; color: var(--tx-3);
  transition: background .12s, color .12s;
}
.seg-btn:hover { color: var(--tx); }
.seg-btn.on { background: var(--surface); color: var(--tx); box-shadow: var(--shadow-1); }

/* 命中高亮 */
.item-title mark.hit {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 3px; padding: 0 1px;
}
.crumb-hint {
  color: var(--tx-3); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 340px; display: inline-block; vertical-align: bottom;
}

/* 搜索结果计数条 */
.search-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 18px; font-size: 12px; color: var(--tx-3);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  flex-shrink: 0;
}
.search-bar-right { display: flex; align-items: center; gap: 8px; }
.link-btn {
  border: none; background: none; cursor: pointer; padding: 2px 4px;
  color: var(--accent); font-size: 12px; font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--tx-3); opacity: .5; cursor: not-allowed; text-decoration: none; }

/* ---------- 在线预览 ---------- */
.preview {
  position: fixed; inset: 0; z-index: 65;
  background: var(--bg); display: flex; flex-direction: column;
  animation: fadein .14s ease;
}
@keyframes fadein { from { opacity: 0; } }
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface); flex-shrink: 0;
}
.preview-title { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.preview-title > span {
  font-size: 13.5px; font-weight: 500; color: var(--tx);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview-title small { font-size: 11.5px; color: var(--tx-3); }
.preview-actions { display: flex; gap: 2px; flex-shrink: 0; }
.preview-body {
  flex: 1; overflow: auto; display: flex;
  align-items: center; justify-content: center; padding: 20px;
}
.preview-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-sm); }
.preview-pdf { width: 100%; height: 100%; border: none; background: #fff; border-radius: var(--radius-sm); }
.preview-media { width: min(760px, 100%); }
.preview-text {
  width: 100%; max-width: 980px; align-self: flex-start;
  margin: 0; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.7; color: var(--tx-2);
  white-space: pre-wrap; word-break: break-word;
}
.preview-empty, .preview-loading {
  text-align: center; color: var(--tx-3); font-size: 13px;
  padding: 40px 20px; line-height: 1.9;
}

/* ---------- 目录选择器（移动到） ---------- */
.pick-list {
  max-height: 46vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.pick-row:last-child { border-bottom: none; }
.pick-row:hover { background: var(--surface); }
.pick-row.on { background: var(--accent-soft); }
.pick-icon {
  width: 26px; height: 26px; padding: 5px; flex-shrink: 0;
  color: var(--accent); display: grid; place-items: center;
}
.pick-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.pick-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.pick-name { font-size: 13px; color: var(--tx); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-crumb { font-size: 11px; color: var(--tx-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 管理后台 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
  padding: 8px 13px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-family: inherit; color: var(--tx-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--tx-2); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

.admin-body { min-height: 200px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 6px;
}
.stat {
  display: flex; flex-direction: column; gap: 5px;
  padding: 13px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface-2);
}
.stat-label { font-size: 11.5px; color: var(--tx-3); }
.stat-value { font-size: 19px; font-weight: 600; color: var(--tx); font-variant-numeric: tabular-nums; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.admin-table th {
  text-align: left; padding: 7px 9px; color: var(--tx-3);
  font-weight: 500; font-size: 11.5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.admin-table td {
  padding: 7px 9px; border-bottom: 1px solid var(--line);
  color: var(--tx-2); vertical-align: middle;
}
.admin-table code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; background: var(--surface-2);
  padding: 1px 5px; border-radius: 4px; color: var(--tx-2);
}
.admin-table .ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pct { color: var(--tx-3); font-size: 11px; }
.ok-mark { color: var(--accent); font-size: 12px; }
.err-mark { color: var(--danger); font-size: 12px; }
.admin-empty, .admin-note {
  color: var(--tx-3); font-size: 12.5px; text-align: center;
  padding: 26px 0; line-height: 1.9;
}
.admin-note { text-align: left; padding: 8px 0 0; }
.admin-sub {
  font-size: 12.5px; font-weight: 500; color: var(--tx-2);
  margin: 14px 0 8px;
}
.admin-sub:first-child { margin-top: 0; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px;
  background: var(--accent-soft); color: var(--accent);
}
.chip.off { background: var(--surface-2); color: var(--tx-3); text-decoration: line-through; }

/* ---------- 组织与人员 ---------- */
.org-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.org-hint {
  font-size: 11.5px; color: var(--tx-3); line-height: 1.7;
  margin-bottom: 12px;
}
.org-hint b { color: var(--tx-2); font-weight: 500; }
#orgResult { margin-bottom: 12px; }

/* ---------- MK 接入配置 ---------- */
#adminTabs + .admin-body { min-width: 0; }

/* 配置项两列排布：一屏能看到全部，且不必频繁滚动 */
.cfg-group {
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}
.cfg-group:last-of-type { border-bottom: none; }
.cfg-group-title {
  grid-column: 1 / -1;               /* 分组标题独占一行 */
  font-size: 12.5px; font-weight: 500; color: var(--tx);
  margin-bottom: 2px; display: flex; align-items: baseline; gap: 8px;
}
.cfg-group-title small { font-size: 11.5px; font-weight: 400; color: var(--tx-3); }

.cfg-row { margin-bottom: 0; min-width: 0; }
.cfg-row label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--tx-2); margin-bottom: 4px;
}
.cfg-secret {
  font-size: 10px; padding: 0 5px; border-radius: 3px;
  background: var(--accent-soft); color: var(--accent);
}
.cfg-row input:focus, .cfg-row select:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.cfg-hint {
  display: block; margin-top: 3px;
  font-size: 11px; color: var(--tx-3); line-height: 1.6;
}

.cfg-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
.cfg-result { margin-top: 12px; }
.cfg-testing { font-size: 12.5px; color: var(--tx-3); padding: 6px 0; }

.cfg-test-row {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 11px; margin-bottom: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.cfg-test-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cfg-test-row strong { font-size: 12.5px; font-weight: 500; color: var(--tx); }
.cfg-test-row small { font-size: 11px; color: var(--tx-3); word-break: break-all; }
.cfg-test-mark {
  width: 18px; height: 18px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 11px; margin-top: 1px;
}
.cfg-test-mark.ok { background: var(--accent-soft); color: var(--accent); }
.cfg-test-mark.err { background: var(--danger); color: #fff; }

/* 窄屏（模态框本身会缩窄）退回单列，否则输入框被压到不可用 */
@media (max-width: 720px) {
  .cfg-group { grid-template-columns: 1fr; }
}

/* 权限矩阵 */
.perm-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-grid th, .perm-grid td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.perm-grid th { font-size: 11.5px; color: var(--tx-3); font-weight: 500; }
.perm-grid input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.perm-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.perm-row {
  display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 4fr); gap: 10px;
  padding: 8px 10px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.perm-row .who { font-size: 13px; }
.perm-row .who small { display: block; color: var(--tx-3); font-size: 11.5px; }
.perm-row .masks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.masks label { display: grid; gap: 4px; font-size: 12px; min-width: 0; }
.perm-options { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.perm-add { display: flex; align-items: flex-end; gap: 12px; }
.perm-add .field { flex: 1; min-width: 0; margin: 0; }
.perm-effective { font-size: 12px; line-height: 1.8; }
.perm-source { border-top: 1px solid var(--line); padding: 12px 0; }
.perm-source > small { display: block; margin: 3px 0 8px; overflow-wrap: anywhere; }
.perm-source .perm-row { background: transparent; border: 0; padding: 0; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll .admin-table { min-width: 540px; }
.table-ops { display: flex; gap: 4px; }
.quota-global { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 6px 0 14px; border-bottom: 1px solid var(--line); }
.quota-global-value { color: var(--tx-2); font-size: 12px; }
.quota-global .btn { display: inline-flex; align-items: center; gap: 6px; }
.quota-global .btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.quota-form { border-block: 1px solid var(--line); padding: 14px 0; margin: 14px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.quota-form .field { margin: 0; min-width: 0; }
.quota-form .admin-actions, #quotaError { grid-column: 1 / -1; }
.number-unit { display: flex; gap: 6px; }
.number-unit input { min-width: 0; flex: 1; }
.number-unit select { width: 85px; }
.check-label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.check-label input { width: 15px; height: 15px; accent-color: var(--accent); }
.field select, .masks select { width: 100%; min-width: 0; padding: 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--tx); font: inherit; }
.field input[type=number] { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--tx); font: inherit; }
.number-unit select { width: 85px; flex: 0 0 85px; }
.number-unit input[type=number] { width: 0; flex: 1; }
.perm-row .who { overflow-wrap: anywhere; }
.admin-table td { overflow-wrap: anywhere; }
button:disabled { cursor: not-allowed; opacity: .5; }
@media (max-width: 600px) {
  .topbar { height: auto; padding: 6px 10px; flex-direction: column; align-items: stretch; gap: 4px; }
  .topbar-left { height: 32px; flex-shrink: 0; }
  .brand { white-space: nowrap; letter-spacing: 0; }
  .topbar-right { min-width: 0; width: 100%; }
  .topbar-right .icon-btn { flex-shrink: 0; }
  .search-box { flex: 1; min-width: 0; }
  .search-box input { width: 100%; min-width: 0; }
  .user-chip { max-width: 90px; white-space: nowrap; overflow: hidden; }
  .user-chip::before { flex-shrink: 0; }
  .toolbar { flex-wrap: wrap; padding: 8px 10px; gap: 4px; }
  .crumbs { width: 100%; }
  .body { position: relative; }
  .list-head, .item { grid-template-columns: minmax(0, 1fr) 55px 84px; gap: 6px; padding-inline: 10px; }
  .modal-mask { padding: 10px; }
  .perm-row { grid-template-columns: minmax(0, 1fr); }
  .perm-row .masks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quota-form { grid-template-columns: minmax(0, 1fr); }
  .tabs { flex-wrap: wrap; }
  .stat-value { font-size: 22px; }
}

/* ---------- 右键菜单 ---------- */
.ctxmenu {
  position: fixed; z-index: 80;
  min-width: 150px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
}
.ctx-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 5px;
  font-size: 13px; color: var(--tx-2); cursor: pointer;
}
.ctx-item:hover { background: var(--surface-2); color: var(--tx); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.ctx-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* ---------- 提示 ---------- */
.toast-wrap {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 9px 16px; border-radius: 999px;
  background: var(--tx); color: var(--bg);
  font-size: 13px; box-shadow: var(--shadow-2);
  animation: toastin .2s ease;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--accent); color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--tx-3); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .list-head, .item { grid-template-columns: 1fr 80px 96px; }
  .col-uploader, .col-time { display: none; }
  .sidebar { position: absolute; z-index: 30; height: calc(100vh - 52px); box-shadow: var(--shadow-2); }
}
