:root{
  color-scheme: light;
  --bg:#f4f6fb; --card:#ffffff; --line:#e5e9f2; --text:#1f2937; --muted:#6b7280;
  --primary:#4f46e5; --primary-weak:#eef2ff; --primary-dark:#4338ca;
  --green:#16a34a; --green-weak:#dcfce7;
  --amber:#b45309; --amber-weak:#fef3c7;
  --red:#dc2626; --red-weak:#fee2e2;
  --blue:#1d4ed8; --blue-weak:#dbeafe;
  --gray:#6b7280; --gray-weak:#f3f4f6;
  --radius:12px; --shadow:0 1px 3px rgba(15,23,42,.08);
  /* B1 新增 20 个（b1-design §3.1 #21–#40；深色值在文件末尾唯一深色块） */
  --card-2:#f8fafc; --line-strong:#cbd5e1; --muted-strong:#374151; --on-primary:#ffffff; --on-ink:#ffffff;
  --overlay:rgba(15,23,42,.45); --shadow-strong:0 20px 50px rgba(15,23,42,.25); --focus:rgba(79,70,229,.14);
  --violet:#6d28d9; --violet-weak:#ede9fe; --cyan:#0e7490; --cyan-weak:#cffafe;
  --ink:#111827; --ink-2:#1f2937; --ink-text:#cbd5e1; --ink-muted:#64748b; --ink-link:#a5b4fc; --ink-accent:#312e81;
  --brand-a:#6366f1; --brand-b:#8b5cf6;
}
*{box-sizing:border-box; margin:0; padding:0;}
body{font-family:"Segoe UI","Microsoft YaHei",system-ui,sans-serif; background:var(--bg); color:var(--text); font-size:14px; line-height:1.55;}
button{font-family:inherit;}
input,select,textarea{font-family:inherit; font-size:14px; color:var(--text); background:var(--card); border:1px solid var(--line); border-radius:8px; padding:8px 10px; outline:none; transition:border-color .15s, box-shadow .15s;}
input:focus,select:focus,textarea:focus{border-color:var(--primary); box-shadow:0 0 0 3px var(--focus);}
input[type=number]{-moz-appearance:textfield;}
input[type=number]::-webkit-outer-spin-button,input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none; margin:0;}
label{display:block; font-size:13px; font-weight:600; margin-bottom:6px; color:var(--muted-strong);}

.app{display:flex; min-height:100vh;}
.sidebar{width:220px; flex-shrink:0; background:var(--ink); color:var(--ink-text); padding:20px 14px; display:flex; flex-direction:column; gap:6px; position:sticky; top:0; height:100vh; overflow-y:auto;}
.brand{display:flex; align-items:center; gap:10px; padding:6px 10px 18px; color:var(--on-ink); font-size:16px; font-weight:700;}
.brand .logo{width:34px; height:34px; border-radius:9px; background:linear-gradient(135deg, var(--brand-a), var(--brand-b)); display:flex; align-items:center; justify-content:center; font-size:18px;}
.nav-item{display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:9px; cursor:pointer; font-size:14px; color:var(--ink-text); border:none; background:transparent; text-align:left; width:100%; transition:background .15s,color .15s;}
.nav-item:hover{background:var(--ink-2); color:var(--on-ink);}
.nav-item.active{background:var(--primary); color:var(--on-primary); font-weight:600;}
.nav-item .ico{width:20px; text-align:center;}
.sidebar > *{flex-shrink:0;}   /* B1′：分组不可收缩 ⇒ 内容超过视口高时侧栏滚动而不是把分组裁掉（.nav-group overflow:hidden + flex 默认可收缩曾在 900px 高裁切） */
.side-nav{display:flex;flex-direction:column;gap:6px;}   /* B2-0 c1：#sideNav 挂载点接管 .sidebar 的列布局与 gap（分组现在是它的子元素） */
.side-nav > *{flex-shrink:0;}   /* B2-0 c1：同 B1′，分组在挂载点内也不可收缩 */
.nav-group{border-radius:10px;overflow:hidden;}
.nav-group-title{justify-content:space-between;}
.nav-group-title .nav-label{display:flex;align-items:center;gap:10px;}
.nav-arrow{font-size:11px;transition:transform .18s;}
.nav-group.open .nav-arrow{transform:rotate(90deg);}
.nav-sub{display:none;padding:2px 0 4px 18px;}
.nav-group.open .nav-sub{display:block;}
.nav-sub .nav-item{padding:8px 10px;font-size:13px;}
.sidebar .foot{margin-top:auto; font-size:12px; color:var(--ink-muted); padding:12px 10px 0; border-top:1px solid var(--ink-2);}
.user-foot{display:flex;flex-direction:column;gap:7px;}
.user-foot b{color:var(--on-ink);font-size:13px;}
.user-foot button{color:var(--ink-link);border:0;background:transparent;text-align:left;cursor:pointer;padding:0;}

