:root {
  --brand: #0b5cad;
  --brand-dark: #084a8c;
  --brand-soft: #e8f1fb;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --ok: #047857;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

.app { min-height: 100vh; padding-bottom: calc(24px + var(--safe-b)); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand); color: #fff;
  padding: calc(10px + var(--safe-t)) 16px 12px;
  box-shadow: 0 2px 8px rgba(11, 92, 173, .18);
}
.topbar-row { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { font-size: 12px; opacity: .8; margin-top: 2px; }
.icon-btn {
  background: rgba(255,255,255,.16); border: 0; color: #fff;
  width: 34px; height: 34px; border-radius: 10px; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,.3); }

/* ---------------- 通用 ---------------- */
.page { padding: 12px 12px 0; }
.card {
  background: var(--card); border-radius: 14px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06); margin-bottom: 12px; overflow: hidden;
}
.card-pad { padding: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px; border-radius: 10px;
  border: 0; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; transition: opacity .15s;
}
.btn:active { opacity: .82; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-ghost { background: var(--brand-soft); color: var(--brand); }
.btn-plain { background: transparent; color: var(--muted); font-weight: 500; }
.btn-danger { background: #fdeaea; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }

input[type=text], input[type=password], input[type=search], input[type=tel], select {
  min-height: var(--tap); width: 100%; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,92,173,.12); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------------- 登录 ---------------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; background: linear-gradient(160deg, #0b5cad 0%, #084a8c 55%, #062f5c 100%); }
.login-box { background: #fff; border-radius: 18px; padding: 26px 20px; box-shadow: 0 12px 40px rgba(0,0,0,.22); }
.login-logo { width: 54px; height: 54px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; margin-bottom: 14px; }
.login-box h2 { margin: 0 0 4px; font-size: 21px; }
.login-box .hint { margin-bottom: 20px; }
.login-foot { text-align: center; color: rgba(255,255,255,.72); font-size: 12px; margin-top: 18px; }

/* ---------------- 列表 ---------------- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; min-height: var(--tap);
  border-bottom: 1px solid var(--line); cursor: pointer;
  background: #fff;
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: #f8fafc; }
.avatar {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); font-size: 17px;
}
.avatar.folder { background: #fff7e6; color: #b45309; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.li-arrow { color: #c3c9d2; font-size: 18px; flex: 0 0 auto; }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600; background: var(--brand-soft); color: var(--brand);
}
.badge.archived { background: #f1f3f6; color: var(--muted); }
.badge.current { background: #e7f7ee; color: var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 44px 20px; font-size: 14px; }
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .5; }

.searchbar { padding: 12px 12px 4px; display: flex; gap: 8px; align-items: center; }
.searchbar input { background: #fff; flex: 1; min-width: 0; }
.searchbar .btn { flex: 0 0 auto; white-space: nowrap; }

/* ---------------- 多选 / 批量 ---------------- */
.list-item.is-selected { background: #eef6ff; }
.sel-box {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #cbd5e1; background: #fff; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.sel-box.on { background: var(--brand); border-color: var(--brand); }
.selbar { display: flex; gap: 8px; align-items: center; padding: 6px 12px 0; }
.bulkbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b));
  display: flex; gap: 8px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 12px; box-shadow: 0 8px 28px rgba(15,23,42,.22);
  z-index: 40; white-space: nowrap;
}
.bulk-count { font-size: 12px; color: var(--muted); margin-right: 2px; }

/* ---------------- 筛选面板 ---------------- */
.filter-group { padding: 4px 10px 12px; }
.filter-label { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

/* ---------------- 面包屑 ---------------- */
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); padding: 2px 4px 10px; overflow-x: auto; white-space: nowrap; }
.crumbs a { color: var(--brand); text-decoration: none; }
.crumbs .sep { opacity: .5; }

/* ---------------- 上传 FAB ---------------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + var(--safe-b));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: #fff; border: 0; font-size: 26px;
  box-shadow: 0 8px 20px rgba(11,92,173,.38); cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 30;
}
.fab:active { transform: scale(.94); }

/* ---------------- 版本时间线 ---------------- */
.timeline { padding: 4px 0; }
.ver {
  display: flex; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--line); align-items: flex-start;
}
.ver:last-child { border-bottom: 0; }
.ver-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; margin-top: 7px; flex: 0 0 10px; }
.ver.is-current .ver-dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(4,120,87,.14); }
.ver-body { flex: 1; min-width: 0; }
.ver-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ver-no { font-weight: 700; font-size: 15px; }
.ver-file { font-size: 13px; color: var(--text); word-break: break-all; margin-top: 3px; }
.ver-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ver-actions { flex: 0 0 auto; }

