:root {
  --primary: #2f6bff;
  --primary-dark: #1f54d6;
  --primary-soft: #eef3ff;
  --danger: #e5484d;
  --text: #1f2329;
  --text-2: #646a73;
  --muted: #8f959e;
  --line: #e8eaed;
  --bg: #f3f5f8;
  --side: #1d2433;
  --radius: 10px;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.empty { padding: 40px 0 !important; text-align: center; color: var(--muted); }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; padding: 0 16px; border: 1px solid #d9dce1; border-radius: 6px; background: #fff; color: var(--text); white-space: nowrap; text-decoration: none !important; transition: all .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; height: 42px; font-size: 16px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--text-2); }
.link-btn:hover { color: var(--danger); }

/* 布局 */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 220px; display: flex; flex-direction: column; background: var(--side); color: #b7bdc8; overflow-y: auto; transition: transform .25s; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px; color: #fff !important; text-decoration: none !important; }
.sidebar-brand strong { display: block; font-size: 16px; line-height: 1.2; }
.sidebar-brand small { color: #8a93a5; font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; background: linear-gradient(135deg, #e2231a, #b51912); color: #fff; font-size: 19px; font-weight: 700; }
.nav-group { padding: 6px 12px; }
.nav-group-title { padding: 8px 10px 4px; color: #6b7487; font-size: 12px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #c4cad4; text-decoration: none; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav a.is-active { background: var(--primary); color: #fff; }
.badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; font-style: normal; line-height: 20px; text-align: center; }
.sidebar-mask { display: none; }
.admin-main { margin-left: 220px; min-height: 100vh; }
.admin-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--line); }
.admin-top h1 { font-size: 18px; }
.admin-top-right { display: flex; align-items: center; gap: 20px; margin-left: auto; color: var(--text-2); }
.admin-top-right a { display: flex; align-items: center; gap: 4px; color: var(--text-2); }
.admin-user { display: flex; align-items: center; gap: 4px; }
.sidebar-toggle { display: none; border: 0; background: none; padding: 4px; }
.admin-content { padding: 24px 28px 60px; max-width: 1400px; }

/* 卡片 */
.card { margin-bottom: 20px; padding: 22px 24px; border-radius: var(--radius); background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; }