.main{flex:1; padding:26px 30px 60px; min-width:0;}
.page-head{display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:20px; flex-wrap:wrap;}
.page-head h1{font-size:22px; font-weight:700;}
.page-head .sub{color:var(--muted); font-size:13px; margin-top:4px;}
.head-actions{display:flex; gap:10px; flex-wrap:wrap;}

.btn{display:inline-flex; align-items:center; justify-content:center; gap:6px; border:1px solid var(--line); background:var(--card); color:var(--text); border-radius:9px; padding:8px 16px; font-size:14px; cursor:pointer; transition:all .15s; white-space:nowrap;}
.btn:hover{border-color:var(--line-strong); background:var(--card-2);}
.btn-primary{background:var(--primary); border-color:var(--primary); color:var(--on-primary);}
.btn-primary:hover{background:var(--primary-dark); border-color:var(--primary-dark);}
.btn-danger{background:var(--red-weak); border-color:var(--red-weak); color:var(--red);}
.btn-danger:hover{background:var(--red-weak);}
.btn-ghost{background:transparent; border:none; color:var(--muted); padding:6px 8px;}
.btn-ghost:hover{background:var(--gray-weak); color:var(--text);}
.btn-sm{padding:5px 11px; font-size:13px; border-radius:7px;}
.btn:disabled{opacity:.5; cursor:not-allowed;}

.card{background:var(--card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow);}
.card .card-head{padding:14px 18px; border-bottom:1px solid var(--line); font-weight:600; display:flex; align-items:center; justify-content:space-between; gap:10px;}
.card .card-body{padding:16px 18px;}
.card .card-body.nopad{padding:0;}

.grid-stats{display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:20px;}
.stat{background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:16px 18px; box-shadow:var(--shadow);}
.stat .label{font-size:13px; color:var(--muted); margin-bottom:8px;}
.stat .value{font-size:26px; font-weight:700; letter-spacing:-.5px;}
.stat .value small{font-size:14px; font-weight:600; color:var(--muted);}
.stat .tip{font-size:12px; color:var(--muted); margin-top:6px;}
.stat.primary .value{color:var(--primary);}
.stat.green .value{color:var(--green);}
.stat.amber .value{color:var(--amber);}
.stat.red .value{color:var(--red);}.toolbar{display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap;}
.toolbar .search{flex:1; min-width:200px; max-width:380px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:10px center; padding-left:34px;}

table{width:100%; border-collapse:collapse; font-size:13.5px;}
thead th{background:var(--card-2); color:var(--muted-strong); font-weight:600; text-align:left; padding:10px 14px; border-bottom:1px solid var(--line); white-space:nowrap; position:sticky; top:0;}
tbody td{padding:10px 14px; border-bottom:1px solid var(--line); vertical-align:middle;}
tbody tr:last-child td{border-bottom:none;}
tbody tr:hover{background:var(--card-2);}
.tbl-wrap{overflow-x:auto;}
.tbl-empty{text-align:center; color:var(--muted); padding:36px 0;}
.tbl-empty .emoji{font-size:34px; display:block; margin-bottom:8px;}

.badge{display:inline-flex; align-items:center; gap:4px; padding:3px 9px; border-radius:999px; font-size:12px; font-weight:600; white-space:nowrap;}
.badge.blue{background:var(--blue-weak); color:var(--blue);}
.badge.amber{background:var(--amber-weak); color:var(--amber);}
.badge.green{background:var(--green-weak); color:var(--green);}
.badge.red{background:var(--red-weak); color:var(--red);}
.badge.gray{background:var(--gray-weak); color:var(--gray);}

.text-muted{color:var(--muted);}
.text-right{text-align:right;}
.nowrap{white-space:nowrap;}
.mt16{margin-top:16px;}
.mt8{margin-top:8px;}
.mb12{margin-bottom:12px;}
.flex{display:flex; gap:10px; align-items:center; flex-wrap:wrap;}
.flex-between{display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap;}

