:root {
  color-scheme: light;
  --navy: #17365d;
  --blue: #24547d;
  --sky: #d9eef8;
  --sky-strong: #bfe3f3;
  --ink: #1d2939;
  --muted: #667085;
  --line: #d8e2ec;
  --surface: #ffffff;
  --background: #f3f7fb;
  --danger: #b42318;
  --success: #067647;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.brand-mark {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  color: white; font-size: 25px; font-weight: 800; background: linear-gradient(145deg, #2f80b5, var(--navy));
  box-shadow: 0 12px 30px rgba(23, 54, 93, .2);
}
.brand-mark.small { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; box-shadow: none; }
.eyebrow { margin: 0 0 8px; color: #2c6f9e; font-size: 13px; font-weight: 800; letter-spacing: .12em; }

.loading-page { min-height: 100vh; display: grid; place-items: center; }
.loading-card { text-align: center; }
.loading-card .brand-mark { margin: 0 auto; }

.auth-page { min-height: 100vh; background: linear-gradient(135deg, #eef7fb 0%, #f8fbfd 48%, #e2eef7 100%); }
.auth-layout { min-height: 100vh; max-width: 1120px; margin: 0 auto; padding: 50px 28px; display: grid; grid-template-columns: 1.08fr .92fr; gap: 70px; align-items: center; }
.auth-intro h1 { margin: 24px 0 18px; color: var(--navy); font-size: clamp(34px, 5vw, 58px); line-height: 1.16; }
.auth-intro > p:not(.eyebrow) { max-width: 580px; color: var(--muted); font-size: 17px; line-height: 1.8; }
.auth-intro ul { margin: 28px 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.auth-intro li::before { content: "✓"; margin-right: 10px; color: var(--success); font-weight: 900; }
.dev-note { padding: 12px 14px; border-left: 4px solid #eaaa08; background: #fffaeb; border-radius: 8px; font-size: 14px !important; }
.auth-card, .panel-card, .search-panel, .result-section { background: var(--surface); border: 1px solid rgba(23, 54, 93, .1); border-radius: 18px; box-shadow: 0 14px 42px rgba(23, 54, 93, .08); }
.auth-card { padding: 28px; }
.tab-row { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: #eef3f8; border-radius: 12px; margin-bottom: 28px; }
.tab-button { border: 0; border-radius: 9px; padding: 11px 12px; background: transparent; color: var(--muted); cursor: pointer; }
.tab-button.active { background: white; color: var(--navy); font-weight: 800; box-shadow: 0 3px 10px rgba(23, 54, 93, .09); }
.form-stack { display: grid; gap: 16px; }
.form-stack h2 { margin: 0 0 4px; color: var(--navy); }
.form-stack label, .product-form label, .search-label { display: grid; gap: 7px; color: #344054; font-size: 14px; font-weight: 700; }
input, select { width: 100%; min-height: 44px; border: 1px solid #c8d4df; border-radius: 10px; padding: 9px 12px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus { border-color: #4388b7; box-shadow: 0 0 0 3px rgba(67, 136, 183, .14); }
.form-message { min-height: 22px; margin: 0; color: var(--danger); }

.primary-button, .secondary-button, .ghost-button, .table-action {
  border-radius: 9px; border: 1px solid transparent; padding: 9px 15px; font-weight: 750; cursor: pointer; text-decoration: none;
}
.primary-button { color: white; background: var(--blue); }
.primary-button:hover { background: var(--navy); }
.secondary-button { color: var(--blue); background: #edf6fb; border-color: #bdd8e9; }
.ai-button { color: #6542a6; background: #f4f0ff; border-color: #d8c9f5; white-space: nowrap; }
.ai-button:hover { background: #ebe3ff; }
.ghost-button { color: var(--blue); background: transparent; border-color: #c9d8e5; }
button:disabled { opacity: .5; cursor: not-allowed; }
.link-button { display: inline-flex; align-items: center; }

.topbar { min-height: 70px; padding: 10px 28px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 30px; color: white; background: var(--navy); box-shadow: 0 5px 20px rgba(23, 54, 93, .18); position: sticky; top: 0; z-index: 10; }
.brand-link { display: flex; gap: 10px; align-items: center; color: white; text-decoration: none; font-weight: 800; }
.topnav { display: flex; gap: 6px; }
.topnav a, .disabled-link { color: #d5e5f1; padding: 10px 13px; border-radius: 9px; text-decoration: none; font-size: 14px; }
.topnav a.active, .topnav a:hover { color: white; background: rgba(255,255,255,.14); }
.disabled-link { opacity: .48; cursor: not-allowed; }
.user-panel { display: flex; gap: 14px; align-items: center; }
.user-panel div { display: grid; text-align: right; }
.user-panel small { color: #bfd1df; }
.topbar .ghost-button { color: white; border-color: rgba(255,255,255,.32); }

.page-shell { width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 28px 0 50px; }
.page-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 22px; }
.page-heading h1 { margin: 0 0 8px; color: var(--navy); font-size: 32px; }
.page-heading p:last-child { margin: 0; color: var(--muted); }
.dashboard-shell { max-width: 1120px; }
.dashboard-welcome { padding: 22px 2px 10px; }
.dashboard-welcome h1 { margin: 0 0 10px; color: var(--navy); font-size: clamp(30px, 5vw, 44px); }
.dashboard-welcome > p:last-child { margin: 0; color: var(--muted); font-size: 16px; }
.feature-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.feature-card {
  width: 100%; min-height: 126px; padding: 22px; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center;
  color: var(--ink); background: var(--surface); border: 1px solid rgba(23, 54, 93, .12); border-radius: 18px;
  box-shadow: 0 12px 32px rgba(23, 54, 93, .07); text-align: left; text-decoration: none; cursor: pointer;
}
.feature-card.available:hover { border-color: #78b6d7; transform: translateY(-2px); box-shadow: 0 16px 36px rgba(23, 54, 93, .12); }
.feature-card.locked { opacity: .78; background: #f7f8fa; border-style: dashed; }
.feature-card.locked .feature-badge { color: #b42318; background: #fee4e2; }
.feature-card.pending { opacity: .72; }
.feature-card.pending:hover { border-color: #c7d3df; background: #f8fafc; }
.feature-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; background: #e8f4fa; font-size: 27px; }
.feature-copy { display: grid; gap: 7px; }
.feature-copy strong { color: var(--navy); font-size: 20px; }
.feature-copy small { color: var(--muted); line-height: 1.5; }
.feature-badge { padding: 6px 9px; color: #667085; background: #f2f4f7; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.feature-badge.ready { color: var(--success); background: #ecfdf3; }
.search-panel { padding: 20px; display: grid; grid-template-columns: 1fr minmax(180px, 260px); gap: 18px; align-items: end; }
.search-main > label, .brand-filter { display: block; margin-bottom: 8px; color: #344054; font-size: 14px; font-weight: 750; }
.search-input-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; }
.camera-button { color: #166a52; background: #ecfdf3; border-color: #abefc6; white-space: nowrap; }
.camera-button:hover:not(:disabled) { background: #dff7ea; }
.brand-filter select { margin-top: 8px; }
.result-section { margin-top: 20px; overflow: hidden; }
.result-toolbar { padding: 15px 18px; display: flex; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); background: #f8fbfd; }
.result-toolbar span { color: var(--muted); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; background: white; }
th { padding: 12px 13px; color: white; background: var(--blue); text-align: left; font-size: 13px; white-space: nowrap; }
td { padding: 10px 13px; border-bottom: 1px solid #e5edf3; vertical-align: top; font-size: 13px; }
tbody tr:nth-child(odd) { background: #f2faff; }
tbody tr:hover { background: var(--sky); }
.product-table th:nth-child(1) { min-width: 145px; }
.product-table th:nth-child(2) { min-width: 85px; }
.product-table th:nth-child(3) { min-width: 230px; }
.product-table th:nth-child(4) { min-width: 330px; }
.product-table th:nth-child(5) { min-width: 65px; }
.product-table th:nth-child(6) { min-width: 180px; }
.product-table th:nth-child(7) { min-width: 145px; }
.code-cell { font-family: Consolas, "Microsoft YaHei", monospace; white-space: nowrap; }
.name-cell { font-weight: 650; }
.clickable-row { cursor: pointer; }
.row-actions { display: flex; gap: 7px; white-space: nowrap; }
.center-cell { text-align: center; }
.empty-state { padding: 52px 20px; text-align: center; color: var(--muted); }
.pagination { padding: 15px 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
.table-action { display: inline-block; padding: 6px 10px; color: var(--blue); background: #eaf5fb; border-color: #bdd8e9; font-size: 12px; }
.permission-cell { text-align: center; }
.permission-cell input { width: 20px; height: 20px; accent-color: var(--blue); cursor: pointer; }
.button-like { min-height: 34px; }

.product-detail-dialog { width: min(1100px, calc(100% - 28px)); max-height: min(860px, calc(100vh - 28px)); overflow: auto; }
.detail-dialog-header { display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.detail-dialog-header h2 { margin: 0 0 6px; color: var(--navy); font-size: 27px; }
.detail-dialog-header .ghost-button { flex-shrink: 0; white-space: nowrap; }
.detail-dialog-header p:last-child { margin: 0; color: var(--muted); font-family: Consolas, "Microsoft YaHei", monospace; }
.product-detail-layout { margin-top: 20px; display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.2fr); gap: 20px; }
.detail-info-card, .detail-image-card { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: #fbfdff; }
.detail-info-card h3, .detail-image-card h3 { margin: 0 0 14px; color: var(--navy); }
.detail-image-card .section-title p { font-size: 13px; }
.detail-list { margin: 0; display: grid; gap: 0; }
.detail-list > div { padding: 11px 0; display: grid; grid-template-columns: 90px 1fr; gap: 14px; border-bottom: 1px solid #e8eef4; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: 13px; }
.detail-list dd { margin: 0; color: var(--ink); font-weight: 650; word-break: break-word; }
.product-image-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.product-image-item { position: relative; margin: 0; min-width: 0; }
.product-image-link { display: block; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.product-image-link img { width: 100%; height: 100%; display: block; object-fit: contain; }
.product-image-item figcaption { margin-top: 6px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-delete-button { position: absolute; top: 7px; right: 7px; padding: 5px 8px; color: white; background: rgba(180, 35, 24, .9); border: 0; border-radius: 8px; cursor: pointer; }
.image-empty { padding: 44px 16px; color: var(--muted); text-align: center; border: 1px dashed #cbd7e2; border-radius: 12px; background: white; }
.image-upload { margin-top: 18px; padding-top: 17px; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; border-top: 1px solid var(--line); }
.image-upload label { display: grid; gap: 7px; color: #344054; font-size: 14px; font-weight: 700; }
.image-upload input { padding: 7px; }
.image-upload small, .image-upload .form-message { grid-column: 1 / -1; }
.image-upload small { color: var(--muted); }

dialog { width: min(460px, calc(100% - 28px)); border: 0; border-radius: 18px; padding: 26px; box-shadow: 0 25px 80px rgba(16, 24, 40, .28); }
dialog::backdrop { background: rgba(15, 35, 55, .48); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 100; padding: 11px 18px; color: white; background: #203c56; border-radius: 999px; box-shadow: 0 10px 25px rgba(0,0,0,.2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.recognition-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: 0; }
.recognition-header { padding: 24px 24px 18px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.recognition-header h2 { margin: 0 0 7px; color: var(--navy); font-size: 27px; }
.recognition-subtitle { margin: 0; color: var(--muted); line-height: 1.55; }
.recognition-scanner { position: relative; margin: 18px 24px 0; min-height: 380px; display: grid; place-items: center; overflow: hidden; color: white; background: #13283a; border-radius: 17px; }
.recognition-video, .recognition-fallback-preview { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; background: #0b1722; }
.recognition-video { opacity: 0; }
.recognition-video.active { opacity: 1; }
.recognition-camera-placeholder { position: relative; z-index: 1; display: grid; gap: 8px; place-items: center; color: #dce8f1; text-align: center; }
.recognition-camera-placeholder > span { font-size: 48px; }
.recognition-camera-placeholder strong { font-size: 17px; }
.recognition-camera-placeholder small { color: #a8becd; }
.recognition-scan-frame { position: absolute; z-index: 3; inset: 11% 9%; pointer-events: none; }
.recognition-scan-frame i { position: absolute; width: 44px; height: 44px; border-color: #55e6b2; border-style: solid; filter: drop-shadow(0 0 5px rgba(85, 230, 178, .45)); }
.recognition-scan-frame i:nth-child(1) { left: 0; top: 0; border-width: 4px 0 0 4px; border-radius: 8px 0 0 0; }
.recognition-scan-frame i:nth-child(2) { right: 0; top: 0; border-width: 4px 4px 0 0; border-radius: 0 8px 0 0; }
.recognition-scan-frame i:nth-child(3) { right: 0; bottom: 0; border-width: 0 4px 4px 0; border-radius: 0 0 8px 0; }
.recognition-scan-frame i:nth-child(4) { left: 0; bottom: 0; border-width: 0 0 4px 4px; border-radius: 0 0 0 8px; }
.recognition-scan-frame span { position: absolute; left: 50%; bottom: -2px; transform: translate(-50%, 50%); padding: 5px 10px; color: white; background: rgba(8, 25, 38, .76); border-radius: 999px; font-size: 12px; white-space: nowrap; }
.recognition-scan-line { position: absolute; z-index: 4; left: 12%; right: 12%; top: 18%; height: 2px; background: linear-gradient(90deg, transparent, #55e6b2 15%, #55e6b2 85%, transparent); box-shadow: 0 0 12px #55e6b2; animation: scan-product 1.7s ease-in-out infinite alternate; }
@keyframes scan-product { from { top: 18%; } to { top: 80%; } }
.recognition-camera-actions { margin: 12px 24px 0; display: flex; gap: 10px; }
.recognition-camera-actions > * { flex: 1; text-align: center; }
.recognition-file-button { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.recognition-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.recognition-hint { margin: 16px 24px 0; display: grid; gap: 7px; color: #344054; font-size: 14px; font-weight: 750; }
.recognition-service-state { margin: 14px 24px 0; padding: 12px 14px; display: grid; gap: 4px; border-radius: 11px; }
.recognition-service-state strong { font-size: 14px; }
.recognition-service-state span { font-size: 13px; line-height: 1.5; }
.recognition-service-state.pending { color: #7a4d08; background: #fffaeb; border: 1px solid #fedf89; }
.recognition-service-state.ready { color: #067647; background: #ecfdf3; border: 1px solid #abefc6; }
.recognition-service-state.error { color: #b42318; background: #fef3f2; border: 1px solid #fecdca; }
.recognition-footer { margin-top: 18px; padding: 16px 24px 22px; display: flex; justify-content: space-between; gap: 16px; align-items: center; border-top: 1px solid var(--line); background: #fbfcfd; }
.recognition-context { color: var(--muted); font-size: 13px; }
.recognition-results { margin: 15px 24px 0; display: grid; gap: 9px; }
.recognition-result-title { color: var(--navy); font-weight: 800; }
.recognition-candidate { padding: 12px; display: flex; justify-content: space-between; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: white; }
.recognition-candidate-copy { min-width: 0; display: grid; gap: 4px; }
.recognition-candidate-copy strong { color: var(--navy); }
.recognition-candidate-copy span, .recognition-candidate-copy small { color: var(--muted); }
.recognition-candidate-action { display: grid; gap: 6px; justify-items: end; }
.recognition-candidate-action b { color: var(--success); }
.recognition-candidate-action.returns-recognition-actions { grid-template-columns: auto repeat(3, auto); align-items: center; }

.admin-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(440px, 1.2fr); gap: 20px; }
.full-span { grid-column: 1 / -1; }
.panel-card { padding: 22px; }
.panel-card h2 { margin: 0 0 16px; color: var(--navy); }
.panel-card p { color: var(--muted); }
.wide-card { min-width: 0; }
.compact { gap: 12px; }
.section-title { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.section-title h2 { margin-bottom: 4px; }
.section-title p { margin: 0 0 16px; }
.invite-output { margin-top: 18px; padding: 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; background: #ecfdf3; border: 1px solid #abefc6; border-radius: 12px; }
.invite-output strong { color: var(--success); font-family: Consolas, monospace; font-size: 18px; word-break: break-all; }
.admin-product-layout { display: grid; grid-template-columns: minmax(260px, .7fr) minmax(480px, 1.3fr); gap: 24px; }
.mini-results { max-height: 350px; overflow: auto; margin-top: 10px; border-radius: 10px; }
.mini-result { width: 100%; display: grid; gap: 3px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: #f8fbfd; text-align: left; cursor: pointer; }
.mini-result:hover { background: var(--sky); }
.mini-result span { color: var(--muted); font-size: 13px; }
.product-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-two { grid-column: 1 / -1; }

.packing-shell { max-width: 1500px; }
.packing-heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.packing-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.packing-sidebar { display: grid; gap: 18px; position: sticky; top: 90px; }
.packing-sidebar .panel-card { padding: 18px; }
.packing-sidebar .section-title { align-items: center; }
.packing-status-card { margin-top: 15px; padding: 14px; display: grid; gap: 7px; border-radius: 12px; background: #ecfdf3; border: 1px solid #abefc6; }
.packing-status-card.completed { color: #344054; background: #f2f4f7; border-color: #d0d5dd; }
.packing-status-card.empty { color: var(--muted); background: #f8fafc; border-color: var(--line); }
.packing-status-card span { font-size: 13px; }
.packing-status-card strong { color: var(--navy); }
.packing-manage-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.packing-manage-actions button { padding: 8px 9px; }
.danger-button { color: #b42318; background: #fff5f4; border: 1px solid #fecdca; border-radius: 9px; font-weight: 750; cursor: pointer; }
.danger-button:hover:not(:disabled) { background: #fee4e2; }
.danger-button:disabled { opacity: .45; cursor: not-allowed; }
.packing-history-card .section-title p { margin: 2px 0 12px; font-size: 12px; }
.packing-history-list { display: grid; gap: 9px; max-height: 340px; overflow-y: auto; }
.packing-history-item { position: relative; width: 100%; display: block; padding: 8px 54px 8px 8px; color: var(--text); background: #f8fbff; border: 1px solid var(--line); border-radius: 11px; }
.packing-history-item:hover { border-color: #8cb8df; background: #eef7ff; }
.packing-history-open { min-width: 0; display: grid; gap: 4px; padding: 3px 4px; text-align: left; color: inherit; background: transparent; border: 0; cursor: pointer; }
.packing-history-open strong { color: var(--navy); font-size: 14px; }
.packing-history-open span { font-size: 13px; }
.packing-history-open small { color: var(--muted); line-height: 1.45; }
.packing-history-delete { position: absolute; right: 7px; bottom: 7px; padding: 4px 7px; color: #b42318; background: #fff5f4; border: 1px solid #fecdca; border-radius: 7px; font-size: 11px; line-height: 1.2; cursor: pointer; }
.packing-history-delete:hover { background: #fee4e2; }
.packing-history-dialog { width: min(980px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow: auto; }
.history-box-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 16px; align-items: end; margin-top: 18px; }
.history-dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.history-table-wrap { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; }
.packing-wide-button { width: 100%; margin-top: 14px; }
.packing-help { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.packing-main { min-width: 0; }
.packing-scan-panel { grid-template-columns: 1fr; }
.packing-scan-row { grid-template-columns: minmax(220px, 1fr) auto auto; }
.last-packing-action { margin-top: 12px; padding: 12px 14px; color: var(--success); background: #ecfdf3; border: 1px solid #abefc6; border-radius: 11px; font-weight: 700; }
.last-packing-action.empty { color: var(--muted); background: #f8fafc; border-color: var(--line); }
.last-packing-action.error { color: var(--danger); background: #fef3f2; border-color: #fecdca; }
.packing-search-card { margin-top: 18px; }
.packing-search-heading { margin-bottom: 11px; display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.packing-search-heading > div { display: grid; gap: 4px; }
.packing-search-heading strong { color: #344054; font-size: 14px; }
.packing-search-heading small { color: var(--muted); }
.packing-search-results { margin-top: 10px; display: grid; gap: 8px; }
.packing-search-result { padding: 11px 12px; display: flex; justify-content: space-between; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 11px; background: #f8fbfd; }
.packing-search-result > div { min-width: 0; display: grid; gap: 4px; }
.packing-search-result strong { color: var(--navy); }
.packing-search-result span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.packing-search-empty { margin: 4px 0 0; color: var(--muted); }
.packing-items-section { margin-top: 18px; }
.packing-table th:nth-child(1) { min-width: 150px; }
.packing-table th:nth-child(2) { min-width: 340px; }
.packing-table th:nth-child(3) { min-width: 70px; }
.packing-table th:nth-child(4) { min-width: 90px; }
.packing-table th:nth-child(5) { min-width: 190px; }
.packing-quantity { color: var(--navy); font-size: 20px; font-weight: 900; text-align: center; }
.quantity-actions { display: flex; gap: 7px; align-items: center; }
.quantity-button, .quantity-delete { min-width: 38px; min-height: 34px; border: 1px solid #bdd8e9; border-radius: 9px; color: var(--blue); background: #edf6fb; cursor: pointer; font-weight: 800; }
.quantity-delete { padding: 6px 10px; color: var(--danger); background: #fff2f0; border-color: #fecdca; font-weight: 700; }
.quantity-button:disabled, .quantity-delete:disabled { opacity: .45; cursor: not-allowed; }

.returns-shell { max-width: 1500px; }
.returns-heading { align-items: center; }
.returns-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; align-items: start; }
.returns-sidebar { display: grid; gap: 18px; position: sticky; top: 90px; }
.returns-sidebar .panel-card { padding: 18px; }
.return-status-card { margin-top: 15px; padding: 14px; display: grid; gap: 7px; border: 1px solid #f6c56b; border-radius: 12px; background: #fffaeb; }
.return-status-card span { color: var(--muted); font-size: 13px; }
.return-status-card strong { color: #7a4d08; line-height: 1.5; }
.return-status-card.done { border-color: #abefc6; background: #ecfdf3; }
.return-status-card.done strong { color: var(--success); }
.return-status-card.empty { border-color: var(--line); background: #f8fafc; }
.return-status-card.empty strong { color: var(--muted); }
.returns-history-card .section-title p { margin: 2px 0 12px; font-size: 12px; }
.returns-main { min-width: 0; }
.returns-register-card { min-height: 150px; }
.return-physical-tip { margin: 10px 0 0 !important; padding: 9px 11px; color: #8b3a12 !important; background: #fff7ed; border-left: 4px solid #f97316; border-radius: 8px; font-size: 13px; line-height: 1.5; }
.returns-items-section { margin-top: 18px; }
.return-search-result { padding: 11px 12px; display: flex; justify-content: space-between; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 11px; background: #f8fbfd; }
.return-search-result > div:first-child { min-width: 0; display: grid; gap: 4px; }
.return-search-result strong { color: var(--navy); }
.return-search-result span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.return-register-controls { display: grid; grid-template-columns: 56px repeat(3, auto); gap: 5px; flex: 0 0 auto; }
.return-register-controls input { width: 56px; min-height: 34px; padding: 5px 6px; text-align: center; font-size: 14px; font-weight: 800; }
.return-register-good, .return-register-bad, .return-register-non-factory { min-height: 34px; padding: 6px 9px; color: white; border-radius: 8px; font-size: 13px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.return-register-good { background: #12845b; border: 1px solid #067647; }
.return-register-bad { background: #d92d20; border: 1px solid #b42318; }
.return-register-non-factory { background: #f79009; border: 1px solid #b54708; }
.return-register-good:hover:not(:disabled) { background: #067647; }
.return-register-bad:hover:not(:disabled) { background: #b42318; }
.return-register-non-factory:hover:not(:disabled) { background: #b54708; }
.returns-table th:nth-child(1) { min-width: 240px; }
.returns-table th:nth-child(2) { min-width: 90px; }
.returns-table th:nth-child(3), .returns-table th:nth-child(4), .returns-table th:nth-child(6), .returns-table th:nth-child(7) { min-width: 92px; text-align: center; }
.returns-table th:nth-child(5), .returns-table th:nth-child(8) { min-width: 110px; text-align: center; }
.returns-table th:nth-child(9) { min-width: 72px; text-align: center; }
.returns-table td:first-child strong, .returns-table td:first-child small { display: block; }
.returns-table td:first-child strong { color: var(--navy); }
.returns-table td:first-child small { margin-top: 5px; color: var(--muted); }
.return-product-heading, .packing-product-heading { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.return-product-heading strong, .packing-product-heading strong { min-width: 0; }
.return-oem-code { display: inline-flex; width: fit-content; max-width: 100%; padding: 2px 7px; color: #175cd3; background: #eff8ff; border: 1px solid #b2ddff; border-radius: 6px; font-size: 11px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.return-product-meta { display: block; margin-top: 4px; color: var(--muted); }
.return-other-reasons { display: block; margin-top: 5px; color: #9a5b0a; font-size: 12px; line-height: 1.45; }
.return-original { color: var(--navy); font-size: 15px; font-weight: 800; white-space: nowrap; }
.return-good, .return-bad, .return-non-factory, .return-pending { font-size: 15px; font-weight: 800; text-align: center; }
.return-good { color: #067647; }
.return-bad, .return-pending { color: #d92d20; }
.return-non-factory { color: #b54708; }
.return-good.done, .return-bad.done, .return-non-factory.done, .return-pending.done { color: var(--success); }
.return-row-complete { background: #f0fff6 !important; }
.return-data-row.return-row-complete .return-product-heading strong,
.return-data-row.return-row-complete .return-product-meta,
.return-data-row.return-row-complete .return-original,
.return-data-row.return-row-complete .return-good,
.return-data-row.return-row-complete .return-bad,
.return-data-row.return-row-complete .return-non-factory,
.return-data-row.return-row-complete .return-pending {
  text-decoration-line: line-through;
  text-decoration-color: #667085;
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: none;
  opacity: .72;
}
.return-data-row td { padding-bottom: 6px; border-bottom: 0; vertical-align: middle; }
.return-action-row td { padding: 0 4px 8px; }
.return-action-row .return-action-spacer { padding-left: 13px; }
.return-check-actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.return-check-actions button { flex: 0 0 auto; min-width: 0; min-height: 30px; padding: 4px 7px; border-radius: 7px; font-size: 11px; }
.return-single-action button { width: 100%; }
.return-check-button { min-height: 32px; padding: 5px 10px; color: white; background: #d92d20; border: 1px solid #b42318; border-radius: 7px; font-weight: 850; cursor: pointer; white-space: nowrap; }
.return-check-button:hover:not(:disabled) { background: #b42318; }
.return-check-button:disabled { color: #067647; background: #ecfdf3; border-color: #abefc6; opacity: 1; }
.return-check-button.good { background: #12845b; border-color: #067647; }
.return-check-button.good:hover:not(:disabled) { background: #067647; }
.return-check-button.bad { background: #d92d20; border-color: #b42318; }
.return-check-button.bad:hover:not(:disabled) { background: #b42318; }
.return-check-button.non-factory { background: #f79009; border-color: #b54708; }
.return-check-button.non-factory:hover:not(:disabled) { background: #b54708; }
.return-check-actions .table-action, .return-check-actions .quantity-delete { min-height: 30px; }
.returns-history-actions { margin-top: 18px; justify-content: flex-end; }

.inventory-shell { max-width: 1280px; }
.inventory-layout { display: grid; gap: 20px; }
.inventory-form-card { padding: 24px; }
.inventory-form-card .section-title p { margin: 2px 0 16px; }
.inventory-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; align-items: end; }
.inventory-form label { display: grid; gap: 7px; color: #344054; font-size: 14px; font-weight: 700; }
.inventory-form input, .inventory-form select { min-height: 46px; }
.inventory-product-field { position: relative; }
.inventory-product-results { position: absolute; top: 72px; left: 0; right: 0; z-index: 4; display: grid; gap: 6px; max-height: 330px; overflow: auto; background: white; border-radius: 12px; box-shadow: 0 15px 35px rgba(23, 54, 93, .2); }
.inventory-product-option { padding: 11px 13px; display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: left; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.inventory-product-option:hover { background: #f0f8fc; border-color: #8bc1dc; }
.inventory-product-option > span { min-width: 0; display: grid; gap: 4px; }
.inventory-product-option strong { color: var(--navy); }
.inventory-product-option small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-product-option b { flex: 0 0 auto; color: var(--blue); }
.inventory-search-empty { margin: 0; padding: 14px; color: var(--muted); }
.selected-product { margin-top: 9px; padding: 12px 14px; display: grid; gap: 5px; border: 1px solid #8bc1dc; border-radius: 11px; background: #f0f8fc; }
.selected-product strong { color: var(--navy); }
.selected-product span { color: var(--muted); font-size: 13px; }
.inventory-type-field { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
.inventory-type-field legend { margin-bottom: 8px; color: #344054; font-size: 14px; font-weight: 700; }
.inventory-type-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.inventory-type-button { min-width: 100px; min-height: 40px; padding: 7px 18px; color: var(--blue); background: #f5f9fc; border: 1px solid #bdd2e2; border-radius: 9px; cursor: pointer; font-weight: 800; }
.inventory-type-button.active { color: white; background: var(--blue); border-color: var(--blue); }
.inventory-reason-field { grid-column: span 2; }
.inventory-submit-cell { display: flex; align-items: end; justify-content: flex-end; }
.inventory-submit-cell button { min-height: 46px; min-width: 150px; }
.inventory-message { grid-column: 1 / -1; }
.inventory-records-card { margin-top: 0; }
.inventory-record-toolbar { padding: 16px 18px; display: flex; justify-content: space-between; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); background: #f8fbfd; }
.inventory-record-toolbar > div:first-child { display: grid; gap: 4px; }
.inventory-record-toolbar small { color: var(--muted); }
.inventory-filters { display: grid; grid-template-columns: minmax(200px, 1fr) 130px 150px; gap: 9px; }
.inventory-filters input, .inventory-filters select { min-height: 40px; }
.inventory-record-list { display: grid; }
.inventory-record { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 13px 22px; border-bottom: 1px solid var(--line); }
.inventory-record:last-child { border-bottom: 0; }
.inventory-record.is-completed { background: #f7fcf9; }
.inventory-record-heading { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; grid-column: 1 / -1; }
.inventory-record-heading > div:first-child { min-width: 0; display: grid; gap: 5px; }
.inventory-record-heading strong { color: var(--navy); font-size: 17px; }
.inventory-record-heading small { color: var(--muted); overflow-wrap: anywhere; }
.inventory-record-badges { display: flex; gap: 7px; flex: 0 0 auto; }
.inventory-type-label, .inventory-status-label { padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.type-add_stock { color: #175cd3; background: #eff8ff; border: 1px solid #b2ddff; }
.type-transfer { color: #93370d; background: #fff6ed; border: 1px solid #ffdcc1; }
.type-other { color: #344054; background: #f2f4f7; border: 1px solid #d0d5dd; }
.status-pending { color: #b54708; background: #fffaeb; border: 1px solid #fedf89; }
.status-completed { color: #067647; background: #ecfdf3; border: 1px solid #abefc6; }
.inventory-record-details { display: flex; gap: 8px 22px; flex-wrap: wrap; align-items: center; color: #475467; font-size: 14px; }
.inventory-record-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.inventory-record-actions button { min-height: 36px; padding: 6px 10px; font-size: 12px; }
.inventory-delete-button { color: var(--danger); background: transparent; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; gap: 30px; padding-top: 30px; }
  .auth-intro h1 { font-size: 38px; }
  .topbar { grid-template-columns: 1fr auto; gap: 12px; padding: 10px 14px; }
  .topnav { grid-row: 2; grid-column: 1 / -1; overflow-x: auto; }
  .search-panel, .admin-grid, .admin-product-layout, .product-detail-layout, .packing-layout, .returns-layout { grid-template-columns: 1fr; }
  .inventory-record-toolbar { align-items: stretch; flex-direction: column; }
  .packing-sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .returns-sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .full-span { grid-column: auto; }
  .wide-card { grid-column: auto; }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 20px, 1480px); padding-top: 18px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .search-input-row { grid-template-columns: 1fr 1fr; }
  .search-input-row input { grid-column: 1 / -1; }
  .user-panel strong { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  .brand-link > span:last-child { display: none; }
  .product-form { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .invite-output { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; gap: 12px; }
  .feature-card { min-height: 108px; padding: 17px; gap: 13px; }
  .feature-icon { width: 46px; height: 46px; font-size: 23px; }
  .feature-copy strong { font-size: 17px; }
  .product-image-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .image-upload { grid-template-columns: 1fr; }
  .image-upload small, .image-upload .form-message { grid-column: auto; }
  .packing-sidebar { grid-template-columns: 1fr; }
  .returns-sidebar { grid-template-columns: 1fr; }
  .packing-heading-actions { width: 100%; }
  .packing-heading-actions button { flex: 1; }
  .packing-scan-row { grid-template-columns: 1fr 1fr; }
  .packing-scan-row input { grid-column: 1 / -1; }
  .packing-search-result { align-items: flex-start; flex-direction: column; }
  .return-search-result { align-items: stretch; flex-direction: column; }
  .return-register-controls { grid-template-columns: 52px repeat(3, minmax(0, 1fr)); gap: 5px; }
  .return-register-controls input { width: 52px; }
  .return-check-actions { display: grid; align-items: stretch; grid-template-columns: 1fr 1fr; }
  .return-check-actions button { width: 100%; }
  .returns-history-actions { display: grid; grid-template-columns: 1fr; }
  .returns-table, .returns-table tbody { display: block; width: 100%; }
  .returns-table thead { display: none; }
  .returns-table tr { margin: 0; padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 8px; border-bottom: 1px solid var(--line); }
  .returns-table td { min-width: 0; padding: 0; border: 0; }
  .returns-table td:first-child { grid-column: 1 / -1; padding-bottom: 10px; border-bottom: 1px solid #dce6ee; }
  .returns-table td:nth-child(2), .returns-table td:nth-child(3), .returns-table td:nth-child(4), .returns-table td:nth-child(5), .returns-table td:nth-child(6), .returns-table td:nth-child(7), .returns-table td:nth-child(8), .returns-table td:nth-child(9) { text-align: center; }
  .returns-table td:nth-child(2)::before, .returns-table td:nth-child(3)::before, .returns-table td:nth-child(4)::before, .returns-table td:nth-child(5)::before, .returns-table td:nth-child(6)::before, .returns-table td:nth-child(7)::before, .returns-table td:nth-child(8)::before, .returns-table td:nth-child(9)::before { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
  .returns-table td:nth-child(2)::before { content: "登记原数量"; }
  .returns-table td:nth-child(3)::before { content: "登记好件"; }
  .returns-table td:nth-child(4)::before { content: "登记坏件"; }
  .returns-table td:nth-child(5)::before { content: "登记其他"; }
  .returns-table td:nth-child(6)::before { content: "已核好件"; }
  .returns-table td:nth-child(7)::before { content: "已核坏件"; }
  .returns-table td:nth-child(8)::before { content: "已核其他"; }
  .returns-table td:nth-child(9)::before { content: "还差"; }
  .returns-table .return-data-row { margin-bottom: 0; padding-bottom: 9px; border-bottom: 0; }
  .returns-table .return-action-row { margin-bottom: 12px; padding: 0 14px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-bottom: 1px solid var(--line); }
  .returns-table .return-action-row td { display: block; padding: 0; border: 0; }
  .returns-table .return-action-row .return-action-spacer { display: none; }
  .returns-table .return-good-action-cell::before, .returns-table .return-bad-action-cell::before, .returns-table .return-non-factory-action-cell::before, .returns-table .return-checked-good-action-cell::before, .returns-table .return-checked-bad-action-cell::before, .returns-table .return-checked-non-factory-action-cell::before, .returns-table .return-edit-action-cell::before, .returns-table .return-delete-action-cell::before { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
  .returns-table .return-edit-action-cell::before { content: "登记总数"; }
  .returns-table .return-good-action-cell::before { content: "登记好件"; }
  .returns-table .return-bad-action-cell::before { content: "登记坏件"; }
  .returns-table .return-non-factory-action-cell::before { content: "登记其他"; }
  .returns-table .return-checked-good-action-cell::before { content: "已核好件"; }
  .returns-table .return-checked-bad-action-cell::before { content: "已核坏件"; }
  .returns-table .return-checked-non-factory-action-cell::before { content: "已核其他"; }
  .returns-table .return-delete-action-cell::before { content: "完成/还差"; }
  .returns-table .row-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .returns-table .row-actions button { width: 100%; min-height: 38px; }
  .history-box-toolbar { grid-template-columns: 1fr; }
  .history-dialog-actions button { flex: 1; }
  .packing-search-result button { width: 100%; }
  .recognition-dialog { width: calc(100% - 12px); max-height: calc(100vh - 12px); border-radius: 15px; }
  .recognition-header { padding: 18px 16px 14px; }
  .recognition-header h2 { font-size: 23px; }
  .recognition-scanner, .recognition-camera-actions, .recognition-hint, .recognition-service-state, .recognition-results { margin-left: 16px; margin-right: 16px; }
  .recognition-scanner { min-height: 330px; }
  .recognition-footer { padding: 14px 16px 18px; align-items: stretch; flex-direction: column; }
  .recognition-footer button { width: 100%; }
  .recognition-candidate { align-items: stretch; flex-direction: column; }
  .recognition-candidate-action { grid-template-columns: auto 1fr; align-items: center; }
  .recognition-candidate-action button { width: 100%; }
  .recognition-candidate-action.returns-recognition-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); justify-items: stretch; }
  .recognition-candidate-action.returns-recognition-actions b { grid-column: 1 / -1; }
  .packing-search-heading { align-items: flex-start; }
  .inventory-form { grid-template-columns: 1fr; }
  .inventory-form .span-two, .inventory-reason-field { grid-column: auto; }
  .inventory-type-buttons { grid-template-columns: repeat(3, 1fr); }
  .inventory-submit-cell button { width: 100%; }
  .inventory-filters { grid-template-columns: 1fr; }
  .inventory-record { grid-template-columns: 1fr; }
  .inventory-record-heading { align-items: stretch; flex-direction: column; }
  .inventory-record-badges { flex-wrap: wrap; }
  .inventory-record-actions { justify-content: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .inventory-record-actions button:first-child { grid-column: 1 / -1; }
}
