:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0e7490;
  --primary-dark: #155e75;
  --primary-soft: #ecfeff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

/* 保证 hidden 属性始终生效，不被其他 display 规则覆盖 */
[hidden] { display: none !important; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 认证页 ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/bg-salmon.jpg') center / cover no-repeat fixed;
  padding: 24px;
}
.auth-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.55);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  position: relative;
  z-index: 1;
}

.brand { text-align: center; margin-bottom: 28px; }
.brand-logo {
  display: block;
  margin: 0 auto 18px;
  height: 44px;
  width: auto;
}
.brand h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: 0.3px; }
.brand p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- 表单 ---------- */
label.field { display: block; margin-bottom: 16px; }
label.field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  height: 44px;
}
input[type="date"] {
  position: relative;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.55;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 0.9; background: #f1f5f9; }
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.15);
}
select:disabled { background: #f8fafc; color: var(--muted); cursor: not-allowed; }

.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand-inline { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; }
.topbar-logo { height: 28px; width: auto; display: block; }
.topbar .right { display: flex; align-items: center; gap: 16px; }
.topbar .company { color: var(--primary); font-weight: 600; }
.topbar .muted { color: var(--muted); font-size: 13px; }

/* ---------- 布局 ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 28px 24px 60px; }
.section { margin-bottom: 28px; }
.section-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); display: inline-block;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- 下单表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}
.form-grid .full { grid-column: 1 / -1; }

.unit-group { display: flex; gap: 10px; }
.unit-group label {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s;
}
.unit-group input { display: none; }
.unit-group label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: none; background: #f8fafc; white-space: nowrap; }
tbody tr:hover { background: #fafcfe; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-withdrawn { background: #f1f5f9; color: var(--muted); }
.badge-shipped { background: var(--success-soft); color: var(--success); }
.badge-unmarked { background: #fffbeb; color: #b45309; }

.empty { text-align: center; color: var(--muted); padding: 32px 0; font-size: 14px; }

/* ---------- 筛选栏 ---------- */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: end;
}
.filter-grid .field { margin-bottom: 0; }
.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-range input { flex: 1; min-width: 0; }
.date-sep {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  user-select: none;
  white-space: nowrap;
}

/* ---------- 操作栏 ---------- */
.action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.action-bar .spacer { flex: 1; }
.check-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.check-all input { width: 16px; height: 16px; cursor: pointer; }

/* ---------- 表格分组行 ---------- */
.group-row td {
  background: #eef6fb;
  color: #0c4a6e;
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
td input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; vertical-align: middle; }

/* ---------- 已撤回/已发货 删除线 ---------- */
tr.row-withdrawn td:not(:first-child),
tr.row-shipped td:not(:first-child) {
  text-decoration: line-through;
  opacity: 0.62;
}
tr.row-withdrawn td:first-child,
tr.row-shipped td:first-child {
  opacity: 0.85;
}

/* ---------- 摘要条 ---------- */
.summary {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.summary .stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  min-width: 120px;
}
.summary .stat b { font-size: 22px; display: block; }
.summary .stat span { color: var(--muted); font-size: 12px; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
}
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal .modal-detail {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  margin: 12px 0 20px;
}
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  padding: 11px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---------- 手机端响应式 ---------- */
@media (max-width: 768px) {
  /* 认证卡片 */
  .auth-card { padding: 28px 20px; border-radius: 14px; }
  .brand-logo { height: 36px; }
  .brand h1 { font-size: 18px; }

  /* 顶栏 */
  .topbar { padding: 0 12px; height: 54px; }
  .topbar .brand-inline { font-size: 14px; gap: 8px; }
  .topbar-logo { height: 24px; }
  .topbar .right { gap: 8px; }
  .btn-sm { padding: 5px 9px; font-size: 12px; }

  /* 容器 */
  .container { padding: 16px 12px 40px; }

  /* 卡片内边距缩小 */
  .card { padding: 16px 14px; border-radius: 10px; }

  /* 筛选栏：单列堆叠 */
  .filter-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .date-range { flex-wrap: wrap; }
  .date-range input { min-width: 120px; }

  /* 操作栏：换行 */
  .action-bar { gap: 8px; margin-bottom: 12px; }
  .action-bar .spacer { display: none; }
  #btn-export { width: 100%; order: -1; margin-bottom: 4px; }

  /* 摘要：等分两列 */
  .summary { gap: 10px; }
  .summary .stat {
    flex: 1 1 calc(50% - 5px);
    min-width: auto;
    padding: 8px 12px;
  }
  .summary .stat b { font-size: 18px; }

  /* 表格：小字号 + 横向滚动 */
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }
  th { font-size: 11px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 下单表单单列 */
  .form-grid { grid-template-columns: 1fr; gap: 12px; }

  /* 弹窗全宽 */
  .modal { max-width: 100%; padding: 20px 18px; border-radius: 12px; }
  .modal h3 { font-size: 15px; }

  /* toast */
  .toast { left: 12px; right: 12px; transform: none; top: 70px; font-size: 13px; padding: 10px 14px; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 16px; }
  .brand-logo { height: 30px; margin-bottom: 12px; }
  .brand h1 { font-size: 16px; }
  .brand p { font-size: 13px; }

  input[type="text"],
  input[type="password"],
  input[type="number"],
  select { padding: 10px 11px; font-size: 15px; }

  .btn-block { padding: 11px; font-size: 15px; }

  .topbar .brand-inline span { display: none; } /* 极窄屏只留logo */

  .summary .stat b { font-size: 16px; }
  .summary .stat span { font-size: 11px; }

  table { font-size: 11px; }
  th, td { padding: 6px 6px; }
  .badge { font-size: 10px; padding: 1px 7px; }
}
