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

:root {
  --bg-0: #f0f4fa;
  --bg-1: #e7eef7;
  --bg-soft: #e7eef7;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.85);
  --border: rgba(226, 232, 240, 0.8);
  --border-soft: rgba(232, 237, 244, 0.6);
  --text: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.1));
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 40px rgba(99, 102, 241, 0.12), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-glow: 0 8px 30px rgba(99, 102, 241, 0.25);
  --mono: "Cascadia Mono", Consolas, "JetBrains Mono", monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(99, 102, 241, 0.12) 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, rgba(139, 92, 246, 0.10) 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 背景光斑 */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55; }
.orb-1 { width: 500px; height: 500px; background: #818cf8; top: -140px; left: -100px; animation: float1 18s ease-in-out infinite; }
.orb-2 { width: 460px; height: 460px; background: #c4b5fd; bottom: -160px; right: -80px; animation: float2 22s ease-in-out infinite; }
.orb-3 { width: 340px; height: 340px; background: #a5f3fc; top: 40%; left: 55%; opacity: 0.35; animation: float1 26s ease-in-out infinite reverse; }
@keyframes float1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px, 30px) scale(1.05); } }
@keyframes float2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-50px, -20px) scale(1.08); } }

/* 卡片通用（精致毛玻璃） */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: normal; }
.tiny { font-size: 0.78rem; }
.small { font-size: 0.8rem; }
.tip { margin-top: 10px; }

/* ===== 登录 ===== */
.login-screen {
  position: relative; z-index: 2;
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 380px; max-width: 100%; padding: 36px 30px; text-align: center;
}
.login-card h1 { font-size: 1.5rem; margin: 14px 0 6px; letter-spacing: 1px; }
.login-card input { margin: 18px 0 14px; }
.login-card .tiny { margin-top: 14px; }

.logo-badge {
  width: 64px; height: 64px; margin: 0 auto;
  display: grid; place-items: center;
  background: var(--grad); border-radius: 20px;
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255,255,255,0.3);
  overflow: hidden;
}
.logo-badge.sm { width: 40px; height: 40px; border-radius: 12px; margin: 0; }
.logo-badge .logo-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===== 主布局 ===== */
.app {
  position: relative; z-index: 2;
  display: flex; gap: 18px; padding: 16px;
  max-width: 1280px; margin: 0 auto;
  min-height: 100vh;
  align-items: flex-start;
}
/* 主内容区：撑满侧边栏以外的空间 */
.main { flex: 1; min-width: 0; }

/* 侧边栏 */
.sidebar {
  width: 210px; flex-shrink: 0; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 20px;
  max-height: calc(100vh - 40px);
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.side-brand-text strong { display: block; font-size: 1rem; }
.side-brand-text .tiny { margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: none; color: var(--muted);
  padding: 11px 14px; border-radius: 12px; cursor: pointer;
  font-size: 0.92rem; text-align: left; transition: all 0.2s var(--ease); width: 100%;
  position: relative;
}
.nav-item:hover { background: var(--glass-strong); color: var(--text); transform: translateX(2px); }
.nav-item.active { background: var(--grad); color: #fff; box-shadow: var(--shadow-glow); }
.nav-ico { font-size: 1rem; width: 18px; text-align: center; }
.side-foot { margin-top: auto; }

/* 主内容 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.topbar {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 2px 4px 0;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); transition: 0.3s; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 10px var(--ok); }

/* 视图切换 */
.view { display: none; flex-direction: column; gap: 18px; animation: fade .3s ease; }
.view.active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 卡片 */
.card { padding: 18px; }
.card h3 { font-size: 1.05rem; margin-bottom: 14px; }
.card.highlight { border-color: rgba(155,107,255,0.45); background: rgba(155,107,255,0.08); }

/* 统计 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat { padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-ico {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.2rem;
  background: var(--glass-strong); border: 1px solid var(--border-soft);
}
.stat-num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-family: var(--mono); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* 表单 */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .grow { flex: 1 1 200px; }

input {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 0.9rem;
  outline: none;
  width: 100%;
  transition: all 0.2s var(--ease);
}
input::placeholder { color: #94a3b8; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,0.12); background: #fff; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.grid .span2 { grid-column: span 2; }
input[type="file"] { padding: 9px 12px; }
/* 隐藏 number 输入框的加减按钮（手输即可） */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
input[type="file"]::file-selector-button {
  background: var(--glass-strong); color: var(--text); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 6px 12px; margin-right: 12px; cursor: pointer; font-size: 0.82rem;
}

/* 按钮 */
.btn {
  border: 1px solid var(--border);
  background: var(--glass-strong);
  color: var(--text);
  border-radius: 11px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  backdrop-filter: blur(10px);
}
.btn:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.12); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-glow); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 28px rgba(99,102,241,0.35); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.lg { padding: 13px 24px; font-size: 1rem; margin-top: 6px; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: rgba(220,38,38,0.08); }
.btn.sm { padding: 6px 12px; font-size: 0.8rem; }


/* 最近目录项 */
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 10px;
  background: #f8fafc; border: 1px solid var(--border-soft);
}
.recent-name { font-size: 0.88rem; word-break: break-all; }

