/* 管理后台样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: #333;
  background: #f0f2f5;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: #001529;
  color: #fff;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo-icon {
  font-size: 24px;
}

.nav-menu {
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  color: rgba(255,255,255,0.75);
  transition: all 0.2s;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.nav-item.active {
  color: #fff;
  background: #1890ff;
}

.nav-icon {
  font-size: 16px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.refresh-btn {
  cursor: pointer;
  color: #1890ff;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 4px;
  transition: background 0.2s;
}

.refresh-btn:hover {
  background: #e6f7ff;
}

.content-area {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

.page-content {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 统计卡片 */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card.primary {
  background: linear-gradient(135deg, #1890ff, #096dd9);
  color: #fff;
}

.stat-card.success {
  background: linear-gradient(135deg, #52c41a, #389e0d);
  color: #fff;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-card.primary .stat-value {
  color: #fff;
}

.stat-card.success .stat-value {
  color: #fff;
}

.stat-sub-label {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  margin-top: 4px;
}

.stat-card:not(.primary):not(.success) .stat-sub-label {
  color: #999;
}

.stat-label {
  font-size: 14px;
  color: #999;
}

.stat-card.primary .stat-label {
  color: rgba(255,255,255,0.85);
}

.stat-card.success .stat-label {
  color: rgba(255,255,255,0.85);
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f0;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-tools {
  font-size: 13px;
  color: #999;
}

.card-body {
  padding: 20px 24px;
}

/* 商品汇总 */
.product-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.product-summary-item {
  flex: 1;
  min-width: 120px;
  background: #fafafa;
  border-radius: 6px;
  padding: 16px;
  text-align: center;
}

.product-summary-name {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.product-summary-qty {
  font-size: 20px;
  font-weight: 600;
  color: #1890ff;
}

.product-summary-unit {
  font-size: 12px;
  color: #999;
  margin-left: 2px;
}

.empty-text {
  color: #999;
  font-size: 14px;
}

/* 订单列表 */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-item {
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  padding: 16px 20px;
  transition: all 0.2s;
}

.order-item:hover {
  border-color: #1890ff;
  box-shadow: 0 2px 8px rgba(24,144,255,0.1);
}

.order-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.order-customer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-customer-name {
  font-size: 16px;
  font-weight: 600;
}

.order-customer-address {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

.order-price {
  font-size: 18px;
  font-weight: 700;
  color: #ff4d4f;
}

.order-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.order-item-tag {
  background: #f5f5f5;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  color: #666;
}
.order-item-tag.order-item-refund {
  background: #fff2f0;
  color: #ff4d4f;
}

.order-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed #f0f0f0;
}

.order-gift {
  font-size: 12px;
  color: #52c41a;
}

.order-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.status-normal {
  background: #f6ffed;
  color: #52c41a;
}

.status-undelivered {
  background: #fff2f0;
  color: #ff4d4f;
}

.status-cancelled {
  background: #f5f5f5;
  color: #999;
}

.order-date {
  font-size: 12px;
  color: #999;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* 查询表单 */
.query-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-item {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-item label {
  font-size: 13px;
  color: #666;
}

.form-item input,
.form-item select {
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-item input:focus,
.form-item select:focus {
  border-color: #1890ff;
}

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

/* 送货日模式开关 */
.delivery-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  margin-right: auto;
  user-select: none;
}
.delivery-mode-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #1890ff;
}
.delivery-mode-toggle:has(input:checked) {
  color: #1890ff;
  font-weight: 500;
}

/* 按钮 */
.btn {
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: #1890ff;
  color: #fff;
}

.btn-primary:hover {
  background: #40a9ff;
}

.btn-default {
  background: #fff;
  color: #333;
  border: 1px solid #d9d9d9;
}

.btn-default:hover {
  border-color: #1890ff;
  color: #1890ff;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
}

.btn-danger {
  background: #ff4d4f;
  color: #fff;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #f0f0f0;
}

.page-info {
  font-size: 14px;
  color: #666;
}

/* 客户列表 */
.customer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.customer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
}

.customer-info {
  flex: 1;
}

.customer-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.customer-detail {
  font-size: 12px;
  color: #999;
}

.customer-actions {
  display: flex;
  gap: 8px;
}

/* 统计表格 */
.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

.stats-table th {
  background: #fafafa;
  font-weight: 600;
  font-size: 13px;
  color: #666;
}

.stats-table tr:hover {
  background: #fafafa;
}

/* ===== 实时送货页面（手机端优化） ===== */
.delivery-page {
  background: #f5f5f5;
  min-height: 100vh;
}
.delivery-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  padding: 10px 12px;
  border-bottom: 1px solid #e8e8e8;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.delivery-search {
  position: relative;
}
.delivery-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid #e8e8e8;
  border-radius: 20px;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  background: #f7f8fa;
  -webkit-appearance: none;
}
.delivery-search input:focus {
  border-color: #1890ff;
  background: #fff;
}
.delivery-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 14px;
}
.delivery-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 4px;
  font-size: 12px;
  color: #999;
}
.delivery-count {
  font-weight: 600;
  color: #333;
}
.delivery-count-num {
  color: #1890ff;
  font-size: 14px;
}
.delivery-range {
  display: inline-block;
  font-size: 11px;
  color: #bbb;
  margin-left: 6px;
  padding: 1px 6px;
  background: #f5f5f5;
  border-radius: 10px;
}
.delivery-timer {
  display: flex;
  align-items: center;
  gap: 4px;
}
.delivery-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e6f7ff;
  color: #1890ff;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s;
}
.delivery-refresh-btn:active {
  transform: scale(0.9);
}
.delivery-refresh-btn.refreshing {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.delivery-new-badge {
  display: inline-block;
  background: #ff4d4f;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.delivery-list {
  padding: 8px;
}
.delivery-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: relative;
  transition: all 0.3s ease;
}
.delivery-card.is-new {
  border-left: 4px solid #ff4d4f;
  background: #fff7f7;
  animation: slideIn 0.4s ease;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.delivery-new-tag {
  position: absolute;
  top: 0;
  right: 12px;
  background: #ff4d4f;
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 0 0 6px 6px;
  font-weight: 600;
}
.delivery-card-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}
.delivery-index {
  background: #1890ff;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.delivery-card-info {
  flex: 1;
  margin-left: 10px;
  min-width: 0;
}
.delivery-name {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.delivery-address {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.delivery-amount {
  font-size: 17px;
  font-weight: 700;
  color: #ff4d4f;
  flex-shrink: 0;
}
.delivery-items {
  font-size: 14px;
  color: #555;
  margin: 6px 0;
  line-height: 1.5;
  word-break: break-all;
}
.delivery-gift-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-top: 2px;
}
.delivery-gift-zheng { background: #1890ff; }
.delivery-gift-zhu { background: #fa8c16; }
.delivery-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #f0f0f0;
}
.delivery-time {
  font-size: 11px;
  color: #bbb;
}
.delivery-status-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.delivery-status-normal {
  background: #f6ffed;
  color: #52c41a;
}
.delivery-status-undelivered {
  background: #fff2f0;
  color: #ff4d4f;
}
.delivery-actions {
  display: flex;
  gap: 6px;
}
.delivery-action-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}
.delivery-action-btn:active {
  background: #f0f0f0;
}
.delivery-action-btn.danger {
  border-color: #ffa39e;
  color: #ff4d4f;
}
.delivery-action-btn.danger:active {
  background: #fff2f0;
}

/* 手机端全屏送货模式：隐藏侧边栏，只留送货列表 */
.delivery-fullscreen .sidebar,
.delivery-fullscreen .topbar {
  display: none;
}
.delivery-fullscreen .main-content {
  padding: 0;
}
.delivery-fullscreen .content-area {
  padding: 0;
}

/* 小屏适配 */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .topbar {
    padding: 0 16px;
  }
  .content-area {
    padding: 12px;
  }
  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card {
    padding: 16px;
  }
  .stat-value {
    font-size: 24px;
  }
}