/* ---------------- 审计表 ---------------- */
.audit-row { padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-row:last-child { border-bottom: 0; }
.audit-top { display: flex; justify-content: space-between; gap: 10px; }
.audit-act { font-weight: 600; }
.audit-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.audit-detail { color: var(--muted); font-size: 12px; margin-top: 3px; word-break: break-all; }
.act-upload { color: var(--brand); }
.act-download, .act-download_version { color: var(--ok); }
.act-login_failed { color: var(--danger); }
.act-delete_document { color: var(--danger); }

/* ---------------- 上传浮层 ---------------- */
.uploader { position: fixed; inset: 0; background: rgba(15,23,42,.42); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px; }
.uploader-card { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 340px; }
.uploader-title { font-weight: 600; margin-bottom: 6px; }
.uploader-name { font-size: 13px; color: var(--muted); margin-bottom: 12px; word-break: break-all; }
.bar { height: 8px; border-radius: 99px; background: #eef1f5; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--brand); transition: width .18s; }
.uploader-meta { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: right; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  background: rgba(31,41,55,.94); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px;
  max-width: 86vw; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 80; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: rgba(180,83,9,.96); }
.toast.err { background: rgba(185,28,28,.96); }
.toast.ok { background: rgba(4,120,87,.96); }

/* ---------------- 提示条（微信环境等） ---------------- */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 12px 12px 0; padding: 12px 14px;
  background: #fff8e8; border: 1px solid #f5dfae; border-radius: 12px;
}
.notice-main { flex: 1; min-width: 0; font-size: 13px; color: #704a05; line-height: 1.55; }
.notice .btn { flex: 0 0 auto; color: #8a6212; }

/* ---------------- 底部动作面板 ---------------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(15,23,42,.42);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 82vh; overflow-y: auto;
  background: #fff; border-radius: 16px 16px 0 0;
  padding: 8px 8px calc(8px + var(--safe-b));
  box-shadow: 0 -6px 24px rgba(0,0,0,.18);
  animation: sheet-up .18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-title { font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0 10px; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: #fff; border: 0; border-radius: 12px;
  padding: 14px 14px; font-size: 15px; color: var(--text);
  text-align: left; cursor: pointer;
}
.sheet-item:active { background: #f4f6f9; }
.sheet-ico { font-size: 20px; width: 26px; text-align: center; }
.sheet-txt { display: flex; flex-direction: column; line-height: 1.35; }
.sheet-txt small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sheet-cancel { justify-content: center; color: var(--muted); border-top: 1px solid var(--line); border-radius: 0; margin-top: 6px; }

/* ---------------- 工具类 ---------------- */
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.wrap-any { word-break: break-all; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 4px 8px; }

/* ---------------- 容量面板 ---------------- */
.meter-wrap { display: flex; flex-direction: column; gap: 6px; }
.meter {
  height: 10px; border-radius: 6px; overflow: hidden;
  background: #edf0f5;
}
.meter-fill { height: 100%; border-radius: 6px; transition: width .3s ease; }

/* ---------------- 微信登录 / 绑定 ---------------- */
.wx-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px; margin: 14px 0 10px;
}
.wx-divider::before, .wx-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.wx-bind-card { margin-bottom: 12px; }
.wx-bind-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
