/* ---------- Tokens ---------- */
:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #f9faf8;
  --surface-3: #f1f3ef;
  --border: #e3e7e1;
  --border-strong: #cdd5cc;
  --text: #1d2521;
  --text-2: #4a5650;
  --text-3: #7b867f;
  --accent: #235b49;
  --accent-hover: #1b4a3b;
  --accent-soft: #e7f0eb;
  --accent-text: #1d4d3e;
  --warn: #8a5a00;
  --warn-soft: #fdf4de;
  --warn-line: #f0dca9;
  --danger: #b0372b;
  --danger-hover: #952d23;
  --danger-soft: #fdecea;
  --danger-line: #f3c4be;
  --info: #2c5b86;
  --info-soft: #e9f1f9;
  --success: #1f6b4b;
  --success-soft: #e3f2ea;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgb(22 40 32 / 0.05);
  --shadow: 0 1px 2px rgb(22 40 32 / 0.05), 0 2px 8px rgb(22 40 32 / 0.04);
  --shadow-lg: 0 12px 32px rgb(22 40 32 / 0.16), 0 2px 6px rgb(22 40 32 / 0.08);
  --sidebar: 232px;
  --topbar: 56px;
  --focus: 0 0 0 3px rgb(35 91 73 / 0.28);
  --z-sticky: 10;
  --z-topbar: 20;
  --z-toast: 40;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar) + 72px);
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3 {
  margin: 0;
  color: var(--text);
  text-wrap: balance;
}
h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
h3 {
  font-size: 14px;
  font-weight: 600;
}
p {
  margin: 0;
}
a {
  color: var(--accent);
}
code,
.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
code {
  overflow-wrap: anywhere;
}
.muted {
  color: var(--text-3);
  font-size: 13px;
}
small {
  color: var(--text-3);
  font-size: 12px;
}
.num,
.stat-value,
td {
  font-variant-numeric: tabular-nums;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: var(--z-toast);
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: top 0.15s;
}
.skip-link:focus {
  top: 12px;
}

/* ---------- Busy state ---------- */
body[aria-busy="true"]::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: var(--z-toast);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: busy 1s ease-in-out infinite;
}
body[aria-busy="true"] {
  cursor: progress;
}
body[aria-busy="true"] #content {
  opacity: 0.72;
  transition: opacity 0.2s 0.15s;
}
@keyframes busy {
  from {
    background-position: -40% 0;
  }
  to {
    background-position: 140% 0;
  }
}

/* ---------- Controls ---------- */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s,
    transform 0.05s;
}
button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible,
.thumb-upload:focus-within {
  outline: none;
  box-shadow: var(--focus);
}
button:disabled {
  cursor: not-allowed;
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--text-3);
}
.btn.secondary,
button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover:not(:disabled),
button.secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #b5c0b4;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  box-shadow: none;
}
.btn.ghost:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: transparent;
  color: var(--text);
}
.btn.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
}
.btn.danger:hover:not(:disabled),
button.danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
.btn.warn {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  color: var(--warn);
}
.btn.warn:hover:not(:disabled) {
  background: #fbecc4;
  border-color: #e7c979;
}
.btn.sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.btn.block {
  width: 100%;
  min-height: 42px;
}
.btn svg,
button svg {
  width: 16px;
  height: 16px;
  flex: none;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:hover,
select:hover,
textarea:hover {
  border-color: #b5c0b4;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
}
input::placeholder,
textarea::placeholder {
  color: #a4ada7;
}
textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}
input[type="number"] {
  font-variant-numeric: tabular-nums;
}
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  flex: none;
}
input[type="file"] {
  font-size: 13px;
  padding: 6px;
}
.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
}
.field > span:first-child,
.field-label {
  color: var(--text-2);
  font-weight: 500;
}
.field .hint {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 400;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.form-grid .span-all {
  grid-column: 1 / -1;
}
.form-stack {
  display: grid;
  gap: 14px;
}
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Toggle switch */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #cfd6cf;
  border: none;
  position: relative;
  cursor: pointer;
  transition: background-color 0.15s;
}
input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: transform 0.15s;
}
input.switch:checked {
  background: var(--accent);
}
input.switch:checked::after {
  transform: translateX(14px);
}
input.switch:focus-visible {
  box-shadow: var(--focus);
}

