:root {
  color-scheme: light;
  --sidebar-width: 220px;
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
.loading { padding: 32px; }
.small, small { font-size: 13px; color: var(--dim); }

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: white;
}
.auth-illustration {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(135deg, #9ca3af, #6b7280 50%, #78716c);
}
.auth-illustration::after { content: ''; height: 40px; flex: none; }
.auth-illustration .brand { color: white; }
.auth-illustration .mark { width: 32px; height: 32px; background: rgb(255 255 255 / 15%); }
.auth-art { position: relative; flex: none; align-self: center; width: min(100%, 460px); aspect-ratio: 460 / 400; container-type: inline-size; }
.auth-character { position: absolute; bottom: 0; transform-origin: bottom center; transition: transform 450ms ease, height 450ms ease; }
.auth-character.purple { left: 13%; width: 32.6%; height: 85%; background: #6c3ff5; border-radius: 10px 10px 0 0; }
.auth-character.charcoal { left: 43.5%; width: 21.7%; height: 65%; background: #2d2d2d; border-radius: 8px 8px 0 0; }
.auth-character.orange { left: 0; width: 43.5%; height: 42.5%; background: #ff9b6b; border-radius: 100% 100% 0 0 / 115% 115% 0 0; }
.auth-character.yellow { left: 56.5%; width: 26%; height: 48.75%; background: #e8d754; border-radius: 50% 50% 0 0 / 31% 31% 0 0; }
.auth-face { position: absolute; display: flex; gap: 4cqw; left: 24%; top: 10%; }
.purple .auth-face { gap: 5cqw; }
.orange .auth-face { top: 45%; left: 34%; }
.yellow .auth-face { top: 18%; left: 32%; }
.auth-eye { width: 3.65cqw; height: 3.65cqw; border-radius: 50%; background: white; display: grid; place-items: center; }
.auth-eye::after { content: ''; width: 42%; height: 42%; border-radius: 50%; background: #2d2d2d; transform: translate(var(--eye-x, 0), var(--eye-y, 0)); }
:is(.orange, .yellow) .auth-eye { width: 2.6cqw; height: 2.6cqw; background: transparent; }
:is(.orange, .yellow) .auth-eye::after { width: 100%; height: 100%; }
.auth-mouth { position: absolute; left: 24%; top: 32%; width: 50%; height: 3px; border-radius: 2px; background: #666; }
.yellow .auth-mouth { width: 42%; top: 38%; background: #2d2d2d; }
.auth:has(input[name="name"]:focus, input[type="password"]:focus) .purple { height: 92.5%; transform: skewX(-12deg) translateX(22%); }
.auth:has(input[type="password"]:focus) .auth-eye::after { transform: translate(-1px, 1px); }
.auth-panel { display: grid; align-items: center; justify-items: center; padding: 40px clamp(24px, 5vw, 60px); }
.auth-card { width: min(100%, 420px); }
.auth-heading { text-align: center; margin-bottom: 40px; }
.auth-heading h1 { font-size: 30px; line-height: 1.25; color: #1a1a2e; margin-bottom: 8px; }
.auth-card form { display: grid; gap: 22px; }
.auth-card .field { gap: 6px; color: #333; font-weight: 500; }
.auth-card .field input { min-height: 48px; padding: 12px 14px; border: 1.5px solid #e5e7eb; border-radius: 10px; font-size: 15px; }
.auth-card .field input:focus { border-color: #6c3ff5; outline-color: #6c3ff5; }
.auth-card form button.primary { min-height: 48px; margin-top: 4px; border: 0; border-radius: 10px; background: #1a1a2e; font-size: 15px; }
.auth-card form button.primary:hover:not(:disabled) { background: #2d2d3e; }
.auth-card .error:not(:empty) { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 14px; }
.auth-error-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-error-page .panel { padding: 24px; }

.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100dvh; }
.shell.nav-collapsed { --sidebar-width: 52px; }
.site-side {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: white;
  border-right: 1px solid var(--line);
  min-width: 0;
  z-index: 50;
}
.site-brand-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  padding: 0 10px 0 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.3px;
  text-decoration: none;
  white-space: nowrap;
}
.site-brand-bar .brand { margin-right: auto; }
.mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 800;
}
#site-menu { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.site-nav { flex: 1; overflow: auto; padding: 8px 10px; scrollbar-width: thin; }
.site-nav svg, .nav-icon-button svg { flex: none; width: 16px; height: 16px; }
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--control-radius);
  color: var(--dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
}
.nav svg { color: var(--subtle); }
.nav:hover, .nav-category summary:hover { background: var(--muted); color: var(--ink); }
.nav.current { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav.current svg { color: inherit; }
.nav-category { margin-bottom: 4px; }
.nav-category summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: var(--control-radius);
  color: var(--subtle);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .35px;
}
.nav-category summary::-webkit-details-marker { display: none; }
.nav-category summary .nav-chevron { margin-left: auto; width: 13px; height: 13px; }
.nav-category[open] .nav-chevron { transform: rotate(90deg); }
.nav-category.has-current summary { color: var(--primary); }
.nav-category .nav-group { display: grid; gap: 1px; padding: 1px 0 2px 8px; }
.account {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.account-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--muted); color: var(--dim); font-weight: 700; }
.account-info { display: grid; flex: 1; min-width: 0; line-height: 1.45; }
.account-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-info small { font-size: 11px; }
button.nav-icon-button { width: 28px; min-height: 28px; padding: 0; }
.nav-icon-button.text { color: var(--subtle); }
button.mobile-nav-toggle, .nav-overlay, button.nav-close { display: none; }
@media (min-width: 768px) {
  .nav-collapsed .site-brand-bar { justify-content: center; padding: 0; }
  .nav-collapsed .site-brand-bar .brand,
  .nav-collapsed .nav-label,
  .nav-collapsed .nav-chevron,
  .nav-collapsed .nav-group,
  .nav-collapsed .account-info,
  .nav-collapsed .account-avatar { display: none; }
  .nav-collapsed .site-nav { padding-inline: 6px; }
  .nav-collapsed :is(.nav, summary, .account) { justify-content: center; padding-inline: 0; }
  .nav-collapsed .nav-collapse svg { transform: rotate(180deg); }
}
.main { padding: 24px 32px 40px; min-width: 0; }
.heading,
.topline,
.actions,
.filters,
.dialog-head,
.dialog-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.heading,
.topline,
.dialog-head {
  justify-content: space-between;
}
.heading {
  align-items: center;
  margin-bottom: 20px;
}
.heading h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.01em;
}
.heading .page-title {
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.page-title-parent { color: var(--dim); font-size: 16px; font-weight: 550; }
.page-title-separator {
  margin-inline: .15em;
  color: var(--dim);
  font-size: .75em;
  font-weight: 600;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 17px;
}
.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--surface-radius);
  box-shadow: var(--shadow);
  padding: 14px 15px;
  display: grid;
  gap: 5px;
}
.stat b {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}
.stat b small {
  font-size: 12px;
  font-weight: 500;
  margin-left: 4px;
  letter-spacing: 0;
}
.panel {
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--surface-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.topline {
  padding: 11px 14px;
}
.filters {
  border-top: 1px solid var(--line);
  padding: 9px 14px;
  background: var(--bg);
}
.filters input {
  width: 245px;
}
.filters select,
.filters input {
  min-height: 36px;
  padding: 6px 8px;
  font-size: 13px;
}
.scroll {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
}
th,
td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--muted);
}
tr:last-child td {
  border-bottom: 0;
}
th {
  background: var(--bg);
  color: var(--dim);
  font-weight: 600;
  font-size: 13px;
}
td {
  background: white;
  font-variant-numeric: tabular-nums;
}
tr:hover td {
  background: var(--bg);
}
.empty {
  padding: 31px 14px;
  color: var(--dim);
  text-align: center;
}
.badge {
  display: inline-block;
  font-size: 12px;
  background: #f0fdf4;
  padding: 2px 8px;
  border-radius: 5px;
  color: #166534;
}
.badge.out {
  color: #92400e;
  background: #fffbeb;
}
.number {
  font-weight: 650;
}
.panel-note {
  padding: 10px 18px;
  font-size: 13px;
  color: var(--dim);
}
.error {
  color: var(--red);
  font-size: 14px;
  white-space: pre-wrap;
}
.error:empty {
  display: none;
}
dialog {
  width: min(575px, calc(100% - 28px));
  border: 1px solid var(--line);
  padding: 0;
  border-radius: var(--surface-radius);
  background: white;
  color: var(--ink);
  max-height: 90vh;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 8%), 0 8px 10px -6px rgb(0 0 0 / 4%);
}
dialog::backdrop {
  background: rgb(15 23 42 / 42%);
}
.dialog-head {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 16px 21px;
}
.dialog-head button {
  font-size: 22px;
  padding: 0 5px;
  min-height: 30px;
  color: var(--dim);
}
.dialog-body {
  padding: 19px 21px;
}
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 590;
  min-width: 0;
}
.field input:not([type="checkbox"], [type="radio"]),
.field select {
  font-weight: 400;
  width: 100%;
}
.wide {
  grid-column: 1/-1;
}
.dialog-foot {
  background: var(--white);
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 12px 20px;
  margin-top: 5px;
}
.dialog-error {
  margin-top: 12px;
}
.detail-list {
  margin: 0 0 17px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}
.detail-list dt {
  font-size: 12px;
  color: var(--dim);
}
.detail-list dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}
.history-row {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 3px;
  font-size: 14px;
}
.history {
  margin-top: 8px;
}
.inset {
  background: var(--primary-light);
  padding: 10px 12px;
  border-radius: 5px;
  font-size: 14px;
}
.stack {
  display: grid;
  gap: 12px;
}
#notice {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 30;
  background: var(--ink);
  color: white;
  padding: 10px 15px;
  border-radius: 6px;
  box-shadow: 0 6px 22px #0f172a2a;
  font-size: 14px;
  max-width: 85vw;
}
#notice:empty {
  display: none;
}
@media (max-width: 1020px) {
  .main { padding-inline: 20px; }
}
@media (max-width: 767px) {
  .shell { display: block; }
  button.nav-collapse { display: none; }
  button.nav-close { display: inline-flex; width: 36px; min-height: 36px; }
  .site-side { position: fixed; inset: 0 auto 0 0; width: min(220px, 84vw); height: 100dvh; }
  .shell:not(.mobile-menu-open) .site-side { visibility: hidden; }
  .nav-overlay { position: fixed; inset: 0; z-index: 49; background: rgb(0 0 0 / 30%); }
  .mobile-menu-open .nav-overlay { display: block; }
  button.mobile-nav-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 48;
    display: grid;
    place-items: center;
    width: 36px;
    min-height: 36px;
    background: white;
    border-color: var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
  .mobile-menu-open button.mobile-nav-toggle { visibility: hidden; }
  .main { padding: 58px 14px 32px; }
  .heading { margin-bottom: 14px; align-items: flex-start; }
  .heading h1 { font-size: 22px; }
  .stat { padding: 10px; }
  .stat b { font-size: 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 13px; }
  .topline, .filters { padding: 10px; }
  .filters input { width: 100%; }
  .field input:not([type="checkbox"], [type="radio"]), .field select, .field textarea { font-size: 16px; }
  .fields { grid-template-columns: 1fr; }
  .dialog-body, .dialog-head { padding: 14px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-illustration { display: none; }
  .auth-panel { padding: 32px 24px; }
}
@media (prefers-reduced-motion: no-preference) {
  .purple .auth-eye { animation: auth-blink 6.2s infinite; }
  .charcoal .auth-eye { animation: auth-blink 7.8s 1s infinite; }
}
@keyframes auth-blink {
  0%, 47%, 51%, 100% { scale: 1; }
  49% { scale: 1 .12; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-character { transition: none; }
}
@media print {
  .site-side, .mobile-nav-toggle, .nav-overlay { display: none !important; }
  .shell { display: block; }
}
[hidden] {
  display: none !important;
}

.optional summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 14px;
}
.optional[open] summary {
  margin-bottom: 10px;
}

.table-sub {
  display: block;
  color: var(--dim);
  font-size: 12px;
  margin-top: 2px;
}

a { color: var(--primary-hover); }
.scroll:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

summary:focus-visible { outline:2px solid var(--primary); outline-offset:-2px; }
.inventory-filters { padding:16px 20px; margin-bottom:20px; background:var(--muted); border-radius:12px; }
.inventory-filter-core {
  display:grid;
  grid-template-columns:minmax(185px,2fr) repeat(3,minmax(110px,1fr));
  gap:10px;
}
.inventory-filter-bottom,.inventory-ranges,.inventory-pager,.inventory-pager label {
  display:flex;
  flex-wrap:wrap;
  align-items:end;
  gap:10px;
}
.inventory-filter-bottom { margin-top:9px; justify-content:space-between; }
.inventory-ranges fieldset { display:flex; gap:6px; margin:0; padding:0; min-width:0; border:none; }
.inventory-ranges legend { padding:0; margin-bottom:4px; color:var(--dim); font-size:13px; }
.inventory-ranges .range-label { font-size:12px; color:var(--dim); max-width:108px; }
.inventory-filters .error { margin-top:8px; }
.inventory-row { cursor:pointer; }
.inventory-row:focus-within td { background:var(--primary-light); }
button.text.inventory-sort { color:inherit; padding-inline:2px; min-height:26px; font-size:inherit; }
.sort-mark { margin-left:3px; color:var(--dim); }
[aria-sort] .sort-mark { color:var(--primary); }
.inventory-pager {
  align-items:center;
  justify-content:space-between;
  border-top:1px solid var(--line);
  padding:9px 12px;
  color:var(--dim);
  font-size:13px;
}
.inventory-pager label { align-items:center; }
.inventory-pager select,.inventory-pager button { min-height:32px; padding-block:4px; }
.inventory-pager button:disabled { cursor:default; }
.badge.info { color:#1e40af; background:#dbeafe; }
dialog.inventory-detail { width:min(960px,calc(100% - 28px)); max-height:calc(100dvh - 28px); }
dialog.inventory-detail[open] { display:flex; flex-direction:column; }
.inventory-detail .dialog-head { flex-wrap:nowrap; justify-content:flex-start; }
.inventory-detail .dialog-head button { margin-left:auto; }
.inventory-detail .dialog-head h2 { overflow-wrap:anywhere; }
.inventory-detail .dialog-head .badge { white-space:nowrap; }
.inventory-detail .dialog-foot { margin:0; overflow:auto; max-height:32dvh; }
.inventory-detail-body { overflow:auto; min-height:0; background:var(--bg); display:flex; flex-direction:column; gap:10px; }
.inventory-detail-card { flex:none; padding:12px 14px; }
.inventory-detail-card h3 { margin-bottom:8px; }
.inventory-detail-card .detail-list { grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); margin:0; gap:8px; }
.inventory-detail-card .detail-list div { background:var(--muted); border-radius:8px; padding:6px 9px; }
#take-shell.shell .take-main,#import-shell.shell main { width:100%; max-width:none; margin:0; min-width:0; }
@media (max-width:900px) {
  .inventory-filter-core { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:650px) {
  .inventory-filters { padding:12px; margin-bottom:14px; }
  .inventory-filter-core .inventory-keyword { grid-column:1/-1; }
  .inventory-ranges .range-label { max-width:none; min-width:0; width:100%; }
  .inventory-ranges { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
  .inventory-pager { gap:6px; }
  .inventory-detail-card .detail-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

.warehouse-pending { margin-bottom: 14px; }
.warehouse-pending .empty { padding-block: 16px; }

.warehouse-count-history { margin-top: 14px; }

.location-page .filters label { color: var(--dim); font-size: 13px; }
.location-page .location-table { white-space: normal; }
.location-table thead th:first-child { width: 32%; }
.location-table thead th:last-child { width: 24%; }
.location-table td, .location-table th { overflow-wrap: anywhere; }
.location-table .location-group th, .location-table .location-group td {
  background: var(--primary-light);
  color: var(--ink);
}
.location-table .location-group th { font-size: 14px; }
.location-table tbody + tbody > tr:first-child > * { border-top: 1px solid var(--line); }
.location-table button.text { white-space: nowrap; }

.settings-page > .panel + .panel { margin-top: 14px; }
.settings-editor { padding: 16px; }
.settings-editor fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.settings-editor > .actions { justify-content: flex-end; }
.settings-editor .error:empty { display: none; }
