:root {
  --bg: #F4F5F8; --panel: #fff; --ink: #14151A; --ink2: #3A3C46; --muted: #7A7D8A; --line: #E6E7EC; --soft: #F7F7FA;
  --acc: #6E44FF; --acc2: #5A33E6; --accs: #EFEAFF; --ok: #12A150; --oks: #E7F6EE; --warn: #C27A00; --warns: #FFF4DB; --bad: #D92D20; --bads: #FDECEB; --info: #1D6FE0; --infos: #E8F1FF;
  --r: 10px; --side: 232px; --font: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 13.5px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--acc); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.layout { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
aside.side { background: #111218; color: #C8CAD3; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 30px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 900; letter-spacing: .08em; font-size: 18px; padding: 6px 10px 16px; }
.brand i { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); display: inline-block; }
.brand small { font-weight: 600; letter-spacing: 0; color: #7f8290; font-size: 11px; }
.navgrp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #6a6d7a; padding: 14px 10px 6px; }
.side a { display: flex; align-items: center; gap: 10px; color: #C8CAD3; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.side a:hover { background: #1D1F28; color: #fff; text-decoration: none; }
.side a.on { background: var(--acc); color: #fff; }
.side a .cnt { margin-left: auto; background: var(--bad); color: #fff; border-radius: 9px; font-size: 10.5px; padding: 0 6px; font-weight: 700; }
.side svg { width: 16px; height: 16px; flex: none; opacity: .9; }
.main { min-width: 0; }
.top { height: 58px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 20; }
.top .crumb { font-weight: 700; font-size: 15px; flex: 1; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { border: 0; background: #fff; padding: 6px 10px; font-weight: 600; font-size: 12px; } .lang button.on { background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accs); color: var(--acc); display: grid; place-items: center; font-weight: 800; }
.content { padding: 22px; max-width: 1500px; }
.ph { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.ph h1 { font-size: 21px; flex: 1; }
.ph .sub { color: var(--muted); font-size: 12.5px; width: 100%; margin-top: -8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card + .card { margin-top: 14px; }
.card h3 { font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 .r { margin-left: auto; font-weight: 500; font-size: 12px; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 2px; letter-spacing: -.01em; }
.kpi .d { font-size: 11.5px; color: var(--muted); }
.kpi.alert .v { color: var(--bad); } .kpi.warnk .v { color: var(--warn); } .kpi.okk .v { color: var(--ok); }
.kpi a.v { display: block; color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.btn:hover { opacity: .9; text-decoration: none; }
.btn.acc { background: var(--acc); border-color: var(--acc); } .btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); } .btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); } .btn.ok { background: var(--ok); border-color: var(--ok); } .btn.warnb { background: var(--warn); border-color: var(--warn); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; } .btn:disabled { opacity: .45; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.input, select.input, textarea.input { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #fff; outline: 0; }
textarea.input { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--accs); }
label.f { display: block; margin-bottom: 10px; } label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink2); margin-bottom: 4px; }
label.f small { color: var(--muted); font-weight: 400; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; } .chk input { width: 16px; height: 16px; accent-color: var(--acc); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { width: auto; min-width: 140px; } .toolbar .search { min-width: 240px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button, .tabs a { border: 0; background: none; padding: 9px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .on { color: var(--ink); border-bottom-color: var(--acc); } .tabs .n { background: var(--soft); border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.tw { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #FAFAFD; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--ink2); white-space: nowrap; }
.tag.ok, .tag.green, .tag.verified, .tag.delivered, .tag.approved, .tag.allow, .tag.captured, .tag.low, .tag.passed, .tag.active, .tag.submitted, .tag.resolved, .tag.closed { background: var(--oks); color: var(--ok); }
.tag.warn, .tag.yellow, .tag.pending, .tag.manual_review, .tag.on_hold, .tag.compliance_review, .tag.medium, .tag.review, .tag.generated, .tag.payment_pending, .tag.warning, .tag.open { background: var(--warns); color: var(--warn); }
.tag.bad, .tag.red, .tag.failed, .tag.block, .tag.cancelled, .tag.refunded, .tag.high, .tag.blocked, .tag.compliance_hold, .tag.payment_failed, .tag.critical, .tag.inactive, .tag.urgent { background: var(--bads); color: var(--bad); }
.tag.info, .tag.shipped, .tag.processing, .tag.out_for_delivery, .tag.reviewed, .tag.ready_to_ship, .tag.paid, .tag.in_transit { background: var(--infos); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; } .dot.green { background: var(--ok); } .dot.yellow { background: #F5B300; } .dot.red { background: var(--bad); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.note { padding: 10px 12px; border-radius: 8px; font-size: 12.5px; background: var(--soft); margin-bottom: 12px; }
.note.warn { background: var(--warns); color: #6b4300; } .note.bad { background: var(--bads); color: #8a1a12; } .note.ok { background: var(--oks); color: #0a5c2f; } .note.info { background: var(--infos); color: #134d9c; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 16, 25, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); }
.modal .mh { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal .mh h3 { flex: 1; font-size: 15px; }
.modal .mb { padding: 18px; max-height: 70vh; overflow-y: auto; } .modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; z-index: 200; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.2); transform: translateY(150%); transition: transform .25s; max-width: 420px; }
.toast.on { transform: none; } .toast.err { background: var(--bad); }
.timeline { list-style: none; padding: 0; margin: 0; } .timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--acc); }
.timeline li.hold::before, .timeline li.risk::before { background: var(--warn); } .timeline li.payment_failed::before, .timeline li.cancelled::before { background: var(--bad); } .timeline li.shipped::before, .timeline li.delivered::before { background: var(--ok); }
.timeline .tm { font-size: 11.5px; color: var(--muted); }
dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; } dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.chart { width: 100%; height: 200px; }
.chart text { font-size: 10px; fill: var(--muted); }
.funnel .row { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center; margin-bottom: 8px; }
.funnel .bar { height: 26px; border-radius: 6px; background: linear-gradient(90deg, var(--acc), #9C82FF); min-width: 4px; }
.funnel .drop { font-size: 11px; color: var(--bad); }
.matrix { border-collapse: collapse; font-size: 11.5px; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 0; text-align: center; }
.matrix th { background: var(--soft); padding: 6px 4px; position: sticky; top: 0; z-index: 1; font-size: 11px; }
.matrix th.sk, .matrix td.sk { position: sticky; left: 0; background: #fff; text-align: left; padding: 4px 8px; z-index: 2; min-width: 200px; white-space: nowrap; }
.matrix th.sk { z-index: 3; background: var(--soft); }
.matrix td button { width: 34px; height: 26px; border: 0; font-size: 10px; font-weight: 700; }
.cell-allow { background: #E7F6EE; color: var(--ok); } .cell-block { background: #FDECEB; color: var(--bad); } .cell-x-allow { background: #12A150; color: #fff; } .cell-x-block { background: var(--bad); color: #fff; }
.cell-dirty { outline: 2px solid var(--acc); outline-offset: -2px; }
.statemap { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.statemap div { border-radius: 8px; padding: 8px 4px; text-align: center; font-weight: 800; font-size: 13px; cursor: pointer; border: 1px solid transparent; }
.statemap div small { display: block; font-weight: 500; font-size: 10px; }
.sm-ok { background: var(--oks); color: var(--ok); } .sm-warn { background: var(--warns); color: var(--warn); } .sm-bad { background: var(--bads); color: var(--bad); } .sm-pend { background: var(--soft); color: var(--muted); border-color: var(--line) !important; }
.cond { display: grid; grid-template-columns: 1fr 110px 1fr 30px; gap: 6px; margin-bottom: 6px; }
.perm-table td, .perm-table th { text-align: center; } .perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(120% 120% at 80% 0%, #2a1f66 0%, #111218 60%); padding: 20px; }
.login { background: #fff; border-radius: 16px; padding: 30px; width: min(400px, 100%); }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.img-doc { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--acc); border-radius: 50%; animation: s .8s linear infinite; margin: 40px auto; }
@keyframes s { to { transform: rotate(360deg); } }
.swatch { width: 16px; height: 16px; border-radius: 4px; display: inline-block; vertical-align: middle; border: 1px solid var(--line); }
.sku-edit td { padding: 4px; } .sku-edit .input { height: 30px; font-size: 12px; padding: 0 6px; min-width: 70px; }
.burger { display: none; }
@media (max-width: 1100px) { .g4, .g5, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; } aside.side { position: fixed; left: 0; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .25s; } aside.side.on { transform: none; }
  .burger { display: inline-flex; } .g2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } .content { padding: 14px; } .who span { display: none; }
}
.grid > .card + .card { margin-top: 0; }
.toast:not(.on) { visibility: hidden; }
/* Image upload */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 10px; }
.img-tile { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--soft); cursor: grab; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.img-tile img { width: 100%; height: 100%; object-fit: cover; }
.img-tile.dragging { opacity: .4; } .img-tile.target { outline: 2px solid var(--acc); outline-offset: -2px; }
.img-tile.loading { cursor: default; font-size: 11px; color: var(--muted); padding: 6px; text-align: center; word-break: break-all; }
.img-main, .img-no { position: absolute; left: 6px; top: 6px; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--acc); color: #fff; }
.img-no { background: rgba(0,0,0,.55); }
.img-acts { position: absolute; right: 4px; top: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.img-tile:hover .img-acts { opacity: 1; }
.img-acts button { width: 24px; height: 24px; border-radius: 6px; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; line-height: 1; }
.img-acts button:hover { background: var(--bad); }
.img-empty { grid-column: 1 / -1; padding: 14px; text-align: center; color: var(--muted); font-size: 12px; border: 1px dashed var(--line); border-radius: 10px; }
.drop-zone { border: 2px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; cursor: pointer; background: var(--soft); transition: border-color .15s, background .15s; }
.drop-zone:hover, .drop-zone.over { border-color: var(--acc); background: var(--accs); }
.img-field { display: flex; gap: 8px; align-items: center; }
.img-field .img-prev { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); flex: none; overflow: hidden; }
.img-field .img-prev img { width: 100%; height: 100%; object-fit: contain; }
.pthumb { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; vertical-align: middle; border: 1px solid var(--line); }
@media (hover: none) { .img-acts { opacity: 1; } }
/* Inline brand / category manager */
.sel-row { display: flex; gap: 6px; align-items: center; }
.sel-row select { flex: 1; min-width: 0; }
.sel-row .btn { height: 34px; }
.lk-warn { display: block; color: var(--warn); font-size: 11.5px; margin-top: 3px; min-height: 0; }
.lk-warn:empty { display: none; }
.modal .lkm .tw { max-height: 52vh; overflow: auto; }
.sku-img { display: flex; gap: 4px; align-items: center; }
.sku-img .pthumb { width: 28px; height: 28px; flex: none; }
/* SKU bulk edit */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--accs); border: 1px solid #DDD3FF; border-radius: 10px; }
.bulk-bar .input { width: auto; height: 32px; }
.bulk-bar #bkField { min-width: 120px; } .bulk-bar #bkOp { min-width: 130px; }
.bulk-bar .bk-val { display: inline-flex; align-items: center; gap: 4px; } .bulk-bar #bkVal { width: 140px; }
.bulk-bar .bk-tip { flex-basis: 100%; }
.sku-chk { width: 34px; text-align: center; padding-left: 8px !important; padding-right: 0 !important; }
.sku-chk input { width: 16px; height: 16px; accent-color: var(--acc); vertical-align: middle; }
#skuBody tr.sel td { background: #F6F3FF; }
.sku-edit .input.bk-changed { border-color: var(--acc); background: #F1ECFF; }
