:root {
  --bg: #0b0d11; --panel: #14171d; --line: #262b35; --text: #e5e7eb; --muted: #8b93a3;
  --accent: #38bdf8; --standard: #22c55e; --test: #f59e0b; --placeholder: #f97316;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid; grid-template-columns: 300px 1fr 340px; height: 100vh; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* sidebar */
#sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); min-height: 0; }
#sidebar header { padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 20px; }
.sub { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
#search { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.legend { display: flex; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 4px; }
#part-list { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.cat { font-size: 12px; color: var(--muted); padding: 12px 8px 4px; letter-spacing: .03em; }
.item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 8px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.item:hover { background: #1c2129; }
.item.active { background: #1e3a5f; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-spec { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qty { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 12px; }
.qty-zero { color: var(--muted); opacity: .6; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.st-standard { background: var(--standard); }
.st-test { background: var(--test); }
.st-placeholder { background: var(--placeholder); }
#bom-summary { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
#bom-summary b { color: var(--text); }

/* center */
main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#toolbar { display: flex; align-items: center; gap: 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
#toolbar label { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 13px; }
#toolbar button { padding: 5px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.seg { display: flex; }
.seg button { border-radius: 0 !important; }
.seg button:first-child { border-radius: 7px 0 0 7px !important; }
.seg button:last-child { border-radius: 0 7px 7px 0 !important; border-left: 0 !important; }
.seg button.on { background: var(--accent) !important; color: #04111d; border-color: var(--accent) !important; }
.spacer { flex: 1; }
#viewport { position: relative; flex: 1; min-height: 0; }
#viewport canvas { display: block; }
.label-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); z-index: 2; pointer-events: none; background: #0b0d11cc; padding: 6px 10px; border-radius: 8px; }
.k-red { color: #ef4444; } .k-yellow { color: #facc15; } .k-pink { color: #f472b6; }
#schema { font-size: 11px; padding: 4px 12px; border-top: 1px solid var(--line); background: var(--panel); }

.dim-label { font-size: 11px; color: #e0f2fe; background: #0b0d11d9; border: 1px solid #22d3ee55; padding: 1px 6px; border-radius: 5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.axis-label { font-size: 11px; color: #fecaca; background: #450a0acc; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.name-label { font-size: 11px; color: var(--text); background: #0b0d11cc; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.cat-label { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }

/* info */
#info { border-left: 1px solid var(--line); background: var(--panel); padding: 18px; overflow-y: auto; }
.info-cat { font-size: 12px; color: var(--accent); }
#info h2 { margin: 2px 0 0; font-size: 20px; }
.info-en { color: var(--muted); font-size: 12px; }
.badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #262b35; color: var(--text); }
.badge.st-standard { background: var(--standard); } .badge.st-test { background: var(--test); } .badge.st-placeholder { background: var(--placeholder); }
.badge.st-standard, .badge.st-test, .badge.st-placeholder { color: #0b0d11; font-weight: 600; }
#hover-tip { position: absolute; z-index: 3; pointer-events: none; font-size: 12px; background: #0b0d11ee; border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.spec { margin-top: 12px; padding: 8px 10px; background: var(--bg); border-radius: 8px; font-variant-numeric: tabular-nums; }
#info h3 { font-size: 12px; color: var(--muted); margin: 16px 0 4px; font-weight: 500; }
#info p { margin: 0; }
.note { background: #3b2a0a; border-left: 3px solid var(--test); padding: 6px 10px; border-radius: 4px; }
.kw { font-family: ui-monospace, Menlo, monospace; font-size: 12px; user-select: all; }
.params { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.params td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.params td:last-child { text-align: right; }
.params tr.group td { color: var(--accent); padding-top: 10px; }
.err { color: #f87171; }
code { font-size: 11px; }

@media (max-width: 1000px) {
  body { grid-template-columns: 1fr; grid-template-rows: 40vh 55vh auto; overflow: auto; height: auto; }
  #sidebar { max-height: 40vh; }
  main { height: 55vh; }
  #info { border-left: 0; border-top: 1px solid var(--line); }
}

.nav-link { padding: 5px 12px; border-radius: 7px; background: #ec4899; color: #fff; text-decoration: none; font-weight: 600; font-size: 13px; }
.nav-link.alt { background: #334155; }
