:root {
  --bg: #F5F5F5;
  --panel: #FFFFFF;
  --panel-soft: #F5F5F5;
  --ink: #1A1A1A;
  --muted: #6B7280;
  --line: rgba(26, 26, 26, 0.10);
  --brand: #4F46E5;
  --brand-soft: rgba(79, 70, 229, 0.10);
  --success: #059669;
  --danger: #b73b28;
  --danger-soft: rgba(183, 59, 40, 0.10);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px;
  background: #EBEBEB;
  color: var(--ink);
}

h1 { font-size: 18px; margin: 0; }
h2 { font-size: 14px; margin: 0; }

button, input, textarea { font: inherit; }

button {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

button:hover { transform: translateY(-1px); }

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 11px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}

input:focus, textarea:focus {
  border-color: rgba(79, 70, 229, 0.4);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.06);
}

textarea { min-height: 100px; resize: vertical; }

/* Shell */
.admin-shell {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.admin-kicker {
  margin: 0 0 2px;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10px;
}

/* Sections */
.admin-section {
  margin-bottom: 12px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.admin-section.compact {
  padding: 12px 16px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* Drop zone */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: all 180ms ease;
  text-align: center;
}

.drop-zone:hover {
  border-color: rgba(79, 70, 229, 0.25);
  background: rgba(79, 70, 229, 0.02);
}

.drop-zone.drag-over {
  border-color: var(--brand);
  background: rgba(79, 70, 229, 0.05);
}

.drop-zone-icon { color: var(--muted); margin-bottom: 6px; opacity: 0.4; }
.drop-zone.drag-over .drop-zone-icon { color: var(--brand); opacity: 1; }
.drop-zone-text { margin: 0; font-size: 13px; color: var(--muted); }
.drop-zone-link { color: var(--brand); cursor: pointer; }
.drop-zone-hint { margin: 3px 0 0; font-size: 11px; color: var(--muted); opacity: 0.5; }
.drop-zone input[type="file"] { display: none; }

/* Toggle paste */
.toggle-paste {
  display: flex; align-items: center; gap: 4px;
  margin-top: 10px; padding: 5px 10px;
  background: transparent; color: var(--muted); font-size: 11px;
  box-shadow: none; border: 1px solid var(--line);
}
.toggle-paste:hover { color: var(--brand); border-color: rgba(79, 70, 229, 0.2); }
.toggle-icon { font-size: 13px; transition: transform 200ms ease; }
.toggle-paste.open .toggle-icon { transform: rotate(45deg); }

.paste-section {
  display: grid; gap: 8px; margin-top: 8px; padding: 12px;
  border-radius: 12px; background: var(--panel-soft); border: 1px solid var(--line);
}
.paste-section.hidden { display: none; }
.button-row { display: flex; gap: 8px; }

/* File list */
.file-list { display: grid; gap: 5px; margin-top: 10px; }
.file-list:empty { display: none; }

.file-item {
  border-radius: 10px; border: 1px solid var(--line);
  background: #fff; transition: background 160ms ease; overflow: hidden;
}
.file-item:hover { background: var(--panel-soft); }

.file-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.file-icon {
  flex: none; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; background: var(--brand-soft); color: var(--brand);
  font-size: 10px; font-weight: 700;
}
.file-info { flex: 1; min-width: 0; }
.file-name { display: block; font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.file-meta.success { color: var(--success); }
.file-meta.error { color: var(--danger); }

.file-progress { height: 3px; border-radius: 3px; background: var(--line); margin-top: 3px; overflow: hidden; }
.file-progress-fill { height: 100%; width: 0; border-radius: 3px; background: var(--brand); transition: width 400ms ease; }

.file-delete {
  flex: none; width: 22px; height: 22px; padding: 0;
  border-radius: 999px; background: transparent; color: var(--muted);
  font-size: 13px; line-height: 1; box-shadow: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 160ms ease;
}
.file-item:hover .file-delete { opacity: 1; }
.file-delete:hover { background: var(--danger-soft); color: var(--danger); }

.file-snippets {
  padding: 0 10px 10px; display: grid; gap: 3px; max-height: 200px;
  overflow-y: auto; border-top: 1px solid var(--line); padding-top: 8px;
}
.file-snippets.hidden { display: none; }

/* Search */
.search-bar input { border-radius: 999px; padding: 8px 14px; font-size: 12px; background: var(--panel-soft); }
.search-results { margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; max-height: 280px; overflow-y: auto; }
.search-results.hidden { display: none; }
.search-group-title { padding: 6px 12px 3px; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid rgba(26,26,26,0.04); background: var(--panel-soft); }
.search-item { display: flex; align-items: flex-start; gap: 6px; padding: 6px 12px; font-size: 12px; line-height: 1.5; border-bottom: 1px solid rgba(26,26,26,0.04); }
.search-item:last-child { border-bottom: none; }
.search-item mark { background: rgba(79,70,229,0.15); color: var(--brand); padding: 0 2px; border-radius: 2px; }
.search-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12px; }

/* Dataset cards */
.overview-section { padding: 16px; }

.overview-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  min-height: 300px;
}

.overview-left {
  overflow-y: auto;
  max-height: 500px;
  padding-right: 6px;
}

.overview-right {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.drill-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.drill-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.drill-head h3 { margin: 0; font-size: 13px; }

.dataset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.dataset-grid + .dataset-grid { margin-top: 10px; }
.dataset-grid:empty { display: none; }

.dataset-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: all 180ms ease;
}

.dataset-card:hover {
  border-color: rgba(79, 70, 229, 0.2);
  background: rgba(79, 70, 229, 0.02);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}

.dataset-card.active {
  border-color: var(--brand);
  background: rgba(79, 70, 229, 0.04);
}

.dataset-icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
}

