:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e6eaf2;
  --soft: #f0f4fb;
  --primary: #2f6df6;
  --primary-strong: #1f56d8;
  --primary-soft: #e9f0ff;
  --green: #16a34a;
  --orange: #f59e0b;
  --red: #dc2626;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top left, #eef4ff 0, #f8fafc 30%, var(--bg) 70%);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  overflow: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(245, 247, 251, 0.82);
  backdrop-filter: blur(18px);
  transition: opacity .25s ease, visibility .25s ease;
}
.page-loader.hide { opacity: 0; visibility: hidden; }
.loader-card {
  min-width: 260px;
  padding: 24px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}
.loader-card strong { display: block; margin: 12px 0 6px; }
.loader-card small { color: var(--muted); }
.loader-dot {
  width: 36px; height: 36px;
  display: inline-block;
  border: 4px solid #d9e4fb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app { display: grid; grid-template-columns: 272px 1fr; height: 100%; }
.sidebar {
  background: rgba(255, 255, 255, .92);
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.brand-row { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; }
.brand-mark {
  width: 43px; height: 43px;
  display: grid; place-items: center;
  color: white;
  border-radius: 14px;
  background: linear-gradient(135deg, #2f6df6, #33b6ff);
  box-shadow: 0 12px 26px rgba(47, 109, 246, .24);
}
.brand-mark svg { width: 28px; height: 28px; }
.brand-row strong { display: block; font-size: 17px; }
.brand-row span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary, .secondary, .ghost, .plain-btn, .icon-only, .profile-btn, .toolbar-actions button, .storage-panel button {
  border: 0;
  border-radius: 12px;
  min-height: 40px;
}
.primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), #37a6ff);
  box-shadow: 0 12px 24px rgba(47, 109, 246, .22);
}
.primary:hover { background: linear-gradient(135deg, var(--primary-strong), #228de2); }
.primary b { margin-left: 8px; font-size: 18px; }
.primary.small { padding: 0 18px; min-height: 38px; }
.ghost, .secondary, .toolbar-actions button, .storage-panel button {
  color: #27364f;
  background: var(--soft);
}
.ghost:hover, .secondary:hover, .toolbar-actions button:hover, .storage-panel button:hover { background: #e6edf8; }

.side-nav { display: flex; flex-direction: column; gap: 5px; }
.side-nav a {
  height: 42px;
  padding: 0 11px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #3d4b63;
  font-size: 14px;
}
.side-nav a:hover { background: #f2f6fd; }
.side-nav a.active { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.side-nav a span { margin-left: auto; color: #98a2b3; font-size: 12px; }
.side-nav.compact a { height: 38px; }
.side-separator { height: 1px; background: var(--line); margin: -2px 4px; }

.side-nav i, .card-icon, .file-icon, .detail-icon {
  width: 28px; height: 28px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  position: relative;
  background: #eaf0fb;
}
.i-folder, .card-icon.folder, .file-icon.folder { background: #fff5dc; }
.i-doc, .card-icon.doc, .file-icon.document, .detail-icon.document { background: #eaf0ff; }
.i-img, .card-icon.img, .file-icon.image, .detail-icon.image { background: #ebfbf2; }
.i-video, .file-icon.video, .detail-icon.video { background: #fff1f2; }
.i-zip, .file-icon.archive, .detail-icon.archive { background: #f5efff; }
.i-grid::after { content: ""; width: 14px; height: 14px; background: linear-gradient(90deg, #4b7cf7 45%, transparent 45% 55%, #4b7cf7 55%), linear-gradient(#4b7cf7 45%, transparent 45% 55%, #4b7cf7 55%); border-radius: 3px; }
.i-folder::after, .card-icon.folder::after, .file-icon.folder::after { content: ""; width: 17px; height: 12px; background: #d89b18; border-radius: 3px; box-shadow: -4px -4px 0 -1px #f4bf46; }
.i-doc::after, .card-icon.doc::after, .file-icon.document::after, .detail-icon.document::after { content: ""; width: 13px; height: 16px; background: #4779f6; border-radius: 2px; }
.i-img::after, .card-icon.img::after, .file-icon.image::after, .detail-icon.image::after { content: ""; width: 16px; height: 13px; border: 2px solid #22a463; border-radius: 3px; }
.i-video::after, .file-icon.video::after, .detail-icon.video::after { content: ""; width: 0; height: 0; border-left: 11px solid #e34e62; border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 3px; }
.i-zip::after, .file-icon.archive::after, .detail-icon.archive::after { content: "ZIP"; color: #7c3aed; font-weight: 800; font-size: 8px; }
.i-share::after { content: ""; width: 14px; height: 14px; border: 2px solid #64748b; border-radius: 50%; box-shadow: 9px -4px 0 -5px #64748b, 9px 8px 0 -5px #64748b; }
.i-clock::after { content: ""; width: 15px; height: 15px; border: 2px solid #64748b; border-radius: 50%; background: linear-gradient(90deg, transparent 48%, #64748b 48% 58%, transparent 58%), linear-gradient(180deg, transparent 42%, #64748b 42% 52%, transparent 52%); }
.i-trash::after { content: ""; width: 13px; height: 15px; border: 2px solid #64748b; border-top: 0; border-radius: 2px; box-shadow: 0 -5px 0 -2px #64748b; }

.storage-panel {
  margin-top: auto;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, #f8fbff, #edf4ff);
  border: 1px solid #dbe7fb;
}
.storage-top { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px; }
.storage-bar { height: 8px; border-radius: 99px; background: #d9e3f3; overflow: hidden; }
.storage-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #33b6ff); }
.storage-panel p { color: var(--muted); margin: 12px 0; font-size: 13px; }
.storage-panel p b { color: var(--text); }
.storage-panel button { width: 100%; }

.main { min-width: 0; overflow: auto; }
.topbar {
  height: 72px;
  padding: 14px 28px;
  display: flex;
  gap: 18px;
  align-items: center;
  background: rgba(245, 247, 251, .82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(230, 234, 242, .75);
}
.menu-btn { display: none; border: 0; background: white; border-radius: 12px; width: 42px; height: 42px; }
.search-box {
  flex: 1;
  max-width: 680px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
  box-shadow: 0 8px 24px rgba(17, 24, 39, .04);
}
.search-box svg { width: 20px; height: 20px; color: #7c8799; }
.search-box input { flex: 1; border: 0; outline: none; min-width: 0; }
.search-box kbd { border: 1px solid #d7deeb; background: #f8fafc; color: #98a2b3; padding: 2px 7px; border-radius: 7px; font-size: 12px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.plain-btn { padding: 0 16px; background: white; border: 1px solid var(--line); }
.icon-only { position: relative; width: 42px; background: white; border: 1px solid var(--line); }
.notice-dot { position: absolute; top: 10px; right: 10px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; border: 1px solid white; }
.profile-btn { padding: 0 12px 0 6px; background: white; border: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.profile-btn span { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, #111827, #64748b); font-weight: 800; }
.profile-btn em { font-style: normal; color: #374151; }

.workspace { padding: 24px 28px 36px; }
.workspace-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 18px; }
.crumbs { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.crumbs a:hover { color: var(--primary); }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.workspace-header p { margin: 8px 0 0; color: var(--muted); }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.secondary { padding: 0 15px; border: 1px solid transparent; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.summary-card {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 25px rgba(17,24,39,.04);
}
.card-icon { width: 42px; height: 42px; border-radius: 14px; }
.summary-card b { display: block; font-size: 20px; }
.summary-card small { color: var(--muted); }

.content-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.file-panel, .detail-panel {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.file-toolbar {
  height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.selection-info { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.selection-info input, .file-check { width: 16px; height: 16px; accent-color: var(--primary); }
.toolbar-actions { display: flex; gap: 8px; }
.toolbar-actions button { padding: 0 12px; min-height: 34px; color: #3c4960; }
.toolbar-actions button:disabled { opacity: .45; cursor: not-allowed; }
.table-wrap { position: relative; overflow: auto; min-height: 390px; }
.file-table { width: 100%; border-collapse: collapse; min-width: 790px; }
th { height: 44px; text-align: left; color: #7a8495; font-size: 12px; font-weight: 700; background: #fbfcff; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { width: 46px; text-align: center; }
td { height: 62px; border-bottom: 1px solid #edf1f7; font-size: 14px; color: #344054; }
tr:hover td { background: #f8fbff; }
tr.selected td { background: #eef5ff; }
.file-name { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.file-name strong { display: block; color: var(--text); font-weight: 700; }
.file-name small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 99px; background: #eefbf3; color: #188343; font-size: 12px; font-weight: 700; }
.badge.sync { background: #fff7e6; color: #b26a00; }
.more-btn { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 9px; font-size: 18px; color: #7a8495; }
.more-btn:hover { background: #edf2fb; }
.empty { display: none; position: absolute; inset: 74px 0 0; place-items: center; text-align: center; color: var(--muted); }
.empty.show { display: grid; }
.empty-icon { width: 58px; height: 58px; border-radius: 20px; background: #eef4ff; display: grid; place-items: center; margin: 0 auto 12px; font-size: 24px; color: var(--primary); }
.empty strong { color: var(--text); display: block; }
.empty p { margin: 8px 0 0; }

.detail-panel { padding: 18px; position: sticky; top: 92px; }
.detail-head { display: flex; justify-content: space-between; align-items: start; }
.detail-icon { width: 58px; height: 58px; border-radius: 20px; }
#closeDetail { width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--soft); color: var(--muted); font-size: 22px; }
.detail-panel h2 { margin: 16px 0 6px; font-size: 18px; word-break: break-all; }
.detail-panel p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
dl { margin: 0; border-top: 1px solid var(--line); }
dl div { padding: 13px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 80px 1fr; gap: 12px; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; color: #354052; font-size: 13px; word-break: break-all; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

.context-menu {
  position: fixed;
  z-index: 50;
  min-width: 168px;
  padding: 8px;
  display: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(17,24,39,.16);
}
.context-menu.show { display: block; }
.context-menu button { display: block; width: 100%; height: 36px; border: 0; border-radius: 9px; background: transparent; text-align: left; padding: 0 10px; color: #374151; }
.context-menu button:hover { background: #f2f6fd; }
.context-menu .danger { color: var(--red); }
.context-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(10px);
}
.modal.show { display: grid; }
.modal-card { width: min(560px, 100%); background: white; border-radius: 24px; box-shadow: 0 30px 80px rgba(15, 23, 42, .22); overflow: hidden; }
.modal-title { height: 62px; padding: 0 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-title button { width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--soft); font-size: 22px; color: var(--muted); }
.dropzone { margin: 20px; min-height: 190px; border: 2px dashed #c8d6ee; border-radius: 22px; background: #f8fbff; display: grid; place-items: center; text-align: center; padding: 26px; color: var(--muted); }
.dropzone input { display: none; }
.dropzone span { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 28px; margin-bottom: 8px; }
.dropzone b { color: var(--text); display: block; }
.dropzone small { margin-top: 8px; display: block; }
.upload-list { margin: 0 20px; display: grid; gap: 8px; max-height: 140px; overflow: auto; }
.upload-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 20px; border-top: 1px solid var(--line); }

.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 80;
  min-width: 220px;
  max-width: 520px;
  padding: 12px 16px;
  background: #111827;
  color: white;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(0,0,0,.24);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1180px) {
  .content-layout { grid-template-columns: 1fr; }
  .detail-panel { position: static; display: none; }
  .detail-panel.open { display: block; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; min-height: 100%; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 282px; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
  .topbar { padding: 12px 16px; }
  .profile-btn em, .plain-btn, .search-box kbd { display: none; }
  .workspace { padding: 20px 16px 28px; }
  .workspace-header { align-items: flex-start; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .summary-grid { grid-template-columns: 1fr; }
  .file-toolbar { align-items: flex-start; height: auto; padding: 12px; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions button { flex: 1; }
}
