:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #d97706;
  --primary-dark: #b45309;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Microsoft YaHei', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--blue); text-decoration: none; }
.topbar {
  display: flex;
  align-items: center;
  gap: 10px 16px;
  padding: 6px 20px;
  min-height: 56px;
  background: #111827;
  color: #fff;
  flex-wrap: wrap;
}
.brand { font-size: 17px; font-weight: 700; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  color: #d1d5db;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.nav a:hover { background: #1f2937; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.main { width: 100%; max-width: 100%; margin: 0; padding: 18px clamp(12px, 2.5vw, 28px); }
h1 { font-size: 20px; margin: 0 0 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
input, select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card .num { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card .lbl { color: var(--muted); font-size: 13px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table-scroll table { min-width: 640px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f9fafb; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #f3f4f6; }
.pill.gray { background: #f3f4f6; color: var(--muted); }
.pill.green { background: #dcfce7; color: var(--green); }
.pill.orange { background: #fef3c7; color: #b45309; }
.pill.red { background: #fee2e2; color: var(--red); }
.pill.blue { background: #dbeafe; color: var(--blue); }
.empty { text-align: center; color: var(--muted); padding: 30px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; }
.modal {
  position: fixed; top: 5%; left: 50%; transform: translateX(-50%);
  width: min(720px, 94vw); max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 12px; z-index: 60; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.hidden { display: none !important; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-row { display: flex; gap: 8px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 80; box-shadow: 0 8px 20px rgba(0,0,0,.2);
}
.toast.error { background: var(--red); }
.line-item { display: grid; grid-template-columns: 1fr 100px 110px 70px 32px; gap: 8px; align-items: center; margin-bottom: 8px; }
.delivery-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 14px 16px; margin-bottom: 16px; }
.delivery-head { display: flex; justify-content: space-between; align-items: center; }
.delivery-head .school { font-size: 16px; font-weight: 700; }
.sub { color: var(--muted); font-size: 13px; }
.summary-box { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
@media (max-width: 720px) {
  .topbar { padding: 6px 12px; }
  .brand { font-size: 15px; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .main { padding: 12px 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr 80px 95px 58px 28px; }
  .filter-bar input, .filter-bar select { width: 100%; min-width: 0; }
  .pager { flex-wrap: wrap; }
  .page-head { flex-direction: column; align-items: stretch; }
  .delivery-head { flex-direction: column; align-items: flex-start; }
  .delivery-head > div:last-child { text-align: left; }
  .btn { padding: 6px 12px; }
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; color: #d1d5db; }
.topbar-right .btn { background: transparent; color: #d1d5db; border-color: #374151; }
.topbar-right .btn:hover { background: #1f2937; color: #fff; }
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(360px, 90vw); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.login-box h1 { font-size: 20px; margin: 0 0 16px; }
.login-box .btn { width: 100%; margin-top: 8px; }
.prod-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f3f4f6; display: block; }
.prod-thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
.pf-img { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pf-img .prod-thumb { width: 64px; height: 64px; }
.pf-img input[type="file"] { width: auto; }

/* 下拉模糊搜索 */
.ac-wrap { position: relative; }
.ac-list { position: absolute; top: calc(100% + 2px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; max-height: 230px; overflow: auto; z-index: 70; box-shadow: 0 8px 20px rgba(0,0,0,.12); display: none; }
.ac-item { padding: 8px 12px; cursor: pointer; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item:hover, .ac-item.ac-hl { background: #f3f4f6; }
.ac-sub { color: var(--muted); font-size: 12px; }
.ac-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* 商品筛选 + 分页 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filter-bar input, .filter-bar select { width: auto; min-width: 110px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
.pager-info { color: var(--muted); font-size: 13px; }
