:root {
  --primary: #2f6fed;
  --primary-dark: #1f56c8;
  --success: #18a058;
  --danger: #d03050;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e2e6ee;
  --text: #262a33;
  --muted: #8a919f;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

/* ---------- 登录页 ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #2f6fed 0%, #5b8def 100%);
}
.login-card {
  width: 360px;
  background: #fff;
  padding: 40px 36px;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
}
.login-card h1 { font-size: 19px; margin: 0 0 20px; text-align: center; line-height: 1.5; }

/* ---------- 布局：侧边栏 + 内容 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #1f2937;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 20px 18px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: block;
  padding: 12px 20px;
  color: #cbd5e1;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  border-left-color: var(--primary);
}
.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-user { color: #9ca3af; font-size: 13px; margin-bottom: 8px; }
.logout-link { color: #cbd5e1; font-size: 13px; text-decoration: none; }
.logout-link:hover { color: #fff; }

.content { flex: 1; padding: 24px; min-width: 0; }
.page-title { font-size: 20px; margin: 0 0 20px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.list-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.placeholder { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ---------- 统计卡片 ---------- */
.stat-section { margin-bottom: 24px; }
.stat-section-title { font-size: 15px; margin: 0 0 12px; color: #555; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- 表单 ---------- */
label { display: block; font-size: 13px; color: #555; margin: 12px 0 4px; }
input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
input[type=date] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
}
input[type=date]:focus { border-color: var(--primary); }
textarea { resize: vertical; }
#search-input { width: 240px; }
#filter-shipped { width: auto; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: 200px; }

.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.checkbox-label input { width: auto; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:disabled { background: #a8d5bd; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.row-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f7f8fb; color: #555; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fafbfd; }
td.phone { white-space: nowrap; }

/* ---------- 发货状态 / 结果徽章 ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.badge-no { background: #fdecea; color: #d03050; }
.badge-yes { background: #e6f7ee; color: #18a058; }

/* ---------- 合计栏 ---------- */
.summary-bar {
  margin-bottom: 14px;
  padding: 12px 16px;
  background: #f7f8fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: #555;
}
.summary-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 17px;
  margin: 0 2px;
}

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; align-items: center; }
#pagination-buttons { display: flex; gap: 6px; align-items: center; }
.page-size-wrap { margin-left: auto; display: flex; align-items: center; }
.page-size-select { width: auto; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.pagination button { padding: 6px 12px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .page-info { margin-left: 8px; color: var(--muted); font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); }
.modal-box { position: relative; background: #fff; border-radius: 12px; padding: 24px 26px; width: 520px; max-width: 92vw; max-height: 90vh; overflow-y: auto; }
.modal-box h3 { margin: 0 0 4px; }

/* ---------- 工具 ---------- */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}

/* ---------- 移动端 H5 适配 ---------- */
.mobile-topbar { display: none; }
.sidebar-mask { display: none; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 300;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 290;
  }
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
  }
  .mobile-brand {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    line-height: 1.4;
  }
  .hamburger {
    font-size: 22px;
    line-height: 1;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text);
  }
  .content { padding: 16px; }
  .page-title { font-size: 18px; }
  .card { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-num { font-size: 22px; }
  .list-header { flex-direction: column; align-items: stretch; }
  .filters { flex-direction: column; }
  .filters input[type=text], .filters input[type=date], .filters select,
  #search-input { width: 100%; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; text-align: center; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input { width: 100%; }
  .row-actions { flex-wrap: wrap; }
  .btn { padding: 10px 14px; }
  .modal-box { width: 100%; margin: 0 12px; padding: 20px; }
  .table-scroll { -webkit-overflow-scrolling: touch; }
  th, td { padding: 8px 10px; font-size: 12px; }
  .login-card { width: calc(100% - 32px); margin: 0 16px; }
  .login-card h1 { font-size: 17px; }

  /* 记录列表：移动端表格转卡片 */
  .records-table thead { display: none; }
  .records-table tbody { display: block; }
  .records-table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 12px 14px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
  }
  .records-table tr:hover td { background: transparent; }
  .records-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border: none;
    padding: 5px 0;
    text-align: right;
    white-space: normal;
  }
  .records-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #888;
    flex-shrink: 0;
    text-align: left;
  }
  .records-table td[data-label="ID"] { display: none; }
  .records-table td[data-label="地址"] { word-break: break-all; }
  .records-table td[data-label="操作"] {
    justify-content: flex-end;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
  }
  .records-table td[data-label="操作"] .btn-sm {
    padding: 9px 18px;
    font-size: 14px;
  }
  .records-table td[data-label="发货状态"] .badge {
    padding: 5px 14px;
    font-size: 13px;
  }
}