.text-icon { background: var(--brand-soft); color: var(--brand); }
.doc-icon { background: rgba(5, 150, 105, 0.10); color: var(--success); }

.dataset-info { flex: 1; min-width: 0; }
.dataset-name { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dataset-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.dataset-meta strong { color: var(--ink); }

/* Drill panel */
.drill-body { max-height: 400px; overflow-y: auto; }

.drill-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; font-size: 12px; line-height: 1.5;
  border-bottom: 1px solid rgba(26, 26, 26, 0.04);
}
.drill-item:last-child { border-bottom: none; }
.drill-item:hover { background: var(--panel-soft); }

.drill-idx {
  flex: none; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--panel-soft); color: var(--muted);
  font-size: 10px; font-weight: 700;
}

.drill-text { flex: 1; min-width: 0; word-break: break-word; }

.drill-tag {
  flex: none; padding: 2px 6px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 10px;
}

.drill-delete {
  flex: none; width: 20px; height: 20px; padding: 0;
  border-radius: 999px; background: transparent; color: var(--muted);
  font-size: 12px; line-height: 1; box-shadow: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 160ms ease;
}
.drill-item:hover .drill-delete { opacity: 1; }
.drill-delete:hover { background: var(--danger-soft); color: var(--danger); }

.drill-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; }

/* Snippet sub-items (indented) */
.drill-snippet {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 5px 12px 5px 44px; font-size: 11px; line-height: 1.5;
  border-bottom: 1px solid rgba(26, 26, 26, 0.02);
  color: var(--muted);
}
.drill-snippet:hover { background: rgba(26, 26, 26, 0.02); }
.drill-snippet .drill-delete { width: 18px; height: 18px; font-size: 11px; }
.drill-snippet:hover .drill-delete { opacity: 1; }

/* Footer */
.admin-footer { margin-top: 16px; text-align: center; }
.footer-brand { margin: 0; font-size: 11px; font-weight: 300; letter-spacing: 0.28em; color: rgba(107,114,128,0.20); }

/* Toast */
.toast { position: fixed; right: 16px; bottom: 16px; padding: 8px 14px; border-radius: 10px; background: rgba(26,26,26,0.92); color: #fff; font-size: 12px; }
.toast.error { background: rgba(183,59,40,0.95); }
.hidden { display: none; }

@media (max-width: 600px) {
  .admin-shell { padding: 10px; }
  .dataset-grid { grid-template-columns: 1fr; }
  .overview-layout { grid-template-columns: 1fr; }
  .overview-left { max-height: 200px; }
}