/* 目录列表 */
.cat-toolbar { display: flex; gap: 10px; margin: 10px 0 14px; }
.cat-toolbar .grow { flex: 1; }
.item-list { display: flex; flex-direction: column; gap: 6px; }
.item {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: all 0.2s var(--ease);
}
.item:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.selbox { margin-top: 14px; width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; word-break: break-all; }
.item-url { font-size: 0.8rem; color: var(--muted); word-break: break-all; margin: 3px 0; }
.tag {
  font-size: 0.72rem; padding: 2px 10px; border-radius: 999px;
  background: var(--grad-soft); color: var(--primary); border: 1px solid rgba(99,102,241,0.2);
  margin-left: 6px; font-weight: 500;
}
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.empty { color: var(--muted); text-align: center; padding: 18px; font-size: 0.9rem; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--glass-strong); backdrop-filter: blur(20px);
  color: var(--text); font-weight: 600;
  padding: 12px 24px; border-radius: 12px; border: 1px solid var(--border);
  font-size: 0.9rem; z-index: 99; box-shadow: var(--shadow-lg);
  animation: toastIn .3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 自定义滚动条 */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); background-clip: content-box; }

/* 空状态 */
.empty {
  color: var(--muted); text-align: center; padding: 26px 18px; font-size: 0.9rem;
  border: 1px dashed var(--border-soft); border-radius: 12px; background: #f8fafc;
}

/* 统计卡图标着色 */
.stat:nth-child(1) .stat-ico { background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(99,102,241,0.08)); }
.stat:nth-child(2) .stat-ico { background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(16,185,129,0.08)); }
.stat:nth-child(3) .stat-ico { background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(139,92,246,0.08)); }
.stat:nth-child(4) .stat-ico { background: linear-gradient(135deg, rgba(14,165,233,0.25), rgba(14,165,233,0.08)); }

/* 目录项卡片细化为 richer */
.item-ico {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.15rem;
  background: rgba(255,255,255,0.6); border: 1px solid var(--border-soft);
}
.item-ico.file { background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(99,102,241,0.08)); }
.item-ico.link { background: linear-gradient(135deg, rgba(14,165,233,0.25), rgba(14,165,233,0.08)); }
.item-desc { margin: 4px 0 2px; }
.item-meta { display: flex; align-items: center; gap: 8px; margin: 2px 0 0; flex-wrap: wrap; }
.chip {
  font-size: 0.72rem; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border-soft); font-weight: 500;
}
.chip-file { background: rgba(99,102,241,0.12); color: var(--primary); border-color: rgba(99,102,241,0.25); }
.chip-link { background: rgba(14,165,233,0.12); color: #0284c7; border-color: rgba(14,165,233,0.25); }
.dl-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.dl-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.dl-bar span { display: block; height: 100%; border-radius: 999px; background: var(--grad); }
.dl-count { white-space: nowrap; font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }

.icon-btn {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px;
  border: 1px solid var(--border-soft); background: rgba(255,255,255,0.6);
  color: var(--text); cursor: pointer; font-size: 0.95rem; transition: all 0.2s var(--ease);
  display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--primary); transform: translateY(-1px); background: var(--glass-strong); }
.icon-btn.danger:hover { border-color: var(--err); color: var(--err); background: rgba(220,38,38,0.08); }

/* 上传拖拽区 */
.dropzone {
  border: 2px dashed var(--border); border-radius: 14px; padding: 28px 18px;
  text-align: center; cursor: pointer; transition: all 0.25s var(--ease); background: rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
}
.dropzone:hover { border-color: var(--primary); background: var(--grad-soft); }
.dropzone.drag { border-color: var(--primary); background: rgba(99,102,241,0.12); transform: scale(1.01); }
.dz-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dz-inner { pointer-events: none; }
.dz-ico { font-size: 1.5rem; margin-bottom: 6px; }
.dz-link { color: var(--primary); text-decoration: underline; }

