* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── 顶部导航 ─────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 56px;
  background: #fff;
  color: #1a1a2e;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  flex-shrink: 0;
}
.topbar-left { font-size: 18px; font-weight: 600; letter-spacing: .5px; color: #1a1a2e; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.admin-badge {
  background: linear-gradient(135deg, #f6c90e, #f39c12);
  color: #1a1a2e;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
}
.open-panel-btn {
  background: #f0f2f5;
  color: #333;
  border: 1px solid #e2e8f0;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
}
.open-panel-btn:hover { background: #e2e8f0; }
.dl-btn { background: #2f855a !important; }
.dl-btn:hover { background: #276749 !important; }
.btn-outline {
  background: #f0f2f5;
  color: #333;
  border: 1px solid #e2e8f0;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
}
.btn-outline:hover { background: #e2e8f0; }

/* ── 分区标签 ─────────────────────────────────── */
.zone-tabs {
  display: flex;
  background: #fff;
  border-bottom: 2px solid #e2e8f0;
  padding: 0 24px;
  overflow-x: auto;
  flex-shrink: 0;
}
.zone-tab {
  padding: 14px 26px;
  font-size: 15px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  user-select: none;
}
.zone-tab:hover { color: #4f8ef7; }
.zone-tab.active { color: #4f8ef7; border-bottom-color: #4f8ef7; font-weight: 600; }

/* ── 主布局 ───────────────────────────────────── */
.layout { display: flex; flex: 1; min-height: 0; }
.main-area { flex: 1; min-width: 0; padding: 24px 20px; overflow-y: auto; }

/* ── 上传区 ───────────────────────────────────── */
.upload-zone {
  background: #fff;
  border: 2px dashed #a0aec0;
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 20px;
}
.upload-zone.dragover { border-color: #4f8ef7; background: #ebf4ff; }
.upload-icon { font-size: 40px; margin-bottom: 10px; }
.upload-zone p { color: #555; margin-bottom: 6px; font-size: 15px; }
.upload-zone .hint { font-size: 12px; color: #aaa; }
.upload-link { color: #4f8ef7; cursor: pointer; text-decoration: underline; }
.progress-wrap { background: #e2e8f0; border-radius: 99px; height: 7px; margin-top: 14px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #4f8ef7, #6dd5fa); width: 0%; transition: width .2s; border-radius: 99px; }
#uploadMsg { margin-top: 10px; font-size: 14px; min-height: 20px; }
#uploadMsg.success { color: #38a169; }
#uploadMsg.error { color: #e53e3e; }

/* ── 文件列表标题 & 批量工具栏 ──────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  flex-wrap: wrap;
}
.file-count { font-size: 13px; font-weight: 400; color: #aaa; }

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.select-all-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 400;
  color: #555;
  cursor: pointer;
  user-select: none;
}
.select-all-label input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer; accent-color: #4f8ef7;
}
.btn-bulk-action {
  padding: 5px 12px;
  background: #fffbeb;
  color: #b7791f;
  border: 1px solid #fbd38d;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.btn-bulk-action:hover { background: #f6ad55; color: #fff; border-color: #f6ad55; }
.btn-bulk-delete {
  padding: 5px 12px;
  background: #fff5f5;
  color: #e53e3e;
  border: 1px solid #fed7d7;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.btn-bulk-delete:hover { background: #e53e3e; color: #fff; border-color: #e53e3e; }
.btn-archive-zone {
  padding: 5px 12px;
  background: #ebf4ff;
  color: #3a7bd5;
  border: 1px solid #bee3f8;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.btn-archive-zone:hover { background: #4f8ef7; color: #fff; border-color: #4f8ef7; }

/* ── 文件卡片 ─────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.file-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  position: relative;
}
.file-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }
.file-card--featured { border: 2px solid #f6c90e; box-shadow: 0 2px 10px rgba(246,201,14,0.25); }
.file-card--featured:hover { box-shadow: 0 6px 18px rgba(246,201,14,0.4); }
.featured-badge {
  position: absolute; top: 8px; left: 8px;
  background: linear-gradient(135deg, #f6c90e, #f39c12);
  color: #1a1a2e; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 99px; z-index: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.file-select-cb {
  position: absolute; top: 8px; right: 8px;
  width: 17px; height: 17px; z-index: 2;
  cursor: pointer; accent-color: #4f8ef7;
}
.file-thumb { width: 100%; height: 130px; object-fit: cover; display: block; background: #f7f8fa; }
.file-thumb-excel { width: 100%; height: 130px; display: flex; align-items: center; justify-content: center; font-size: 50px; background: linear-gradient(135deg, #f0fff4, #c6f6d5); }
.file-info { padding: 10px 12px 6px; flex: 1; }
.file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.file-meta { font-size: 11px; color: #bbb; display: flex; justify-content: space-between; }
.file-actions { display: flex; gap: 4px; padding: 6px 8px 10px; flex-wrap: wrap; }
.file-actions button {
  flex: 1;
  min-width: 0;
  padding: 5px 2px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f7f8fa;
  font-size: 11px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.file-actions button:hover { background: #ebf4ff; border-color: #4f8ef7; color: #4f8ef7; }
.file-actions .arch-action { border-color: #fbd38d; color: #b7791f; background: #fffbeb; }
.file-actions .arch-action:hover { background: #f6ad55; color: #fff; border-color: #f6ad55; }
.file-actions .del-action { border-color: #fed7d7; color: #e53e3e; background: #fff5f5; }
.file-actions .del-action:hover { background: #e53e3e; color: #fff; border-color: #e53e3e; }
.empty-tip { color: #bbb; padding: 40px 0; text-align: center; grid-column: 1/-1; font-size: 14px; }

/* ── 聊天侧边栏 ───────────────────────────────── */
.chat-sidebar {
  width: 300px; flex-shrink: 0;
  background: #fff; border-left: 1px solid #e2e8f0;
  display: flex; flex-direction: column;
  height: calc(100vh - 56px - 50px);
  overflow: hidden; transition: width .25s ease;
}
.chat-sidebar.collapsed { width: 0; border-left: none; }
.chat-header {
  padding: 14px 16px; font-size: 15px; font-weight: 600;
  color: #1a1a2e; background: #f7f8fa;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; white-space: nowrap; overflow: hidden;
}
.chat-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-clear-btn {
  background: none; border: 1px solid #fed7d7; border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; font-size: 13px; color: #e53e3e;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-clear-btn:hover { background: #e53e3e; color: #fff; border-color: #e53e3e; }
.chat-toggle-btn {
  background: none; border: 1px solid #e2e8f0; border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; font-size: 16px; color: #666;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.chat-toggle-btn:hover { background: #e2e8f0; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
.chat-loading { color: #bbb; font-size: 13px; text-align: center; padding: 20px 0; }
.chat-msg { display: flex; flex-direction: column; gap: 2px; }
.chat-msg-head { display: flex; align-items: baseline; gap: 6px; }
.chat-nick { font-size: 12px; font-weight: 600; color: #4f8ef7; }
.chat-time { font-size: 11px; color: #ccc; }
.chat-bubble {
  background: #f0f2f5; border-radius: 0 10px 10px 10px;
  padding: 7px 11px; font-size: 13px; line-height: 1.5;
  word-break: break-word; max-width: 100%; position: relative;
}
.chat-bubble:hover .del-msg-btn { display: block; }
.del-msg-btn {
  display: none; position: absolute; top: 4px; right: 6px;
  background: #e53e3e; color: #fff; border: none;
  border-radius: 4px; font-size: 10px; padding: 1px 5px; cursor: pointer;
}
.chat-input-area {
  border-top: 1px solid #e2e8f0; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0; background: #fff;
}
.chat-nick-input {
  width: 100%; padding: 6px 10px; border: 1px solid #e2e8f0;
  border-radius: 6px; font-size: 13px; outline: none; transition: border-color .15s;
}
.chat-nick-input:focus { border-color: #4f8ef7; }
.chat-send-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-textarea {
  flex: 1; padding: 7px 10px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 13px; resize: none; outline: none;
  font-family: inherit; transition: border-color .15s; line-height: 1.4;
}
.chat-textarea:focus { border-color: #4f8ef7; }
.chat-send-btn {
  padding: 8px 14px; background: #4f8ef7; color: #fff;
  border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s; white-space: nowrap; align-self: flex-end;
}
.chat-send-btn:hover { background: #3a7bd5; }
.chat-fab {
  position: fixed; bottom: 28px; right: 28px;
  width: 52px; height: 52px; border-radius: 50%;
  background: #4f8ef7; color: #fff; font-size: 22px;
  border: none; cursor: pointer;
  box-shadow: 0 4px 16px rgba(79,142,247,0.45); z-index: 90; transition: transform .15s;
}
.chat-fab:hover { transform: scale(1.08); }

/* ── 弹窗通用 ─────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff; border-radius: 16px; padding: 32px 28px;
  width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal h2 { font-size: 20px; margin-bottom: 20px; color: #1a1a2e; }
.modal-input {
  width: 100%; padding: 10px 14px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 15px; margin-bottom: 12px;
  outline: none; transition: border-color .15s; font-family: inherit;
}
.modal-input:focus { border-color: #4f8ef7; }
.login-err { color: #e53e3e; font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.modal-btns { display: flex; gap: 10px; margin-top: 4px; }
.btn-primary { flex: 1; padding: 10px; background: #4f8ef7; color: #fff; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; font-weight: 600; }
.btn-primary:hover { background: #3a7bd5; }
.btn-ghost { flex: 1; padding: 10px; background: #f7f8fa; color: #555; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 15px; cursor: pointer; }
.btn-ghost:hover { background: #e2e8f0; }

/* ── 管理员面板（卡密）────────────────────────── */
.admin-panel {
  width: 600px !important; max-width: 95vw; max-height: 85vh;
  display: flex; flex-direction: column; padding: 24px !important;
}
.admin-panel-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.admin-panel-head h2 { font-size: 18px; color: #1a1a2e; }
.close-x {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: #999; padding: 4px 8px; border-radius: 6px;
}
.close-x:hover { background: #f0f0f0; }
.gen-card-area {
  display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
}
.modal-select {
  padding: 10px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; outline: none; background: #fff; cursor: pointer;
}
.card-list {
  flex: 1; overflow-y: auto; border: 1px solid #e2e8f0;
  border-radius: 10px; min-height: 200px;
}
.card-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid #f0f0f0; font-size: 13px;
}
.card-item:last-child { border-bottom: none; }
.card-code { font-family: 'Courier New', monospace; font-size: 14px; font-weight: 700; color: #1a1a2e; letter-spacing: 1px; flex: 1; }
.card-label { color: #888; font-size: 12px; min-width: 80px; }
.card-uses { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #ebf4ff; color: #3a7bd5; white-space: nowrap; }
.card-uses.depleted { background: #fed7d7; color: #e53e3e; }
.card-copy-btn { background: #f7f8fa; border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.card-copy-btn:hover { background: #ebf4ff; }
.card-del-btn { background: #fff5f5; border: 1px solid #fed7d7; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: #e53e3e; }
.card-del-btn:hover { background: #e53e3e; color: #fff; border-color: #e53e3e; }
.card-empty { color: #bbb; text-align: center; padding: 40px 0; }
.card-code-input { font-family: 'Courier New', monospace; letter-spacing: 2px; font-size: 17px !important; text-align: center; text-transform: uppercase; }

/* ── 归档库面板 ───────────────────────────────── */
.archive-panel {
  width: 700px !important; max-width: 96vw; max-height: 88vh;
  display: flex; flex-direction: column; padding: 24px !important;
}
.archive-count { font-size: 13px; color: #aaa; font-weight: 400; }
.archive-filter { margin-bottom: 12px; }
.archive-list {
  flex: 1; overflow-y: auto;
  border: 1px solid #e2e8f0; border-radius: 10px; min-height: 200px;
}
.archive-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid #f5f5f5;
}
.archive-item:last-child { border-bottom: none; }
.archive-item:hover { background: #fafbff; }
.archive-icon { font-size: 24px; flex-shrink: 0; }
.archive-info { flex: 1; min-width: 0; }
.archive-name {
  font-size: 14px; font-weight: 500; color: #1a1a2e;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.archive-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #aaa; flex-wrap: wrap; }
.archive-zone-tag {
  background: #ebf4ff; color: #3a7bd5;
  padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 500;
}
.archive-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-archive-dl {
  padding: 5px 12px; background: #f0fff4; color: #2f855a;
  border: 1px solid #c6f6d5; border-radius: 6px; font-size: 12px;
  cursor: pointer; text-decoration: none; transition: background .15s;
  white-space: nowrap;
}
.btn-archive-dl:hover { background: #38a169; color: #fff; border-color: #38a169; }
.btn-archive-rm {
  padding: 5px 12px; background: #fff5f5; color: #e53e3e;
  border: 1px solid #fed7d7; border-radius: 6px; font-size: 12px;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn-archive-rm:hover { background: #e53e3e; color: #fff; border-color: #e53e3e; }
.archive-empty { color: #bbb; text-align: center; padding: 60px 0; font-size: 14px; }

/* ── Viewer ───────────────────────────────────── */
.viewer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  z-index: 300; display: flex; flex-direction: column;
}
.viewer-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: #12121f; color: #fff; flex-shrink: 0;
}
.viewer-title { font-size: 14px; color: #a0aec0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.viewer-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.viewer-toolbar button {
  background: #2d3748; color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background .15s;
}
.viewer-toolbar button:hover { background: #4a5568; }
.close-btn { background: #9b2335 !important; margin-left: 8px; }
.close-btn:hover { background: #c53030 !important; }
#zoomLabel { font-size: 13px; color: #718096; min-width: 42px; }
.viewer-body {
  flex: 1; overflow: auto; display: flex; align-items: center;
  justify-content: center; padding: 24px; cursor: grab;
}
.viewer-body:active { cursor: grabbing; }
#viewerImg { max-width: none; transform-origin: center center; transition: transform .15s; border-radius: 4px; user-select: none; }
#sheetTabsWrap { display: flex; gap: 6px; padding: 8px 16px; background: #1e2133; flex-wrap: wrap; }
.sheet-tab { padding: 4px 14px; border-radius: 6px; border: 1px solid #3d4a6a; cursor: pointer; font-size: 13px; background: #2d3561; color: #a0aec0; }
.sheet-tab.active { background: #4f8ef7; color: #fff; border-color: #4f8ef7; }
.excel-body { flex: 1; overflow: auto; background: #fff; }
.excel-body table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.excel-body th, .excel-body td { border: 1px solid #e2e8f0; padding: 6px 14px; white-space: nowrap; }
.excel-body th { background: #f7f8fa; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.excel-body tr:hover td { background: #ebf4ff; }
