:root {
  --navy: #1b3a5c;
  --navy-dark: #142c47;
  --blue: #2e6fe0;
  --blue-light: #eaf1fd;
  --text: #2a3342;
  --text-muted: #6b7688;
  --border: #e3e6eb;
  --bg: #f5f6f8;
  --white: #ffffff;
  --danger: #d64545;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; }

/* ---------------- 语言切换 ---------------- */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}
.lang-switch button {
  border: none;
  background: #fff;
  padding: 5px 10px;
  color: var(--text-muted);
  cursor: pointer;
}
.lang-switch button.active {
  background: var(--navy);
  color: #fff;
}
.lang-switch button:not(.active):hover { background: var(--bg); }

.login-lang-switch {
  position: absolute;
  top: 22px;
  right: 22px;
}
.login-lang-switch .lang-switch {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
}
.login-lang-switch .lang-switch button {
  background: transparent;
  color: rgba(255,255,255,0.75);
}
.login-lang-switch .lang-switch button.active {
  background: rgba(255,255,255,0.92);
  color: var(--navy);
}

/* ---------------- 登录页 ---------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 55%, #0d2136 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 40px 36px 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-brand .mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.5px;
}

.login-brand .name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.login-brand .name small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.login-card h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 6px;
}

.login-card .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fbfbfc;
  transition: border-color 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}

.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s;
}

.login-btn:hover { background: var(--navy-dark); }
.login-btn:disabled { opacity: 0.6; cursor: default; }

.error-msg {
  background: #fdecec;
  color: var(--danger);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: none;
}

.login-foot {
  margin-top: 22px;
  font-size: 11.5px;
  color: #a4acba;
  text-align: center;
}

/* ---------------- 仪表盘布局 ---------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy);
  color: #cbd6e6;
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}

.sidebar .brand .mark {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

.sidebar .brand .name { font-size: 14px; font-weight: 600; color: #fff; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  color: #b7c3d6;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item svg { width: 16px; height: 16px; opacity: 0.85; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.08);
  border-left-color: var(--blue);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.storage-box { font-size: 11.5px; color: #93a1b7; margin-bottom: 8px; }
.storage-bar {
  height: 5px;
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.storage-bar > div { height: 100%; background: var(--blue); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
}

.crumbs { font-size: 13.5px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs .seg { cursor: pointer; }
.crumbs .seg:hover { color: var(--blue); }
.crumbs .seg.current { color: var(--text); font-weight: 500; cursor: default; }

.topbar-actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.btn:hover { border-color: #c3cad6; background: #fafbfc; }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.primary:hover { background: #255cc2; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
  padding-left: 14px;
  border-left: 1px solid var(--border);
  margin-left: 4px;
  cursor: pointer;
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue-light); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.content { flex: 1; padding: 22px 26px; overflow-y: auto; }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
}

.file-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 12px 12px;
  cursor: pointer;
  position: relative;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.file-card:hover { box-shadow: 0 4px 14px rgba(20,44,71,0.08); border-color: #d2d8e2; }

.file-icon { font-size: 30px; margin-bottom: 10px; }
.file-name {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 34px;
}
.file-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.file-menu-btn {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.1s;
}
.file-card:hover .file-menu-btn { opacity: 1; }
.file-menu-btn:hover { background: var(--bg); }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 42px; margin-bottom: 12px; opacity: 0.5; }
.empty-state .title { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.empty-state .sub { font-size: 12.5px; }

.dropzone-active::after {
  content: "";
  position: fixed; inset: 0;
  background: rgba(46, 111, 224, 0.06);
  border: 2px dashed var(--blue);
  pointer-events: none;
  z-index: 50;
}

/* 右键菜单 / 弹出菜单 */
.ctx-menu {
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(20,44,71,0.16);
  padding: 6px;
  min-width: 150px;
  z-index: 100;
  display: none;
}
.ctx-menu.open { display: block; }
.ctx-menu button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  border-radius: 5px;
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--bg); }
.ctx-menu button.danger { color: var(--danger); }

/* 模态框 */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,30,45,0.4);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal h3 { margin: 0 0 14px; font-size: 15px; }
.modal input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.modal input:focus { outline: none; border-color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 上传进度提示 */
.toast {
  position: fixed;
  bottom: 22px; right: 22px;
  background: #1f2937;
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 300;
  display: none;
  align-items: center;
  gap: 10px;
}
.toast.open { display: flex; }
.toast.error { background: #7a2323; }

@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .sidebar .brand .name, .nav-item span, .storage-box { display: none; }
  .nav-item { justify-content: center; }
}
