:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #6b7280;
  --line: #e6e9ef;
  --panel: #ffffff;
  --bg: #f4f6f9;
  --brand: #1268f3;
  --brand-dark: #0c4fbe;
  --nav: #101828;
  --success: #16865c;
  --warning: #b76908;
  --danger: #c43c43;
  --radius: 18px;
  --shadow: 0 8px 28px rgba(16, 24, 40, .07);
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7edf7;
  --muted: #94a3b8;
  --line: #2b3647;
  --panel: #17202d;
  --bg: #0d141e;
  --nav: #090f18;
  --brand: #3b82f6;
  --brand-dark: #2563eb;
  --success: #43c790;
  --warning: #f5a524;
  --danger: #ff7b82;
  --shadow: 0 10px 32px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.app-shell { min-height: 100vh; }

.login-gate {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px);
}
.login-card {
  width: min(420px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 20px;
  display: grid; gap: 18px; background: var(--panel); box-shadow: 0 24px 70px rgba(0,0,0,.22);
}
.login-card .brand-mark { width: 46px; height: 46px; color: white; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0; color: var(--muted); font-size: 13px; }
.login-card label { display: grid; gap: 8px; font-weight: 700; font-size: 13px; }
.login-card input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); }
.login-card .login-error { min-height: 18px; color: var(--danger); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 244px; padding: 28px 18px 20px;
  display: flex; flex-direction: column; background: var(--nav); color: #fff; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 9px 28px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--brand); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .2px; }
.brand small { margin-top: 3px; color: #98a2b3; font-size: 11px; }
.sidebar nav { display: grid; gap: 7px; }
.nav-item { width: 100%; border: 0; border-radius: 11px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; background: transparent; color: #aeb7c6; text-align: left; cursor: pointer; }
.nav-item span { width: 20px; text-align: center; font-size: 18px; }
.nav-item b { margin-left: auto; min-width: 20px; padding: 2px 6px; border-radius: 999px; background: #f04438; color: white; font-size: 11px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 8px 22px rgba(18,104,243,.28); }
.sidebar-foot { margin-top: auto; padding: 13px; border-top: 1px solid rgba(255,255,255,.09); color: #98a2b3; font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #f79009; }
.status-dot.ok { background: #12b76a; }

.main { margin-left: 244px; min-height: 100vh; padding: 0 34px 50px; }
.topbar { min-height: 110px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.topbar h1 { margin: 2px 0 0; font-size: clamp(24px, 3vw, 32px); letter-spacing: -.5px; }
.eyebrow { margin: 0; color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: 1.8px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.sync-note { margin-right: 6px; color: var(--muted); font-size: 12px; }

.button { min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; text-decoration: none; font-weight: 700; font-size: 13px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: default; transform: none; }
.button.primary { background: var(--brand); color: white; box-shadow: 0 6px 16px rgba(18,104,243,.2); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { border-color: var(--line); background: white; color: #344054; }
.button.wide { width: 100%; margin-top: 14px; }
.text-button { border: 0; background: transparent; color: var(--brand); cursor: pointer; font-weight: 700; font-size: 12px; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f2f4f7; cursor: pointer; font-size: 22px; color: #667085; }

.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: .3; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { position: relative; overflow: hidden; min-height: 146px; padding: 21px; border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.stat-card::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card span { font-weight: 700; font-size: 13px; }
.stat-card strong { display: block; margin: 12px 0 9px; font-size: 34px; line-height: 1; }
.stat-card small { font-size: 11px; }
.accent-blue { --accent: #2e90fa; }.accent-amber { --accent: #f79009; }.accent-purple { --accent: #7a5af8; }.accent-red { --accent: #f04438; }.accent-teal { --accent: #15b79e; }.accent-green { --accent: #12b76a; }
.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.panel-grid .span-2 { grid-column: span 2; }
.panel { padding: 22px; border: 1px solid rgba(230,233,239,.8); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel-head { min-height: 38px; margin-bottom: 18px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.panel h2 { margin: 0; font-size: 16px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.panel-filters { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.panel-filters select { width: auto; min-width: 130px; }
.check-filter { min-height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.check-filter input { width: 15px; min-height: 15px; height: 15px; margin: 0; accent-color: var(--brand); }
.empty { padding: 36px 12px; color: #98a2b3; text-align: center; font-size: 13px; }

.order-cards { display: grid; gap: 10px; }
.mini-order { display: grid; grid-template-columns: minmax(150px,1.2fr) minmax(140px,2fr) minmax(100px,1fr) auto; gap: 14px; align-items: center; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.mini-order:hover { border-color: #b9d3ff; background: #f8fbff; }
.mini-order strong, .mini-order span, .mini-order small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-order strong { font-size: 13px; }.mini-order span { color: #475467; font-size: 12px; }.mini-order small { margin-top: 4px; color: #98a2b3; font-size: 10px; }
.mini-product, .product-cell { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.mini-product > div, .product-cell > div { min-width: 0; }
.product-thumb { position: relative; display: grid !important; place-items: center; flex: 0 0 52px; width: 52px; height: 52px; overflow: hidden; border: 1px solid #e7eaf0; border-radius: 9px; background: linear-gradient(145deg,#f1f4f8,#e7ecf3); color: #98a2b3 !important; font-size: 9px !important; font-weight: 700; }
.product-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: white; cursor: zoom-in; }
.image-preview { position: fixed; left: 0; top: 0; z-index: 90; width: min(360px, calc(100vw - 28px)); padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 18px 55px rgba(16,24,40,.28); opacity: 0; visibility: hidden; transform: scale(.97); transform-origin: top left; pointer-events: none; transition: opacity .12s ease, transform .12s ease, visibility .12s; }
.image-preview.show { opacity: 1; visibility: visible; transform: scale(1); }
.image-preview img { display: block; width: 100%; max-height: min(480px, calc(100vh - 100px)); border-radius: 9px; background: white; object-fit: contain; }
.image-preview span { display: block; padding: 8px 4px 2px; overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 700; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; width: fit-content; padding: 5px 9px; border-radius: 999px; background: #ecfdf3; color: var(--success); font-size: 11px; font-weight: 800; white-space: nowrap; }
.pill.warning { background: #fff7e8; color: var(--warning); }.pill.blue { background: #eff6ff; color: var(--brand); }.pill.muted { background: #f2f4f7; color: #667085; }.pill.danger { background: #fff0f0; color: var(--danger); }

.event-list { display: grid; gap: 2px; }
.event-item { display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding: 11px 3px; border-bottom: 1px solid #f0f2f5; }
.event-item:last-child { border-bottom: 0; }
.event-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--brand); }
.event-item.read .event-dot { background: #d0d5dd; }
.event-item strong, .event-item span, .event-item time { display: block; }
.event-item strong { font-size: 12px; }.event-item span { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }.event-item time { margin-top: 5px; color: #98a2b3; font-size: 9px; }
.event-list.large .event-item { padding: 15px 4px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.search { flex: 1; min-width: 230px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #f9fafb; }
.search input { width: 100%; height: 40px; border: 0; outline: 0; background: transparent; }
select, input, textarea { width: 100%; border: 1px solid #dfe3e9; border-radius: 9px; background: white; color: var(--ink); outline: none; }
input, select { min-height: 40px; padding: 8px 10px; } textarea { padding: 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18,104,243,.1); }
.toolbar > select { width: auto; min-width: 145px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th { padding: 11px 12px; background: #f8f9fb; color: #667085; text-align: left; font-size: 10px; letter-spacing: .3px; }
td { padding: 15px 12px; border-bottom: 1px solid #edf0f4; vertical-align: top; font-size: 12px; }
.date-group-row td { padding: 9px 12px; border-bottom-color: #dce5f2; background: #f4f7fb; color: #344054; font-size: 11px; font-weight: 800; }
.date-group-row b { display: inline-flex; min-width: 21px; margin-left: 7px; padding: 2px 6px; justify-content: center; border-radius: 999px; background: #e2ecfb; color: var(--brand); font-size: 9px; }
td strong, td small { display: block; } td strong { max-width: 260px; } td small { max-width: 280px; margin-top: 5px; color: #98a2b3; line-height: 1.35; }
.product-cell strong, .product-cell small { max-width: 230px; }
.money { font-weight: 800; }.link-button { border: 0; padding: 5px 0; background: transparent; color: var(--brand); cursor: pointer; font-weight: 800; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 760px); gap: 18px; align-items: start; }
.connection-state { display: grid; align-content: center; gap: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; }
.connection-state span, .connection-state small { color: var(--muted); font-size: 10px; }
.connection-state strong { color: var(--danger); font-size: 12px; }
.connection-state strong.connected { color: var(--success); }
.wrap-actions { flex-wrap: wrap; }
.integration-note { margin-top: 16px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: #f8fbff; }
.integration-note strong { font-size: 12px; }
.integration-note p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.integration-note a { color: var(--brand); font-weight: 700; text-decoration: none; }
.recommended-badge { display: inline-flex; margin-left: 6px; padding: 3px 7px; border-radius: 999px; background: #e9f9f1; color: var(--success); vertical-align: 2px; font-size: 9px; }
.browser-collector-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 20px; align-items: center; padding: 17px; border: 1px solid #b9d3ff; border-radius: 13px; background: #f4f8ff; }
.browser-collector-card strong { font-size: 13px; }
.browser-collector-card p { max-width: 620px; margin: 7px 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.browser-collector-card span { color: var(--success); font-size: 11px; font-weight: 800; }
.collector-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: 420px; }
.source-badge { display: inline-flex; margin-bottom: 6px; padding: 3px 7px; border-radius: 999px; background: #eef4ff; color: var(--brand); font-size: 9px; font-weight: 800; }
.source-badge.source-1688 { background: #fff1e8; color: #d85c00; }
.pair-card { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; }
.pair-card span { color: var(--muted); font-size: 11px; }
.pair-card strong { word-break: break-all; font-size: 14px; }
.pair-card .pair-code { color: var(--brand); font-size: 30px; letter-spacing: 7px; }
.pair-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.pair-qr-block { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 14px; align-items: center; margin-bottom: 5px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.pair-qr-block img { width: 116px; height: 116px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pair-qr-block strong { font-size: 14px; }
.pair-qr-block p { margin-top: 6px; }
.inline-match { display: flex; min-width: 330px; gap: 7px; align-items: center; flex-wrap: wrap; }
.inline-match select { min-width: 200px; }
.inline-match select { flex: 1 1 260px; }
.compact-purchase { min-width: 0; max-width: 310px; margin-top: 8px; gap: 5px; }
.compact-purchase select { min-width: 0; min-height: 34px; flex: 1 1 100%; padding: 6px 8px; font-size: 10px; }
.compact-purchase input[type="number"] { width: 58px; min-height: 34px; flex: 0 0 58px; padding: 6px 7px; font-size: 11px; }
.compact-purchase .link-button { padding: 5px 3px; font-size: 10px; }
.matched-workflow { display: grid; gap: 5px; margin: 8px 0 4px; }
.matched-workflow small { max-width: 330px; margin: 0; color: var(--muted); font-size: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.workflow-hint { margin: -3px 0 2px; padding: 9px 11px; border-radius: 9px; background: #f6f8fb; color: var(--muted); font-size: 11px; line-height: 1.5; }
.match-suggestion { width: 100%; min-width: 330px; margin-bottom: 8px; padding: 9px 10px; border: 1px solid #b9d3ff; border-radius: 10px; background: #f3f8ff; }
.match-suggestion > div { display: flex; align-items: center; gap: 7px; }
.match-suggestion span { padding: 3px 6px; border-radius: 999px; background: var(--brand); color: white; font-size: 9px; font-weight: 800; }
.match-suggestion strong { flex: 1; color: var(--ink); font-size: 11px; }
.match-suggestion b { color: var(--brand); font-size: 11px; white-space: nowrap; }
.match-suggestion small { max-width: none; margin-top: 6px; color: var(--muted); font-size: 9px; }
.match-suggestion.high { border-color: #9ed8bf; background: #effbf6; }
.match-suggestion.high span { background: var(--success); }
.match-suggestion.high b { color: var(--success); }
.pdd-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: -4px 0 16px; }
.pdd-summary span { padding: 8px 11px; border-radius: 10px; background: #f6f8fb; color: var(--muted); font-size: 12px; }
.pdd-summary b { margin-left: 5px; color: var(--text); font-size: 14px; }
.shared-shipment { display: inline-flex; margin-top: 7px; padding: 4px 8px; border-radius: 999px; background: #fff4e5; color: #a15c00; font-size: 10px; font-weight: 800; white-space: nowrap; }
.pdd-ignored { opacity: .62; }
.purchase-pool-line { display: grid; gap: 3px; margin-bottom: 8px; }
.purchase-pool-line:last-child { margin-bottom: 0; }
.purchase-pool-line b { color: var(--brand); font-size: 10px; }
.allocation-pool-state { display: grid; justify-items: start; gap: 7px; min-width: 190px; }
.allocation-pool-state small { margin: 0; }
.order-allocation-progress { display: flex; align-items: center; gap: 7px; margin-top: 8px; }
.order-allocation-progress > span { width: 92px; height: 6px; overflow: hidden; border-radius: 99px; background: #e8edf4; }
.order-allocation-progress i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.order-allocation-progress b { color: var(--muted); font-size: 10px; }
.manual-purchase-section { display: block; }
.manual-purchase-section > summary { margin-bottom: 15px; color: var(--brand); cursor: pointer; font-size: 12px; font-weight: 800; }
.allocation-modal { width: min(860px, calc(100vw - 30px)); }
.modal-body { padding: 24px; }
.allocation-progress-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; }
.allocation-progress-card > strong { font-size: 14px; }
.allocation-meter { height: 8px; margin: 10px 0; overflow: hidden; border-radius: 99px; background: #e7edf6; }
.allocation-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--brand),#15b79e); transition: width .2s ease; }
.allocation-lines { display: grid; gap: 5px; }
.allocation-lines > div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.allocation-lines b { color: var(--ink); }
.allocation-list { display: grid; gap: 8px; }
.allocation-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; }
.allocation-item > div { min-width: 0; }
.allocation-item strong,.allocation-item small { display: block; }
.allocation-item strong { font-size: 12px; }
.allocation-item small { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.button.tiny { min-height: 34px; padding: 6px 10px; white-space: nowrap; font-size: 11px; }
.raw-detail { margin-top: 8px; color: var(--muted); font-size: 10px; }
.raw-detail summary { cursor: pointer; color: var(--brand); }
.raw-detail pre { width: 360px; max-height: 180px; margin: 7px 0 0; padding: 9px; overflow: auto; border-radius: 8px; background: #f5f7fa; white-space: pre-wrap; word-break: break-all; font: 10px/1.5 Consolas, monospace; }
.anomaly-panel { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.anomaly-panel > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 800; }
.anomaly-panel > summary b { padding: 2px 7px; border-radius: 999px; background: #fff0f0; color: var(--danger); font-size: 10px; }
.anomaly-panel > summary span { color: var(--muted); font-size: 10px; font-weight: 400; }
.anomaly-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.anomaly-item strong, .anomaly-item small { display: block; }.anomaly-item small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.anomaly-item pre { max-width: 700px; max-height: 120px; overflow: auto; margin: 7px 0 0; padding: 8px; border-radius: 7px; background: #f7f8fa; white-space: pre-wrap; font: 10px/1.45 Consolas, monospace; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 6px; color: #475467; font-size: 11px; font-weight: 700; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.modal { width: min(720px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 24px 80px rgba(16,24,40,.22); overflow: auto; }
.modal::backdrop { background: rgba(16,24,40,.56); backdrop-filter: blur(2px); }
.modal form { padding: 24px; }
.compact-modal { width: min(480px, calc(100vw - 30px)); }.compact-modal form:not(.form-grid) { text-align: center; }.compact-modal p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }.modal-head h2 { margin: 3px 0 0; font-size: 21px; }
.form-section { padding: 18px 0; border-top: 1px solid var(--line); }.form-section h3 { margin: 0 0 15px; font-size: 13px; }
.check-row { display: flex !important; grid-template-columns: 18px 1fr !important; align-items: center; min-height: 40px; }.check-row input { width: 18px; min-height: 18px; box-shadow: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 15px; border-top: 1px solid var(--line); }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 30px)); padding: 12px 16px; border-radius: 11px; background: #101828; color: white; box-shadow: 0 14px 38px rgba(16,24,40,.3); font-size: 12px; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .22s; z-index: 100; }
.toast.show { opacity: 1; transform: none; }.toast.error { background: #9f252b; }

[data-theme="dark"] .button.secondary { border-color: var(--line); background: #1d2837; color: #dbe5f3; }
[data-theme="dark"] .button.secondary:hover { background: #243247; }
[data-theme="dark"] .icon-button { background: #222e3e; color: #aebdd1; }
[data-theme="dark"] .mini-order:hover { border-color: #365f9b; background: #19263a; }
[data-theme="dark"] .product-thumb { border-color: #334155; background: linear-gradient(145deg,#222d3c,#182230); color: #91a0b5 !important; }
[data-theme="dark"] .image-preview { border-color: #3a485d; box-shadow: 0 20px 60px rgba(0,0,0,.48); }
[data-theme="dark"] .pill { background: #14382e; color: #65d6aa; }
[data-theme="dark"] .pill.warning { background: #3a2b13; color: #ffc765; }
[data-theme="dark"] .pill.blue { background: #172f53; color: #79afff; }
[data-theme="dark"] .pill.muted { background: #283343; color: #a7b4c7; }
[data-theme="dark"] .pill.danger { background: #462329; color: #ff9ba0; }
[data-theme="dark"] .event-item { border-bottom-color: #253143; }
[data-theme="dark"] .search { border-color: var(--line); background: #121a25; }
[data-theme="dark"] select,
[data-theme="dark"] input,
[data-theme="dark"] textarea { border-color: #354256; background: #111925; color: var(--ink); }
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #718096; }
[data-theme="dark"] th { background: #111925; color: #9cacbf; }
[data-theme="dark"] td { border-bottom-color: #253143; }
[data-theme="dark"] .pair-card { border-color: var(--line); background: #142238; }
[data-theme="dark"] .pair-qr-block img { border-color: #40506a; background: #fff; }
[data-theme="dark"] .connection-state { background: #111925; }
[data-theme="dark"] .integration-note { background: #142238; }
[data-theme="dark"] .recommended-badge { background: #14382e; color: #65d6aa; }
[data-theme="dark"] .browser-collector-card { border-color: #365f9b; background: #14243b; }
[data-theme="dark"] .source-badge { background: #172f53; color: #79afff; }
[data-theme="dark"] .source-badge.source-1688 { background: #402719; color: #ffad73; }
[data-theme="dark"] .workflow-hint { background: #111925; }
[data-theme="dark"] .match-suggestion { border-color: #365f9b; background: #14243b; }
[data-theme="dark"] .match-suggestion.high { border-color: #29674e; background: #123126; }
[data-theme="dark"] .pdd-summary span { background: #202b3a; color: #9cabbf; }
[data-theme="dark"] .shared-shipment { background: #3b2b12; color: #ffc565; }
[data-theme="dark"] .order-allocation-progress > span,
[data-theme="dark"] .allocation-meter { background: #2a3749; }
[data-theme="dark"] .allocation-progress-card { background: #142238; }
[data-theme="dark"] .allocation-item { border-color: var(--line); background: #111925; }
[data-theme="dark"] .raw-detail pre,
[data-theme="dark"] .anomaly-item pre { background: #101722; color: #c7d2e1; }
[data-theme="dark"] .anomaly-panel > summary b { background: #462329; color: #ff9ba0; }
[data-theme="dark"] .modal { background: var(--panel); color: var(--ink); }
[data-theme="dark"] .form-section,
[data-theme="dark"] .modal-actions,
[data-theme="dark"] .anomaly-panel { border-color: var(--line); }
[data-theme="dark"] .toast { background: #263246; color: #f8fafc; }
[data-theme="dark"] .toast.error { background: #7f2930; }

@media (max-width: 1050px) {
  .sidebar { width: 205px; }.main { margin-left: 205px; padding-inline: 24px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }.panel-grid .span-2 { grid-column: auto; }
}

@media (max-width: 720px) {
  .sidebar { position: static; width: auto; padding: 12px; }
  .brand { padding: 4px 6px 12px; }
  .sidebar nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .nav-item { justify-content: center; padding: 10px 6px; font-size: 11px; }
  .nav-item span { display: none; }
  .sidebar-foot { display: none; }
  .main { margin: 0; padding: 0 14px 22px; }
  .topbar { min-height: auto; padding: 18px 2px 14px; align-items: flex-start; }.topbar .eyebrow { display: none; }.topbar h1 { font-size: 23px; }
  .top-actions { gap: 6px; }.sync-note, #notifyPermissionBtn { display: none; }.top-actions .button { min-height: 36px; padding: 7px 11px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }.stat-card { min-height: 112px; padding: 16px; }.stat-card strong { font-size: 28px; margin-block: 9px; }
  .panel { padding: 16px; border-radius: 15px; }.panel-grid, .settings-grid { grid-template-columns: 1fr; gap: 12px; }
  .mini-order { grid-template-columns: 1fr auto; gap: 8px; }.mini-order > div:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }.mini-order > div:nth-child(3) { display: none; }
  .toolbar { align-items: stretch; }.toolbar > * { width: 100% !important; }.toolbar .button { flex: 1; width: auto !important; }
  .inline-match, .match-suggestion { min-width: 280px; }
  .browser-collector-card { grid-template-columns: 1fr; }
  .collector-actions { justify-content: stretch; max-width: none; }
  .collector-actions .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }.form-grid .span-2 { grid-column: auto; }
  .modal { max-height: calc(100vh - 16px); }.modal form { padding: 18px; }
  .toast { right: 15px; bottom: 15px; }
}

@media (hover: none) { .image-preview { display: none !important; } }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
