:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --sidebar: #0e1726;
  --sidebar-soft: #17223a;
  --text: #16202f;
  --muted: #6b7789;
  --border: #e4e9f2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --success: #15803d;
  --success-soft: #e8f7ee;
  --brand: #fe2c55;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px -18px rgba(16, 24, 40, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
ul { margin: 0; padding: 0; }
em { font-style: normal; }

.muted { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ============ 布局 ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-mark {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fe2c55, #ff6b81);
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 6px 16px -8px rgba(254, 44, 85, 0.9);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
  scrollbar-gutter: stable;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.28); border-radius: 999px; }
.nav::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.45); }
/* 分组折叠：分组标题为整行按钮，箭头指示展开/收起，分组之间用细分隔线区分 */
.nav-group-block { display: flex; flex-direction: column; gap: 2px; }
.nav-group-block + .nav-group-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}
.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-group-toggle:hover { color: #e2e8f0; background: rgba(148, 163, 184, 0.10); }
.nav-group-toggle:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
.nav-group-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: #8b9bb4;
  transition: transform 0.18s ease, color 0.15s ease;
}
.nav-group-toggle:hover .nav-group-arrow { color: #cbd5e1; }
.nav-group-block.is-collapsed .nav-group-arrow { transform: rotate(-90deg); }
.nav-group-body { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav-group-block.is-collapsed .nav-group-body { display: none; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #b8c3d4;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: var(--sidebar-soft); color: #fff; text-decoration: none; }
.nav-item.is-active { background: rgba(37, 99, 235, 0.18); color: #fff; box-shadow: inset 2px 0 0 #60a5fa; }

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 0;
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title h1 { font-size: 18px; }
.topbar-title p { color: var(--muted); font-size: 12px; margin-top: 2px; }

.userbox { display: flex; align-items: center; gap: 16px; }
.user-meta { display: flex; flex-direction: column; text-align: right; line-height: 1.3; }
.user-meta strong { font-size: 13px; }
.user-meta span { color: var(--muted); font-size: 12px; }
.userbox form { margin: 0; }

.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ============ 通用组件 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.card-head h3 { font-size: 15px; }
.card-foot { margin-top: 14px; font-size: 12px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; }
.page-head p { margin-top: 4px; font-size: 13px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #c8d2e3; background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.link {
  color: var(--primary);
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }

.row-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  font-weight: 500;
  white-space: nowrap;
}
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-blue { background: var(--primary-soft); color: var(--primary-dark); }
.badge-gray { background: #eef1f6; color: #5b6678; }

.code {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: #f1f4f9;
  color: #66748a;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); border-color: #c6ebd4; color: #14663a; }
.alert-error { background: var(--danger-soft); border-color: #f7cccc; color: #a61b1b; }
.alert-warn { background: #fff8e6; border-color: #f5dfa6; color: #8a5a00; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fafbfd;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid #f0f3f8;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcff; }
.table-compact td, .table-compact th { padding: 8px 10px; }
.table .empty { text-align: center; color: var(--muted); padding: 34px 12px; }
/* 备注等长文本列：单行截断，完整内容放在 title 中，避免撑破表格 */
.cell-note {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell div { display: flex; flex-direction: column; line-height: 1.35; }
.user-cell .muted { font-size: 11px; }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.filter-bar input[type="search"], .filter-bar select, .filter-bar input[type="date"] {
  min-width: 150px;
}
/* 成本列表页快速录入条：三个字段一行，回车即保存 */
.quick-entry-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.quick-entry-bar input[type="text"], .quick-entry-bar input[type="number"] {
  width: auto; flex: 1 1 170px; min-width: 0;
}
.quick-entry-bar input[name="original_amount"] { flex: 0 1 170px; }
.quick-entry-bar .btn { flex: 0 0 auto; }
.inline-field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.inline-field input { min-width: 0; width: 140px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.pagination-links { display: flex; gap: 8px; }
.page-link {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
}
.page-link:hover { text-decoration: none; border-color: #c8d2e3; }
.page-link.is-disabled { color: #b3bccb; background: #f7f9fc; cursor: not-allowed; }

/* ============ 表单 ============ */
input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  padding: 8px 11px;
  border: 1px solid #d7dee9;
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: #94b4f6;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
input[readonly], input:disabled, select:disabled {
  background: #f5f7fb;
  color: #6b7789;
  cursor: not-allowed;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; }
.field > span em { color: var(--danger); }
.field small { color: var(--muted); font-size: 11.5px; }
.field-error { color: var(--danger); font-size: 12px; }

.form-card { display: flex; flex-direction: column; gap: 8px; }
.form-card.narrow { max-width: 520px; }
.form-section { padding: 6px 0 18px; border-bottom: 1px dashed var(--border); display: flex; flex-direction: column; gap: 14px; }
.form-section:last-of-type { border-bottom: 0; }
.form-section h3 { font-size: 14px; }
.section-desc { font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-actions { display: flex; gap: 10px; padding-top: 8px; }

/* ============ 仓库库存汇总 ============ */
.warehouse-type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.warehouse-type-card { display: block; text-decoration: none; color: inherit; border: 1px solid var(--border); }
.warehouse-type-card.is-active { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12); }
.warehouse-type-card .card-head { margin-bottom: 8px; }
.warehouse-type-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.warehouse-type-metrics > span { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.warehouse-type-metrics strong { font-size: 16px; color: #0f172a; }
.warehouse-type-coverage { margin-top: 10px; font-size: 11.5px; }
.warehouse-type-link { display: block; margin-top: 10px; font-size: 12px; color: #2563eb; }
.warehouse-inventory-note { margin: 0 0 12px; border-left: 3px solid #eab308; font-weight: 500; }
.inventory-card { margin-top: 16px; }
.inventory-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.inventory-metric { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.inventory-metric strong { font-size: 20px; }
.inventory-note { margin-top: 12px; }
.inventory-formula { margin-top: 10px; font-size: 12px; }

/* ============ 修改密码 ============ */
.password-alerts { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.password-grid { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 16px; align-items: start; }
.password-card { gap: 0; max-width: 560px; }
.password-sub { margin-top: 4px; font-size: 12px; }
.password-section { padding: 4px 0 10px; border-bottom: 0; gap: 16px; }
.password-rules {
  background: #f7f9fd;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}
.password-rules-title { display: block; margin-bottom: 4px; font-weight: 600; color: #475569; }
.password-rules ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.password-side .card { height: 100%; max-width: 560px; }
.password-facts { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: #475569; }
.password-tip { margin-top: 16px; }
.password-tip p { margin-top: 4px; }


.hint { font-size: 11px; color: #94a3b8; margin-left: 8px; }
.hint-on { color: #15803d; }
.hint-block {
  background: #f7f9fd;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12.5px;
}

/* ============ 授权矩阵 ============ */
.perm-table { min-width: 560px; }
.perm-table td.center, .perm-table th.center { text-align: center; width: 110px; }
.perm-module td {
  background: #f7f9fd;
  font-weight: 600;
  color: #334155;
  font-size: 12.5px;
}

.perm-groups { display: flex; flex-direction: column; gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.perm-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f7f9fd;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.perm-group-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 18px; padding: 12px 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check span { display: flex; align-items: center; }

/* ============ 工作台 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { display: flex; flex-direction: column; gap: 4px; padding: 18px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-hint { font-size: 12px; color: #94a3b8; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
.perm-summary { display: flex; flex-direction: column; gap: 14px; }
.perm-summary-group { display: flex; flex-direction: column; gap: 6px; }
.perm-summary-head { display: flex; align-items: baseline; justify-content: space-between; font-size: 13px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 2px 9px; border-radius: 6px; font-size: 12px; }
.tag-on { background: var(--primary-soft); color: var(--primary-dark); }
.tag-off { background: #f1f4f9; color: #7c8798; }

/* ============ 审计详情 ============ */
.detail-box summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 12px;
  list-style: none;
  white-space: nowrap;
}
.detail-box summary::-webkit-details-marker { display: none; }
.detail-box summary::before { content: "▸ "; }
.detail-box[open] summary::before { content: "▾ "; }
.detail-body { margin-top: 8px; min-width: 260px; max-width: 420px; }
.detail-summary { font-size: 12.5px; margin-bottom: 6px; }
.diff-list { display: flex; flex-direction: column; gap: 4px; }
.diff-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  align-items: baseline;
  font-size: 12px;
}
.diff-field { color: var(--muted); }
.diff-before { color: #b45309; background: #fffbeb; padding: 1px 5px; border-radius: 4px; }
.diff-after { color: #15803d; background: #f0fdf4; padding: 1px 5px; border-radius: 4px; }
.diff-arrow { color: #94a3b8; }
.detail-text { font-size: 12px; color: var(--muted); }

/* ============ AI 助手 ============ */
.chat-card { display: flex; flex-direction: column; gap: 14px; }
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 260px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 4px 2px;
}
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.chat-msg-user { flex-direction: row-reverse; }
.chat-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.chat-msg-user .chat-avatar { background: #e8f5ee; color: #15803d; }
.chat-bubble {
  max-width: min(760px, 82%);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafd;
}
.chat-msg-user .chat-bubble { background: var(--primary-soft); border-color: #d7e3fb; }
.chat-text { font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.chat-empty { padding: 26px 18px; text-align: center; color: var(--muted); }
.chat-empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 10px; }
.chat-empty ul { list-style: none; display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: #475569; }
.chat-empty p { margin-top: 14px; font-size: 12.5px; }
.chat-usage { font-size: 12px; color: var(--muted); }
.chat-form { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.chat-form textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
.chat-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chat-form-foot .muted { font-size: 11.5px; }
.inline-link { color: inherit; text-decoration: underline; margin-left: 4px; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; color: #475569; line-height: 1.6; }
.plain-list code, .hint-block code { background: #eef2f8; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* ============ 登录页 ============ */
.auth-body {
  background: radial-gradient(1200px 600px at 10% 10%, #1e293b 0%, #0b1220 55%, #070c16 100%);
  min-height: 100vh;
}
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  align-items: center;
  gap: 56px;
  padding: 48px 9vw;
}
.auth-page-center { grid-template-columns: 1fr; place-items: center; }
.auth-panel { color: #e2e8f0; max-width: 520px; }
.auth-brand { display: flex; align-items: center; gap: 16px; }
.brand-mark-lg { width: 56px; height: 56px; flex: 0 0 56px; font-size: 26px; border-radius: 16px; }
.auth-brand h1 { font-size: 26px; color: #fff; }
.auth-brand p { color: #93a4bd; font-size: 13px; margin-top: 4px; }
.auth-points { list-style: none; margin: 36px 0 0; display: flex; flex-direction: column; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #c3cede; }
.auth-points span {
  font-size: 12px;
  font-family: Consolas, monospace;
  color: #7c8aa3;
  border: 1px solid #2b3a52;
  border-radius: 8px;
  padding: 3px 7px;
}
.auth-foot { margin-top: 40px; font-size: 12px; color: #5f708a; }

.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 34px 32px;
  box-shadow: 0 30px 80px -30px rgba(2, 8, 23, 0.9);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-card h2 { font-size: 22px; }
.auth-card-sub { color: var(--muted); font-size: 13px; }
.auth-card .form { gap: 16px; }
.auth-tip { font-size: 12px; color: #94a3b8; text-align: center; }

/* ============ 错误页 ============ */
.error-card { max-width: 480px; text-align: center; padding: 40px 32px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.error-code { font-size: 44px; font-weight: 700; color: #c8d3e5; line-height: 1; }
.error-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ============ 业务模块通用 ============ */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.tab:hover { text-decoration: none; border-color: #c8d2e3; }
.tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab-count {
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 11px;
}
.tab.is-active .tab-count { background: rgba(255, 255, 255, 0.24); }

.sort-link { color: inherit; }
.sort-link:hover { color: var(--primary); text-decoration: none; }
.sort-link.is-active { color: var(--primary); }

.table .group-row td {
  background: #f7f9fd;
  font-weight: 600;
  color: #334155;
  font-size: 12.5px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.alert-badge { font-weight: 600; }
.alert-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #f4f6fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9aa6b8;
  font-size: 11px;
}
.thumb-empty { width: 44px; height: 44px; }
.thumb-lg { width: 96px; height: 96px; }
.thumb-link { display: inline-flex; }
.image-field { display: flex; gap: 12px; align-items: flex-start; }
.image-inputs { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.image-inputs small { color: var(--muted); font-size: 11.5px; }

.field-full { grid-column: 1 / -1; }

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding: 28px 8px;
}
.empty-state strong { font-size: 15px; }

/* 列表无数据：不使用宽表占位，避免窄屏下提示被横向滚出可视区 */
.list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafbfd;
  text-align: center;
}
.list-empty strong { font-size: 14px; }
.list-empty p { font-size: 12.5px; }

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.module-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: #fbfcfe;
  transition: all 0.15s ease;
}
.module-card:hover { border-color: #b9cdf4; background: #f6f9ff; text-decoration: none; }
.module-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.module-card .muted { font-size: 12px; }

.alert-rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.alert-rule { padding: 16px; }
.alert-rule .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1080px) {
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .alert-rule-grid { grid-template-columns: 1fr; }
}

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .password-grid { grid-template-columns: 1fr; }
  .perm-group-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .warehouse-type-grid { grid-template-columns: 1fr; }
  .inventory-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .inventory-metrics { grid-template-columns: 1fr; }
  /* 窄屏顶栏改为两行：标题独占一行，账号信息与退出按钮一行，避免文字被挤成竖排 */
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-title { flex: 1 1 100%; }
  .userbox { width: 100%; justify-content: flex-end; }
  .user-meta { white-space: nowrap; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; padding: 14px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; flex: none; overflow: visible; padding-right: 0; }
  .nav-group-toggle { display: none; }
  .nav-group-block, .nav-group-body { display: contents; }
  .nav-group-block.is-collapsed .nav-group-body { display: contents; }
  .nav-item { padding: 7px 12px; }
  .sidebar-foot { display: none; }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 16px 40px; }
  .auth-page { grid-template-columns: 1fr; padding: 32px 20px; gap: 32px; }
  .auth-panel { max-width: none; }
  .auth-points { display: none; }
  .auth-card { padding: 26px 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .perm-group-body { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -20px; padding: 0 8px; }
}

/* ============ 仓库详情 / 出库单内嵌明细 ============ */
.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: -4px 0 12px; font-size: 13px; }
.breadcrumb .sep { color: #c3ccdc; }
.stat-link { color: inherit; }
.stat-link:hover { text-decoration: none; border-color: #b9cdf4; background: #f8fbff; }
.view-switch { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.view-switch .muted { font-size: 12px; }
.order-detail-list { display: flex; flex-direction: column; gap: 16px; }
.order-detail-card { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.order-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: #f8fafd;
  border-bottom: 1px solid var(--border);
}
.order-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.order-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.order-meta strong { color: var(--text); }
.order-detail-card .table-wrap { margin: 0; padding: 0; }
.order-detail-card .table th { background: #fbfcfe; }
tr.is-unmatched td { background: var(--danger-soft); }
tr.is-unmatched td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.unmatched-name { color: var(--danger); font-weight: 600; }

/* ============ 侵权预警（海外仓产品标签） ============ */
.risk-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; font-size: 13px; }
.risk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: inherit;
  text-decoration: none;
  font-size: 12px;
}
.risk-chip:hover { text-decoration: none; border-color: #b9cdf4; }
.risk-chip.is-active { border-color: var(--risk-color, #2563eb); box-shadow: inset 0 0 0 1px var(--risk-color, #2563eb); }
.risk-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.risk-count { color: var(--muted); font-size: 11px; }
.risk-note { font-size: 12px; }
.risk-badge { text-decoration: none; cursor: pointer; }
.risk-badge:hover { text-decoration: none; filter: brightness(0.96); }

/* ============ 员工日报周报（草稿 / 已提交） ============ */
.report-board { margin-bottom: 4px; }
.report-board .table-wrap table { min-width: 520px; }
.report-board th, .report-board td { white-space: nowrap; }
.report-table { min-width: 900px; }
.report-table .badge { white-space: nowrap; }
.report-table th:nth-child(5), .report-table td:nth-child(5),
.report-table th:nth-child(7), .report-table td:nth-child(7) { white-space: nowrap; }
.report-table td:nth-child(6) { max-width: 300px; }
.report-table td:last-child form { display: inline-block; margin: 0 0 0 6px; }
.report-board-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-board tr.is-pending td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.report-board-note { margin-top: 10px; font-size: 12px; }
.report-form .form-section { gap: 12px; }
.report-form textarea { resize: vertical; min-height: 72px; line-height: 1.6; }
.report-sources { margin-bottom: 2px; }
.report-detail { display: flex; flex-direction: column; gap: 16px; }
.report-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.report-detail-head strong { margin-left: 4px; }
.report-block { border-left: 3px solid var(--primary-soft); padding: 2px 0 2px 14px; }
.report-block h4 { font-size: 13px; color: #475569; margin-bottom: 4px; }
.report-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.7; }
.report-actions { align-items: center; }
.report-actions form { margin: 0; }
.btn-danger { color: var(--danger); border-color: #f3c9c9; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: #eaa8a8; }

@media (max-width: 640px) {
  .report-detail-head { flex-direction: column; }
}
