
:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-soft: #e8f0fe;
  --danger: #d93025;
  --danger-soft: #fce8e6;
  --text: #1f2937;
  --muted: #64748b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.14);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo {
  width: 48px; height: 48px; border-radius: 12px; background: var(--primary-soft);
  color: var(--primary); display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 12px;
}
.login-card h2 { margin: 0 0 6px; font-size: 20px; }
.login-card p { margin: 0 0 20px; font-size: 12px; color: var(--muted); word-break: break-all; }

input[type="password"], input[type="text"], select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; background: #fff; color: var(--text);
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,0.12); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-icon {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  border-radius: 6px; padding: 4px 6px; font-size: 14px;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

/* Top Header */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.brand-group { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; cursor: pointer; }
.brand-badge {
  background: var(--primary-soft); color: var(--primary);
  padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
}
.search-box { flex: 1; max-width: 420px; min-width: 180px; }
.search-box input { background: var(--bg); border-radius: 999px; padding: 7px 16px; }
.top-actions { display: flex; align-items: center; gap: 6px; }

/* Two-Column App Shell */
.main-layout {
  display: flex;
  min-height: calc(100vh - 55px);
}
.sidebar {
  width: 245px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  overflow-y: auto;
  transition: width 0.2s, padding 0.2s;
}
.sidebar.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text); user-select: none;
}
.tree-row:hover { background: var(--surface-hover); }
.tree-row.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree-arrow {
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--muted); border-radius: 4px; flex-shrink: 0;
}
.tree-arrow:hover { background: rgba(0,0,0,0.06); }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Workspace */
.workspace { flex: 1; min-width: 0; padding: 18px 22px 80px; }
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; background: var(--surface); padding: 10px 14px;
  border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.breadcrumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 14px; }
.crumb { color: var(--primary); cursor: pointer; padding: 4px 8px; border-radius: 6px; font-weight: 500; }
.crumb:hover { background: var(--primary-soft); }
.crumb.active { color: var(--text); cursor: default; font-weight: 600; }
.crumb.active:hover { background: transparent; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: none; background: #fff; padding: 6px 10px; cursor: pointer; font-size: 13px; color: var(--muted); }
.view-toggle button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* Selection Bar */
.batch-bar {
  display: none; align-items: center; justify-content: space-between;
  background: var(--primary-soft); border: 1px solid #bfdbfe;
  border-radius: 10px; padding: 8px 14px; margin-bottom: 14px; font-size: 13px;
}

/* Grid View */
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  display: flex; flex-direction: column; position: relative;
}
.card:hover { border-color: #93c5fd; box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08); }
.card.selected { border-color: var(--primary); background: #f8fbff; }
.card-check { position: absolute; top: 8px; left: 8px; z-index: 2; width: 16px; height: 16px; cursor: pointer; }
.card-thumb {
  height: 132px; background: #f8fafc; display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; border-bottom: 1px solid var(--border); font-size: 40px; position: relative;
}
.card-thumb img, .card-thumb canvas { width: 100%; height: 100%; object-fit: cover; }
.pdf-badge {
  position: absolute; bottom: 6px; right: 6px; background: rgba(217, 48, 37, 0.9);
  color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
}
.card-body { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.card-title {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; margin-bottom: 4px;
}
.card-title:hover { color: var(--primary); }
.card-meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.card-actions {
  display: flex; gap: 4px; margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--border); justify-content: flex-end;
}

/* List View */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: #f8fafc; }
.item-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; color: var(--text); }
.item-name:hover { color: var(--primary); }

/* Drag Overlay */
.drop-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(26, 115, 232, 0.14); border: 3px dashed var(--primary);
  backdrop-filter: blur(2px); align-items: center; justify-content: center; pointer-events: none;
}
.drop-box { background: #fff; padding: 28px 40px; border-radius: 16px; box-shadow: var(--shadow-lg); font-size: 18px; font-weight: 600; color: var(--primary); }

/* Upload Dock */
.upload-dock {
  position: fixed; right: 20px; bottom: 20px; width: 340px; max-width: calc(100vw - 40px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); z-index: 50; display: none; overflow: hidden;
}
.upload-dock-header { background: #1e293b; color: #fff; padding: 10px 14px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.upload-list { max-height: 220px; overflow-y: auto; padding: 8px 14px; }
.upload-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.upload-item:last-child { border-bottom: none; }
.progress-bar { height: 5px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.2s; }

/* Modal & Lightbox */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 80;
  background: rgba(15, 23, 42, 0.65); align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 960px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-header {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #fff;
}
.modal-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body {
  padding: 16px; overflow: hidden; flex: 1; min-height: 360px;
  display: flex; align-items: center; justify-content: center; background: #0f172a; position: relative;
}
.lightbox-stage {
  width: 100%; height: 68vh; display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: grab; user-select: none; position: relative;
}
.lightbox-stage:active { cursor: grabbing; }
.lightbox-stage img {
  max-width: 100%; max-height: 100%; transition: transform 0.08s ease-out;
  transform-origin: center center; pointer-events: none;
}
.zoom-hud {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.78); color: #fff; padding: 4px 12px;
  border-radius: 999px; font-size: 12px; pointer-events: none;
}
.modal-body textarea {
  width: 100%; height: 64vh; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px; line-height: 1.55; padding: 14px; border: 1px solid var(--border);
  border-radius: 8px; resize: vertical; outline: none; background: #fff; color: var(--text);
}
.modal-body iframe { width: 100%; height: 68vh; border: none; border-radius: 8px; background: #fff; }
.modal-body video { max-width: 100%; max-height: 68vh; border-radius: 8px; }
.modal-footer {
  padding: 10px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; background: #fff;
}

.shortcut-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.shortcut-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
kbd {
  background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 4px;
  padding: 2px 6px; font-family: monospace; font-size: 12px;
}
.empty-state {
  text-align: center; padding: 64px 20px; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.footer-info {
  margin-top: 16px; font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}

@media (max-width: 768px) {
  .sidebar { position: fixed; top: 55px; bottom: 0; left: 0; z-index: 30; box-shadow: var(--shadow-lg); }
}
