:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { font-size: 18px; font-weight: 700; color: var(--primary); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.role-badge {
  background: #dbeafe;
  color: var(--primary-dark);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

.role-badge.super { background: #fef3c7; color: #92400e; }

.status-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}
.status-badge.on { background: #dcfce7; color: #166534; }
.status-badge.off { background: #fee2e2; color: #991b1b; }

button {
  font-family: inherit;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid #bfdbfe;
}
button.ghost:hover { background: #eff6ff; }

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fecaca;
}
button.danger:hover { background: #fef2f2; }

button.link {
  background: none;
  color: var(--primary);
  padding: 4px 8px;
  text-decoration: underline;
  font-size: 13px;
}
button.link:hover { background: #eff6ff; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.msg { min-height: 20px; font-size: 14px; margin: 10px 0 0; }
.msg.error { color: var(--danger); }
.msg.success { color: #16a34a; }

/* ---------- 客户页 ---------- */
.customer-main {
  max-width: 760px;
  margin: 48px auto 60px;
  padding: 0 16px;
}

.search-card { text-align: center; padding: 32px; }
.search-card h1 { margin: 0 0 20px; font-size: 24px; }

.search-row {
  display: flex;
  gap: 10px;
}
.search-row input { flex: 1; height: 44px; font-size: 15px; }

.captcha-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  justify-content: center;
  align-items: center;
}
.captcha-row svg { height: 44px; border: 1px solid var(--border); border-radius: 8px; background: #f2f6fc; }
.captcha-row input { width: 200px; height: 44px; }

.results { margin-top: 24px; }
.result-count { color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.result-info { min-width: 0; }
.result-name {
  font-weight: 600;
  word-break: break-all;
}
.result-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.result-meta .kw { color: var(--primary-dark); }

.empty-tip { color: var(--muted); text-align: center; padding: 32px 0; }

/* ---------- 管理端 ---------- */
.admin-main { max-width: 1100px; margin: 24px auto 60px; padding: 0 16px; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 18px;
}
.tab:hover { background: #f1f5f9; color: var(--text); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.panel { display: none; }
.panel.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card { text-align: center; padding: 20px; }
.stat-num { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar input[type="text"], .toolbar select { min-width: 220px; }
.toolbar .spacer { flex: 1; }

.upload-box {
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.upload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.upload-head h3 { margin: 0; font-size: 16px; }
.upload-tag {
  font-size: 12px;
  color: var(--primary-dark);
  background: #dbeafe;
  border-radius: 999px;
  padding: 3px 10px;
}

.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  background: #fafbfe;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}
.drop-zone.dragover { transform: scale(1.01); }
.drop-icon { font-size: 42px; line-height: 1; }
.drop-title { font-size: 15px; margin: 12px 0 4px; color: var(--text); }
.pick-link { color: var(--primary); text-decoration: underline; }
.drop-sub { font-size: 12px; color: var(--muted); margin: 0; }
.drop-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}
.drop-actions .ghost { border-color: #bfdbfe; }

.file-list-wrap {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.file-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.file-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 220px;
  overflow: auto;
}
.file-list-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  font-size: 13px;
}
.file-list-item:nth-child(odd) { background: #fafbfe; }
.file-list-name { word-break: break-all; }
.file-list-size { color: var(--muted); white-space: nowrap; }
.file-list-more { padding: 6px 14px; font-size: 12px; color: var(--muted); }

.file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 14px;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08);
}
.file-icon { font-size: 28px; line-height: 1; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.file-size { font-size: 12px; color: var(--muted); margin-top: 3px; }

.keywords-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.keywords-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  align-self: center;
}
.keywords-row input { flex: 1; }
.keywords-row button { min-width: 96px; }

.toolbar-label {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}

.progress {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.upload-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.upload-row input[type="file"] { flex: 1; min-width: 220px; padding: 6px; }
.upload-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th { background: #f8fafc; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.log-detail { color: var(--muted); font-size: 12px; word-break: break-all; max-width: 320px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card { width: 360px; padding: 32px; }
.login-card h1 { font-size: 20px; margin: 0 0 20px; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.hidden { display: none !important; }