.modal-overlay{position:fixed; inset:0; background:var(--overlay); display:none; align-items:flex-start; justify-content:center; padding:40px 16px; z-index:100; overflow-y:auto;}
.modal-overlay.show{display:flex;}
.modal{background:var(--card); border-radius:16px; width:100%; max-width:620px; box-shadow:var(--shadow-strong); animation:pop .18s ease;}
.modal.lg{max-width:820px;}
.modal.sm{max-width:440px;}
@keyframes pop{from{opacity:0; transform:translateY(10px) scale(.98);} to{opacity:1; transform:none;}}
.modal-head{padding:18px 22px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between;}
.modal-head h3{font-size:16px;}
.modal-close{border:none; background:transparent; font-size:20px; color:var(--muted); cursor:pointer; padding:4px; line-height:1;}
.modal-close:hover{color:var(--text);}
.modal-body{padding:20px 22px; max-height:65vh; overflow-y:auto;}
.modal-foot{padding:14px 22px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px;}
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.form-grid .full{grid-column:1 / -1;}
.field-hint{font-size:12px; color:var(--muted); margin-top:5px;}
.product-image-upload{width:100%; height:190px; margin-top:6px; padding:0; border:1.5px dashed var(--line-strong); border-radius:8px; background:var(--card-2); color:var(--muted); cursor:pointer; overflow:hidden; display:flex; align-items:center; justify-content:center; transition:border-color .16s, background .16s, box-shadow .16s;}
.product-image-upload:hover{border-color:var(--primary); background:var(--primary-weak);}
.product-image-upload:focus-visible{outline:none; border-color:var(--primary); box-shadow:0 0 0 3px var(--focus);}
.product-image-upload.has-image{border-style:solid; background:var(--card);}
.product-image-upload img{width:100%; height:100%; object-fit:contain; display:none;}
.product-image-upload.has-image img{display:block;}
.product-image-upload.has-image .product-image-empty{display:none;}
.product-image-empty{display:flex; flex-direction:column; align-items:center; gap:7px; font-size:13px;}
.product-image-plus{width:42px; height:42px; border-radius:50%; display:grid; place-items:center; background:var(--primary); color:var(--on-primary); font-size:30px; font-weight:300; line-height:1;}
.product-image-empty small{font-size:12px; color:var(--muted);}
.product-image-actions{display:none; gap:8px; align-items:center; margin-top:8px;}
.product-image-actions.show{display:flex;}
.product-image-actions .btn{padding:6px 10px; font-size:12px;}
.product-thumb{width:42px;height:42px;padding:0;border:1px solid var(--line);border-radius:6px;background:var(--card);overflow:hidden;cursor:zoom-in;display:block;}
.product-thumb:hover{border-color:var(--primary);box-shadow:0 0 0 2px var(--focus);}
.product-thumb img{width:100%;height:100%;object-fit:cover;display:block;}
.product-image-preview{display:flex;align-items:center;justify-content:center;min-height:260px;background:var(--card-2);border:1px solid var(--line);border-radius:8px;overflow:hidden;}
.product-image-preview img{display:block;max-width:100%;max-height:58vh;object-fit:contain;}
.segmented{display:inline-flex; padding:3px; border:1px solid var(--line); border-radius:8px; background:var(--card-2); gap:3px;}
.segmented button{border:0; border-radius:6px; background:transparent; color:var(--muted); padding:7px 14px; cursor:pointer; font-size:13px;}
.segmented button.active{background:var(--card); color:var(--primary); font-weight:600; box-shadow:var(--shadow);}
.warehouse-stock-editor{border:1px solid var(--line); border-radius:8px; overflow:hidden;}
.warehouse-stock-row{display:grid; grid-template-columns:minmax(140px,1fr) auto 140px; gap:12px; align-items:center; padding:9px 12px; border-bottom:1px solid var(--line);}
.warehouse-stock-row:last-child{border-bottom:none;}
.warehouse-stock-row .name{font-weight:600;}
.warehouse-stock-row input{text-align:right; width:100%;}
.warehouse-listing-toggle{display:flex;align-items:center;gap:7px;margin:0;font-weight:500;white-space:nowrap;}
.warehouse-listing-toggle input{width:16px;height:16px;accent-color:var(--primary);}
.order-group-start td{border-top:2px solid var(--line-strong);}
.linked-orders{margin-top:16px;padding-top:14px;border-top:1px solid var(--line);}
.linked-orders h4{font-size:14px;margin-bottom:8px;}
.dimension-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:10px;}
.dimension-grid label{font-weight:500; color:var(--muted);}
.stock-breakdown{font-size:12px; color:var(--muted); margin-top:3px; max-width:260px; white-space:normal;}
.follow-list{display:flex; flex-direction:column; gap:10px; margin-bottom:16px;}
.follow-item{border-left:3px solid var(--primary); background:var(--card-2); padding:10px 12px; border-radius:0 6px 6px 0;}
.follow-item .meta{font-size:12px; color:var(--muted); margin-top:5px;}
.follow-form{border-top:1px solid var(--line); padding-top:14px;}
.follow-form textarea{width:100%; min-height:82px; resize:vertical;}
.source-order-picker{max-height:150px; overflow:auto; border:1px solid var(--line); border-radius:8px; background:var(--card);}
.source-order-option{display:flex; align-items:center; gap:9px; padding:8px 10px; border-bottom:1px solid var(--line); cursor:pointer; font-weight:400; margin:0;}
.source-order-option:last-child{border-bottom:none;}
.source-order-option:hover{background:var(--card-2);}
.source-order-option input,.order-select{width:16px; height:16px; accent-color:var(--primary);}
.selection-actions{display:flex; align-items:center; gap:10px; margin-left:auto;}
.delivery-item-row{display:grid; grid-template-columns:1.6fr .6fr auto; gap:8px; align-items:center; margin-bottom:8px;}
.product-choice{min-height:38px;border:1px solid var(--line);border-radius:8px;background:var(--card-2);padding:8px 10px;display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0;}
.product-choice .product-choice-main{min-width:0;}
.product-choice .product-choice-name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.product-choice .product-choice-meta{font-size:11px;color:var(--muted);}
.product-picker-overlay{position:fixed;inset:0;background:var(--overlay);display:none;align-items:flex-start;justify-content:center;padding:32px 16px;z-index:180;overflow:auto;}
.product-picker-overlay.show{display:flex;}
.product-picker{width:min(920px,100%);background:var(--card);border-radius:16px;box-shadow:var(--shadow-strong);}
.product-picker-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(245px,1fr));gap:10px;max-height:46vh;overflow:auto;padding:2px;}
.product-picker-card{display:flex;gap:10px;align-items:flex-start;border:1px solid var(--line);border-radius:10px;padding:11px;cursor:pointer;background:var(--card);}
.product-picker-card:hover,.product-picker-card.selected{border-color:var(--primary);background:var(--primary-weak);}
.product-picker-card input{width:17px;height:17px;accent-color:var(--primary);margin-top:2px;}
.product-picker-card .name{font-weight:600;}
.product-picker-card .meta{font-size:12px;color:var(--muted);margin-top:2px;}
.quick-product-form{display:none;background:var(--card-2);border:1px solid var(--line);border-radius:10px;padding:12px;margin:12px 0;}
.quick-product-form.show{display:block;}
.login-screen{position:fixed;inset:0;z-index:300;background:linear-gradient(135deg, var(--ink), var(--ink-accent));display:flex;align-items:center;justify-content:center;padding:20px;}
.login-card{width:min(430px,100%);background:var(--card);border-radius:18px;padding:30px;box-shadow:var(--shadow-strong);}
.login-card h1{font-size:23px;margin-bottom:5px;}
.login-card .login-sub{color:var(--muted);margin-bottom:22px;}
.login-card .login-field{margin-bottom:14px;}
.login-card input{width:100%;padding:11px 12px;}
.login-card .btn{width:100%;padding:11px;}
.login-tip{font-size:12px;color:var(--muted);margin-top:14px;background:var(--card-2);border-radius:8px;padding:10px;}
.inventory-filter{display:grid;grid-template-columns:repeat(4,minmax(150px,1fr));gap:10px;align-items:end;}
.download-fab{position:fixed;right:24px;bottom:22px;z-index:55;box-shadow:0 8px 24px var(--focus);}
@media(max-width:900px){.inventory-filter{grid-template-columns:1fr 1fr}.product-picker-list{grid-template-columns:1fr}}
@media (max-width:640px){.dimension-grid{grid-template-columns:1fr}.warehouse-stock-row{grid-template-columns:1fr}.segmented{width:100%}.segmented button{flex:1}}

