:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #d9dee7; --text: #1f2937;
  --muted: #6b7280; --brand: #176b87; --brand-2: #0f766e;
  --primary: #176b87;
  --ok: #15803d; --warn: #b7791f; --bad: #b42318; --blue: #2563eb;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Inter","PingFang SC","Microsoft YaHei",Arial,sans-serif; color: var(--text); background: var(--bg); letter-spacing: 0; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px; padding: 8px 12px; cursor: pointer; min-height: 36px; white-space: nowrap; }
button:hover { border-color: var(--brand); color: var(--brand); }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.success { background: var(--ok); color: #fff; border-color: var(--ok); }
button.danger { background: #fff5f5; color: var(--bad); border-color: #f3b5ae; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; background: #fff; color: var(--text); min-height: 38px; }
select { white-space: nowrap; text-overflow: ellipsis; }
textarea { min-height: 76px; resize: vertical; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { background: #102a43; color: #dbeafe; padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.brand { padding: 0 10px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 8px 0 0; color: #a8c4dd; font-size: 13px; line-height: 1.5; }
.nav { margin-top: 18px; display: grid; gap: 18px; }
.nav-group { display: grid; gap: 6px; }
.nav-group-title { padding: 0 12px 4px; color: #8fb3d1; font-size: 12px; font-weight: 700; }
.nav a {
  width: 100%; text-align: left; color: #dbeafe; border: 1px solid transparent;
  background: transparent; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: 6px; text-decoration: none; font-size: 14px; min-height: 36px;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,.11); color: #fff; }
.nav a.active::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #67e8f9; flex: 0 0 auto; }
.main { min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 22px; display: flex; justify-content: space-between; gap: 16px; align-items: center; position: sticky; top: 0; z-index: 8; }
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h2 { margin: 0; font-size: 20px; white-space: nowrap; }
.topbar .meta { color: var(--muted); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.topbar .meta::-webkit-scrollbar { display: none; }
.breadcrumb { display: flex; align-items: center; gap: 6px; margin-top: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow-x: auto; scrollbar-width: none; max-width: min(62vw, 720px); }
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb a { color: var(--brand); text-decoration: none; flex: 0 0 auto; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { flex: 0 0 auto; }
.breadcrumb-separator { color: #9ca3af; }
.menu-toggle { display: none; width: 40px; height: 40px; padding: 0; align-items: center; justify-content: center; gap: 4px; flex-direction: column; flex: 0 0 auto; }
.menu-toggle span { width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
.sidebar-backdrop { display: none; }
.content { padding: 22px; display: grid; gap: 18px; min-width: 0; }
.toolbar, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.toolbar { padding: 14px; display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)) auto; gap: 12px; align-items: end; }
.panel { padding: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 16px; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
td.actions { flex-wrap: nowrap; white-space: nowrap; min-width: max-content; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 10px; border-bottom: 1px solid #eef1f5; text-align: left; vertical-align: middle; }
th { color: #4b5563; font-weight: 700; background: #fafbfc; }
tr:hover td { background: #fbfdff; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.table-wrap table th, .table-wrap table td { white-space: nowrap; }
.table-wrap table .url-cell { white-space: normal; min-width: 260px; }
.table-wrap table .url-cell .muted { overflow-wrap: anywhere; }
.lookup { position: relative; min-width: 260px; }
.lookup-menu { display: none; position: fixed; z-index: 1000; width: 520px; max-width: min(720px, calc(100vw - 24px)); max-height: 280px; overflow-y: auto; background: #fff; border: 1px solid #d0d7de; border-radius: 6px; box-shadow: 0 12px 28px rgba(15, 23, 42, .16); padding: 4px; }
.lookup.open .lookup-menu { display: block; }
.lookup-option { width: 100%; min-height: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 8px; text-align: left; }
.lookup-option:hover, .lookup-option.active { background: #eef6ff; color: var(--text); }
.lookup-option span { display: grid; gap: 2px; min-width: 0; }
.lookup-option strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.lookup-option small, .lookup-option em { color: var(--muted); font-size: 12px; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-option em { max-width: 180px; }
.lookup-empty { padding: 9px 10px; color: var(--muted); font-size: 13px; }
.attr-picker { display: flex; flex-wrap: nowrap; gap: 6px; min-width: max-content; white-space: nowrap; }
.attr-picker label { min-width: 78px; max-width: 104px; gap: 4px; font-size: 12px; }
.attr-picker select { min-height: 32px; padding: 5px 7px; }
.attr-picker.single { min-width: 78px; }
.permission-matrix table { min-width: 1120px; width: max-content; }
.permission-matrix th, .permission-matrix td { text-align: center; }
.permission-matrix th:first-child, .permission-matrix td:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 12px; border: 1px solid; white-space: nowrap; }
.tag.gray { color: #4b5563; background: #f3f4f6; border-color: #d1d5db; }
.tag.blue { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.tag.green { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.tag.yellow { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.tag.red { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.urgent-badge { font-weight: 700; animation: urgentPulse 1.6s ease-in-out infinite; }
@keyframes urgentPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
tr.row-urgent { background: #fff5f5; }
tr.row-urgent td:first-child { box-shadow: inset 3px 0 0 #ef4444; }
.urgent-toggle { display: flex; align-items: center; gap: 8px; flex-direction: row !important; cursor: pointer; }
.urgent-toggle input { width: auto; }
.progress { height: 8px; width: 110px; background: #e5e7eb; border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 8px; }
.progress span { display: block; height: 100%; background: var(--brand-2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
.form-section { display: grid; gap: 8px; }
.form-section-title { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
label { display: grid; gap: 6px; color: #4b5563; font-size: 13px; }
label > span, label { min-width: 0; }
.muted { color: var(--muted); }
.request-title { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.timeline { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.timeline li { border: 1px solid var(--line); background: #fff; padding: 8px 10px; border-radius: 6px; min-width: 120px; }
.timeline strong { display: block; font-size: 13px; }
.timeline span { color: var(--muted); font-size: 12px; }
.workbench-head { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 12px; box-shadow: var(--shadow); min-width: 0; }
.workbench-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.item-list { display: grid; gap: 10px; }
.task-card { border: 1px solid var(--line); border-left: 5px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 12px; display: grid; gap: 7px; cursor: pointer; }
.task-card.done { border-left-color: var(--ok); }
.task-card.warn { border-left-color: var(--warn); background: #fffaf0; }
.task-card.active { outline: 2px solid var(--blue); }
.task-main { display: flex; justify-content: space-between; gap: 10px; align-items: start; min-width: 0; }
.task-main strong { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.task-sub { color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.side-box { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 14px; display: grid; gap: 12px; min-width: 0; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.segmented button { border: 0; border-radius: 0; min-height: 34px; }
.segmented button.active { background: var(--brand); color: #fff; }
.panel-head .segmented { max-width: 100%; overflow-x: auto; }
.panel-head .segmented button { white-space: nowrap; flex: 0 0 auto; }
.switch { display: flex; align-items: center; gap: 8px; color: #4b5563; white-space: nowrap; }
.switch input { width: 18px; min-height: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; box-shadow: var(--shadow); }
.stat strong { display: block; font-size: 28px; margin-top: 8px; }
.sku-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.sku-toolbar { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(120px, 1fr)) auto; gap: 12px; align-items: end; margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdff; }
.sku-subnav { margin-bottom: 14px; }
.attr-toolbar { grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(120px, 1fr)) auto; }
.attr-option-row { align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdff; }
.chart { height: 180px; display: flex; align-items: end; gap: 12px; padding: 12px 8px 0; border-top: 1px solid #eef1f5; }
.bar { flex: 1; background: #b7d7d8; border-radius: 5px 5px 0 0; min-height: 20px; position: relative; }
.bar span { position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--muted); }
.receipt { width: 255px; border: 1px dashed #94a3b8; padding: 12px; background: #fff; font-family: "Courier New", monospace; color: #111827; }
.fake-qr { width: 104px; height: 104px; margin: 10px auto; background: linear-gradient(90deg,#111 8px,transparent 8px) 0 0/16px 16px, linear-gradient(#111 8px,transparent 8px) 0 0/16px 16px, #fff; border: 8px solid #fff; box-shadow: inset 0 0 0 2px #111; }
.qr-preview { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; display: grid; gap: 10px; }
.qr-preview img { width: 132px; height: 132px; border: 1px solid #eef1f5; border-radius: 6px; justify-self: center; background: #fff; }
.qr-preview strong { font-size: 14px; overflow-wrap: anywhere; }
.qr-preview code { display: block; word-break: break-all; color: var(--muted); font-size: 12px; line-height: 1.5; }
.qr-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.print-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.print-request-list { display: grid; gap: 8px; max-height: calc(100vh - 220px); overflow: auto; padding-right: 2px; }
.print-request-card { width: 100%; min-height: 72px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; padding: 10px; }
.print-request-card.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37, 99, 235, .14); }
.print-request-card span { display: grid; gap: 4px; min-width: 0; }
.print-request-card strong { white-space: nowrap; }
.print-request-card em { color: var(--muted); font-size: 12px; font-style: normal; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.print-request-card em::-webkit-scrollbar { display: none; }
.print-table tr.row-active td { background: #eef6ff; }
.scan-page { min-height: 100vh; background: #eef2f6; padding: 16px; display: grid; align-content: start; gap: 14px; }
.scan-header { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 8px; }
.scan-header h1 { margin: 0; font-size: 20px; }
.scan-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.scan-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.scan-sku { display: grid; gap: 6px; }
.scan-sku strong { font-size: clamp(24px, 8vw, 42px); line-height: 1.12; }
.scan-sku span { color: var(--muted); font-size: 15px; }
.scan-sku .scan-quantity { color: #ea580c; font-size: clamp(22px, 6vw, 34px); font-weight: 800; line-height: 1.15; }
.scan-qty { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.scan-qty div { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfdff; }
.scan-qty span { display: block; color: var(--muted); font-size: 13px; }
.scan-qty strong { font-size: 26px; }
.scan-actions { display: grid; gap: 10px; }
.scan-actions button { min-height: 56px; font-size: 18px; font-weight: 700; }
.scan-actions .secondary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scan-list { display: grid; gap: 14px; }
.scan-list button { text-align: left; min-height: 96px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px; }
.scan-list button.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }
.scan-item-main { display: grid; gap: 8px; min-width: 0; }
.scan-item-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.scan-grade { flex: 0 0 auto; min-width: 34px; height: 34px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: #eef6ff; color: #1d4ed8; border: 1px solid #bfdbfe; font-size: 18px; font-weight: 800; line-height: 1; }
.scan-item-name { font-size: clamp(20px, 5vw, 30px); font-weight: 800; color: var(--text); line-height: 1.15; overflow-wrap: anywhere; }
.scan-item-qty { font-size: 18px; font-weight: 700; color: #ea580c; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.scan-item-qty::-webkit-scrollbar { display: none; }
.scan-item-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.toggle-switch { display: inline-flex; align-items: center; gap: 8px; color: #4b5563; font-size: 14px; white-space: nowrap; }
.toggle-switch input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-switch .toggle-track { width: 46px; height: 26px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .18s ease; flex: 0 0 auto; }
.toggle-switch .toggle-track::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; left: 3px; top: 3px; box-shadow: 0 1px 4px rgba(15, 23, 42, .25); transition: transform .18s ease; }
.toggle-switch input:checked + .toggle-track { background: var(--brand); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }
dialog { border: 0; border-radius: 8px; box-shadow: 0 24px 80px rgba(0,0,0,.28); width: min(560px, calc(100vw - 28px)); padding: 0; }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.modal { padding: 18px; display: grid; gap: 14px; }
.modal h3 { margin: 0; }
.confirm-item { display: grid; gap: 8px; }
.confirm-item-name { font-size: clamp(24px, 7vw, 38px); font-weight: 800; line-height: 1.15; color: var(--text); }
.confirm-item-qty { color: #ea580c; font-size: clamp(22px, 6vw, 34px); font-weight: 800; line-height: 1.15; }
.confirm-item-meta { color: var(--muted); font-size: 14px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #111827; color: #fff; padding: 12px 14px; border-radius: 8px; box-shadow: var(--shadow); z-index: 20; display: none; gap: 12px; align-items: center; }
.toast button { min-height: 28px; padding: 4px 8px; }
.empty { padding: 28px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 8px; background: #fff; }
#scan-overlay { display: none; position: fixed; inset: 0; z-index: 100; overflow-y: auto; background: #eef2f6; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  body.sidebar-open { overflow: hidden; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(82vw, 310px); height: 100dvh;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 16px 0 40px rgba(15, 23, 42, .24);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); z-index: 25; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .nav { gap: 16px; }
  .menu-toggle { display: inline-flex; }
  .toolbar, .form-grid, .grid-2, .grid-3, .workbench-grid, .stats, .sku-summary, .sku-toolbar, .print-layout { grid-template-columns: 1fr; }
  .toolbar { overflow-x: auto; }
  .toolbar > label, .form-grid > label { min-width: 0; }
  .toolbar button { justify-self: start; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 12px 14px; }
  .topbar-title { width: 100%; }
  .topbar-title > div { min-width: 0; }
  .breadcrumb { max-width: calc(100vw - 82px); padding-bottom: 2px; }
  .topbar .actions { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .actions { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .actions::-webkit-scrollbar { display: none; }
  .actions button, .segmented button, .tag { flex: 0 0 auto; }
  .content { padding: 14px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-head .actions { width: 100%; }
  dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); overflow: auto; }
  .modal { padding: 14px; }
  .modal .actions { width: 100%; }
  .modal .actions button { flex: 0 0 auto; }
  .lookup { min-width: min(260px, calc(100vw - 64px)); }
  .lookup-option { grid-template-columns: minmax(0, 1fr); }
  .lookup-option strong { white-space: normal; overflow: visible; text-overflow: clip; }
  .lookup-option small, .lookup-option em { max-width: none; }
  .task-main { align-items: center; }
  .task-main .tag { max-width: 48vw; overflow-x: auto; scrollbar-width: none; }
  .task-main .tag::-webkit-scrollbar { display: none; }
  .task-sub { font-size: 14px; line-height: 1.65; }
  .side-box { overflow: hidden; }
  .scan-page { padding: 12px; }
  .scan-card { padding: 14px; }
  .scan-header-row { flex-wrap: nowrap; align-items: flex-start; overflow-x: auto; }
  .scan-list button { grid-template-columns: minmax(0, 1fr); }
  .scan-item-title { align-items: flex-start; }
  table { min-width: 840px; }
  .table-wrap { overflow: auto; }
  .scan-qty, .scan-actions .secondary-row { grid-template-columns: 1fr; }
}
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; gap: 12px; flex-wrap: wrap; }
.pagination-btns { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pagination-btns button { min-width: 32px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.pagination-btns button:hover:not(:disabled) { background: var(--bg); }
.pagination-btns button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btns button:disabled { opacity: .4; cursor: default; }
.pagination-ellipsis { padding: 0 4px; color: var(--muted); }
@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; left: 0; top: 0; box-shadow: none; }
}