/* ---------- Pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
  line-height: 1;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}
.pill.plain::before {
  display: none;
}
.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.pill.info {
  background: var(--info-soft);
  color: var(--info);
}
.pill.success {
  background: var(--success-soft);
  color: var(--success);
}
.pill.accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.pill.gold {
  background: #fbefd2;
  color: #7a4f00;
}

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, #e2ede6 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #efeadb 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.login-card .brand {
  margin-bottom: 28px;
}
.login-card h1 {
  font-size: 24px;
}
.login-lead {
  margin: 6px 0 24px;
  color: var(--text-2);
}
#login-form,
#shared-form {
  display: grid;
  gap: 14px;
}
.login-block {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.login-block h2,
.login-block summary {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.login-block summary {
  cursor: pointer;
  color: var(--text-3);
  font-weight: 500;
}
.login-hint {
  font-size: 12px;
  color: var(--text-3);
}
.login-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--danger-line, #efc3b8);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}
a.btn.block {
  text-align: center;
  text-decoration: none;
}
a.btn.disabled {
  pointer-events: none;
  opacity: 0.5;
}
.role-picker {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.role-picker legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.role-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background-color 0.15s;
}
.role-option:hover {
  border-color: var(--border-strong);
}
.role-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.role-option input {
  margin-top: 3px;
}
.role-option span {
  display: grid;
  gap: 1px;
}
.role-option strong {
  font-weight: 600;
  font-size: 14px;
}
.login-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex: none;
}
.brand-text {
  display: grid;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.brand-text small {
  font-weight: 400;
  font-size: 12px;
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100dvh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sidebar .brand {
  padding: 4px 8px;
}
#nav {
  display: grid;
  gap: 18px;
}
.nav-group {
  display: grid;
  gap: 2px;
}
.nav-label {
  padding: 0 10px 4px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}
#nav button {
  justify-content: flex-start;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  gap: 10px;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  font-weight: 500;
  box-shadow: none;
}
#nav button svg {
  width: 18px;
  height: 18px;
  color: var(--text-3);
}
#nav button:hover {
  background: var(--surface-3);
  color: var(--text);
}
#nav button.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
#nav button.active svg {
  color: var(--accent);
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 32px;
  background: rgb(245 246 243 / 0.86);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.env {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  min-width: 0;
}
.identity {
  display: flex;
  align-items: center;
  gap: 10px;
}
.who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 13px;
}
#content {
  width: 100%;
  max-width: 1360px;
  padding: 28px 32px 64px;
  outline: none;
}

/* ---------- Page scaffolding ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.page-intro {
  margin-top: 6px;
  max-width: 72ch;
  color: var(--text-2);
  font-size: 13px;
  text-wrap: pretty;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex: none;
}
.stack {
  display: grid;
  gap: 20px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: grid;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.stat-hint {
  font-size: 12px;
  color: var(--text-3);
}
.stat.warn .stat-value {
  color: var(--warn);
}
.stat.danger .stat-value {
  color: var(--danger);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head p {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-3);
  max-width: 80ch;
}
.card-body {
  padding: 20px;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: #5d4200;
  font-size: 13px;
}
.callout svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
}
.callout.info {
  border-color: #cfdeec;
  background: var(--info-soft);
  color: #234a6d;
}
.callout.neutral {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .spacer {
  flex: 1;
}
.search {
  position: relative;
  width: 280px;
  max-width: 100%;
}
.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.search input {
  padding-left: 32px;
  background: var(--surface);
}
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.segmented button {
  min-height: 28px;
  padding: 0 12px;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  font-size: 13px;
  box-shadow: none;
}
.segmented button:hover:not(:disabled) {
  background: rgb(255 255 255 / 0.6);
  border-color: transparent;
  color: var(--text);
}
.segmented button.on {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.segmented .count {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.result-count {
  font-size: 13px;
  color: var(--text-3);
}
.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty svg {
  width: 36px;
  height: 36px;
  color: #b9c3bb;
  margin-bottom: 4px;
}
.empty strong {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}
.empty.card {
  padding: 56px 24px;
}
.subnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.subnav a {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
}
.subnav a:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ---------- Tables ---------- */
.table-card {
  overflow: hidden;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  white-space: nowrap;
}
th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover td {
  background: #fbfcfa;
}
tr.group-row th {
  position: static;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 14px;
}
tr.group-row .count {
  font-weight: 400;
  color: var(--text-3);
  margin-left: 6px;
}
td.right,
th.right {
  text-align: right;
}
.cell-stack {
  display: grid;
  gap: 3px;
}
.cell-stack.start {
  justify-items: start;
}
.nowrap {
  white-space: nowrap;
}
.cell-sub {
  color: var(--text-3);
  font-size: 12px;
}
.truncate {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  object-fit: contain;
  background: var(--surface-3);
  border: 1px solid var(--border);
  flex: none;
}
.product-line {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 200px;
}
.id-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 1px 6px;
  min-height: 0;
  font-weight: 400;
  box-shadow: none;
  cursor: copy;
}
.id-chip:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}