/* 提示 */
.alert { margin-bottom: 18px; padding: 12px 16px; border-radius: 8px; border: 1px solid; }
.alert-success { background: #ecfdf3; border-color: #b7ebc6; color: #18794e; }
.alert-error { background: #fff1f0; border-color: #ffccc7; color: #c62a2f; }
.alert-warn { background: #fffbe6; border-color: #ffe58f; color: #8a6100; }

/* 统计 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 16px; padding: 22px; border-radius: var(--radius); background: #fff; color: var(--text) !important; text-decoration: none !important; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); transition: box-shadow .2s, transform .2s; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, .06); }
.stat strong { display: block; font-size: 28px; line-height: 1.2; }
.stat small { color: var(--muted); }
.stat-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.stat-icon .icon { width: 24px; height: 24px; }
.stat-icon.is-orange { background: #fff4e5; color: #f08c00; }
.stat-icon.is-green { background: #e9f9ef; color: #19a05a; }
.stat-icon.is-blue { background: #e8f6fc; color: #0b8bc4; }
.quick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; }
.quick a:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.quick .icon { width: 26px; height: 26px; color: var(--primary); }
.dash-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.msg-mini li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.msg-mini li div { display: flex; gap: 12px; align-items: baseline; }
.msg-mini time { margin-left: auto; color: var(--muted); font-size: 12px; }
.msg-mini span { color: var(--text-2); font-size: 13px; }
.msg-mini p { color: var(--text-2); font-size: 13px; }
.msg-mini .is-unread strong::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--danger); vertical-align: middle; }

/* 表格 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters input, .filters select { height: 34px; padding: 0 10px; border: 1px solid #d9dce1; border-radius: 6px; background: #fff; outline: 0; }
.filters input { width: 220px; }
.filters input:focus, .filters select:focus { border-color: var(--primary); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 11px 12px; background: #f7f8fa; color: var(--text-2); font-weight: 500; text-align: left; white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: #fafbfc; }
.table tfoot td { border-bottom: 0; padding-top: 16px; }
.col-id { width: 56px; color: var(--muted); }
.col-title { min-width: 200px; }
.col-title a { color: var(--text); }
.col-title a:hover { color: var(--primary); }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.col-actions form { display: inline; }
.thumb { width: 50px; height: 50px; border-radius: 6px; object-fit: cover; background: #f2f3f5; vertical-align: middle; }
.col-wide-img .thumb { width: 160px; height: 40px; }
.price { color: #e2231a; font-size: 18px; }
.switch { position: relative; width: 40px; height: 22px; padding: 0; border: 0; border-radius: 11px; background: #d0d4da; transition: background .2s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch.is-on { background: #19a05a; }
.switch.is-on i { left: 21px; }
.tag { display: inline-block; padding: 0 8px; border-radius: 4px; font-size: 12px; line-height: 22px; white-space: nowrap; background: #f2f3f5; color: var(--text-2); }
.tag-待处理 { background: #fff1f0; color: #d4380d; }
.tag-已确认 { background: #e6f4ff; color: #0958d9; }
.tag-已发货 { background: #f9f0ff; color: #722ed1; }
.tag-已完成 { background: #f6ffed; color: #389e0d; }
.tag-已取消 { background: #f2f3f5; color: var(--muted); }
.order-prod { display: flex; align-items: center; gap: 10px; color: var(--text); }
.seg { display: inline-flex; padding: 3px; border-radius: 8px; background: #f2f3f5; }
.seg a { padding: 4px 16px; border-radius: 6px; color: var(--text-2); text-decoration: none; }
.seg a.is-active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.msg-list li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.msg-list li.is-unread { background: linear-gradient(90deg, #fff8f7, transparent 60%); margin: 0 -24px; padding: 16px 24px; }
.msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.msg-head time { color: var(--muted); font-size: 13px; }
.msg-product { margin-top: 6px; color: var(--text-2); font-size: 13px; }
.msg-content { margin-top: 8px; white-space: pre-wrap; word-break: break-word; }
.msg-actions { display: flex; gap: 8px; margin-top: 10px; }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 24px; }
.info-grid .full { grid-column: 1 / -1; }
.info-grid dt { color: var(--muted); font-size: 13px; }
.info-grid dd { white-space: pre-wrap; word-break: break-word; }

/* 分页 */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 18px; }
.pager a { min-width: 32px; height: 32px; padding: 0 10px; border: 1px solid #d9dce1; border-radius: 6px; color: var(--text); line-height: 30px; text-align: center; text-decoration: none; }
.pager a.is-active { border-color: var(--primary); background: var(--primary); color: #fff; }
.pager-gap, .pager-total { color: var(--muted); }
.pager-total { margin-left: 8px; }

/* 表单 */
.form-section { margin: 30px 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 15px; }
.form-section:first-of-type { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 140px 1fr; gap: 16px; margin-bottom: 18px; }
.form-label { padding-top: 7px; color: var(--text-2); text-align: right; }
.form-label em { margin-left: 2px; color: var(--danger); font-style: normal; }
.form-field { max-width: 820px; min-width: 0; }
.form-field > input[type=text], .form-field > input[type=number], .form-field > input[type=password], .form-field > select, .form-field > textarea, .color-field input[type=text] {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid #d9dce1; border-radius: 6px; background: #fff; outline: 0; transition: border-color .15s, box-shadow .15s;
}
.form-field > textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 1.7; }
.form-field > input:focus, .form-field > select:focus, .form-field > textarea:focus, .color-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-field > .input-short { max-width: 220px; }
.help { margin-top: 6px; color: var(--muted); font-size: 12px; }
.form-actions { display: flex; gap: 10px; padding: 20px 0 0 156px; border-top: 1px solid var(--line); margin-top: 26px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; margin-top: 6px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 12px; background: #d0d4da; cursor: pointer; transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; }
.toggle input:checked + span { background: #19a05a; }
.toggle input:checked + span::after { left: 23px; }
.toggle input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.color-field { display: flex; gap: 10px; max-width: 240px; }
.color-field input[type=color] { width: 46px; height: 36px; padding: 2px; border: 1px solid #d9dce1; border-radius: 6px; background: #fff; }

/* 图片上传 */
.up-list { display: flex; flex-wrap: wrap; gap: 10px; }
.up-list:not(:empty) { margin-bottom: 10px; }
.up-item { position: relative; width: 110px; height: 110px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #f7f8fa; }
.up-item img { width: 100%; height: 100%; object-fit: contain; }
.up-item-actions { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; gap: 2px; padding: 4px; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .2s; }
.up-item:hover .up-item-actions { opacity: 1; }
.up-item-actions button { border: 0; border-radius: 4px; padding: 0 7px; background: rgba(255, 255, 255, .9); font-size: 12px; line-height: 22px; }
.up-item-actions button:hover { background: #fff; color: var(--danger); }
.up-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.up-url { flex: 1; min-width: 200px; max-width: 420px; height: 28px; padding: 0 10px; border: 1px solid #d9dce1; border-radius: 6px; font-size: 13px; outline: 0; }
.up-url:focus { border-color: var(--primary); }
.uploader.is-loading .up-btn-text::after { content: "中…"; }

/* 富文本编辑器 */
.editor { border: 1px solid #d9dce1; border-radius: 8px; background: #fff; }
.editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ed-toolbar { position: sticky; top: 60px; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; background: #f7f8fa; }
.ed-toolbar button, .ed-color { display: inline-flex; align-items: center; height: 28px; padding: 0 9px; border: 0; border-radius: 5px; background: none; font-size: 13px; color: var(--text); cursor: pointer; }
.ed-toolbar button:hover, .ed-color:hover { background: #e6e8eb; }
.ed-toolbar i { width: 1px; height: 18px; margin: 0 4px; background: #d9dce1; }
.ed-color { position: relative; font-weight: 700; color: #e2231a; }
.ed-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.editor.is-source .ed-toolbar button:not(.ed-source-btn), .editor.is-source .ed-color { opacity: .35; pointer-events: none; }
.editor.is-source .ed-source-btn { background: var(--primary); color: #fff; }
.ed-area { min-height: 320px; max-height: 70vh; overflow-y: auto; padding: 16px 18px; outline: 0; line-height: 1.85; }
.ed-source { display: block; width: 100%; min-height: 320px; padding: 14px; border: 0; border-radius: 0 0 8px 8px; outline: 0; resize: vertical; font: 13px/1.6 Consolas, Menlo, monospace; background: #1e1e1e; color: #d4d4d4; }
.rich > * + * { margin-top: 12px; }
.rich h2 { font-size: 20px; }
.rich h3 { font-size: 17px; }
.rich ul, .rich ol { padding-left: 24px; }
.rich ul { list-style: disc; }
.rich img { max-width: 100%; height: auto; }
.rich blockquote { margin: 0; padding: 8px 14px; border-left: 4px solid #d9dce1; background: #fafafa; color: var(--text-2); }

/* 登录页 */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(circle at 20% 10%, #2a3550, transparent 50%), radial-gradient(circle at 80% 90%, #3a1f2a, transparent 50%), #161b26; }
.login-box { width: 100%; max-width: 380px; padding: 36px 32px 28px; border-radius: 14px; background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login-head { margin-bottom: 26px; text-align: center; }
.login-head .brand-mark { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 14px; font-size: 26px; }
.login-head h1 { font-size: 22px; }
.login-head p { color: var(--muted); }
.login-box label { display: block; margin-bottom: 16px; }
.login-box label span { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; }
.login-box input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #d9dce1; border-radius: 8px; outline: 0; }
.login-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-box .btn { margin-top: 8px; }
.login-back { display: block; margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; }

/* 响应式 */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .quick { grid-template-columns: repeat(3, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: none; }
  .sidebar-mask.is-open { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .4); }
  .sidebar-toggle { display: block; }
  .admin-main { margin-left: 0; }
  .admin-top { padding: 0 16px; }
  .admin-top-right span { display: none; }
  .admin-top-right .admin-user { display: none; }
  .admin-content { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat strong { font-size: 22px; }
  .stat-icon { width: 40px; height: 40px; }
  .form-row { grid-template-columns: 1fr; gap: 6px; }
  .form-label { padding: 0; text-align: left; }
  .form-actions { padding-left: 0; }
  .filters input { width: 100%; }
  .filters { width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
  .msg-list li.is-unread { margin: 0 -16px; padding: 16px; }
  .ed-toolbar { top: 0; }
}

/* ===== 元器件商城新增 ===== */
.brand-logo { width: 38px; height: 38px; object-fit: contain; flex-shrink: 0; border-radius: 8px; background: #fff; padding: 3px; }
.login-head .brand-logo { width: 60px; height: 60px; display: block; margin: 0 auto 12px; }
.stats { grid-template-columns: repeat(3, 1fr); }
.stats-sm { grid-template-columns: repeat(4, 1fr); margin: 0; }
.stats-sm .stat { padding: 14px; background: #f7f8fa; box-shadow: none; }
.card-head-actions { display: flex; gap: 8px; }
.col-check { width: 36px; }
.col-logo .thumb { width: 90px; height: 36px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.list-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.list-foot .pager { margin-left: auto; }
.batch-bar { display: flex; align-items: center; gap: 6px; margin-top: 18px; color: var(--text-2); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 7px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.i18n-box { margin-top: 8px; border: 1px dashed #c9d3e0; border-radius: 6px; background: #fafcff; }
.i18n-box summary { padding: 6px 12px; color: var(--primary); font-size: 12px; cursor: pointer; }
.i18n-item { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 6px 12px 10px; }
.i18n-lang { padding-top: 7px; color: var(--muted); font-size: 12px; }
.i18n-item input[type=text], .i18n-item textarea, .i18n-item select { width: 100%; padding: 8px 12px; border: 1px solid #d9dce1; border-radius: 6px; background: #fff; outline: 0; }
.i18n-item input[type=text] { height: 36px; padding: 0 12px; }
.tiers-editor table { border-collapse: collapse; }
.tiers-editor th { padding: 6px 8px; color: var(--text-2); font-weight: 500; font-size: 13px; text-align: left; }
.tiers-editor td { padding: 4px 8px 4px 0; }
.tiers-editor input { width: 150px; height: 34px; padding: 0 10px; border: 1px solid #d9dce1; border-radius: 6px; outline: 0; }
.tiers-editor input:focus { border-color: var(--primary); }
.tiers-tools { display: flex; gap: 8px; margin-top: 8px; }
.up-file { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #f7f8fa; font-size: 13px; }
.up-file button { border: 0; background: none; color: var(--danger); }
.flow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.flow span { display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 20px; background: #f2f3f5; color: var(--muted); font-size: 13px; }
.flow span i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #d0d4da; color: #fff; font-style: normal; font-size: 12px; }
.flow span.is-done { background: var(--primary-soft); color: var(--primary); }
.flow span.is-done i { background: var(--primary); }
.info-grid .span-2 { grid-column: span 2; }
.danger-zone { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); text-align: right; }
.form-compact .form-row { grid-template-columns: 100px 1fr; }
.form-compact .form-actions { padding-left: 116px; }
.form-field select + .btn { margin-left: 8px; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.filters + .mini-list { margin-top: 12px; }
.tag-待支付 { background: #fff1f0; color: #cf1322; }
.tag-待发货, .tag-已报价, .tag-已通过 { background: #e6f4ff; color: #0958d9; }
.tag-待收货, .tag-已寄出 { background: #f9f0ff; color: #722ed1; }
.tag-已完成, .tag-已成交 { background: #f6ffed; color: #389e0d; }
.tag-待报价 { background: #fff4e5; color: #d46b08; }
.tag-已关闭, .tag-已拒绝 { background: #f2f3f5; color: var(--muted); }
code { padding: 1px 6px; border-radius: 4px; background: #f2f3f5; font-size: 12px; }
@media (max-width: 1100px) { .stats-sm { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .i18n-item { grid-template-columns: 1fr; gap: 4px; }
  .form-compact .form-row { grid-template-columns: 1fr; }
  .form-compact .form-actions { padding-left: 0; }
  .tiers-editor input { width: 110px; }
}
