/* ========== 基础样式 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2c5f8a;
  --primary-light: #3a7bb5;
  --primary-dark: #1e4263;
  --accent: #4a90d9;
  --bg: #f4f6f9;
  --bg-white: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #e1e8ed;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 6px;
  --sidebar-width: 240px;
  --header-height: 56px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}
#app { display: flex; height: 100vh; }

/* ========== 侧边栏 ========== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e4263 0%, #2c5f8a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.logo {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
}
.logo-text { font-size: 16px; font-weight: 600; }

.nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.nav-group { margin-bottom: 4px; }
.nav-group-title {
  padding: 10px 20px 6px;
  font-size: 12px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.nav-group-title .icon { font-size: 16px; }
.nav-group-title .arrow {
  margin-left: auto;
  transition: transform 0.2s;
  font-size: 10px;
}
.nav-group.collapsed .arrow { transform: rotate(-90deg); }
.nav-group.collapsed .nav-items { display: none; }

.nav-items { padding: 0; }
.nav-item {
  display: block;
  padding: 8px 20px 8px 48px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 500;
}

/* ========== 主内容区 ========== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.header {
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.breadcrumb { font-size: 15px; font-weight: 500; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-info { color: var(--text-light); font-size: 13px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; padding: 24px; min-height: 0; }

/* ========== 仪表盘 ========== */
.dashboard { min-height: 0; padding-right: 4px; }
.dashboard .welcome {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 32px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.dashboard .welcome h1 { font-size: 24px; margin-bottom: 8px; }
.dashboard .welcome .subtitle { opacity: 0.9; font-size: 14px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-white);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
}
.stat-info .stat-value { font-size: 22px; font-weight: 600; color: var(--text); }
.stat-info .stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.recent-activity {
  background: var(--bg-white);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.recent-activity h3 { margin-bottom: 16px; font-size: 16px; }
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 13px;
}
.activity-time { color: var(--text-light); font-size: 12px; }

/* ========== 页面标题和操作栏 ========== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.page-title { font-size: 18px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  background: var(--bg-white);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); color: #fff; }
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { opacity: 0.9; color: #fff; }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { opacity: 0.9; color: #fff; }
.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover { opacity: 0.9; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ========== 搜索/筛选栏 ========== */
.filter-bar {
  background: var(--bg-white);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-bar .form-group { margin: 0; }

/* ========== 表单 ========== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.form-group label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.form-group label .required { color: var(--danger); }
.form-control {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  transition: border-color 0.15s;
  background: var(--bg-white);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(74,144,217,0.15);
}
.form-control:disabled { background: var(--bg); color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 60px; }
select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* ========== 表格 ========== */
.table-container {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.table-wrapper { overflow-x: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.table-wrapper table { width: max-content; min-width: 100%; }
.table-wrapper thead { display: table-header-group; }
.table-wrapper tbody { display: table-row-group; }
table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
thead { background: var(--bg); }
th {
  padding: 4px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ★ 列宽拖拽把手 */
.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  user-select: none;
}
.col-resizer:hover,
.col-resizer.active {
  background: rgba(74,144,217,0.3);
}
.table-wrapper table.col-resizing { cursor: col-resize; user-select: none; }
.table-wrapper table.col-resizing th,
.table-wrapper table.col-resizing td { user-select: none; }
td {
  padding: 3px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ★ td 内联/行内块文本元素也跟随列宽截断，避免溢出到相邻列 */
td > span, td > a, td > label, td > div {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(74,144,217,0.04); }
tr.selected td { background: rgba(74,144,217,0.12); }
tr.bom-group-row td { background: #f0f4f8; font-weight: 500; border-top: 2px solid #d0d7de; }
tr.bom-group-row td:first-child { border-top-left-radius: 4px; }
tr.bom-group-row td:last-child { border-top-right-radius: 4px; }

/* 分页 */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-white);
  flex-shrink: 0;
  gap: 12px;
}
.pagination-info { font-size: 12px; color: var(--text-light); }
.pagination-controls { display: flex; align-items: center; gap: 4px; }
.pagination-controls .btn { padding: 4px 10px; font-size: 12px; min-width: 32px; }
.pagination-controls .page-btn { min-width: 32px; }
.pagination-controls .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-controls .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-size { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-light); }
.pagination-size select { padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }

/* 客户分类栏 */
.customer-layout { display: flex; gap: 16px; flex: 1; min-height: 0; }
/* ★ 选中产品进入明细视图时：JS 会在 renderModule 后把 min-height 锚定到 main.scrollHeight，
   让 customer-layout 高度 = main 自然高度，sidebar 通过 max-height:100% 跟随；
   同时 min-height:0 保持 flex 约束，sidebar-body 内部滚动生效 */
.category-sidebar {
  width: 200px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: visible;
  max-height: 100%;
}
/* ★ detail 模式下 sidebar 保持 max-height:100%，由父容器 min-height 锚定 */
.customer-layout.customer-layout--detail .category-sidebar {
  height: auto;
}
.category-sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 13px;
}
.category-sidebar-body { flex: 1; overflow-y: auto; padding: 4px 0; }
.category-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}
.category-item:hover { background: var(--bg); }
.category-item.active {
  background: rgba(74,144,217,0.08);
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}
.category-item .cat-count {
  background: var(--bg);
  color: var(--text-light);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}