.order-item-field label{font-size:12px; line-height:1.2; font-weight:500; color:var(--muted); margin:0;}
.order-item-field input{width:100%;}
.items-total{margin-top:10px; text-align:right; font-size:15px;}
.items-total b{color:var(--primary); font-size:19px;}
.accessory-editor{border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--card);}
.accessory-row{padding:12px;border-bottom:1px solid var(--line);}
.accessory-row:last-child{border-bottom:0;}
.accessory-row-grid{display:grid;grid-template-columns:1.2fr 1fr .8fr .8fr .55fr .7fr auto;gap:8px;align-items:end;}
.accessory-row-grid label{font-size:11px;color:var(--muted);font-weight:500;}
.accessory-row-grid input{width:100%;}
.accessory-check{display:flex;align-items:center;gap:7px;margin:0 0 8px;font-weight:500;white-space:nowrap;}
.accessory-check input{width:16px;height:16px;accent-color:var(--primary);}
.accessory-plan{display:grid;grid-template-columns:1.35fr .45fr .58fr .78fr 1fr;gap:10px;align-items:end;padding:10px 0;border-bottom:1px solid var(--line);}
.accessory-plan:last-child{border-bottom:0;}
.contract-preview{background:var(--card-2);border:1px solid var(--line);border-radius:9px;padding:10px 12px;font-size:12px;line-height:1.7;}
@media(max-width:900px){.accessory-row-grid{grid-template-columns:1fr 1fr}.accessory-row-grid .accessory-check,.accessory-row-grid .accessory-remove{grid-column:auto}.accessory-plan{grid-template-columns:1fr}}

