:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e4e8ef;
  --text: #1f2733;
  --muted: #5c6675;
  --hint: #98a1b3;
  --primary: #2563eb;
  --primary-weak: #eef4ff;
  --primary-strong: #1d4ed8;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ---------- 顶栏访客统计 ---------- */
.visit-counter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 18px;
  white-space: nowrap;
  user-select: none;
  transition: border-color .15s, background .15s;
}
.visit-counter:hover { border-color: var(--primary); background: var(--primary-weak); color: var(--primary-strong); }
.visit-counter b {
  color: var(--primary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 0 7px;
  background: var(--primary-weak);
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}


/* ---------- 顶栏 ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f8ef7);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .3);
}
.brand h1 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand .sub { font-size: 12px; color: var(--hint); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search {
  width: 230px; padding: 8px 14px; border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; outline: none; background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-weak); }

.role-switch { display: flex; border: 1px solid var(--border); border-radius: 20px; overflow: hidden; background: var(--bg); }
.role-btn {
  padding: 6px 14px; border: none; background: transparent; cursor: pointer;
  font-size: 12px; color: var(--muted);
}
.role-btn + .role-btn { border-left: 1px solid var(--border); }
.role-btn.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }

.btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 13px; color: var(--text);
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(37, 99, 235, .25); }
.btn.primary:hover { background: var(--primary-strong); color: #fff; }
.btn.ghost { color: var(--muted); }
.btn.danger { color: var(--danger); border-color: #f3c8c8; }
.file-btn { position: relative; }

/* ---------- 统计卡 ---------- */
.stats {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
  padding: 18px 28px 0;
}
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: all .15s;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: #cbd5e1;
}
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .num .badge { font-size: 20px; padding: 2px 14px; box-shadow: none; }
.stat .label { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.stat .sub { font-size: 11px; color: var(--hint); margin-top: 4px; }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); background: #fbfdff; }
.stat.active::before { background: var(--primary); }
.stat[data-status="批次"]::before { background: #3b82f6; }
.stat[data-status="待补批次"]::before { background: #94a3b8; }
.stat[data-status="证照"]::before { background: #8b5cf6; }
.stat[data-status="即将过期"]::before { background: #f59e0b; }

/* ---------- 打包操作条(全局) ---------- */
.pack-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px 0;
}

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 4px; padding: 16px 28px 0; }
.tab {
  padding: 9px 22px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px 8px 0 0; cursor: pointer; font-size: 13px; color: var(--muted);
  border-bottom: none; transition: color .15s;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); font-weight: 600; background: #fff; box-shadow: 0 -2px 6px rgba(16,24,40,.04); }

/* ---------- 视图容器 ---------- */
.view { padding: 0 28px 40px; }

/* ---------- 工具栏 ---------- */
.toolbar {
  background: #fff; border: 1px solid var(--border); border-top: none;
  padding: 12px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border-radius: 0 0 var(--radius) var(--radius);
}
.toolbar select {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); cursor: pointer;
  transition: border-color .15s;
}
.toolbar select:hover { border-color: var(--primary); }
/* ---------- 多选下拉(客户/品牌筛选) ---------- */
.multi-select { position: relative; }
.ms-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); cursor: pointer;
  transition: border-color .15s; min-width: 120px; max-width: 260px;
}
.ms-trigger:hover { border-color: var(--primary); }
.ms-trigger .ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-trigger .ms-count {
  background: var(--primary); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 0 6px; line-height: 16px; min-width: 16px; text-align: center;
}
.ms-trigger .ms-arrow { color: var(--hint); font-size: 10px; }
.ms-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-md); min-width: 220px; max-height: 320px;
  display: none; flex-direction: column; overflow: hidden;
}
.multi-select.open .ms-panel { display: flex; }
.multi-select.open-up .ms-panel { top: auto; bottom: calc(100% + 4px); }
.ms-actions {
  display: flex; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.ms-actions a { color: var(--primary); cursor: pointer; user-select: none; }
.ms-actions a:hover { text-decoration: underline; }
.ms-options { overflow-y: auto; padding: 4px 0; }
.ms-opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  font-size: 13px; cursor: pointer; user-select: none;
}
.ms-opt:hover { background: var(--primary-weak); }
.ms-opt input { accent-color: var(--primary); cursor: pointer; flex: none; }
.ms-opt .ms-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-count-opt {
  flex: none; margin-left: 6px; font-size: 11px; color: var(--hint);
  background: #f1f3f5; border-radius: 8px; padding: 0 6px; line-height: 16px; white-space: nowrap;
}
.ms-empty { padding: 16px 12px; font-size: 12px; color: var(--hint); text-align: center; }
.ms-opt .ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-opt.search-opt { display: flex; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.ms-opt.search-opt input { border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 12px; flex: 1; outline: none; }
.ms-opt.search-opt input:focus { border-color: var(--primary); }
.toolbar-search {
  width: 220px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.toolbar-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
#import-msg { font-size: 12px; color: var(--primary); }

/* ---------- 表格 ---------- */
.table-wrap {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  margin-top: 12px; overflow: auto; box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: #f8fafc; text-align: left;
  padding: 11px 12px; border-bottom: 1px solid var(--border);
  color: var(--muted); font-weight: 600; white-space: nowrap; cursor: pointer;
  user-select: none; font-size: 12px; letter-spacing: .2px;
}
thead th .sort { color: var(--hint); font-size: 11px; }
tbody td { padding: 10px 12px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
tbody tr:nth-child(even) { background: #fbfcfe; }
tbody tr:hover { background: var(--primary-weak); }
tbody tr:last-child td { border-bottom: none; }
.customer { font-weight: 600; color: var(--text); }
.cell-brand { white-space: nowrap; min-width: 90px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
th[data-key="brand"] { min-width: 90px; }
.cell-link a { color: var(--primary); text-decoration: none; }
.cell-link a:hover { text-decoration: underline; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; white-space: nowrap; border: 1px solid transparent; font-weight: 500;
}
.b-normal  { background: #ecfdf3; color: #15803d; border-color: #bbf7d0; }
.b-soon    { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.b-urgent  { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.b-over    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.b-unknown { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.b-batch   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.b-cert    { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.muted { color: #c3cad6; }
.nowrap { white-space: nowrap; }
.b-old    { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; }
.old-row td { color: #9aa4b5; background: #f8fafc; }
.old-row .customer, .old-row a { color: #9aa4b5; }
.old-row .badge { opacity: .7; }
.chk-current {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); cursor: pointer;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: #fff; user-select: none; transition: border-color .15s;
}
.chk-current:hover { border-color: var(--primary); }
.chk-current input { accent-color: var(--primary); cursor: pointer; }
.dl-link {
  color: var(--primary); text-decoration: none; font-size: 14px;
  margin-left: 4px; padding: 0 2px;
}
.dl-link:hover { color: var(--primary-strong); }
.days { font-size: 12px; color: var(--muted); white-space: nowrap; }
.days.neg { color: var(--danger); font-weight: 600; }

.row-actions { display: flex; gap: 8px; }
.row-actions button {
  border: none; background: none; cursor: pointer; font-size: 12px; padding: 2px 4px;
}
.row-actions .edit-btn { color: var(--primary); }
.row-actions .del-btn { color: var(--danger); }
.empty-tip { padding: 40px; text-align: center; color: var(--hint); }

/* ---------- 看板分组切换 ---------- */
.board-groups { display: flex; gap: 8px; margin-top: 14px; }
.bg-btn {
  padding: 6px 16px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; font-size: 13px; color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.bg-btn:hover { border-color: var(--primary); color: var(--primary); }
.bg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 看板 ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px; margin-top: 14px;
  align-items: start;
}
.board-col {
  background: #eef1f6; border-radius: 12px; padding: 10px; min-height: 200px;
}
.board-col h3 {
  font-size: 13px; color: var(--muted); margin: 4px 6px 10px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}
.board-col h3 .cnt {
  background: #fff; border-radius: 20px; padding: 1px 9px; font-size: 12px;
  box-shadow: var(--shadow-sm);
}
.card {
  background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--border); border-left: 4px solid #cbd5e1; cursor: default;
  box-shadow: var(--shadow-sm); transition: box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card .card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card .c-name { font-weight: 600; font-size: 13px; }
.card .c-type { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card .c-meta { font-size: 12px; color: var(--hint); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .c-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.card .c-file { margin-top: 8px; font-size: 12px; }
.card .c-file a { color: var(--primary); text-decoration: none; margin-right: 8px; }
.card .c-ops { margin-top: 8px; display: flex; gap: 10px; }
.card .c-ops button { border: none; background: none; cursor: pointer; font-size: 12px; padding: 0; }
.card.border-normal { border-left-color: #4ade80; }
.card.border-soon { border-left-color: #fbbf24; }
.card.border-urgent { border-left-color: #fb923c; }
.card.border-over { border-left-color: #f87171; }

/* ---------- 日历 ---------- */
.cal-toolbar {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px;
}
.cal-toolbar .cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-toolbar .cal-title { font-size: 15px; font-weight: 700; }
.cal-toolbar button {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 14px; color: var(--muted);
}
.cal-toolbar button:hover { color: var(--primary); border-color: var(--primary); }
.cal-grid {
  background: #fff; border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
}
.cal-week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: #f8fafc; border-bottom: 1px solid var(--border);
}
.cal-week div { padding: 8px 0; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  min-height: 96px; border-right: 1px solid #eef1f6; border-bottom: 1px solid #eef1f6;
  padding: 6px; position: relative; transition: background .15s;
}
.cal-cell:hover { background: #f8fafc; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other-month { background: #f8fafc; }
.cal-cell .day-num { font-size: 12px; color: var(--hint); }
.cal-cell.today .day-num {
  background: var(--primary); color: #fff; border-radius: 50%;
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
}
.cal-item {
  font-size: 11px; border-radius: 5px; padding: 2px 5px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  border: 1px solid transparent;
}
.cal-item:hover { border-color: currentColor; }
.ci-normal { background: #ecfdf3; color: #15803d; }
.ci-soon { background: #fffbeb; color: #b45309; }
.ci-urgent { background: #fff7ed; color: #c2410c; }
.ci-over { background: #fef2f2; color: #b91c1c; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: #fff; border-radius: 16px; width: 600px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 24px 28px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .2);
}
.modal-card h2 { font-size: 16px; font-weight: 700; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-item input, .form-item select, .form-item textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}
.date-row { display: flex; gap: 14px; }
.date-cell { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.att-list { display: flex; flex-wrap: wrap; gap: 8px; }
.att-drop-zone {
  border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px;
  background: #f8fafc; transition: border-color .15s, background .15s;
}
.att-drop-zone.drop-target {
  border-color: var(--primary); border-style: dashed; border-width: 2px;
  background: var(--primary-weak);
}
.att-drop-hint {
  font-size: 12px; color: var(--hint); margin-top: 6px;
  display: flex; align-items: center; gap: 4px;
}
.att-drop-zone.drop-target .att-drop-hint { color: var(--primary); font-weight: 600; }
.att-item {
  display: flex; align-items: center; gap: 6px; background: var(--primary-weak);
  border-radius: 6px; padding: 4px 10px; font-size: 12px;
}
.att-item .att-name { color: var(--primary); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-item .att-del { cursor: pointer; color: var(--danger); border: none; background: none; font-size: 13px; }
.form-foot { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }

/* 设置弹窗 */
.config-sect { margin-bottom: 18px; }
.config-sect h3 { font-size: 14px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #f1f5f9; border-radius: 20px; padding: 4px 12px; font-size: 12px;
  display: flex; align-items: center; gap: 8px;
}
.chip .chip-del { cursor: pointer; color: var(--danger); border: none; background: none; font-size: 14px; }
.config-add { display: flex; gap: 8px; margin-top: 10px; }
.config-add input {
  flex: 1; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none;
}
.config-add input:focus { border-color: var(--primary); }
.tip { font-size: 12px; color: var(--hint); margin-top: 6px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 13px; z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
}
#toast.show { opacity: 1; }

/* ---------- 拖拽上传覆盖层 ---------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 300; pointer-events: none;
  background: rgba(37, 99, 235, .08);
  border: 3px dashed var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.drop-overlay .drop-box {
  background: #fff; border: 2px solid var(--primary); border-radius: 16px;
  padding: 40px 64px; text-align: center; box-shadow: 0 20px 50px rgba(15, 23, 42, .2);
}
.drop-overlay .drop-icon {
  font-size: 42px; color: var(--primary); line-height: 1; margin-bottom: 10px;
}
.drop-overlay .drop-title { font-size: 20px; font-weight: 700; color: var(--text); }
.drop-overlay .drop-hint { font-size: 12px; color: var(--hint); margin-top: 8px; line-height: 1.8; }

/* 拖到表格行/看板卡片上时高亮提示 */
tr.drop-target td { background: #dbeafe !important; }
.card.drop-target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.att-list.drop-target {
  border: 2px dashed var(--primary); border-radius: 8px;
  background: var(--primary-weak); padding: 8px;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .date-row { flex-direction: column; }
}