/* Catalog table */
.product-cell {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 260px;
}
.product-cell .meta {
  display: grid;
  gap: 4px;
  flex: 1;
  min-width: 160px;
}
.size-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.size-field > span {
  flex: none;
  font-size: 12px;
  color: var(--text-3);
}
.size-field input {
  flex: 1;
  min-width: 0;
}
.thumb-upload {
  position: relative;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-3);
  cursor: pointer;
}
.thumb-upload img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.thumb-upload span {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2px 0;
  text-align: center;
  font-size: 11px;
  color: #fff;
  background: rgb(20 36 29 / 0.62);
  opacity: 0;
  transition: opacity 0.15s;
}
.thumb-upload:hover span,
.thumb-upload:focus-within span {
  opacity: 1;
}
.stock-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}
.stock-controls input {
  width: 84px;
}
.stock-cell {
  display: grid;
  gap: 6px;
  justify-items: start;
}
/* Disclosure card (details.card) */
details.card > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
}
details.card > summary::-webkit-details-marker {
  display: none;
}
details.card > summary:hover {
  background: var(--surface-2);
}
details.card[open] > summary {
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
details.card > summary .chev,
details.inline > summary .chev {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  transition: transform 0.2s;
  flex: none;
}
details[open] > summary .chev {
  transform: rotate(180deg);
}
details.card > summary p {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}
details.inline {
  margin-top: 12px;
}
details.inline > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}
details.inline > summary::-webkit-details-marker {
  display: none;
}
details.inline > summary:hover {
  color: var(--accent-hover);
}

/* Draft bar */
.draftbar {
  position: sticky;
  top: calc(var(--topbar) + 8px);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 12px 10px 16px;
  margin-bottom: 20px;
  background: rgb(255 255 255 / 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.draftbar-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-3);
}
.draftbar-actions {
  display: flex;
  gap: 8px;
}
.draft-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--text-2);
}
.draft-state::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9fb0a4;
}
.draft-state.dirty {
  color: var(--warn);
}
.draft-state.dirty::before {
  background: #e0a526;
  box-shadow: 0 0 0 3px rgb(224 165 38 / 0.2);
}
.steps-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.steps-hint b {
  font-weight: 500;
  color: var(--text-2);
}

/* Mengli */
.mengli {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 24px;
  align-items: start;
}
.mengli-photo {
  width: 168px;
  height: 168px;
  border-radius: var(--radius-lg);
  object-fit: contain;
  background: var(--surface-3);
  border: 1px solid var(--border);
}
.facts {
  display: grid;
  gap: 12px;
  margin: 0;
}
.facts div {
  display: grid;
  gap: 2px;
}
.facts dt {
  font-size: 12px;
  color: var(--text-3);
}
.facts dd {
  margin: 0;
  font-weight: 500;
}
.facts dd.big {
  font-size: 20px;
  font-weight: 600;
}
.retired {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
}