/* 弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.45);
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 10px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}
.modal-close:hover {
  background: #f5f5f5;
  color: #333;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 搜索结果 */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  background: #fafafa;
  transition: all 0.15s;
}
.search-result-item:hover {
  background: #f0f7ff;
  border-color: #bae0ff;
}
.search-result-info {
  flex: 1;
  min-width: 0;
}
.search-result-name {
  font-weight: 600;
  font-size: 14px;
}
.search-result-detail {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}
.search-result-add {
  background: #1890ff;
  color: #fff;
  border: none;
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-left: 10px;
}
.search-result-add:hover {
  background: #40a9ff;
}
.search-result-add:active {
  background: #096dd9;
}
.search-empty {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 13px;
}

/* 位置选择列表 */
.position-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.position-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  border: 2px solid transparent;
}
.position-item:hover {
  background: #f5f5f5;
}
.position-item.selected {
  background: #e6f7ff;
  border-color: #1890ff;
  color: #1890ff;
  font-weight: 500;
}
.position-radio {
  width: 16px;
  height: 16px;
  border: 2px solid #d9d9d9;
  border-radius: 50%;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.position-item.selected .position-radio {
  border-color: #1890ff;
  background: #1890ff;
}
.position-item.selected .position-radio::after {
  content: '';
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
}

/* 路线客户项中的插入按钮 */
.route-customer-insert {
  font-size: 12px;
  color: #1890ff;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.15s;
  border: none;
  background: none;
  white-space: nowrap;
}
.route-customer-insert:hover {
  background: #e6f7ff;
}

/* ===== 登录遮罩层 ===== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.login-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.login-title {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  margin-bottom: 28px;
}
.login-input {
  width: 100%;
  height: 48px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 16px;
  margin-bottom: 12px;
  box-sizing: border-box;
  transition: border-color 0.2s;
  outline: none;
}
.login-input:focus {
  border-color: #1890ff;
}
.login-error {
  color: #ff4d4f;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
}
.login-btn {
  width: 100%;
  height: 48px;
  background: #1890ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.login-btn:hover {
  background: #40a9ff;
}
.login-btn:active {
  background: #096dd9;
}
