:root {
  --bg-page: #f5f6fa;
  --bg-white: #ffffff;
  --bg-hover: #f0f4ff;
  --bg-active: #e8f0fe;
  --border-color: #e8eaf0;
  --text-primary: #1a1a2e;
  --text-secondary: #606880;
  --text-muted: #aab0c0;
  --accent: #1677ff;
  --accent-hover: #0e5fd8;
  --accent-light: #e8f0fe;
  --color-danger: #ff4d4f;
  --color-success: #52c41a;
  --color-warning: #faad14;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.13);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar-width: 180px;
  --navbar-height: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b8c8; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes shake {
  0%,100% { transform:translateX(0); }
  20% { transform:translateX(-6px); }
  40% { transform:translateX(6px); }
  60% { transform:translateX(-4px); }
  80% { transform:translateX(4px); }
}

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--navbar-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  box-shadow: var(--shadow-sm);
}

.navbar-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.navbar-logo .logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #1677ff, #40a9ff);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 18px;
}
.navbar-logo span {
  font-size: 1.1rem; font-weight: 700; color: var(--accent);
}

.navbar-search {
  flex: 1; max-width: 400px; position: relative; margin: 0 24px;
}
.navbar-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 15px; pointer-events: none;
}
.navbar-search input {
  width: 100%; background: var(--bg-page);
  border: 1px solid var(--border-color); border-radius: 20px;
  padding: 7px 16px 7px 36px; font-size: 0.875rem;
  font-family: inherit; color: var(--text-primary); transition: all 0.2s;
}
.navbar-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22,119,255,0.1);
  background: var(--bg-white);
}

.navbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.btn-upload {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent); color: white; border: none;
  border-radius: var(--radius-sm); padding: 8px 20px;
  font-size: 0.9rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-upload:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(22,119,255,0.3); }

/* ── Layout ── */
.main-layout {
  display: flex;
  height: calc(100vh - var(--navbar-height));
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--bg-white);
  border-right: 1px solid var(--border-color);
  padding: 16px 10px; overflow-y: auto;
}

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-secondary);
  font-size: 0.9rem; transition: all 0.15s;
  border: none; background: none; width: 100%; text-align: left;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--accent); }
.sidebar-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.sidebar-item .s-icon { font-size: 18px; flex-shrink: 0; }

/* ── Content ── */
.content-area {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-bottom: 12px; border-bottom: 1px solid var(--border-color);
}

.content-title {
  font-size: 1.1rem; font-weight: 700; color: var(--text-primary);
}

.breadcrumb {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.875rem; flex-wrap: wrap;
}
.breadcrumb-item {
  color: var(--text-secondary); cursor: pointer;
  padding: 2px 6px; border-radius: 4px; transition: all 0.15s;
}
.breadcrumb-item:hover { background: var(--bg-hover); color: var(--accent); }
.breadcrumb-item.current { color: var(--text-primary); font-weight: 500; cursor: default; }
.breadcrumb-item.current:hover { background: none; }
.breadcrumb-sep { color: var(--text-muted); }

.toolbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.btn-sm {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg-white); color: var(--text-secondary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  padding: 6px 12px; font-size: 0.8rem; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.btn-primary {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent); color: white; border: none;
  border-radius: var(--radius-sm); padding: 7px 14px;
  font-size: 0.85rem; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border-color); border-radius: var(--radius-lg);
  padding: 24px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--bg-white); position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: var(--accent-light);
}
.upload-zone .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone .upload-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.upload-zone .upload-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

/* ── Upload Progress ── */
.upload-progress-list { display: flex; flex-direction: column; gap: 6px; }
.upload-item {
  background: var(--bg-white); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 10px 14px;
  animation: slideUp 0.2s ease;
}
.upload-item-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; gap: 10px;
}
.upload-file-name { font-size: 0.85rem; color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-pct { font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; }
.progress-wrap { height: 4px; background: var(--bg-page); border-radius: 2px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #1677ff, #40a9ff);
  transition: width 0.3s ease;
}
.progress-fill.done { background: var(--color-success); }
.progress-fill.err { background: var(--color-danger); }

/* ── File Table ── */
.file-table {
  background: var(--bg-white); border-radius: var(--radius-md);
  border: 1px solid var(--border-color); overflow: hidden;
}

.file-table-header {
  display: grid;
  grid-template-columns: 1fr 110px 160px 48px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem; color: var(--text-muted);
  font-weight: 500;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr 110px 160px 48px;
  padding: 12px 16px; align-items: center;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer; transition: background 0.15s;
  animation: slideUp 0.15s ease both;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--bg-hover); }
.file-row.selected { background: var(--accent-light); }

