* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #222;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f2937;
  color: #fff;
  padding: 12px 24px;
}
.topnav .brand { font-weight: 600; }
.topnav .navlinks a {
  color: #cbd5e1;
  text-decoration: none;
  margin-right: 20px;
  font-size: 14px;
}
.topnav .navlinks a:hover { color: #fff; }
.topnav .navuser { font-size: 13px; color: #cbd5e1; }
.topnav .navuser a { color: #93c5fd; }

.container {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 16px;
}

h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 17px; margin-top: 28px; }

.login-box {
  max-width: 320px;
  margin: 80px auto;
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.login-box h1 { text-align: center; font-size: 18px; }
.login-box label { display: block; margin-top: 12px; font-size: 13px; color: #555; }
.login-box input { width: 100%; padding: 8px; margin-top: 4px; border: 1px solid #ccc; border-radius: 4px; }
.login-box button { width: 100%; margin-top: 20px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.page-actions { margin-bottom: 20px; }
.page-actions .btn { margin-right: 8px; }

.stat-cards { display: flex; gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px 24px;
  flex: 1;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-num { font-size: 28px; font-weight: 700; color: #1f2937; }
.stat-label { font-size: 13px; color: #777; margin-top: 4px; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
  color: #222;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: #f0f0f0; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.link-btn {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}

.search-bar { margin-bottom: 16px; display: flex; gap: 8px; }
.search-bar input, .search-bar select {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}
.data-table th { background: #fafafa; color: #555; font-weight: 600; }
.data-table tr[onclick] { cursor: pointer; }
.data-table tr[onclick]:hover { background: #f8fafc; }
.data-table .empty { text-align: center; color: #999; padding: 24px; }
.row-actions a, .row-actions .link-btn { margin-right: 10px; font-size: 13px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #e5e7eb;
  color: #374151;
}
.badge-draft { background: #f3f4f6; color: #6b7280; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-delivered { background: #fef3c7; color: #92400e; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}
.form-row { display: flex; flex-direction: column; }
.form-row-wide { grid-column: 1 / -1; }
.form-row label { font-size: 13px; color: #555; margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}
.form-row textarea { min-height: 60px; }
.form-actions { margin-top: 16px; }
.form-actions .btn { margin-right: 8px; }

.order-total {
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  margin-top: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
  font-size: 14px;
}

.flash-wrap { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 14px;
}
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

@media (max-width: 700px) {
  /* 容器与整体间距 */
  .container { margin: 12px auto; padding: 0 10px; }
  h1 { font-size: 19px; }
  h2 { font-size: 16px; }

  /* 表单/详情/卡片：竖排（原有，保留） */
  .form-grid { grid-template-columns: 1fr; padding: 14px; }
  .detail-grid { grid-template-columns: 1fr 1fr; padding: 12px; font-size: 13px; }
  .stat-cards { flex-direction: column; gap: 10px; }
  .stat-num { font-size: 24px; }

  /* 顶部导航：允许横向滑动，避免菜单挤成一坨 */
  .topnav { padding: 10px 12px; flex-wrap: wrap; }
  .topnav .navlinks {
    width: 100%;
    margin-top: 8px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .topnav .navlinks a { margin-right: 14px; font-size: 13px; }
  .topnav .navuser { font-size: 12px; }

  /* 页头：标题与按钮竖排，按钮不被截断 */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* 关键：表格横向滚动，不再把列硬压到挤成一团 */
  .data-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    border-radius: 8px;
  }
  .data-table thead, .data-table tbody, .data-table tfoot { display: table; width: 100%; min-width: 640px; }
  .data-table th, .data-table td { padding: 9px 10px; font-size: 13px; }

  /* 搜索栏：换行排列，输入框不溢出 */
  .search-bar { flex-wrap: wrap; }
  .search-bar input, .search-bar select { flex: 1 1 auto; min-width: 120px; }

  /* 按钮在手机上更好点按 */
  .btn { padding: 9px 14px; }
  .page-actions .btn, .form-actions .btn { margin-bottom: 6px; }

  /* 登录框适配窄屏 */
  .login-box { margin: 40px auto; padding: 24px; }
}

/* 新增：库存/报表/员工相关 */
.hint { color: #777; font-size: 13px; margin: 8px 0 16px; }
.row-inactive { opacity: 0.5; }
.row-warn { background: #fef2f2; }
.txt-green { color: #166534; font-weight: 600; }
.txt-red { color: #991b1b; font-weight: 600; }
.data-table tfoot td { background: #fafafa; border-top: 2px solid #ddd; }
.data-table select, .data-table input { padding: 6px; border: 1px solid #ccc; border-radius: 4px; }

/* 商品模糊搜索选择器 */
.picker-cell { position: relative; }
.product-search { width: 100%; box-sizing: border-box; }
.picker-dropdown {
  display: none; position: absolute; z-index: 50; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid #ccc; border-top: none;
  max-height: 260px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.picker-item { padding: 8px 10px; cursor: pointer; font-size: 14px; border-bottom: 1px solid #f0f0f0; }
.picker-item:hover { background: #e8f5e9; }


/* 浮动式搜索下拉菜单：避免被表格、卡片、overflow 或手机布局裁掉 */
.floating-picker-dropdown {
  position: absolute;
  z-index: 99999;
  display: none;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .18);
}
.floating-picker-dropdown .picker-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.35;
  border-bottom: 1px solid #f1f5f9;
  white-space: normal;
}
.floating-picker-dropdown .picker-item:hover,
.floating-picker-dropdown .picker-item.active {
  background: #e8f5e9;
}
@media (max-width: 700px) {
  .floating-picker-dropdown {
    max-height: 55vh;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
  }
}
