:root {
  color-scheme: light;
  font: 16px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
.stock-page {
  --bg: #f7f4ee;
  --surface: #fffdfa;
  --ink: #1e2d48;
  --muted: #546176;
  --line: #dfded8;
  --brand: #253a5a;
  --map: #8b512e;
  --pale: #e8edf6;
  --danger: #8d332b;
  --good: #315a47;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
main { padding-block: 32px 56px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.75rem, 4vw, 2.55rem); line-height: 1.23; overflow-wrap: anywhere; }
h2 { font-size: 1.2rem; margin-bottom: 16px; }
p { margin-bottom: 14px; }
.muted, small { color: var(--muted); }
.card { min-width: 0; padding: clamp(14px, 3vw, 22px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 480px; margin-inline: auto; }
.stack { display: grid; gap: 16px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spread { justify-content: space-between; }
a { color: var(--brand); }
button, .button {
  min-height: 42px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--brand);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
}
button:hover:not(:disabled), .button:hover { background: var(--pale); }
.primary { border-color: var(--brand); background: var(--brand); color: white; }
button:disabled { cursor: default; opacity: .55; }
:is(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--map); outline-offset: 2px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
label { display: grid; min-width: 0; gap: 5px; font-size: .875rem; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 78px; resize: vertical; }
.check-label { display: flex; width: fit-content; gap: 7px; align-items: center; }
.check-label input { width: 17px; height: 17px; min-height: 0; margin: 0; accent-color: var(--brand); }
.stock-table table { font-size: .9rem; }
.stock-page [hidden] { display: none !important; }
.stock-page .wrap { width: min(1040px, calc(100% - 36px)); margin-inline: auto; }
.stock-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.stock-top .wrap { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 12px; }
.stock-brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 740; letter-spacing: .09em; text-decoration: none; }
.stock-brand img { object-fit: contain; }
.stock-page button.primary:hover:not(:disabled), .stock-page .button.primary:hover { background: #182943; }
.stock-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.stock-heading h1, .stock-section h2 { margin: 0; }
.stock-section { justify-content: space-between; margin: 20px 0 10px; }
.stock-meta { color: var(--muted); overflow-wrap: anywhere; }
.stock-summary-note { margin: 8px 0 0; font-size: .82rem; }
.stock-notice { color: var(--good); }
.stock-notice:empty { display: none; }
.stock-notice.failure { color: var(--danger); }
.stock-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0 22px; }
.stock-metrics > div { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px clamp(8px, 2vw, 18px); }
.stock-metrics dt, .stock-metrics small { color: var(--muted); font-size: .82rem; }
.stock-metrics dd { margin: 3px 0 0; font-size: clamp(1.08rem, 3vw, 1.85rem); line-height: 1.3; font-weight: 700; font-variant-numeric: tabular-nums; }
.stock-table { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.stock-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stock-table :is(th,td) { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.stock-table thead th { border: 0; font-size: .84rem; font-weight: 650; color: var(--muted); }
.stock-table td small, .stock-pending small { display: block; }
.stock-amount { white-space: nowrap; }
.stock-supplier-totals td { background: var(--bg); font-weight: 650; }
.stock-code { color: var(--map); font-weight: 700; }
.stock-tag { display: inline-block; white-space: nowrap; background: var(--pale); color: var(--brand); padding: 2px 9px; border-radius: 18px; font-size: .82rem; }
.stock-tag.subtle { background: var(--bg); color: var(--muted); }
.stock-finished { margin-top: 18px; }
.stock-finished summary { color: var(--muted); cursor: pointer; }
.stock-finished[open] .stock-table { margin-top: 8px; }
.stock-pending { margin-top: 24px; border-top: 1px solid var(--line); padding: 12px 0; }
.stock-pending h2 { margin-bottom: 5px; }
.stock-pending article { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding-block: 7px; }
.stock-fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.stock-dialog {
  width: min(495px, calc(100vw - 30px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}
.stock-dialog::backdrop { background: rgb(23 34 49 / 65%); }
.stock-dialog .stack { gap: 11px; }
.stock-dialog h2 { margin-bottom: 0; }
.stock-receipt-form .stock-dialog-submit { text-align: center; }
.stock-print { margin-top: 20px; }
.stock-print h2, .stock-print figure { margin: 0; }
.stock-print-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px 24px;
  margin-top: 12px;
}
.stock-print .stack { gap: 10px; }
.stock-label-options { gap: 8px 16px; }
.stock-preview-surface {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 12px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.stock-preview-surface canvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 280px;
  height: auto;
  aspect-ratio: auto;
  box-shadow: 0 0 0 1px var(--line);
  image-rendering: pixelated;
}
.stock-print-actions:not(:empty) { margin: 14px 0 6px; }
.stock-print .stock-notice { margin-bottom: 0; }
.stock-catalog { max-width: 650px; margin-inline: auto; }
.stock-catalog article { border-top: 1px solid var(--line); padding-block: 15px; }
.stock-catalog h2 { margin-bottom: 4px; }
.stock-catalog p { margin-bottom: 0; }
@media (max-width: 630px) {
  .stock-page .wrap { width: calc(100% - 22px); }
  .stock-page main { padding-block: 20px; }
  .stock-metrics { gap: 6px; }
  .stock-table :is(table,tbody) { display: block; }
  .stock-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .stock-table tbody tr { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 12px; border-top: 1px solid var(--line); padding: 8px 10px; }
  .stock-table tbody:first-of-type tr:first-child { border-top: 0; }
  .stock-table td { border: 0; padding: 0; }
  .stock-table td:first-child { flex-basis: 100%; }
  .stock-table .stock-detail-summary-space { display: none; }
  .stock-table td[data-label]:not([data-label=""])::before { content: attr(data-label); margin-right: 5px; font-size: .72rem; color: var(--muted); }
  .stock-print-workspace { grid-template-columns: 1fr; }
}