.dash-cols{display:grid; grid-template-columns:1.4fr 1fr; gap:16px; align-items:start;}
@media (max-width:1100px){.dash-cols{grid-template-columns:1fr;}}
.mini-list .row{display:flex; align-items:center; gap:12px; padding:10px 4px; border-bottom:1px solid var(--line);}
.mini-list .row:last-child{border-bottom:none;}
.mini-list .name{flex:1; min-width:0;}
.mini-list .name .t{font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.mini-list .name .s{font-size:12px; color:var(--muted);}

.toast-wrap{position:fixed; top:18px; left:50%; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:8px; align-items:center;}
.toast{background:var(--ink); color:var(--on-ink); padding:10px 18px; border-radius:10px; font-size:14px; box-shadow:var(--shadow-strong); animation:slideDown .2s ease; display:flex; gap:8px; align-items:center;}
.toast.warn{background:var(--amber);}
.toast.error{background:var(--red);}
.toast.ok{background:var(--green);}
@keyframes slideDown{from{opacity:0; transform:translateY(-8px);} to{opacity:1; transform:none;}}

.detail-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-bottom:16px;}
.detail-item{background:var(--card-2); border:1px solid var(--line); border-radius:10px; padding:10px 14px;}
.detail-item .k{font-size:12px; color:var(--muted); margin-bottom:4px;}
.detail-item .v{font-weight:600;}

.setting-row{display:flex; align-items:center; justify-content:space-between; gap:16px; padding:16px 0; border-bottom:1px solid var(--line);}
.setting-row:last-child{border-bottom:none;}
.setting-row .t{font-weight:600;}
.setting-row .s{font-size:12.5px; color:var(--muted); margin-top:2px; max-width:520px;}
.btn-ghost{background:transparent; border:1px solid var(--line); color:var(--primary);}
.btn-ghost:hover{background:var(--primary-weak);}
.detail-wrap{max-height:62vh; overflow:auto; padding-right:4px;}
.detail-row{display:flex; gap:12px; padding:9px 0; border-bottom:1px solid var(--line); font-size:13.5px;}
.detail-row:last-child{border-bottom:none;}
.detail-k{flex:0 0 150px; color:var(--muted); font-size:12.5px; padding-top:1px;}
.detail-v{flex:1; word-break:break-all; white-space:pre-wrap;}
.detail-v a{color:var(--primary);}

/* ── A1 补丁（登录页两个 view 复用 .login-card；hidden 属性优先级） ── */
[hidden]{display:none !important;}
.login-screen{display:flex;align-items:center;justify-content:center;}
.login-card a{color:inherit;}

/* ── ICP 备案号（10-08 Aaron 要求：四页底部，链接工信部；login 页绝对定位在深色底，其余三页跟在 main 之后） ── */
.icp-foot{flex-shrink:0; font-size:12px; color:var(--muted); text-align:center; padding:10px 16px 14px; line-height:1.4;}
.icp-foot a{color:inherit; text-decoration:none;}
.icp-foot a:hover{text-decoration:underline;}
.main-col{flex:1; min-width:0; display:flex; flex-direction:column;}
.main-col .main{flex:1;}
.login-screen .icp-foot{position:absolute; left:0; right:0; bottom:14px; color:var(--ink-text); opacity:.8;}

