/* ============ 文档中心 · 全局样式（浅色主题） ============ */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1f2733;
  --text-2: #5b6676;
  --text-3: #8a94a6;
  --primary: #2f6bff;
  --primary-soft: #e8efff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #18a058;
  --ok-soft: #e6f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(23, 32, 48, .08), 0 4px 14px rgba(23, 32, 48, .05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { width: 100%; resize: vertical; }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; font-size: 14px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #c8d3e4; background: #f8fafd; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #265fe0; }
.btn.danger { color: var(--danger); border-color: #f3c2c4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.link { border: none; background: none; color: var(--primary); padding: 4px 6px; }
.btn.link:hover { background: none; text-decoration: underline; }

/* ---- 徽标 / 标签 ---- */
.tag {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 99px;
  font-size: 12px; line-height: 20px; white-space: nowrap;
}
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.tag.green { background: var(--ok-soft); color: var(--ok); }
.tag.gray { background: #eef1f6; color: var(--text-2); }
.tag.orange { background: var(--warn-soft); color: var(--warn); }
.tag.red { background: var(--danger-soft); color: var(--danger); }

/* ============ 登录 / 注册页 ============ */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef3ff 0%, #f6f8fc 45%, #fdf6ec 100%);
  padding: 24px;
}
.auth-card {
  width: 400px; max-width: 100%; background: var(--panel); border-radius: 16px;
  box-shadow: var(--shadow); padding: 36px 36px 28px;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .icon {
  width: 52px; height: 52px; border-radius: 14px; background: var(--primary);
  color: #fff; font-size: 26px; display: inline-flex; align-items: center; justify-content: center;
}
.auth-logo h1 { font-size: 20px; margin-top: 12px; }
.auth-logo p { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.auth-tabs { display: flex; background: #eef1f6; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1; border: none; background: none; padding: 8px; border-radius: 8px;
  font-size: 14px; color: var(--text-2); cursor: pointer;
}
.auth-tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(23,32,48,.12); font-weight: 600; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input { width: 100%; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.auth-msg {
  display: none; margin-bottom: 14px; padding: 9px 12px; border-radius: 8px; font-size: 13px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid #f6cfd1;
}
.auth-msg.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe8d2; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-2); }

/* ============ 主框架 ============ */
.layout { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  height: 54px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 18px; flex-shrink: 0;
}
.topbar .brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { width: 100%; padding-left: 32px; background: var(--bg); border-color: transparent; }
.topbar .search .s-ico { position: absolute; left: 10px; top: 8px; color: var(--text-3); }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px;
  border-radius: 99px; cursor: pointer; border: 1px solid transparent; position: relative;
}
.user-chip:hover { background: var(--bg); border-color: var(--border); }
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.user-chip .uname { font-size: 13px; }
.user-menu {
  position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; padding: 6px; display: none; z-index: 50;
}
.user-menu.open { display: block; }
.user-menu .mi { padding: 8px 10px; border-radius: 7px; font-size: 13px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.user-menu .mi:hover { background: var(--bg); }
.user-menu .mi.danger { color: var(--danger); }
.user-menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }

.body { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 216px; background: var(--panel); border-right: 1px solid var(--border);
  padding: 14px 10px; overflow-y: auto; flex-shrink: 0;
}
.sidebar .group-title { font-size: 12px; color: var(--text-3); padding: 8px 10px 4px; }
.side-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-2); cursor: pointer; user-select: none;
}
.side-item:hover { background: var(--bg); color: var(--text); }
.side-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-item .cnt { margin-left: auto; font-size: 12px; color: var(--text-3); }
.side-folder { padding-left: 12px; }
.side-folder .side-item { font-size: 13px; }