/* Board art */
.spec-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.spec-list span {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-2);
}
.board-art-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.board-art-cell {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--surface);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.board-art-cell:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.board-art-cell .cell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}
.board-art-cell > .label-img {
  display: block;
  width: 100%;
  height: 104px;
  margin: 10px 0 8px;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.board-art-cell .cell-name {
  font-weight: 500;
  line-height: 1.4;
}
.board-art-cell .cell-meta {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.board-art-cell details {
  margin-top: auto;
  padding-top: 10px;
}
.board-art-cell form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.board-art-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
  display: grid;
  gap: 10px;
}
.compare {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.compare figure {
  margin: 0;
  display: grid;
  gap: 4px;
  justify-items: center;
  font-size: 11px;
  color: var(--text-3);
}
.compare img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Rules */
.rules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rules li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.rules .step {
  flex: none;
  width: 52px;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- Fulfillment ---------- */
.group-card .card-head {
  align-items: center;
}
.recipient {
  display: grid;
  gap: 2px;
}
.recipient strong {
  font-size: 15px;
  font-weight: 600;
}
.recipient span {
  color: var(--text-2);
  font-size: 13px;
}
.head-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pick-list {
  display: grid;
  margin: -8px 0;
}
.pick-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.pick-list label:last-child {
  border-bottom: 0;
}
.pick-list .qty {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* A pick row carries the item's checkbox label plus its shortage control. */
.pick-list .pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pick-list .pick-row:last-child {
  border-bottom: 0;
}
.pick-list .pick-row label {
  flex: 1;
  min-width: 220px;
  padding: 0;
  border-bottom: 0;
}
.pick-list .pick-row > .cell-stack {
  flex: 1;
  min-width: 220px;
}
.shortage-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
/* Same-tier targets for a shortage item, opened under its row. */
.exchange-picker {
  flex-basis: 100%;
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.exchange-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.exchange-options .cell-sub {
  margin-left: 4px;
}
.pack-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.pack-form .field {
  width: 220px;
}

/* ---------- Parcels ---------- */
.parcel .card-head {
  align-items: center;
}
.parcel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.parcel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 20px 32px;
}
.kv {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}
.kv dt {
  color: var(--text-3);
}
.kv dd {
  margin: 0;
  min-width: 0;
}
.items {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
}
.items li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.items li:last-child {
  border-bottom: 0;
}
.items .qty {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.stepper li {
  position: relative;
  display: grid;
  gap: 2px;
  padding-top: 30px;
  font-size: 12px;
  color: var(--text-3);
  counter-increment: step;
}
.stepper li::before {
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  color: var(--text-3);
}
.stepper li::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 26px;
  right: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--border);
}
.stepper li:last-child::after {
  display: none;
}
.stepper li strong {
  font-weight: 500;
  color: var(--text-2);
  font-size: 13px;
}
.stepper li.done::before {
  content: "✓";
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.stepper li.done::after {
  background: var(--accent);
}
.stepper li.current::before {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgb(35 91 73 / 0.14);
}
.stepper li.current strong {
  color: var(--text);
  font-weight: 600;
}
.next-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.next-step .hint {
  font-size: 13px;
  color: var(--text-2);
}
.more-ops .form-actions {
  margin-top: 10px;
}
pre {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 330px;
  overflow: auto;
}
.result-panel {
  margin-bottom: 16px;
}

/* ---------- Aftersales ---------- */
.ticket {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr);
}
.ticket-main {
  padding: 20px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.ticket-side {
  padding: 20px;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.ticket-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ticket-meta {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
}
.quote {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.timeline li {
  position: relative;
  padding: 0 0 14px 20px;
  font-size: 13px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 6.5px;
  top: 16px;
  bottom: 0;
  width: 1px;
  background: var(--border-strong);
}
.timeline li:last-child::after {
  display: none;
}
.timeline small {
  display: block;
}
.section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 8px;
}

/* ---------- Toast ----------
   #notice-bar floats below the top bar wherever the operator has scrolled,
   and never covers the top bar's own controls (logout included). app.js's
   message() toggles its [hidden] and .error; #notice itself is the live
   region, the "点击关闭" hint is an aria-hidden sibling. */
#notice-bar {
  position: fixed;
  left: 50%;
  top: calc(var(--topbar) + 10px);
  z-index: var(--z-toast);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: min(640px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #1f2a25;
  color: #f1f5f2;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
}
#notice-bar.error {
  background: #fff5f4;
  color: #7d231a;
  border: 1px solid var(--danger-line);
  border-left: 3px solid var(--danger);
}
#notice {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
}
#notice:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
#notice-hint {
  flex: none;
  font-size: 12px;
  opacity: 0.6;
  white-space: nowrap;
}
#notice button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 13px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
}

/* ---------- Dialog ---------- */
dialog {
  width: calc(100% - 32px);
  max-width: 460px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.wide {
  max-width: 860px;
}
dialog::backdrop {
  background: rgb(18 30 24 / 0.45);
  backdrop-filter: blur(2px);
}
dialog h2 {
  font-size: 17px;
}
#confirm-copy,
.dialog-lead {
  margin: 10px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.65;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}
iframe {
  width: 100%;
  height: 55vh;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .mengli {
    grid-template-columns: 140px minmax(0, 1fr);
  }
  .mengli-photo {
    width: 140px;
    height: 140px;
  }
  .mengli .styles-field {
    grid-column: 1 / -1;
  }
  .parcel-grid,
  .ticket {
    grid-template-columns: minmax(0, 1fr);
  }
  .ticket-side {
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
}
@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px 16px 0;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  #nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
  }
  .nav-group {
    display: flex;
  }
  .nav-label {
    display: none;
  }
  #nav button {
    width: auto;
  }
  .topbar {
    padding: 0 16px;
  }
  #content {
    padding: 20px 16px 48px;
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
  .draftbar {
    top: calc(var(--topbar) + 6px);
  }
}
@media (max-width: 640px) {
  .mengli {
    grid-template-columns: minmax(0, 1fr);
  }
  .card-head,
  .card-body {
    padding: 14px 16px;
  }
  .stepper li strong {
    font-size: 12px;
  }
  .stepper li small {
    display: none;
  }
  .search {
    width: 100%;
  }
  .who .role-hint {
    display: none;
  }
  .draftbar-actions {
    width: 100%;
  }
  .draftbar-actions button {
    flex: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Page-specific helpers ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.grid-2 > form.card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.grid-2 > form.card .card-body {
  flex: 1;
}
.card > .card-toolbar {
  margin: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head + .card-toolbar {
  border-top: 0;
}
.card > details.card-section {
  margin: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.card > details.card-section[open] {
  padding-bottom: 20px;
}
.section-note {
  margin: 10px 0 14px;
  max-width: 80ch;
}
.head-pills.start {
  justify-content: flex-start;
}
.next-hint {
  font-size: 13px;
  color: var(--text-2);
}
.pack-field {
  width: 240px;
  max-width: 100%;
}
.result-panel {
  padding: 14px 20px;
}
.result-panel > summary {
  cursor: pointer;
  font-weight: 600;
}
td .empty {
  padding: 28px 12px;
}
@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}
summary svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-3);
  transition: transform 0.2s;
}
details[open] > summary > svg {
  transform: rotate(180deg);
}
td.num {
  white-space: nowrap;
}
@media (max-width: 1280px) {
  th,
  td {
    padding: 12px 10px;
  }
}
.stat.date .stat-value {
  font-size: 17px;
  padding-top: 4px;
}
.who strong {
  white-space: nowrap;
}
.thumb-upload img,
.thumb {
  color: transparent;
}
@media (max-width: 1100px) {
  .env .muted {
    display: none;
  }
}
@media (max-width: 640px) {
  .card-head {
    flex-wrap: wrap;
  }
  .who strong {
    display: none;
  }
}

/* A cell with an uncommitted preview spans the full grid row so the old/new
   comparison renders at a size an operator can actually judge. */
.board-art-cell.board-art-cell--pending {
  grid-column: 1 / -1;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(35 91 73 / 0.12);
}
.board-art-cell--pending > .label-img {
  max-width: 320px;
}
.board-art-cell--pending .compare {
  grid-template-columns: repeat(2, minmax(0, 280px)) minmax(0, 140px);
  gap: 20px;
  align-items: end;
}
.board-art-cell--pending .compare figure {
  font-size: 12px;
}
@media (max-width: 700px) {
  .board-art-cell--pending .compare {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
}
.board-art-cell--pending form {
  max-width: 440px;
}
.runlog-json{white-space:pre-wrap;word-break:break-all;max-height:320px;overflow:auto;font-size:12px;margin:6px 0 0}
.runlog-controls{flex-wrap:wrap;gap:12px;align-items:flex-end}
.runlog-msg{border-top:1px dashed var(--line,#e5e0da);padding-top:6px;margin-top:6px}
form.inline { display: flex; gap: 6px; align-items: center; }
form.inline input { width: 110px; }
td details summary { cursor: pointer; color: var(--muted, #667085); font-size: 12px; }
td details table { margin-top: 6px; }

/* Customer service types a user's new address: the lead and the four fields need air between them. */
#address-dialog .field {
  margin-top: 12px;
}

/* Waybill print settings: paper size beside the lead, above the sandboxed label preview. */
.print-settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 13px;
}
.field.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.field.inline > span:first-child {
  white-space: nowrap;
}
/* 物流设置 · 寄件地址 on the parcels page. */
.sender-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.sender-form {
  display: grid;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.sender-form h3 {
  margin: 0;
  font-size: 15px;
}
.sender-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
/* Retired styles waiting to be purged, above the product table. */
.card-callout {
  margin: 0 20px 14px;
}
.card-callout .btn {
  margin-left: 8px;
  vertical-align: middle;
}
/* 账号与权限 */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.inline-form .field {
  flex: 1 1 160px;
  min-width: 0;
}
.table-card .inline-form.card-body {
  border-top: 1px solid var(--border);
}
.partner-card {
  box-shadow: none;
  background: var(--surface-2);
}
.partner-card .card-head h3 {
  font-size: 15px;
}
.partner-card .inline-form {
  padding: 14px 20px 18px;
}
.partner-card.is-disabled {
  opacity: 0.7;
}
.form-actions.end {
  justify-content: flex-end;
}
.partner-card > .section-note {
  padding: 0 20px;
}
.login-foot a {
  color: var(--accent);
}
a.btn.ghost {
  text-decoration: none;
}