/* ── A2 新品管理（a2-design §7.5） ── */
.inherited{color:var(--muted);}
th.diff::after{content:" ≠"; color:var(--amber);}
.nav-dot{display:inline-block; min-width:16px; padding:0 4px; border-radius:8px; background:var(--red); color:var(--on-primary); font-size:11px; margin-left:6px; text-align:center; line-height:16px;}
.badge-stage-established{background:var(--gray-weak); color:var(--gray);}
.badge-stage-sampling{background:var(--blue-weak); color:var(--blue);}
.badge-stage-first_order{background:var(--amber-weak); color:var(--amber);}
.badge-stage-in_transit{background:var(--violet-weak); color:var(--violet);}
.badge-stage-listed{background:var(--green-weak); color:var(--green);}
.pending-card{border:1px solid var(--line); border-radius:12px; padding:12px 14px; margin-bottom:10px; background:var(--card);}
.pending-card .pc-head{display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:6px;}
.pending-card .pc-body{font-size:13.5px; color:var(--muted-strong);}
.pending-card details{margin-top:6px;}
.pending-card pre{background:var(--card-2); border:1px solid var(--line); border-radius:8px; padding:8px; font-size:12px; overflow:auto; max-height:220px;}
.sku-table td.nowrap{white-space:nowrap;}

/* ── A3 单据与库存（a3-design §6.1） ── */
.order-tabs{display:inline-flex; gap:6px; margin-bottom:12px; flex-wrap:wrap;}
.order-tabs .btn.active{background:var(--primary); border-color:var(--primary); color:var(--on-primary);}
/* B2-0 c2：明细行改 ui/form.js lineTable（<tr class="line-tr">，⛔ 不挂 grid 类）；原「line-row」grid 四条规则是错位根因，已删。 */
.line-table td{padding:6px 8px;vertical-align:middle;}
.line-table input,.line-table select{width:100%;min-width:56px;}
.line-table .nowrap{white-space:nowrap;}
.form-grid .field > input,.form-grid .field > select,.form-grid .field > textarea{width:100%;}
.field.placeholder{visibility:hidden;}
.field .req{color:var(--red);}
.field-row{display:flex; gap:6px; align-items:center;}   /* B2-2：控件 + 右侧按钮同排（SKU 抽屉继承 / 覆盖格、销售单客户格）；值抄自原内联 */
.field-row > input,.field-row > select{flex:1; min-width:0;}
.field-row > .inherited{flex:1; min-width:0; padding:8px 10px; border:1px solid var(--line); border-radius:8px;}   /* 原 newproduct.js:486 内联样式搬家 */
.param-row{display:flex; gap:8px; align-items:center; margin-top:6px;}   /* B2-2 #6：合同付款参数横排；label 去掉全局 margin-bottom:6px 即对齐 */
.param-row > label{min-width:80px; margin-bottom:0;}  .param-row > input{width:100px;}
.payment-area > select,.payment-area > textarea{width:100%;}  .kv-table input{width:100%;}   /* 合同付款区 / 付款预设 KV 表：内联 width 搬家 */
.tl-item{padding:8px 0; border-bottom:1px solid var(--line);}   /* B2-3 跟单时间线（orders.js _odTimelineHTML） */
.tl-item:last-child{border-bottom:0;}
.tl-meta{font-size:12px; color:var(--muted); margin-bottom:2px;}
.mt6{margin-top:6px;}
.kit-missing{color:var(--red); background:var(--red-weak); border:1px solid var(--red-weak); border-radius:8px; padding:8px 12px; margin:8px 0; font-size:13px;}
.kit-missing li{margin:2px 0 2px 16px;}
.badge-status-draft{background:var(--gray-weak); color:var(--gray);}
.badge-status-confirmed{background:var(--blue-weak); color:var(--blue);}
.badge-status-pending{background:var(--amber-weak); color:var(--amber);}
.badge-status-partial{background:var(--violet-weak); color:var(--violet);}
.badge-status-completed{background:var(--green-weak); color:var(--green);}
.badge-status-closed{background:var(--line-strong); color:var(--muted-strong);}
.badge-status-cancelled{background:var(--red-weak); color:var(--red);}
.badge-status-shipped{background:var(--cyan-weak); color:var(--cyan);}
.not-connected{background:var(--gray-weak); color:var(--muted); border:1px dashed var(--line); border-radius:12px; padding:28px 16px; text-align:center; font-size:14px;}
.ledger-in{color:var(--green); font-weight:600;}
.ledger-out{color:var(--red); font-weight:600;}
.linked-orders{margin-top:14px; border-top:1px solid var(--line); padding-top:10px;}
.linked-orders h4{font-size:13.5px; margin:8px 0 6px; color:var(--muted);}
.source-totals{font-size:13px; color:var(--muted); margin-bottom:10px;}

/* ───── A4 合同（a4-design §6.1）───── */
/* ─── 合同模块追加样式（a4-design §6.2）─── */

.contract-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.contract-tabs .btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.contract-preview iframe {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin-top: 14px;
}

.contract-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  display: inline-block;
  vertical-align: middle;
}

