:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #059669;
  --red: #dc2626;
  --orange: #d97706;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 220px; background: #1e1b4b; color: #c7d2fe; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; }
.logo { display: flex; gap: 10px; align-items: center; padding: 20px 18px; }
.logo-icon { background: var(--grad); color: #fff; font-weight: 700; font-size: 12px; padding: 8px 7px; border-radius: 10px; letter-spacing: .5px; }
.logo-title { color: #fff; font-weight: 700; font-size: 15px; }
.logo-sub { font-size: 11px; color: #818cf8; margin-top: 2px; }
.nav { flex: 1; padding: 8px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; cursor: pointer; color: #c7d2fe; margin-bottom: 2px; transition: all .15s; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(79,70,229,.4); }
.nav-item .ico { font-size: 16px; }
.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #6366f1; border-top: 1px solid rgba(255,255,255,.08); line-height: 1.7; }
.meta { color: #4338ca; word-break: break-all; }

/* Main */
.main { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 14px 28px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 19px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; }
.content { padding: 24px 28px; flex: 1; }

/* Buttons */
.btn { border: none; border-radius: 9px; padding: 9px 16px; font-size: 13px; cursor: pointer; font-family: inherit; transition: all .15s; font-weight: 500; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 3px 7px; font-size: 11px; border-radius: 6px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }

/* Cards & KPI */
.grid { display: grid; gap: 18px; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 20px; }
.kpi { background: var(--card); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.kpi .kpi-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.kpi .kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.kpi .kpi-sub { font-size: 11px; color: var(--muted); margin-top: 6px; }
.kpi .kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 16px; background: #eef2ff; }
.card { background: var(--card); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 20px; }
.card h3 { font-size: 15px; margin-bottom: 16px; font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* Charts */
.chart-wrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- 独立登录页（不透明全屏） ---------- */
.login-mask { display: none; position: fixed; inset: 0; z-index: 99999; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%); overflow: hidden; }
.login-mask.open { display: flex; }
.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-bg .blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .35; }
.login-bg .b1 { width: 420px; height: 420px; background: #6366f1; top: -120px; left: -100px; animation: float 9s ease-in-out infinite; }
.login-bg .b2 { width: 360px; height: 360px; background: #0ea5e9; bottom: -100px; right: -80px; animation: float 11s ease-in-out infinite reverse; }
.login-bg .b3 { width: 260px; height: 260px; background: #a855f7; bottom: 20%; left: 18%; animation: float 13s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-26px) scale(1.06); } }
.login-card { position: relative; width: 400px; max-width: calc(100vw - 40px); background: rgba(255,255,255,.96); border-radius: 20px; padding: 36px 36px 24px; box-shadow: 0 24px 80px rgba(0,0,0,.45); animation: cardIn .4s cubic-bezier(.2,.8,.3,1.1); }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; letter-spacing: 1px; box-shadow: 0 8px 24px rgba(79,70,229,.4); }
.login-brand h1 { font-size: 21px; margin: 0 0 4px; color: #0f172a; }
.login-brand p { margin: 0; font-size: 12.5px; color: #64748b; }
.login-field { display: flex; align-items: center; gap: 10px; background: #f1f5f9; border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 0 14px; margin-bottom: 14px; transition: border-color .15s, box-shadow .15s; }
.login-field:focus-within { border-color: #4f46e5; background: #fff; box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.login-field .login-ico { font-size: 15px; opacity: .7; }
.login-field input { flex: 1; border: none; outline: none; background: transparent; padding: 13px 0; font-size: 14px; font-family: inherit; color: #0f172a; }
.login-field input::placeholder { color: #94a3b8; }
.login-error { min-height: 18px; color: #dc2626; font-size: 12.5px; margin: -4px 0 6px; text-align: center; }
.login-btn { width: 100%; border: none; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #4f46e5, #7c3aed); cursor: pointer; font-family: inherit; transition: transform .12s, box-shadow .15s; box-shadow: 0 8px 20px rgba(79,70,229,.35); }
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(79,70,229,.45); }
.login-btn:active { transform: translateY(0); }
.login-foot { text-align: center; font-size: 11px; color: #94a3b8; margin-top: 20px; padding-top: 14px; border-top: 1px solid #f1f5f9; }

/* Table */
.table-wrap { background: var(--card); border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; table-layout: auto; }
th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 7px 7px; background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none; }
th:hover { color: var(--primary); }
td { padding: 5px 7px; border-bottom: 1px solid #f1f5f9; font-size: 12px; vertical-align: middle; }
tr:hover td { background: #f8faff; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.profit-pos { color: var(--green); font-weight: 600; }
.profit-neg { color: var(--red); font-weight: 600; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 10px; font-weight: 500; white-space: nowrap; }
.tag-blue { background: #eef2ff; color: #4338ca; }
.tag-green { background: #ecfdf5; color: #047857; }
.tag-orange { background: #fffbeb; color: #b45309; }
.tag-gray { background: #f1f5f9; color: #475569; }
.tag-red { background: #fef2f2; color: #b91c1c; }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters input, .filters select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; font-family: inherit; background: #fff; outline: none; }
.filters input:focus, .filters select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.filters input[type="text"] { width: 260px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.pager button { border: 1px solid var(--border); background: #fff; border-radius: 7px; padding: 5px 11px; cursor: pointer; font-size: 13px; }
.pager button:disabled { opacity: .4; cursor: default; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 12px; }

/* Modal */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 20px; overflow: auto; }
.modal-mask.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 640px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s ease; }
.modal-lg { width: 760px; }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.close { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 20px 22px; max-height: 65vh; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-grid label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; font-weight: 600; }
.form-grid input, .form-grid select, .modal-body textarea { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; width: 100%; }
.form-grid input:focus, .modal-body textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.full { display: block; margin-top: 12px; font-size: 12px; color: var(--muted); font-weight: 600; }
.full textarea { margin-top: 5px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; width: 100%; }
.full textarea:focus { border-color: var(--primary); }

/* detail */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.detail-item .dl { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.detail-item .dv { font-size: 14px; font-weight: 600; }
.detail-full { border-top: 1px dashed var(--border); padding-top: 12px; margin-top: 6px; }
.detail-full .dl { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.detail-full .dv { font-size: 13px; white-space: pre-wrap; line-height: 1.7; }

/* toast */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px); background: #1e293b; color: #fff; padding: 11px 22px; border-radius: 10px; font-size: 13px; opacity: 0; transition: all .25s; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .bar-label { width: 90px; text-align: right; color: var(--muted); flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; background: #f1f5f9; border-radius: 6px; height: 20px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 6px; background: var(--grad); }
.bar-row .bar-val { width: 110px; flex-shrink: 0; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }

/* 产品条目编辑器 */
.items-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
#itemsEditor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.item-row { display: flex; flex-direction: column; gap: 8px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.item-main, .item-sub { display: flex; align-items: center; gap: 8px; }
.item-sub { padding-top: 2px; }
.item-preview { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.file-btn { border: 1px dashed #94a3b8; border-radius: 8px; padding: 9px 10px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.file-btn:hover { border-color: var(--primary); color: var(--primary); }
.item-row input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; outline: none; min-width: 0; }
.item-row input:focus { border-color: var(--primary); }
.i-size { flex: 1; } .i-qty { flex: .6; } .i-quote { flex: .8; } .i-supplier { flex: 1; } .i-cost { flex: .7; }
.stock-chk { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); white-space: nowrap; flex-shrink: 0; cursor: pointer; }
.stock-chk input { accent-color: var(--green); }
.radio-row { display: flex; gap: 12px; flex-wrap: wrap; padding: 9px 2px; }
.radio-row label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); font-weight: 400; cursor: pointer; white-space: nowrap; }
.radio-row input { accent-color: var(--primary); }

/* 发货弹窗 */
.ship-item { display: flex; align-items: center; gap: 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.ship-chk { display: flex; gap: 5px; font-size: 12px; align-items: center; white-space: nowrap; }
.ship-chk input { accent-color: var(--primary); }
.ship-item input[type=number] { border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; width: 70px; }

/* 发货记录 */
.ship-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ship-card { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.ship-head { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.ship-lines { margin-top: 6px; font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* 详情页产品清单 */
.items-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.item-card { display: flex; align-items: center; gap: 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.item-idx { width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.item-img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; background: #fff; flex-shrink: 0; }
.item-noimg { width: 72px; height: 72px; border-radius: 10px; border: 1px dashed #cbd5e1; color: #94a3b8; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.item-info { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; align-items: center; }
.item-info .dl { margin-right: 4px; }

/* 产品图片 */
.thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 7px; cursor: pointer; border: 1px solid var(--border); transition: transform .12s; background: #f8fafc; }
.thumb:hover { transform: scale(1.18); box-shadow: 0 4px 16px rgba(0,0,0,.18); z-index: 5; position: relative; }
.detail-img-box { text-align: center; margin-bottom: 16px; }
.detail-img { max-width: 100%; max-height: 380px; border-radius: 12px; border: 1px solid var(--border); cursor: zoom-in; }
.img-gallery { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.gallery-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; cursor: zoom-in; border: 1px solid var(--border); }
.gallery-thumb:hover { border-color: var(--primary); }

/* 产品对照表 */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
.guide-item { text-align: center; }
.guide-item img { width: 100%; height: 120px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; background: #fff; }
.guide-size { font-weight: 600; margin-top: 6px; font-size: 14px; }
.guide-price { color: var(--orange); font-size: 13px; margin-top: 2px; }

/* 订单列表展开/折叠明细 */
.expand-btn { margin-left: 6px; padding: 2px 8px; font-size: 11px; }
.expand-tr td { background: #f8faff !important; padding: 12px 16px 14px; }
.expand-box { border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 12px 14px; }
.expand-title { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.expand-list { display: flex; flex-direction: column; gap: 8px; }
.ex-item { display: flex; align-items: center; gap: 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.ex-info { font-size: 13px; }

/* 作废订单置灰 */
.voided-row td { opacity: .55; background: #fafafa !important; }
.voided-row td .tag-red { opacity: 1; }
.void-banner { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }

/* 退款记录 */
.refund-item { display: flex; align-items: center; gap: 10px; background: #fff7f7; border: 1px solid #fecaca; border-radius: 8px; padding: 6px 12px; margin-top: 6px; font-size: 13px; }

/* 详情页快捷备货/入库 */
.item-ops { display: flex; flex-direction: column; gap: 6px; margin-left: auto; flex-shrink: 0; }
.item-ops .btn { min-width: 84px; }

/* 可点击快捷操作的徽标 */
.tag-click { cursor: pointer; border: 1px dashed currentColor; }
.tag-click:hover { filter: brightness(.92); transform: scale(1.05); }