.file-row-name {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.file-icon-wrap {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0; font-weight: 700;
  font-size: 14px;
}
.file-icon-wrap.folder { background: #fff7e6; }
.file-icon-wrap.word   { background: #e8f4ff; color: #1677ff; font-size: 13px; }
.file-icon-wrap.pdf    { background: #fff1f0; color: #ff4d4f; font-size: 13px; }
.file-icon-wrap.excel  { background: #f6ffed; color: #52c41a; font-size: 13px; }
.file-icon-wrap.ppt    { background: #fff7e6; color: #fa8c16; font-size: 13px; }
.file-icon-wrap.image  { background: #f0f5ff; color: #597ef7; font-size: 18px; }
.file-icon-wrap.video  { background: #f9f0ff; color: #722ed1; font-size: 18px; }
.file-icon-wrap.audio  { background: #e6fffb; color: #13c2c2; font-size: 18px; }
.file-icon-wrap.zip    { background: #fff7e6; color: #d46b08; font-size: 18px; }
.file-icon-wrap.code   { background: #f6ffed; color: #389e0d; font-size: 18px; }
.file-icon-wrap.default { background: var(--bg-page); color: var(--text-muted); font-size: 18px; }

.file-label-name {
  font-size: 0.9rem; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-row-size { font-size: 0.85rem; color: var(--text-secondary); }
.file-row-date { font-size: 0.85rem; color: var(--text-secondary); }
.file-row-actions { display: flex; justify-content: flex-end; opacity: 0; transition: opacity 0.15s; }
.file-row:hover .file-row-actions { opacity: 1; }

.action-btn {
  width: 28px; height: 28px; background: none; border: none;
  border-radius: 6px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted); transition: all 0.15s;
}
.action-btn:hover { background: var(--bg-page); color: var(--text-primary); }

/* ── Context Menu ── */
.context-menu {
  position: fixed;
  background: var(--bg-white); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 6px; z-index: 1000;
  min-width: 150px; box-shadow: var(--shadow-lg);
  animation: fadeIn 0.1s ease;
}
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.875rem; color: var(--text-secondary);
  transition: all 0.12s;
}
.ctx-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctx-item.danger:hover { background: #fff1f0; color: var(--color-danger); }
.ctx-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 500; display: flex; align-items: center;
  justify-content: center; padding: 20px; animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
.hidden { display: none !important; }
.modal {
  background: var(--bg-white); border-radius: var(--radius-lg);
  padding: 28px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease;
}
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.modal-body { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal input {
  width: 100%; background: var(--bg-page);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 0.9rem; font-family: inherit;
  color: var(--text-primary); margin-bottom: 20px; transition: all 0.2s;
}
.modal input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,119,255,0.1); }

.btn-danger {
  background: var(--color-danger); color: white; border: none;
  border-radius: var(--radius-sm); padding: 7px 16px;
  font-size: 0.875rem; font-family: inherit; cursor: pointer;
  font-weight: 500; transition: all 0.2s;
}
.btn-danger:hover { background: #d9363e; }
.btn-cancel {
  background: var(--bg-page); color: var(--text-secondary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  padding: 7px 16px; font-size: 0.875rem; font-family: inherit;
  cursor: pointer; transition: all 0.2s;
}
.btn-cancel:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* ── Preview ── */
.preview-modal { max-width: 85vw; width: auto; }
.preview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.preview-title { font-size: 0.95rem; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { display: flex; align-items: center; justify-content: center; }
.preview-body img { max-width: 100%; max-height: 72vh; border-radius: var(--radius-md); object-fit: contain; }
.preview-body pre {
  background: var(--bg-page); border-radius: var(--radius-md); padding: 16px;
  font-size: 0.82rem; color: var(--text-secondary); white-space: pre-wrap;
  word-break: break-all; max-height: 68vh; overflow: auto; min-width: 480px; width: 100%;
}

/* ── Empty State ── */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-muted); text-align: center; gap: 10px;
}
.empty-state .ei { font-size: 56px; opacity: 0.35; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: 0.85rem; }

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-white); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 11px 16px;
  font-size: 0.875rem; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-md); animation: slideUp 0.25s ease;
  max-width: 300px; pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-danger); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast-fade-out { animation: fadeIn 0.25s ease reverse forwards; }

/* ── Login page specific ── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0f5ff 0%, #e8f4ff 100%);
}
.login-box {
  background: var(--bg-white); border-radius: var(--radius-lg);
  padding: 40px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .li { font-size: 44px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); margin-top: 6px; }
.login-logo p { font-size: 0.85rem; color: var(--text-muted); }
.form-label { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; display: block; }
.form-input-wrap { position: relative; margin-bottom: 20px; }
.form-input {
  width: 100%; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 10px 40px 10px 12px;
  font-size: 0.95rem; font-family: inherit; color: var(--text-primary);
  background: var(--bg-page); transition: all 0.2s;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,119,255,0.1); background: white; }
.form-input.err { border-color: var(--color-danger); animation: shake 0.4s ease; }
.toggle-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--text-muted); padding: 0;
}
.toggle-eye:hover { color: var(--text-primary); }
.err-tip { font-size: 0.78rem; color: var(--color-danger); margin-top: -14px; margin-bottom: 14px; display: none; }
.err-tip.show { display: block; }
.btn-login-full {
  width: 100%; background: var(--accent); color: white; border: none;
  border-radius: var(--radius-sm); padding: 12px;
  font-size: 0.95rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.2s;
}
.btn-login-full:hover { background: var(--accent-hover); }
.btn-login-full:disabled { opacity: 0.65; cursor: not-allowed; }
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: white;
  border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .file-table-header { grid-template-columns: 1fr 48px; }
  .file-table-header .col-size,
  .file-table-header .col-date { display: none; }
  .file-row { grid-template-columns: 1fr 48px; }
  .file-row-size, .file-row-date { display: none; }
  .content-area { padding: 16px; }
  .navbar-search { max-width: 180px; }
}
