:root {
  --bg: #f5f6fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-soft: #f8f8fc;
  --ink: #17162b;
  --muted: #74758a;
  --line: #e8e8f2;
  --primary: #6c5ce7;
  --primary-dark: #5644d8;
  --primary-soft: #f0edff;
  --teal: #1fbf9f;
  --teal-soft: #e9fbf7;
  --warning: #f59e0b;
  --warning-soft: #fff7e6;
  --danger: #e9556d;
  --danger-soft: #fff0f3;
  --blue: #4e8df5;
  --blue-soft: #edf4ff;
  --shadow-sm: 0 8px 28px rgba(39, 32, 92, 0.07);
  --shadow-md: 0 18px 48px rgba(39, 32, 92, 0.13);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --sidebar-width: 258px;
  --mobile-nav-height: 72px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
.hidden { display: none !important; }
.no-scroll { overflow: hidden; }

.ambient {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(90px);
  opacity: .18;
  z-index: 0;
}
.ambient-one { width: 340px; height: 340px; background: #7c64ff; top: -120px; right: 8%; }
.ambient-two { width: 260px; height: 260px; background: #25d2aa; bottom: -110px; left: 30%; }

.app-shell { position: relative; z-index: 1; min-height: 100vh; display: flex; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .84);
  border-right: 1px solid rgba(230, 229, 241, .9);
  backdrop-filter: blur(22px);
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 24px; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  color: #fff; font-weight: 900; letter-spacing: -.8px;
  background: linear-gradient(135deg, #765df5, #4e72ef 58%, #27c4a4);
  box-shadow: 0 12px 26px rgba(108, 92, 231, .28);
}
.brand strong { display: block; font-size: 19px; letter-spacing: -.4px; }
.brand span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.side-nav { display: grid; gap: 8px; }
.nav-item {
  border: 0; background: transparent; color: #5f6075; min-height: 50px; padding: 0 14px;
  border-radius: 14px; display: flex; align-items: center; gap: 12px; text-align: left; font-weight: 700;
  transition: .18s ease;
}
.nav-item:hover { background: #f4f2ff; color: var(--primary); transform: translateX(2px); }
.nav-item.active { color: var(--primary); background: linear-gradient(135deg, #f1efff, #f7f6ff); box-shadow: inset 0 0 0 1px #e6e0ff; }
.nav-icon, .nav-item svg { width: 21px; height: 21px; }
.sidebar-tip {
  margin-top: auto; padding: 18px; border-radius: 18px; background: linear-gradient(145deg, #272440, #39325f);
  color: #fff; box-shadow: var(--shadow-md); overflow: hidden; position: relative;
}
.sidebar-tip::after { content: ''; position: absolute; width: 100px; height: 100px; right: -42px; top: -45px; border-radius: 50%; background: rgba(116, 87, 245, .45); }
.tip-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.12); margin-bottom: 12px; }
.tip-icon svg { width: 18px; }
.sidebar-tip strong { font-size: 14px; }
.sidebar-tip p { color: rgba(255,255,255,.68); font-size: 12px; line-height: 1.65; margin: 8px 0 0; }
.sidebar-footer { display: flex; gap: 8px; align-items: center; padding: 18px 8px 0; font-size: 11px; color: #9a9aad; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #28c99f; box-shadow: 0 0 0 4px rgba(40,201,159,.12); }

.main-area { margin-left: var(--sidebar-width); flex: 1; min-width: 0; }
.topbar {
  height: 92px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between;
  background: rgba(245, 246, 251, .76); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid rgba(233, 232, 242, .66);
}
.topbar-title p, .eyebrow { margin: 0 0 4px; color: var(--primary); font-weight: 800; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.topbar-title h1 { margin: 0; font-size: 25px; letter-spacing: -.7px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.menu-button { display: none !important; }
.page-content { padding: 28px 34px 44px; max-width: 1500px; margin: 0 auto; }

button { border: 0; }
.primary-button, .secondary-button, .ghost-button, .danger-button, .success-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 17px;
  border-radius: 12px; font-weight: 800; transition: .18s ease; white-space: nowrap;
}
.primary-button { color: #fff; background: linear-gradient(135deg, #745cf5, #6254e8); box-shadow: 0 10px 24px rgba(108,92,231,.24); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 13px 30px rgba(108,92,231,.32); }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.secondary-button { color: #45455b; background: #fff; border: 1px solid var(--line); }
.secondary-button:hover { border-color: #cfc8ff; color: var(--primary); background: #faf9ff; }
.ghost-button { color: var(--primary); background: var(--primary-soft); }
.ghost-button:hover { background: #e7e1ff; }
.danger-button { color: #fff; background: linear-gradient(135deg, #ef6a80, #dc4762); box-shadow: 0 8px 20px rgba(233,85,109,.2); }
.success-button { color: #0d816a; background: var(--teal-soft); }
.compact { min-height: 40px; padding: 0 14px; font-size: 13px; }
.primary-button svg, .secondary-button svg, .ghost-button svg, .danger-button svg, .success-button svg { width: 17px; height: 17px; }
.icon-button {
  width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center;
  color: #626277; background: rgba(255,255,255,.88); border: 1px solid var(--line); transition: .18s ease;
}
.icon-button:hover { color: var(--primary); border-color: #d5ceff; transform: translateY(-1px); }
.icon-button svg { width: 19px; height: 19px; }
.icon-button.tiny { width: 34px; height: 34px; border-radius: 10px; }
.icon-button.danger-soft { color: var(--danger); background: var(--danger-soft); border-color: #ffd9e0; }

.page-loader, .empty-state { min-height: 380px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.loader-ring { width: 42px; height: 42px; border: 4px solid #e8e4ff; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader p { margin-top: 15px; font-weight: 700; font-size: 13px; }
.empty-icon { width: 66px; height: 66px; border-radius: 20px; display: grid; place-items: center; margin-bottom: 16px; background: var(--primary-soft); color: var(--primary); }
.empty-icon svg { width: 30px; height: 30px; }
.empty-state h3 { color: var(--ink); margin: 0 0 8px; }
.empty-state p { max-width: 420px; margin: 0 0 18px; line-height: 1.7; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  position: relative; overflow: hidden; min-height: 132px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid rgba(232,232,242,.9); box-shadow: var(--shadow-sm);
}
.stat-card::after { content: ''; position: absolute; width: 85px; height: 85px; right: -28px; bottom: -30px; border-radius: 50%; background: var(--stat-soft, var(--primary-soft)); }
.stat-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--stat-soft, var(--primary-soft)); color: var(--stat-color, var(--primary)); }
.stat-icon svg { width: 19px; }
.stat-value { position: relative; z-index: 1; font-size: 29px; font-weight: 900; margin-top: 15px; letter-spacing: -.8px; }
.stat-sub { position: relative; z-index: 1; font-size: 11px; color: #a0a0b2; margin-top: 3px; }

.panel {
  background: var(--surface); border: 1px solid rgba(232,232,242,.9); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-header { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-title h2, .section-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.35px; }
.panel-title p, .section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.panel-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 22px; background: #fbfbfd; border-bottom: 1px solid var(--line); }
.search-box { flex: 1; max-width: 480px; position: relative; }
.search-box input { width: 100%; height: 44px; padding: 0 104px 0 42px; background: #fff; border: 1px solid var(--line); border-radius: 12px; outline: none; transition: .18s; }
.search-box input:focus { border-color: #b9adff; box-shadow: 0 0 0 4px rgba(108,92,231,.08); }
.search-box > svg { position: absolute; left: 14px; top: 13px; width: 18px; color: #aaaabd; }
.scan-search { position: absolute; right: 6px; top: 6px; min-height: 32px; padding: 0 10px; font-size: 11px; border-radius: 9px; }
.toolbar-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }

.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 20px; }
.product-card {
  min-width: 0; border: 1px solid var(--line); border-radius: 20px; background: #fff; overflow: hidden;
  transition: .2s ease; position: relative;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #ddd7ff; }
.product-image { aspect-ratio: 1.75 / 1; position: relative; background: linear-gradient(145deg, #f4f4f9, #fafafe); overflow: hidden; }
.product-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: #b4b4c3; }
.product-placeholder svg { width: 40px; }
.product-select { position: absolute; top: 12px; left: 12px; z-index: 4; }
.product-select input { width: 20px; height: 20px; accent-color: var(--primary); }
.variant-badge { position: absolute; right: 12px; bottom: 12px; padding: 6px 9px; border-radius: 9px; color: #fff; background: rgba(27,25,48,.76); backdrop-filter: blur(8px); font-size: 11px; font-weight: 800; }
.product-body { padding: 16px; }
.product-name-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.product-name { font-size: 16px; font-weight: 900; line-height: 1.4; margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.link-chip { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--blue-soft); color: var(--blue); }
.link-chip svg { width: 15px; }
.product-codes { display: grid; gap: 6px; margin: 13px 0; }
.code-line { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); min-width: 0; }
.code-line span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-icon { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: #f5f5fa; color: #85859a; }
.code-icon svg { width: 13px; }
.money-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.money-box { padding: 10px 11px; border-radius: 12px; background: #f8f8fb; }
.money-box span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.money-box strong { font-size: 14px; }
.money-box.profit { background: var(--teal-soft); color: #14846e; }
.money-box.loss { background: var(--danger-soft); color: var(--danger); }
.product-card-actions { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 14px; margin-top: 14px; border-top: 1px dashed var(--line); }
.card-action { flex: 1 1 calc(33.333% - 7px); min-height: 35px; border-radius: 10px; background: #f7f7fb; color: #5e5e72; font-weight: 800; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.card-action:hover { color: var(--primary); background: var(--primary-soft); }
.card-action svg { width: 14px; }
.card-action.danger:hover { color: var(--danger); background: var(--danger-soft); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px; border-top: 1px solid var(--line); }
.page-button { min-width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: #66667a; font-weight: 800; font-size: 12px; }
.page-button.active { color: #fff; border-color: var(--primary); background: var(--primary); }
.page-button:disabled { opacity: .4; cursor: not-allowed; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; }
.form-main { display: grid; gap: 18px; }
.form-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.section-heading-left { display: flex; align-items: center; gap: 12px; }
.section-number { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 900; }
.section-content { padding: 21px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12px; color: #4b4b5f; font-weight: 800; }
.required { color: var(--danger); }
.field-hint { color: #a1a1b2; font-size: 10px; font-weight: 500; }
.input-wrap { position: relative; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #dfdfea; border-radius: 11px; background: #fff; color: var(--ink); outline: none; transition: .18s;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #b4a7ff; box-shadow: 0 0 0 4px rgba(108,92,231,.08); }
.field input[readonly] { background: #f7f7fa; color: #5c5c70; }
.input-prefix, .input-suffix { position: absolute; top: 12px; color: #9898aa; font-size: 12px; pointer-events: none; }
.input-prefix { left: 12px; }
.input-suffix { right: 12px; }
.has-prefix input { padding-left: 30px; }
.has-suffix input { padding-right: 38px; }
.scan-input input { padding-right: 48px; }
.scan-input button { position: absolute; right: 5px; top: 5px; width: 34px; height: 34px; border-radius: 9px; color: var(--primary); background: var(--primary-soft); }
.scan-input button svg { width: 16px; }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.upload-box { min-width: 0; }
.upload-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.upload-title strong { font-size: 12px; }
.upload-title small { color: var(--muted); font-size: 10px; }
.upload-drop {
  min-height: 150px; border: 1.5px dashed #cdc9e6; border-radius: 16px; background: linear-gradient(145deg,#faf9ff,#f8fafc);
  display: grid; place-items: center; text-align: center; padding: 18px; position: relative; overflow: hidden; transition: .18s;
}
.upload-drop:hover, .upload-drop.dragging { border-color: var(--primary); background: var(--primary-soft); }
.upload-drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-symbol { width: 45px; height: 45px; border-radius: 14px; margin: 0 auto 10px; display: grid; place-items: center; background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.upload-symbol svg { width: 21px; }
.upload-drop strong { display: block; font-size: 12px; }
.upload-drop p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.image-preview-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.image-preview { aspect-ratio: 1; border-radius: 12px; overflow: hidden; position: relative; background: #f3f3f7; border: 1px solid var(--line); }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.remove-image { position: absolute; right: 5px; top: 5px; width: 25px; height: 25px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: rgba(23,22,43,.7); }
.remove-image svg { width: 12px; }
.upload-progress { margin-top: 8px; height: 5px; border-radius: 99px; overflow: hidden; background: #eceaf6; }
.upload-progress span { display: block; width: 55%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--primary),var(--teal)); animation: progress 1.2s ease-in-out infinite alternate; }
@keyframes progress { from { transform: translateX(-70%); } to { transform: translateX(150%); } }

.variants-list { display: grid; gap: 14px; }
.variant-card { border: 1px solid var(--line); border-radius: 18px; background: #fcfcfe; overflow: hidden; }
.variant-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; background: linear-gradient(90deg,#f8f7ff,#fbfbfe); border-bottom: 1px solid var(--line); }
.variant-title { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 900; }
.drag-handle { color: #aaa8ba; cursor: grab; }
.drag-handle svg { width: 16px; }
.variant-actions { display: flex; gap: 6px; }
.variant-body { padding: 16px; }
.cost-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 15px; }
.cost-pill { padding: 12px; border-radius: 13px; background: #f4f4f8; }
.cost-pill span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.cost-pill strong { font-size: 15px; }
.cost-pill.total { background: var(--blue-soft); color: #2e67bc; }
.cost-pill.profit { background: var(--teal-soft); color: #13846d; }
.cost-pill.loss { background: var(--danger-soft); color: var(--danger); }

.form-sidebar { position: sticky; top: 112px; display: grid; gap: 15px; }
.summary-card { padding: 20px; border-radius: var(--radius-lg); background: linear-gradient(145deg,#27233e,#39305f); color: #fff; box-shadow: var(--shadow-md); }
.summary-card h3 { margin: 0 0 5px; font-size: 17px; }
.summary-card > p { margin: 0 0 18px; color: rgba(255,255,255,.58); font-size: 11px; }
.summary-list { display: grid; gap: 11px; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.summary-row span { color: rgba(255,255,255,.6); }
.summary-row strong { font-size: 14px; }
.summary-actions { display: grid; gap: 9px; margin-top: 18px; }
.summary-actions .primary-button { width: 100%; background: linear-gradient(135deg,#8d75ff,#6555ef); }
.summary-actions .secondary-button { width: 100%; color: rgba(255,255,255,.8); background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); }
.help-card { padding: 17px; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
.help-card strong { font-size: 12px; }
.help-card p { color: var(--muted); font-size: 11px; line-height: 1.7; margin: 7px 0 0; }

.list-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th { padding: 13px 15px; background: #fafafd; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; text-align: left; font-weight: 900; letter-spacing: .04em; }
.data-table td { padding: 14px 15px; border-bottom: 1px solid #efeff5; font-size: 12px; vertical-align: middle; }
.data-table tr:hover td { background: #fdfcff; }
.table-product { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.table-thumb { width: 44px; height: 44px; border-radius: 11px; object-fit: cover; background: #f2f2f7; border: 1px solid var(--line); }
.table-product strong { display: block; font-size: 12px; }
.table-product small { display: block; color: var(--muted); margin-top: 3px; }
.table-actions { display: flex; gap: 6px; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; color: #16816c; background: var(--teal-soft); font-size: 10px; font-weight: 800; }
.status-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.picking-editor { display: grid; grid-template-columns: minmax(0,1fr) 390px; gap: 18px; align-items: start; }
.catalog-panel, .selected-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.catalog-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 16px; max-height: calc(100vh - 280px); overflow: auto; }
.catalog-item { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.catalog-item:hover { border-color: #d4cdff; }
.catalog-thumb { width: 62px; height: 62px; border-radius: 12px; object-fit: cover; background: #f2f2f7; flex: 0 0 auto; }
.catalog-info { min-width: 0; flex: 1; }
.catalog-info h4 { margin: 0 0 5px; font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.catalog-info p { margin: 0 0 7px; font-size: 10px; color: var(--muted); }
.catalog-info select { width: 100%; min-height: 34px; border: 1px solid var(--line); border-radius: 9px; padding: 0 8px; font-size: 10px; outline: none; }
.catalog-add { margin-top: 8px; width: 100%; min-height: 33px; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-size: 10px; font-weight: 900; }
.selected-panel { position: sticky; top: 112px; }
.selected-list { max-height: calc(100vh - 390px); overflow: auto; padding: 13px; display: grid; gap: 10px; }
.selected-item { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.selected-item-head { display: flex; align-items: flex-start; gap: 9px; }
.selected-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #f2f2f7; }
.selected-item-info { min-width: 0; flex: 1; }
.selected-item-info strong { display: block; font-size: 11px; line-height: 1.4; }
.selected-item-info span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.selected-fields { display: grid; grid-template-columns: 100px 1fr; gap: 8px; margin-top: 10px; }
.selected-fields input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 9px; font-size: 10px; outline: none; }
.selected-footer { padding: 14px; border-top: 1px solid var(--line); background: #fafafd; }
.selected-totals { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: 11px; }
.selected-totals strong { color: var(--ink); font-size: 13px; }
.selected-footer .primary-button { width: 100%; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(21,18,43,.55); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 18px; }
.modal { width: min(100%, 600px); max-height: calc(100vh - 36px); overflow: auto; background: #fff; border-radius: 24px; box-shadow: 0 30px 90px rgba(16,14,37,.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 19px; }
.scanner-dialog { width: min(100%, 540px); overflow: hidden; }
.scanner-stage { aspect-ratio: 4/3; background: #111; position: relative; overflow: hidden; }
.scanner-stage video { width: 100%; height: 100%; object-fit: cover; }
.html5-scanner { position: absolute; inset: 0; }
.scanner-frame { position: absolute; left: 12%; right: 12%; top: 31%; height: 36%; border: 2px solid rgba(255,255,255,.88); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.24); pointer-events: none; }
.scanner-frame::after { content: ''; position: absolute; left: 7%; right: 7%; top: 50%; height: 2px; background: #ff5d75; box-shadow: 0 0 12px #ff5d75; animation: scanline 1.6s ease-in-out infinite; }
@keyframes scanline { 0%,100% { transform: translateY(-45px); } 50% { transform: translateY(45px); } }
.scanner-hint { margin: 0; padding: 14px 20px 4px; color: var(--muted); text-align: center; font-size: 11px; }
.modal-actions { display: flex; gap: 10px; padding: 15px 20px 20px; justify-content: center; }
.modal-actions.end { justify-content: flex-end; }
.confirm-dialog { width: min(100%, 430px); padding: 26px; text-align: center; }
.confirm-icon { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 14px; color: var(--danger); background: var(--danger-soft); }
.confirm-icon svg { width: 27px; }
.confirm-dialog h2 { margin: 0 0 8px; }
.confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.7; font-size: 12px; }
.preview-dialog { width: min(100%, 850px); }
.preview-body { padding: 20px; }
.preview-gallery { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.preview-gallery img { width: 100%; aspect-ratio: 1.2/1; object-fit: cover; border-radius: 13px; background: #f1f1f6; }
.preview-meta { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 17px 0; }
.preview-meta div { padding: 12px; border-radius: 12px; background: #f7f7fb; }
.preview-meta span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.preview-meta strong { font-size: 12px; word-break: break-all; }
.preview-variant { padding: 14px; border: 1px solid var(--line); border-radius: 14px; margin-top: 10px; }
.preview-variant-top { display: flex; justify-content: space-between; gap: 12px; }
.preview-variant h4 { margin: 0; }
.preview-variant small { color: var(--muted); }
.preview-money { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.preview-money div { padding: 9px; border-radius: 10px; background: #f7f7fa; }
.preview-money span { display: block; color: var(--muted); font-size: 9px; }
.preview-money strong { font-size: 11px; }

.toast-stack { position: fixed; right: 20px; top: 20px; z-index: 200; display: grid; gap: 10px; pointer-events: none; }
.toast { min-width: 260px; max-width: 380px; display: flex; gap: 11px; align-items: flex-start; padding: 14px 15px; border-radius: 14px; color: #fff; box-shadow: var(--shadow-md); animation: toastIn .25s ease; pointer-events: auto; }
.toast.success { background: #178a72; }
.toast.error { background: #d94861; }
.toast.info { background: #4c55b9; }
.toast svg { width: 18px; flex: 0 0 auto; }
.toast strong { display: block; font-size: 12px; }
.toast p { margin: 3px 0 0; color: rgba(255,255,255,.78); font-size: 10px; line-height: 1.5; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

.mobile-nav { display: none; }
.drawer-backdrop { display: none; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .product-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .form-layout { grid-template-columns: minmax(0,1fr) 280px; }
  .picking-editor { grid-template-columns: minmax(0,1fr) 340px; }
  .catalog-grid { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  :root { --sidebar-width: 240px; }
  .sidebar { transform: translateX(-102%); transition: .25s ease; box-shadow: var(--shadow-md); }
  .sidebar.open { transform: translateX(0); }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(26,22,48,.35); opacity: 0; pointer-events: none; transition: .2s; }
  .drawer-backdrop.show { opacity: 1; pointer-events: auto; }
  .main-area { margin-left: 0; }
  .menu-button { display: inline-grid !important; }
  .topbar { padding: 0 22px; }
  .topbar-title { margin-right: auto; margin-left: 12px; }
  .page-content { padding: 22px; }
  .form-layout, .picking-editor { grid-template-columns: 1fr; }
  .form-sidebar, .selected-panel { position: static; }
  .selected-list, .catalog-grid { max-height: none; }
}

@media (max-width: 680px) {
  body { padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  .topbar { height: 74px; padding: 0 14px; }
  .topbar-title p { display: none; }
  .topbar-title h1 { font-size: 19px; }
  .topbar-actions .icon-button { display: none; }
  .topbar-actions .primary-button { min-height: 38px; padding: 0 12px; }
  .topbar-actions .primary-button span:last-child { display: none; }
  .page-content { padding: 14px 12px 22px; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .stat-card { min-height: 108px; padding: 14px; border-radius: 16px; }
  .stat-value { font-size: 23px; margin-top: 11px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-sub { display: none; }
  .panel { border-radius: 19px; }
  .panel-header, .section-heading { padding: 15px; align-items: flex-start; }
  .panel-header { flex-direction: column; }
  .panel-actions { width: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .toolbar { padding: 12px; flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .toolbar-meta { display: none; }
  .product-grid { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .product-image { aspect-ratio: 2/1; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: 1fr; }
  .section-content { padding: 15px; }
  .cost-summary { grid-template-columns: 1fr 1fr; }
  .cost-pill:first-child { grid-column: 1/-1; }
  .form-sidebar { order: -1; }
  .summary-card { border-radius: 18px; }
  .catalog-grid { grid-template-columns: 1fr; padding: 12px; }
  .catalog-item { padding: 10px; }
  .selected-fields { grid-template-columns: 86px 1fr; }
  .list-table-wrap { margin: 0 -1px; }
  .mobile-nav {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 60;
    height: 64px; align-items: center; justify-content: space-around; padding: 5px 10px;
    background: rgba(28,25,48,.94); border: 1px solid rgba(255,255,255,.1); border-radius: 20px; box-shadow: 0 18px 45px rgba(26,22,48,.35); backdrop-filter: blur(18px);
  }
  .mobile-nav-item { width: 74px; height: 52px; border-radius: 14px; background: transparent; color: rgba(255,255,255,.55); display: grid; place-items: center; align-content: center; gap: 3px; }
  .mobile-nav-item svg { width: 20px; height: 20px; }
  .mobile-nav-item small { font-size: 9px; font-weight: 800; }
  .mobile-nav-item.active { color: #fff; background: rgba(255,255,255,.09); }
  .mobile-nav-item.mobile-add { transform: translateY(-12px); background: linear-gradient(135deg,#8069ff,#6c5ce7); color: #fff; width: 58px; height: 58px; border-radius: 18px; box-shadow: 0 10px 25px rgba(108,92,231,.45); }
  .mobile-nav-item.mobile-add small { display: none; }
  .mobile-nav-item.mobile-add svg { width: 24px; }
  .toast-stack { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: 0; width: 100%; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { max-height: 92vh; border-radius: 22px 22px 0 0; }
  .confirm-dialog { border-radius: 22px; margin-bottom: 10px; }
  .preview-gallery { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .preview-meta { grid-template-columns: 1fr 1fr; }
  .preview-money { grid-template-columns: 1fr 1fr; }
}
