:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #1f6feb;
  --primary-dark: #1a5fd0;
  --danger: #d92d20;
  --success: #067647;
  --warning: #b54708;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }

/* ---------------- 登录页 ---------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2f7 0%, #dfe7f2 100%);
}
.login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.login-card .slogan { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13px; }

/* ---------------- 布局 ---------------- */
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-size: 17px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); }

.layout { display: flex; height: calc(100vh - 56px); }
.sidebar {
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  overflow: auto;
  flex-shrink: 0;
}
.sidebar .menu-item {
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  display: block;
}
.sidebar .menu-item:hover { background: #f2f4f7; }
.sidebar .menu-item.active { background: #e8f0fe; color: var(--primary-dark); font-weight: 600; }

.content { flex: 1; padding: 20px; overflow: auto; }

/* ---------------- 组件 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

input, select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label { color: var(--muted); font-size: 13px; }

button, .btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
button:hover, .btn:hover { background: #f2f4f7; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.danger { background: #fff; border-color: #fda29b; color: var(--danger); }
button.danger:hover { background: #fef3f2; }
button:disabled { opacity: .55; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfc; }
tbody tr:hover { background: #fafbfc; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #eef2f7;
  color: var(--muted);
}
.tag.green { background: #e6f6ec; color: var(--success); }
.tag.red { background: #fef3f2; color: var(--danger); }
.tag.blue { background: #e8f0fe; color: var(--primary-dark); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* 目录树 */
.tree-node { padding: 5px 8px; border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-node:hover { background: #f2f4f7; }
.tree-node.active { background: #e8f0fe; color: var(--primary-dark); font-weight: 600; }
.tree-children { margin-left: 14px; }

/* 面包屑 */
.breadcrumb { margin-bottom: 12px; color: var(--muted); }
.breadcrumb span { cursor: pointer; }
.breadcrumb span:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 6px; }

/* 文件网格 */
.file-row { display: flex; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--border); gap: 10px; }
.file-row:hover { background: #fafbfc; }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .meta { width: 110px; color: var(--muted); font-size: 13px; }
.file-row .actions { width: 170px; text-align: right; }
.icon { width: 20px; text-align: center; color: var(--muted); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 10px; width: 720px; max-width: 92vw;
  max-height: 86vh; overflow: auto; box-shadow: 0 20px 40px rgba(16, 24, 40, .2);
}
.modal.small { width: 460px; }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; align-items: center; }
.modal header .close { margin-left: auto; cursor: pointer; color: var(--muted); }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--border); text-align: right; }
.form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
pre.preview-text {
  background: #0d1117; color: #e6edf3; padding: 14px; border-radius: 6px;
  overflow: auto; max-height: 60vh; font-size: 13px; line-height: 1.5; margin: 0;
}

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 200; font-size: 14px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.progress { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

.muted { color: var(--muted); }
.mono { font-family: Consolas, Monaco, "Courier New", monospace; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
