* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: #f2f4f8;
  color: #2b3245;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1d3557 0%, #2a6f97 100%);
}
.login-card {
  background: #fff;
  border-radius: 10px;
  padding: 36px 40px;
  width: 380px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: #889; font-size: 12px; margin-bottom: 22px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: #556; }
.login-card input {
  width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid #ccd3e0; border-radius: 5px; font-size: 14px;
}
.login-hint { margin-top: 14px; font-size: 12px; color: #99a; text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: #1d3557; color: #fff; padding: 0 18px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 16px; font-weight: 600; padding: 13px 0; white-space: nowrap; }
.tab-nav { display: flex; flex: 1; flex-wrap: wrap; }
.tab {
  background: none; border: none; color: #b8c4d8; font-size: 14px;
  padding: 14px 16px; cursor: pointer; border-bottom: 3px solid transparent;
}
.tab.active { color: #fff; border-bottom-color: #ffd166; font-weight: 600; }
.tab:hover { color: #fff; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.btn-link {
  background: none; border: none; color: #b8c4d8; cursor: pointer; font-size: 13px;
}
.btn-link:hover { color: #fff; }

main { padding: 16px 18px 40px; max-width: 1560px; margin: 0 auto; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border-radius: 8px; padding: 12px 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(20, 30, 60, .08);
}
.toolbar label { font-size: 13px; color: #556; display: flex; align-items: center; gap: 6px; }
.toolbar input, .toolbar select, .ai-question {
  padding: 7px 9px; border: 1px solid #ccd3e0; border-radius: 5px; font-size: 13px;
}
.toolbar input[type="date"], .toolbar input[type="month"] { font-family: inherit; }
.ai-question { flex: 1; min-width: 240px; }
.toolbar-info { font-size: 13px; color: #667; margin-right: auto; }
#tab-month .toolbar-info, #tab-stats .toolbar-info { margin: 0 0 12px; }

/* ---------- 按钮 ---------- */
.btn {
  background: #fff; border: 1px solid #c4ccdb; border-radius: 5px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; color: #33415c;
}
.btn:hover { background: #f0f3f9; }
.btn-primary { background: #2a6f97; border-color: #2a6f97; color: #fff; }
.btn-primary:hover { background: #22577a; }
.btn-block { width: 100%; padding: 10px; font-size: 15px; }
.btn-danger { color: #c1121f; border-color: #e5b4b8; }
.btn-danger:hover { background: #fdeef0; }
.btn-sm { padding: 3px 9px; font-size: 12px; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: #fff; border-radius: 8px; overflow: auto;
  box-shadow: 0 1px 3px rgba(20, 30, 60, .08);
  max-height: calc(100vh - 220px);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.data-table th, .data-table td {
  padding: 8px 10px; border-bottom: 1px solid #eceff5; text-align: left; white-space: nowrap;
}
.data-table thead th {
  position: sticky; top: 0; background: #f7f9fc; z-index: 5;
  font-weight: 600; color: #445; border-bottom: 2px solid #e2e7f0;
}
.data-table tbody tr:hover { background: #f4f8fd; }
.col-actions { width: 110px; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px;
}
.tag-缺货 { background: #fdeeda; color: #b45309; }
.tag-拒收, .tag-二配拒收 { background: #fde2e4; color: #c1121f; }
.tag-二配通过 { background: #e2f0e9; color: #1b6e4b; }
.tag-扣点 { background: #ede7f6; color: #5a3d8a; }
.tag-其他 { background: #e8ecf3; color: #4a5568; }
.tag-待处理 { background: #fff3cd; color: #8a6d00; }
.tag-处理中 { background: #dbeafe; color: #1d4ed8; }
.tag-已完成 { background: #dcfce7; color: #15803d; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 5vh 16px; overflow: auto;
}
.modal-card {
  background: #fff; border-radius: 10px; padding: 24px 26px;
  width: 420px; max-width: 100%; box-shadow: 0 16px 50px rgba(0, 0, 0, .25);
}
.modal-wide { width: 720px; }
.modal-card h3 { margin-bottom: 16px; font-size: 16px; }
.modal-card label { display: block; font-size: 13px; color: #556; margin-bottom: 12px; }
.modal-card input, .modal-card select {
  width: 100%; margin-top: 5px; padding: 8px 10px;
  border: 1px solid #ccd3e0; border-radius: 5px; font-size: 14px;
}
#userActiveWrap { display: flex; align-items: center; gap: 8px; }
#userActiveWrap input { width: auto; margin: 0; }
.form-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px;
}
.form-grid .span-2 { grid-column: span 2; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.import-preview { max-height: 300px; margin: 10px 0; }
.import-force-date {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #556; margin: 10px 0 2px;
}
.import-force-date input { width: auto; margin: 0; }
.import-force-hint { color: #c1121f; font-size: 12px; }

/* ---------- 提示 ---------- */
.error-text { color: #c1121f; font-size: 13px; margin: 8px 0; min-height: 1em; }
.notice {
  background: #fff8e6; border: 1px solid #f5dfa0; color: #7a5b00;
  border-radius: 6px; padding: 10px 12px; font-size: 13px; margin: 8px 0;
}
.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: #22304a; color: #fff; padding: 10px 22px; border-radius: 6px;
  font-size: 13px; z-index: 200; box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.section-title { margin: 22px 0 10px; font-size: 15px; color: #33415c; }

/* ---------- 统计页 ---------- */
.stats-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card {
  background: #fff; border-radius: 8px; padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(20, 30, 60, .08);
}
.stat-card .num { font-size: 24px; font-weight: 700; color: #1d3557; margin-top: 4px; }
.stat-card .label { font-size: 12px; color: #778; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stats-panel {
  background: #fff; border-radius: 8px; padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(20, 30, 60, .08);
}
.stats-panel h4 { font-size: 14px; margin-bottom: 12px; color: #33415c; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.bar-row .name { width: 110px; text-align: right; color: #556; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar { height: 16px; background: #2a6f97; border-radius: 3px; min-width: 2px; }
.bar-row .val { color: #889; white-space: nowrap; }
table.mini { min-width: 0; font-size: 12px; }
table.mini th, table.mini td { padding: 5px 8px; }

/* ---------- AI 页 ---------- */
.ai-result {
  background: #fff; border-radius: 8px; padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(20, 30, 60, .08); margin-top: 12px;
}
.ai-report { white-space: pre-wrap; line-height: 1.85; font-size: 14px; }
.ai-meta { margin-top: 14px; font-size: 12px; color: #99a; border-top: 1px dashed #dde; padding-top: 10px; }
.ai-loading { margin-top: 14px; color: #2a6f97; font-size: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  html { font-size: 13px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { gap: 6px; padding: 0 8px; }
  .tab { padding: 12px 9px; font-size: 13px; }
  main { padding: 10px 8px 30px; }
  .modal-wide { width: 100%; }
  .table-wrap { max-height: calc(100vh - 260px); }
  .ai-question { min-width: 160px; }
}
