:root {
  --bg: #f4f6f8;
  --card: #fff;
  --border: #e1e3e5;
  --text: #202223;
  --muted: #6d7175;
  --primary: #008060;
  --primary-dark: #006e52;
  --danger: #d72c0d;
  --warn: #b98900;
  --info: #2c6ecb;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--info); text-decoration: none; }
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 52px;
  background: #1a1c1d;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  color: #c9cccf;
  padding: 6px 12px;
  border-radius: 6px;
}
.tabs a.active, .tabs a:hover { background: #303335; color: #fff; }
.status { margin-left: auto; display: flex; gap: 8px; font-size: 12px; }
.pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: #303335;
  color: #c9cccf;
}
.pill.ok { background: #1c4a3a; color: #7fe0b8; }
.pill.bad { background: #5a1f14; color: #ffb3a3; }
.pill.warn { background: #4d3b00; color: #ffd966; }

.view { padding: 20px; max-width: 1400px; margin: 0 auto; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 16px 0 8px; font-size: 14px; color: var(--muted); }
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1; }

button, .btn {
  font: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #babfc3;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
}
button:hover { background: #f6f6f7; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--danger); border-color: #f1a99c; }
button.danger:hover { background: #fff4f2; }
button.sm { padding: 3px 8px; font-size: 12px; }
button.link { border: none; background: none; color: var(--info); padding: 0 4px; }

input, select, textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid #babfc3;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b3d7ff; outline-offset: -1px; }
input[type="checkbox"] { width: auto; }
textarea { width: 100%; resize: vertical; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; white-space: nowrap; background: #fafbfb; }
tr:hover td { background: #fafbfb; }
td.num, th.num { text-align: right; }
td.actions { white-space: nowrap; }
td.actions button { margin-right: 4px; }
.mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: #e4e5e7;
  color: #303335;
  white-space: nowrap;
}
.badge.green { background: #aee9d1; color: #0b3d2c; }
.badge.yellow { background: #ffea8a; color: #4d3b00; }
.badge.red { background: #fed3d1; color: #5a1f14; }
.badge.blue { background: #a4c8f0; color: #0f2d5c; }
.badge.gray { background: #e4e5e7; color: #55595c; }

.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select { width: 100%; }
.field .hint { font-size: 11px; color: var(--muted); }

.alert {
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  border: 1px solid;
}
.alert.warn { background: #fff8e5; border-color: #ffd966; color: #4d3b00; }
.alert.error { background: #fff4f2; border-color: #f1a99c; color: #5a1f14; }
.alert.info { background: #eaf4ff; border-color: #a4c8f0; color: #0f2d5c; }
.alert.ok { background: #f1f8f5; border-color: #aee9d1; color: #0b3d2c; }
.alert ul { margin: 4px 0 0 16px; padding: 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 1100px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.modal.narrow { max-width: 720px; }
.modal-head {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 16px 20px; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfb;
  border-radius: 0 0 10px 10px;
}
.close { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1c1d;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 200;
  max-width: 80vw;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--primary); }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 8px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.steps { display: flex; gap: 6px; margin: 8px 0 12px; flex-wrap: wrap; }
.steps span { padding: 3px 10px; border-radius: 999px; background: #e4e5e7; font-size: 12px; }
.steps span.done { background: #aee9d1; }
.steps span.now { background: var(--primary); color: #fff; }

.products-table input { width: 100%; }
.products-table td { padding: 4px 6px; }
.section-title { font-weight: 600; margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat { background: #fafbfb; border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; min-width: 140px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }
pre.detail { background: #fafbfb; border: 1px solid var(--border); padding: 8px; border-radius: 6px; max-height: 260px; overflow: auto; font-size: 12px; }
.thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