/* 登录卡片微光 */
.login-card { border-color: rgba(155,107,255,0.3); }
.login-card::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius);
  background: radial-gradient(400px 200px at 50% -20%, rgba(155,107,255,0.18), transparent 70%);
  pointer-events: none;
}
.login-card { position: relative; overflow: hidden; }

/* 响应式 */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { flex-direction: column; padding: 12px; }
  .sidebar {
    width: 100%; position: static; max-height: none;
    flex-direction: row; flex-wrap: wrap; align-items: center;
  }
  .side-brand { flex: 1; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
  .nav-item { width: auto; flex: 1 1 auto; justify-content: center; }
  .side-foot { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: 1fr; }
  .grid .span2 { grid-column: span 1; }
}

/* 近14天下载趋势柱状图 */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart-bar {
  width: 70%; max-width: 34px; border-radius: 6px 6px 2px 2px;
  background: var(--grad); min-height: 3px;
  transition: height 0.4s ease;
}
.chart-label { font-size: 10px; color: var(--muted-2); font-family: var(--mono); white-space: nowrap; }
.chart-total { margin-top: 8px; text-align: center; }

/* 下载历史 */
.hist-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hist-head h3 { margin-bottom: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; }

/* 分类筛选 chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-btn {
  border: 1px solid var(--border); background: rgba(255,255,255,0.6); color: var(--muted);
  border-radius: 999px; padding: 5px 14px; font-size: 0.78rem; cursor: pointer;
  transition: all 0.2s var(--ease); font-weight: 500;
}
.chip-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.chip-btn.active { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-glow); }

select {
  background: rgba(255,255,255,0.7); border: 1px solid var(--border-soft); color: var(--text);
  border-radius: 11px; padding: 11px 14px; font-size: 0.9rem; outline: none; transition: all 0.2s var(--ease);
}
select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,0.12); }

/* 分片上传进度条 */
.up-progress { margin-top: 6px; }
.up-progress-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.up-progress-bar { height: 10px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.up-progress-bar > span {
  display: block; height: 100%; width: 0%;
  background: var(--grad); border-radius: 999px;
  transition: width 0.3s var(--ease);
  box-shadow: 0 0 8px rgba(99,102,241,0.3);
}
.up-progress-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; gap: 8px; }

/* 页脚（版权 / ICP 备案） */
.site-footer {
  position: relative; z-index: 2;
  text-align: center; padding: 14px 20px 24px;
  font-size: 0.78rem; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
}
.site-footer a { color: var(--muted); text-decoration: none; transition: color 0.2s var(--ease); }
.site-footer a:hover { color: var(--primary); }

/* 分类管理列表 */
.cat-list { display: flex; flex-direction: column; gap: 4px; }
.cat-row {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.55); border: 1px solid var(--border-soft);
  transition: all 0.15s var(--ease);
}
.cat-row:hover { background: rgba(255,255,255,0.75); border-color: var(--primary); }
.cat-toggle {
  width: 20px; height: 20px; flex-shrink: 0; cursor: pointer;
  display: grid; place-items: center; border-radius: 5px;
  color: var(--muted); font-size: 0.65rem; transition: all 0.15s;
}
.cat-toggle:hover { background: var(--glass-strong); color: var(--primary); }
.cat-name { font-weight: 600; flex: 1; font-size: 0.88rem; color: var(--text); }
.cat-actions { display: flex; gap: 4px; }
.btn.danger { color: #dc2626; border-color: rgba(220,38,38,0.3); }
.btn.danger:hover { background: rgba(220,38,38,0.1); }

/* 版本历史列表 */
.ver-list { display: flex; flex-direction: column; gap: 12px; }
.ver-row {
  padding: 14px 16px; border-radius: 12px;
  background: var(--glass-strong); border: 1px solid var(--border-soft);
}
.ver-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.ver-ver { font-weight: 700; font-family: var(--mono); color: var(--primary); }
.ver-time { flex: 1; }
.ver-cl { font-size: 0.88rem; line-height: 1.6; color: var(--text); white-space: normal; word-break: break-word; }

.logo-preview { width: 48px; height: 48px; object-fit: cover; border-radius: 12px; flex-shrink: 0; border: 1px solid var(--border-soft); background: var(--bg-soft); }

/* 自定义弹窗（替代原生 alert/confirm） */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade 0.15s ease;
}
.modal-box {
  max-width: 420px; width: 100%; padding: 24px; border-radius: 16px;
  background: var(--glass-strong); box-shadow: 0 20px 60px rgba(15,23,42,0.3);
}
.modal-msg { font-size: 0.95rem; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-word; margin-bottom: 20px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.modal-btns .btn { min-width: 80px; }
