:root {
  --brand: #1C2B4A;
  --brand-light: #2d4270;
  --accent: #D7263D;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #1f2430;
  --muted: #6b7280;
  --ok: #1a7f52;
  --ok-bg: #e8f5ee;
  --warn: #9a6700;
  --warn-bg: #fff8e1;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(28, 43, 74, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------- 布局 */
.topbar {
  height: 56px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .logo { font-size: 16px; font-weight: 600; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px; }
.topbar .logo .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.topbar nav { display: flex; gap: 4px; margin-left: 24px; }
.topbar nav a {
  color: rgba(255, 255, 255, 0.78);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
}
.topbar nav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.topbar nav a.active { background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 500; }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .user .badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
}
.topbar .user .badge.danger { background: var(--accent); }

.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  flex-shrink: 0;
}
.sidebar .group-title {
  padding: 12px 20px 6px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
}
.sidebar a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 20px;
  color: var(--text);
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.sidebar a:hover { background: #f7f9fc; }
.sidebar a.active {
  background: #eef2f8;
  border-left-color: var(--accent);
  color: var(--brand);
  font-weight: 500;
}
.sidebar a .count { font-size: 12px; color: var(--muted); }

.content { flex: 1; padding: 20px; min-width: 0; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-head h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--brand);
}
.page-head h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 15px;
  background: var(--accent);
  margin-right: 9px;
  vertical-align: -2px;
  border-radius: 2px;
}
.page-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------- 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head .sub { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------------------------------------------------------- 统计 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.stat .value { font-size: 24px; font-weight: 600; color: var(--brand); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .value.accent { color: var(--accent); }
.stat .value.ok { color: var(--ok); }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------- 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: #f7f9fc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--brand);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #f2f6fb; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.5px; }
td.actions { text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------- 徽标 */
.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.info { background: #eaf1fb; color: #1f5fb0; }
.chip.mute { background: #f0f1f3; color: var(--muted); }
.chip.brand { background: #eef2f8; color: var(--brand); }

/* ---------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-light); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: #bf1f33; color: #fff; }
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------- 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(28, 43, 74, 0.08); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------------------------------------------------------- 树 */
.tree { font-size: 13.5px; user-select: none; }
.tree-node { border-radius: 6px; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.tree-row:hover { background: #f2f6fb; }
.tree-row.selected { background: #e6edf7; box-shadow: inset 2px 0 0 var(--accent); }
.tree-row .caret { width: 14px; text-align: center; color: var(--muted); font-size: 10px; flex-shrink: 0; }
.tree-row .icon { font-size: 13px; flex-shrink: 0; opacity: 0.75; }
.tree-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .meta { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.tree-children { margin-left: 15px; border-left: 1px dashed var(--border-strong); padding-left: 4px; }
.tree-children.hidden { display: none; }

/* ---------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-mask.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
.modal.wide { max-width: 820px; }
.modal-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head .close { cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 5px; }
.modal-head .close:hover { background: #f0f1f3; color: var(--accent); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------- 提示 */
.toast-wrap { position: fixed; top: 70px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  animation: slideIn 0.2s ease;
  max-width: 340px;
}
.toast.error { background: var(--accent); }
.toast.ok { background: var(--ok); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

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

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 18px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------- 登录页 */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1C2B4A 0%, #2d4270 100%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 14px;
  padding: 34px 30px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
.auth-card .brand { text-align: center; margin-bottom: 24px; }
.auth-card .brand h1 { font-size: 19px; color: var(--brand); font-weight: 600; }
.auth-card .brand p { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.auth-card .brand .mark {
  width: 40px; height: 40px; background: var(--brand); border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 19px; font-weight: 600; margin-bottom: 10px;
}
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
  flex: 1; padding: 10px; background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--muted); font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--brand); font-weight: 600; border-bottom-color: var(--accent); }
.btn-block { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }

/* ---------------------------------------------------------- 阅读器 */
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #f7f9fc; border-bottom: 1px solid var(--border); gap: 12px;
}
.viewer-bar .title { font-weight: 600; color: var(--brand); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-stage {
  background: #2a2f3a; min-height: 460px; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 72vh; border-radius: 6px; }
.viewer-stage iframe { width: 100%; height: 72vh; border: none; background: #fff; border-radius: 6px; }
.viewer-stage .locked { color: #c7ccd6; text-align: center; font-size: 14px; }
.viewer-stage .locked .big { font-size: 38px; margin-bottom: 10px; opacity: 0.6; }
/* 音视频播放区：全宽铺满 + 状态提示（缓冲中／编码不支持） */
.media-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.media-tip {
  color: #ffd9a0; font-size: 12.5px; line-height: 1.6; text-align: center;
  background: rgba(255, 255, 255, 0.07); border-radius: 5px; padding: 6px 12px; max-width: 620px;
}

.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .layout { flex-direction: column; }
  .topbar nav { display: none; }
}
.scroll-y { max-height: 68vh; overflow-y: auto; }
.loading { text-align: center; padding: 30px; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------- 上传面板（右下角常驻） */
.upload-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 2100;
  width: 370px; max-width: calc(100vw - 32px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 28px rgba(28, 43, 74, 0.18);
  overflow: hidden; animation: slideIn 0.2s ease;
}
.upload-panel.hidden { display: none; }
.up-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--brand); color: #fff; font-size: 13px;
}
.up-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-title b { font-weight: 600; }
.up-close {
  background: none; border: none; color: rgba(255, 255, 255, 0.85); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: 5px; flex-shrink: 0; margin-left: 10px;
}
.up-close:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.up-body { padding: 12px 14px 14px; }
.up-bar { height: 8px; background: #edeff3; border-radius: 99px; overflow: hidden; }
.up-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  border-radius: 99px; transition: width 0.15s ease;
}
.up-fill.okk { background: var(--ok); }
.up-fill.err { background: var(--danger); }
.up-stats { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; font-size: 12px; color: var(--muted); }
.up-files { margin-top: 10px; max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.up-file {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  padding: 5px 8px; background: #f7f8fa; border-radius: 6px;
}
.up-file .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-file .sz { color: var(--muted); flex-shrink: 0; }
.up-file .st { flex-shrink: 0; font-size: 11.5px; }
.up-file .st.wait { color: var(--muted); }
.up-file .st.run { color: var(--brand); }
.up-file .st.ok { color: var(--ok); font-weight: 600; }
.up-file .st.err { color: var(--danger); font-weight: 600; }
.up-result {
  margin-top: 10px; padding: 8px 10px; border-radius: 7px; font-size: 12.5px;
  display: none; align-items: center; gap: 8px;
}
.up-result.show { display: flex; }
.up-result.ok { background: var(--ok-bg); color: var(--ok); }
.up-result.err { background: var(--danger-bg); color: var(--danger); }
.up-result .btn { margin-left: auto; padding: 3px 12px; font-size: 12px; }
@media (max-width: 640px) {
  .upload-panel { right: 12px; bottom: 12px; }
}
