:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e5e8ef;
  --text: #1c2434;
  --muted: #687184;
  --accent: #0f6f8f;
  --accent-2: #127fa5;
  --accent-soft: #e7f3f7;
  --green: #1a7f4b;
  --green-soft: #e5f4eb;
  --amber: #a9660b;
  --amber-soft: #fcf1dd;
  --red: #b3382f;
  --red-soft: #fbe9e7;
  --blue: #2563a8;
  --blue-soft: #e6effa;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 15% -10%, #dbeef5 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 110%, #e6edf3 0%, transparent 50%),
    #f4f6f9;
}
.login-card {
  position: relative;
  width: 400px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-card .lang-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.login-brand h1 { font-size: 18px; margin: 0; }
.login-sub { color: var(--muted); margin: 4px 0 24px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--text); font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 72px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #f3f5f8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: var(--red); border-color: #f0c6c2; }
.btn-danger:hover { background: var(--red-soft); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #176d40; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--accent-soft);
  border: 1px solid #d6e9f0;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 16px;
  line-height: 1.7;
}
.hint b { color: var(--text); }
.demo-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.demo-row button { font-size: 12px; padding: 4px 8px; }

/* ---------- 应用布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: #111b2c;
  color: #d7dee8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.side-brand .brand-mark { background: #1b9cc6; }
.side-brand .name { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.3; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  color: #6f7d90;
  padding: 14px 12px 6px;
  letter-spacing: .04em;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #c5ced9;
  font-size: 13px;
  margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(27,156,198,.18); color: #fff; }
.nav a svg { width: 17px; height: 17px; }
.side-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
}
.side-user .uname { color: #fff; font-weight: 600; }
.side-user .urole { color: #8b98a8; margin-top: 2px; }
.side-user .logout { margin-top: 10px; width: 100%; background: rgba(255,255,255,.06); color: #d7dee8; border-color: rgba(255,255,255,.12); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.crumb { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.role-tag {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #d6e9f0;
  padding: 4px 9px;
  border-radius: 20px;
  font-weight: 500;
}

.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title h1 { font-size: 20px; margin: 0; }
.page-title p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 指标卡 ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.metric-num { font-size: 28px; font-weight: 700; line-height: 1; }
.metric-label { display: block; color: var(--muted); font-size: 12px; margin-top: 8px; }
.metric.accent .metric-num { color: var(--accent); }
.metric.green .metric-num { color: var(--green); }
.metric.amber .metric-num { color: var(--amber); }
.metric.red .metric-num { color: var(--red); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-body { padding: 16px; }
.parts-filters {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 1fr;
  gap: 12px;
  align-items: end;
  padding: 12px;
  margin-bottom: 14px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.parts-filters .field { margin-bottom: 0; }
.select[multiple] { height: auto; min-height: 120px; }
.sbom-block { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.sbom-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.sbom-head h3 { font-size: 14px; margin: 0; }
.sbom-block .table-wrap { padding: 12px 16px 16px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; }
.search-box input { padding-left: 30px; }
.search-box svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.sbom-import-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.sbom-import-summary .stat {
  min-width: 120px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
}
.sbom-import-summary .stat strong { display: block; font-size: 22px; line-height: 1; }
.sbom-import-summary .stat span { color: var(--muted); font-size: 12px; }
.sbom-import-summary .stat.warning { border-color: #f2c994; background: #fff9f0; }
.sbom-import-summary .stat.warning strong { color: var(--amber); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfc; white-space: nowrap; }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.tbl .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.pagination-info { color: var(--muted); font-size: 12px; white-space: nowrap; }
.pagination-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-num { min-width: 32px; padding-left: 8px; padding-right: 8px; }
.pagination-size { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.pagination-size .select { width: auto; min-width: 92px; padding: 5px 9px; font-size: 12px; }
.part-image-cell { min-width: 108px; max-width: 180px; vertical-align: middle; }
.part-image-cell .part-thumb { display: block; width: 88px; height: 64px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 5px; background: #fafbfc; }
.part-image-cell .mono { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-image-preview { min-height: 24px; margin-top: 8px; }
.part-image-preview .part-preview-img { display: block; width: 120px; height: 86px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 5px; background: #fafbfc; }
.part-image-preview .small, .part-image-preview .muted { font-size: 12px; line-height: 1.4; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty svg { width: 36px; height: 36px; color: #c5ced9; margin-bottom: 8px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.gray { background: #edf0f4; color: #55606e; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.teal { background: var(--accent-soft); color: var(--accent); }

/* ---------- 详情 ---------- */
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.detail-head .no { font-family: ui-monospace, Menlo, monospace; color: var(--muted); font-size: 13px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.kv { padding: 12px; background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius); }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-size: 14px; font-weight: 600; margin-top: 3px; }
.amount { font-weight: 700; color: var(--text); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px; top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--accent);
}
.timeline .t-meta { font-size: 12px; color: var(--muted); }
.timeline .t-act { font-weight: 600; }

/* ---------- 购物车 / 步骤条 ---------- */
.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.step .dot { width: 22px; height: 22px; border-radius: 50%; background: #edf0f4; color: #7a8594; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.step.active { color: var(--accent); font-weight: 600; }
.step.active .dot { background: var(--accent); color: #fff; }
.step.done .dot { background: var(--green); color: #fff; }
.step-line { width: 24px; height: 2px; background: var(--border); }

/* ---------- 布局组合 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-split { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) {
  .grid-2, .grid-split, .parts-filters { grid-template-columns: 1fr; }
}
.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; }
.mt0 { margin-top: 0; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ---------- 模态 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(16,24,40,.25);
  width: 520px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ---------- toast ---------- */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 11px 14px;
  font-size: 13px;
  max-width: 360px;
  animation: slidein .2s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .side-brand .name, .nav a span, .side-user .uname, .side-user .urole, .nav-section { display: none; }
  .nav a { justify-content: center; padding: 11px; }
  .content { padding: 16px; }
}