/* 档位标签 */
.badge-tier-final   { background: var(--violet-weak); color: var(--violet); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.badge-tier-compact { background: var(--blue-weak); color: var(--blue); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.badge-tier-minimal { background: var(--gray-weak); color: var(--gray); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }

/* 合同状态标签 */
.badge-contract-active { background: var(--green-weak); color: var(--green); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.badge-contract-voided { background: var(--gray-weak);  color: var(--gray);  border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }

/* 弹窗顶部缺口 / 警告块 */
.gap-block {
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.6;
}
.gap-block ul { margin: 6px 0 0 18px; }
.gap-block.red    { background: var(--red-weak);   border-left: 3px solid var(--red);   color: var(--red); }
.gap-block.yellow { background: var(--amber-weak); border-left: 3px solid var(--amber); color: var(--amber); }
.gap-block.blue   { background: var(--blue-weak);  border-left: 3px solid var(--blue);  color: var(--blue); }

/* 图片来源单选行 */
.img-src-radio {
  margin-right: 8px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
}
.img-src-radio input[type="radio"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  margin: 0;
  border: none;
  padding: 0;
  background: transparent;
}

/* 合同详情基础格两列网格 */
.contract-kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin-bottom: 14px;
  font-size: 13px;
}
.contract-kv .k {
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}
.contract-kv .v {
  color: var(--text);
  word-break: break-word;
}

/* ── A5 c4 系统状态 tab（a5-design §6.1；颜色只按后端 levels 的 class 渲染） ── */
.status-overall{padding:10px 14px; border-radius:8px; font-weight:600; margin-bottom:12px; background:var(--gray-weak); color:var(--gray);}
.status-overall.green{background:var(--green-weak); color:var(--green);}
.status-overall.yellow{background:var(--amber-weak); color:var(--amber);}
.status-overall.red{background:var(--red-weak); color:var(--red);}
.status-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:12px;}
.status-card{background:var(--card); border:1px solid var(--line); border-left:4px solid var(--gray); border-radius:8px; padding:10px 12px;}
.status-card.green{border-left-color:var(--green);}
.status-card.yellow{border-left-color:var(--amber);}
.status-card.red{border-left-color:var(--red);}
.status-card.info{border-left-color:var(--blue);}
.status-card .status-k{font-size:12px; color:var(--muted);}
.status-card .status-v{font-size:15px; font-weight:600; margin:4px 0; word-break:break-all;}
.status-card .status-l{font-size:12px; color:var(--muted);}
.alerts-tail{font-family:monospace; font-size:12px; white-space:pre-wrap; max-height:320px; overflow:auto; margin:0; background:var(--gray-weak); padding:10px; border-radius:6px;}

/* ===== B1 深色主题：唯一深色块（theme.js 写 <html data-theme>；守卫 test_dark_block_defines_every_token 对拍浅色块每个 token）===== */
:root[data-theme="dark"]{
  color-scheme: dark;
  --bg:#0f172a; --card:#1e293b; --line:#334155; --text:#e5e7eb; --muted:#9ca3af;
  --primary:#818cf8; --primary-weak:#312e81; --primary-dark:#a5b4fc;
  --green:#4ade80; --green-weak:#14532d; --amber:#fbbf24; --amber-weak:#78350f; --red:#f87171; --red-weak:#7f1d1d;
  --blue:#60a5fa; --blue-weak:#1e3a8a; --gray:#9ca3af; --gray-weak:#374151;
  --shadow:0 1px 3px rgba(0,0,0,.45);
  --card-2:#243044; --line-strong:#475569; --muted-strong:#cbd5e1; --on-primary:#0f172a; --on-ink:#ffffff;
  --overlay:rgba(0,0,0,.6); --shadow-strong:0 20px 50px rgba(0,0,0,.6); --focus:rgba(129,140,248,.35);
  --violet:#c4b5fd; --violet-weak:#4c1d95; --cyan:#67e8f9; --cyan-weak:#164e63;
  --ink:#0b1220; --ink-2:#1e293b; --ink-text:#cbd5e1; --ink-muted:#64748b; --ink-link:#a5b4fc; --ink-accent:#1e1b4b;
  --brand-a:#6366f1; --brand-b:#8b5cf6;
}
/* B1 三态主题开关（theme.js 刷文字；login.html 不放） */
.sidebar .theme-foot{margin-top:auto; border-top:0; padding:0 10px 4px;}
.sidebar .theme-foot + .user-foot{margin-top:0;}
.sidebar .thm-btn{background:transparent; color:var(--ink-text); border:1px solid var(--ink-2); width:100%;}

/* ===== B1 帮助中心（help.js 注入 FAB + 弹窗；help.html 整页复用同一套；全部 token 化）=====
   z-index：.hlp-fab 150 / .hlp-mask 190 —— 压过 .modal-overlay 100 与 .product-picker-overlay 180，低于 .toast-wrap 200 与 .login-screen 300；
   打开帮助时 FAB 被遮罩盖住是预期。让位：admin / help 的 .page-head 右 padding 64（FAB 占 right 16 + 36 = 52，留 12）；app 主区 .page-head 40。 */
.hlp-fab{position:fixed; top:12px; right:16px; z-index:150; width:36px; height:36px; border-radius:50%; background:var(--primary); color:var(--on-primary); box-shadow:var(--shadow); border:0; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:transform .15s;}
.hlp-fab:hover{transform:scale(1.08);}
.hlp-fab svg{width:20px; height:20px; display:block;}
.hlp-mask{position:fixed; inset:0; background:var(--overlay); z-index:190; display:flex; align-items:center; justify-content:center; padding:20px;}
.hlp-mask.hidden{display:none;}
.hlp-modal{background:var(--card); color:var(--text); border-radius:14px; width:100%; max-width:880px; height:min(86dvh,900px); display:flex; flex-direction:column; overflow:hidden; box-shadow:var(--shadow-strong);}
.hlp-head{display:flex; align-items:baseline; gap:10px; padding:16px 20px 12px; border-bottom:1px solid var(--line); flex-shrink:0;}
.hlp-h-title{font-size:17px; font-weight:600;}
.hlp-h-date{font-size:12px; color:var(--muted); flex:1;}
.hlp-x{color:var(--muted); font-size:16px; padding:0 4px; border:0; background:transparent; cursor:pointer;}
.hlp-stale{flex-shrink:0; margin:12px 20px 0; padding:9px 12px; border-radius:8px; border:1px solid var(--amber); color:var(--amber); background:var(--amber-weak); font-size:13px;}
.hlp-stale.hidden{display:none;}
.hlp-body{flex:1; display:flex; min-height:0;}
.hlp-toc{width:200px; flex-shrink:0; overflow-y:auto; padding:14px 8px 20px 16px; border-right:1px solid var(--line);}
.hlp-toc-i{display:block; padding:5px 8px; border-radius:6px; cursor:pointer; font-size:13px; color:var(--text);}
.hlp-toc-i.sub{padding-left:20px; font-size:12.5px; color:var(--muted);}
.hlp-toc-i:hover{background:var(--primary-weak);}
.hlp-content{flex:1; overflow-y:auto; padding:14px 24px 40px; line-height:1.65;}
.hlp-content h1{font-size:18px; margin:6px 0 10px;}
.hlp-content h2{font-size:14.5px; margin:16px 0 6px; color:var(--muted-strong);}
.hlp-content ul,.hlp-content ol{padding-left:22px; margin:4px 0 8px;}
.hlp-content li{margin:3px 0;}
.hlp-content p{margin:6px 0;}
.hlp-content code{background:var(--gray-weak); border-radius:4px; padding:1px 6px; font-size:12.5px;}
.hlp-content pre{background:var(--gray-weak); border-radius:8px; padding:10px 12px; overflow:auto;}
.hlp-content table{border-collapse:collapse; margin:6px 0;}
.hlp-content th,.hlp-content td{border:1px solid var(--line); padding:4px 8px; font-size:13px;}
.hlp-sec{padding-bottom:10px;}
.hlp-sec + .hlp-sec{margin-top:26px; border-top:1px solid var(--line); padding-top:18px;}
.hlp-vis{margin:10px 0; padding:12px 14px; border-radius:10px; background:var(--primary-weak); border:1px solid var(--line); font-size:13px;}
.hlp-vis-h{font-weight:600; margin-bottom:6px;}
.hlp-vis-row{display:flex; flex-wrap:wrap; gap:6px; padding:2px 0; align-items:baseline;}
.hlp-vis-k{color:var(--muted); min-width:84px; flex-shrink:0;}
.hlp-vis-v{font-weight:600;}
.hlp-vis-hint{color:var(--muted); font-size:12px;}
@media (max-width:768px){ .hlp-modal{height:92dvh;} .hlp-toc{display:none;} .hlp-content{padding:12px 16px 32px;} }
/* 整页模式（help.html #hlp-page）复用同一套：目录粘顶，正文随页面滚 */
#hlp-page .hlp-body{height:auto;}
#hlp-page .hlp-toc{position:sticky; top:0; align-self:flex-start; max-height:90vh;}
#hlp-page .hlp-content{overflow:visible;}
/* 让位：FAB 固定在右上 */
#adminTop .page-head, #helpTop .page-head{padding-right:64px;}
.main .page-head{padding-right:40px;}