.category-item.active .cat-count {
  background: var(--primary);
  color: #fff;
}
.category-item .cat-toggle {
  font-size: 10px;
  color: var(--text-light);
  width: 12px;
  text-align: center;
  display: inline-block;
  transition: transform 0.15s, color 0.15s;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.category-item .cat-toggle:hover {
  color: var(--primary);
  background: rgba(74,144,217,0.1);
  border-radius: 2px;
}
.category-item .cat-toggle-empty {
  color: #ccc;
  cursor: default;
}
.category-item .cat-toggle-empty:hover {
  color: #ccc;
  background: transparent;
}
.category-item.active .cat-toggle {
  color: var(--primary);
}
/* ★ 分类树两栏：名称列永远完整显示，编码列多余部分省略 */
.category-item .cat-text {
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: visible;
}
.category-item .cat-code {
  flex: 0 1 auto;
  margin-left: 4px;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.category-item.active .cat-code { color: var(--primary); opacity: 0.75; }
/* ★ 仅商品信息页：编码列强制对齐（仅当存在 cat-code 时 cat-text 才撑满，无 code 的行保持原样） */
.products-page .category-item .cat-text:not(:only-child) { flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; }
.products-page .category-item .cat-code { flex: 0 0 auto; }
/* ★ products-page wrapper 承接 customer-layout 的 flex 高度约束，保证 sidebar-body 内部滚动生效 */
.products-page { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.category-add {
  display: flex;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  gap: 4px;
  flex-shrink: 0;
  overflow: visible;
}
.category-add input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
}
.category-add input:focus { outline: none; border-color: var(--primary); }
.category-add button {
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 28px;
  justify-content: center;
  align-items: center;
  display: inline-flex;
}

/* 右键菜单 */
.context-menu {
  position: fixed;
  z-index: 10001;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 4px 0;
  min-width: 150px;
  display: none;
  font-size: 13px;
}
.context-menu-item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s;
}
.context-menu-item:hover { background: #f0f4f8; }
.context-menu-item.primary { color: #409eff; }
.context-menu-item.primary:hover { background: #ecf5ff; }
.context-menu-item.warning { color: #e6a23c; }
.context-menu-item.warning:hover { background: #fdf6ec; }
.context-menu-item.danger { color: #e74c3c; }
.context-menu-item.danger:hover { background: #fdecea; }
.context-menu-item.success { color: #27ae60; }
.context-menu-item.success:hover { background: #e9f9ef; }
.context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.customer-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.table-empty {
  text-align: center;
  padding: 48px;
  color: var(--text-light);
}

/* ========== 标签 ========== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
}
.tag-success { background: #e8f5e9; color: var(--success); }
.tag-warning { background: #fff3e0; color: var(--warning); }
.tag-danger { background: #ffebee; color: var(--danger); }
.tag-info { background: #e3f2fd; color: var(--accent); }
.tag-default { background: var(--bg); color: var(--text-light); }
.tag-primary { background: #e8eaf6; color: var(--primary); }

/* ========== 模态框 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9990;
}
.modal-overlay.active { display: block; }
.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-white);
  border-radius: var(--radius);
  width: 90%;
  max-width: 880px;
  max-height: 85vh;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
}
.modal.active { display: flex; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
/* 底部粘性操作栏 - 滚动时提交按钮始终可见 */
.form-actions {
  position: sticky;
  bottom: -20px;
  margin: 16px -20px -20px;
  padding: 12px 20px;
  text-align: right;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  z-index: 10;
}
/* 占整行的表单字段（用于备注等长文本字段） */
.form-group-full { grid-column: 1 / -1; }

/* ========== Toast 提示 ========== */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 99999;
  font-size: 13px;
  animation: slideIn 0.3s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.show { display: block; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== 选项卡 ========== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  color: var(--text-light);
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

/* ========== 卡片 ========== */
.card {
  background: var(--bg-white);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h3 { font-size: 15px; margin-bottom: 12px; }

/* ========== 工具类 ========== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-light); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.mono { font-family: Consolas, Monaco, monospace; }

/* 状态颜色 */
.status-pending { color: var(--warning); }
.status-approved { color: var(--success); }
.status-rejected { color: var(--danger); }
.status-completed { color: var(--accent); }

/* 子表格内边距 */
.section { margin-bottom: 24px; }
.section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
}

/* ========== 企业微信聊天 ========== */
.wecom-chat {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}
.chat-header {
  background: linear-gradient(135deg, #07c160, #06ad56);
  color: #fff;
  padding: 16px 20px;
}
.chat-bot-info { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.chat-bot-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.chat-bot-name { font-size: 16px; font-weight: 600; }
.chat-bot-status { font-size: 12px; opacity: 0.85; }
.chat-quick-cmds { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-quick-btn {
  background: rgba(255,255,255,0.2);
  color: #fff; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 16px; padding: 4px 14px;
  font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.chat-quick-btn:hover { background: rgba(255,255,255,0.35); }

.chat-body {
  height: 400px; overflow-y: auto;
  padding: 20px; background: #f5f5f5;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.chat-msg {
  display: flex; gap: 10px; margin-bottom: 16px;
  align-items: flex-start;
}
.chat-msg.user-msg { flex-direction: row-reverse; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
  background: var(--accent); color: #fff;
}
.chat-avatar.bot { background: #07c160; font-size: 18px; }
.chat-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble b { font-weight: 600; }
.chat-msg.bot-msg .chat-bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-top-left-radius: 2px;
}
.chat-msg.user-msg .chat-bubble {
  background: #07c160;
  color: #fff;
  border-top-right-radius: 2px;
}
.chat-time { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.chat-msg.user-msg .chat-time { text-align: right; }

.chat-input-area {
  display: flex; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: #07c160; }
.chat-send-btn { white-space: nowrap; }
.chat-send-btn:hover { background: #06ad56; }

code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  color: var(--primary);
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .logo-text,
  .sidebar .nav-item,
  .sidebar .nav-group-title span:not(.icon):not(.arrow) { display: none; }
  .sidebar .nav-group-title { justify-content: center; padding: 10px; }
  .sidebar .nav-item { padding: 10px; justify-content: center; display: flex; }
  .nav-group-title .arrow { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px; }
}

/* 打印样式 */
@media print {
  .sidebar, .header, .page-actions, .filter-bar { display: none; }
  .content { padding: 0; }
  .table-container { box-shadow: none; }
}

/* ========== 登录页面 ========== */
.login-page {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  overflow: hidden;
  background: #060d1a;
}
.login-bg-image {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: url('/images/login-bg.jpg') center/cover no-repeat;
  z-index: 0;
}
.login-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, rgba(6,13,26,0.65) 0%, rgba(6,13,26,0.3) 35%, rgba(10,22,40,0.45) 65%, rgba(17,43,69,0.7) 100%);
  z-index: 1;
}
.login-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 32px 48px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 10;
}
.login-brand-top {
  display: flex;
  align-items: center;
  gap: 16px;
}
.login-logo-icon {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #4a90d9 0%, #1a3a5c 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 4px 24px rgba(74,144,217,0.5);
  position: relative;
  overflow: hidden;
  letter-spacing: -1px;
  line-height: 1;
}
.login-logo-icon::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
  animation: shimmer 3s infinite;
}
.login-logo-text .en {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.2;
}
.login-logo-text .cn {
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  margin-top: 4px;
  letter-spacing: 0.5px;
}
.login-title-right {
  text-align: right;
  color: #fff;
  padding-top: 8px;
}
.login-title-right h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 6px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
}
.login-title-right .subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 1.5px;
}
.login-main {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  padding: 0 8% 0 48px;
}
.login-panel {
  position: relative;
  width: 440px;
  height: 520px;
}
.login-panel-frame {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(10,22,40,0.65) 0%, rgba(13,33,55,0.75) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 4px;
  overflow: hidden;
}
.login-panel-frame::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 80% 30%, rgba(74,144,217,0.08) 0%, transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(74,144,217,0.06) 0%, transparent 40%);
  pointer-events: none;
}
.login-panel-frame::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    linear-gradient(rgba(74,144,217,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,144,217,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
.login-panel-corners {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 2;
}
.login-panel-corners .corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(74,144,217,0.7);
  border-style: solid;
  border-width: 0;
}
.login-panel-corners .corner-tl {
  top: -2px; left: -2px;
  border-top-width: 2px;
  border-left-width: 2px;
}
.login-panel-corners .corner-tr {
  top: -2px; right: -2px;
  border-top-width: 2px;
  border-right-width: 2px;
}
.login-panel-corners .corner-bl {
  bottom: -2px; left: -2px;
  border-bottom-width: 2px;
  border-left-width: 2px;
}
.login-panel-corners .corner-br {
  bottom: -2px; right: -2px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}
.login-panel-content {
  position: relative;
  z-index: 3;
  padding: 50px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
}
.login-panel-title {
  text-align: center;
  margin-bottom: 30px;
}
.login-panel-title h2 {
  font-size: 20px;
  color: #fff;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.login-panel-title p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}
.login-form-group {
  margin-bottom: 20px;
}
.login-form-group label {
  display: block;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 8px;
  font-weight: 500;
}
.login-form-group label .required {
  color: #e74c3c;
  margin-left: 2px;
}
.login-input-wrap {
  position: relative;
}
.login-input-wrap .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.4);
  font-size: 15px;
  z-index: 1;
}
.login-form-group input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid rgba(74,144,217,0.3);
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.25s;
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.login-form-group input::placeholder {
  color: rgba(255,255,255,0.35);
}
.login-form-group input:focus {
  outline: none;
  border-color: rgba(74,144,217,0.8);
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}
.login-btn {
  width: 100%;
  height: 46px;
  margin-top: 8px;
  background: linear-gradient(135deg, #2c5f8a 0%, #4a90d9 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 4px 16px rgba(44,95,138,0.5);
  position: relative;
  overflow: hidden;
}
.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(74,144,217,0.55);
}
.login-btn:active {
  transform: translateY(0);
}
.login-btn::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.1) 50%, transparent 60%);
  animation: shimmer 3s infinite;
}
.login-tip {
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}
.login-tip code {
  background: rgba(74,144,217,0.2);
  padding: 2px 6px;
  border-radius: 3px;
  color: rgba(255,255,255,0.8);
  font-family: monospace;
}
.login-footer {
  position: absolute;
  bottom: 20px;
  left: 48px;
  z-index: 10;
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  letter-spacing: 0.5px;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 登录页隐藏主界面 */
body.login-mode #app { display: none; }
body.login-mode .modal-overlay { display: none !important; }

/* 响应式登录页 */
@media (max-width: 900px) {
  .login-main {
    justify-content: center;
    padding: 0 20px;
  }
  .login-top {
    padding: 20px;
    flex-direction: column;
    gap: 12px;
  }
  .login-title-right {
    text-align: left;
  }
  .login-title-right h1 {
    font-size: 24px;
    letter-spacing: 2px;
  }
  .login-panel {
    width: 100%;
    max-width: 380px;
    height: auto;
    min-height: 460px;
  }
  .login-footer {
    left: 20px;
  }
}
@media (max-width: 600px) {
  .login-logo-icon {
    width: 50px;
    height: 50px;
    font-size: 16px;
  }
  .login-logo-text .en {
    font-size: 18px;
  }
  .login-logo-text .cn {
    font-size: 12px;
  }
  .login-title-right h1 {
    font-size: 20px;
    letter-spacing: 1px;
  }
  .login-title-right .subtitle {
    font-size: 11px;
  }
}