.main { flex: 1; overflow-y: auto; padding: 20px 24px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; }
.page-head .sub { color: var(--text-3); font-size: 13px; }
.page-head .ops { margin-left: auto; display: flex; gap: 8px; }
.crumbs { font-size: 13px; color: var(--text-2); margin-bottom: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs .sep { color: var(--text-3); }

/* ---- 文件表格 ---- */
.table-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-size: 12.5px; color: var(--text-3); font-weight: 500;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fafbfe; white-space: nowrap;
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #f8fafd; }
.fname { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fname .fico {
  width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; background: #eef1f6;
}
.fname .fico.img { background: #e8f3ff; }
.fname .fico.pdf { background: #fdecec; }
.fname .fico.doc { background: #e8efff; }
.fname .fico.sheet { background: #e6f7ee; }
.fname .fico.md { background: #fdf3e3; }
.fname .fico.code { background: #f3e8ff; }
.fname .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.fname .nm:hover { color: var(--primary); cursor: pointer; text-decoration: underline; }
.cell-actions { display: flex; gap: 4px; flex-wrap: nowrap; }
.muted { color: var(--text-3); font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 27, 40, .45); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(10, 16, 30, .25);
  width: 720px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: 960px; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-head .x { margin-left: auto; border: none; background: none; font-size: 18px; color: var(--text-3); cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.modal-head .x:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ---- 预览 ---- */
.preview-area { min-height: 300px; }
.preview-area img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.preview-area iframe { width: 100%; height: 62vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.preview-area pre {
  background: #f6f8fb; border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; white-space: pre-wrap; word-break: break-all;
  max-height: 62vh; overflow: auto;
}
.preview-area .md-body { padding: 4px 2px; max-height: 62vh; overflow: auto; }
.preview-area .md-body h1, .preview-area .md-body h2, .preview-area .md-body h3 { margin: 14px 0 8px; }
.preview-area .md-body p { margin: 8px 0; }
.preview-area .md-body pre { background: #f0f2f6; padding: 10px; border-radius: 8px; overflow: auto; }
.preview-area .md-body code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.preview-area .md-body table { border-collapse: collapse; margin: 10px 0; }
.preview-area .md-body th, .preview-area .md-body td { border: 1px solid var(--border); padding: 6px 10px; }
.preview-note { color: var(--warn); font-size: 13px; background: var(--warn-soft); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.pv-switch { display: flex; gap: 6px; margin-bottom: 10px; }
.pv-frame { width: 100%; height: 62vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.docx-render { max-height: 62vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 18px 22px; background: #fff; }
.docx-render table { border-collapse: collapse; }
.docx-render td, .docx-render th { border: 1px solid #ccc; padding: 4px 8px; }
.xlsx-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.xlsx-wrap { max-height: 56vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.xlsx-wrap table { border-collapse: collapse; font-size: 13px; }
.xlsx-wrap td, .xlsx-wrap th { border: 1px solid var(--border); padding: 4px 8px; white-space: nowrap; }
.xlsx-wrap th { background: #fafbfe; position: sticky; top: 0; }

/* ---- 编辑 ---- */
.edit-area { width: 100%; min-height: 52vh; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; line-height: 1.6; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #fbfcfe; }
.edit-meta { display: flex; gap: 14px; color: var(--text-3); font-size: 12.5px; margin-bottom: 10px; }

/* ---- 上传 ---- */
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 34px 20px; text-align: center;
  color: var(--text-2); cursor: pointer; transition: all .15s; background: #fafbfe;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone .big { font-size: 30px; margin-bottom: 8px; }

/* ---- 表单行 ---- */
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row .field { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.check-line { display: flex; gap: 16px; align-items: center; padding: 8px 0; flex-wrap: wrap; }
.check-line label { display: flex; gap: 6px; align-items: center; font-size: 13.5px; color: var(--text-2); cursor: pointer; }

/* ---- 管理后台 ---- */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.admin-tabs button {
  border: none; background: none; padding: 10px 16px; font-size: 14px; color: var(--text-2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.admin-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-card .n { font-size: 24px; font-weight: 700; }
.stat-card .l { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.role-perms { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Toast ---- */
#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 18px; border-radius: 99px; font-size: 13.5px; box-shadow: var(--shadow);
  background: #fff; border: 1px solid var(--border); animation: toast-in .18s ease;
  max-width: 70vw;
}
.toast.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.toast.err { background: var(--danger); color: #fff; border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 14px; }
  .fname .nm { max-width: 140px; }
}
