:root {
  --blue: #00A3D9;
  --blue-dark: #007FB1;
  --dark: #111827;
  --text: #243244;
  --muted: #667085;
  --line: #E5ECF3;
  --bg: #F4F8FB;
  --card: #FFFFFF;
  --ok: #07885f;
  --warn: #b7791f;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(22, 46, 74, .12);
  --shadow-soft: 0 12px 35px rgba(22, 46, 74, .07);
  --radius: 20px;
  --radius-sm: 12px;
  --max: 1320px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--blue-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.topbar { position: sticky; top: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem max(1rem, calc((100% - var(--max))/2)); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: .85rem; color: var(--dark); }
.brand svg { width: 146px; height: auto; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 1rem; }
.brand small { color: var(--muted); font-weight: 750; }
.topbar nav { display: flex; gap: 1rem; font-weight: 850; }
.topbar nav a { color: var(--text); }
.hero { display: grid; grid-template-columns: 1fr 290px; gap: 2rem; align-items: end; padding: 5rem max(1rem, calc((100% - var(--max))/2)) 4rem; color: white; background: linear-gradient(120deg, #0f3445, #0a9fd0); }
.eyebrow { margin: 0 0 .45rem; color: var(--blue); text-transform: uppercase; letter-spacing: .13em; font-size: .78rem; font-weight: 950; }
.hero .eyebrow { color: #85e7ff; }
h1, h2, h3 { color: var(--dark); line-height: 1.12; margin: 0; }
.hero h1 { color: #fff; max-width: 950px; font-size: clamp(2rem, 4.8vw, 4.3rem); }
.hero p { max-width: 840px; margin: 1.1rem 0 0; font-size: 1.13rem; }
.hero-stats { background: rgba(255,255,255,.96); border-radius: var(--radius); color: var(--dark); box-shadow: var(--shadow); padding: 1.2rem; display: grid; gap: .1rem; }
.hero-stats strong { font-size: 2.35rem; color: var(--blue-dark); line-height: 1; }
.hero-stats span { color: var(--muted); font-weight: 850; margin-bottom: .75rem; }
.next-action, .workflow, .section { max-width: var(--max); margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }
.next-action { margin-top: -2.2rem; position: relative; display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding-top: 1.2rem; padding-bottom: 1.2rem; }
.next-action h2 { font-size: clamp(1.25rem, 2.2vw, 2rem); }
.next-action p:not(.eyebrow) { margin: .35rem 0 0; color: var(--muted); }
.workflow { padding-top: 1.3rem; display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; }
.flow-card { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .95rem; min-height: 118px; cursor: pointer; display: grid; gap: .3rem; box-shadow: var(--shadow-soft); }
.flow-card span { width: 2.2rem; height: 2.2rem; border-radius: .7rem; display: grid; place-items: center; background: #eef2f6; color: var(--muted); font-weight: 950; }
.flow-card strong { color: var(--dark); font-weight: 950; }
.flow-card small { color: var(--muted); font-weight: 750; }
.flow-card.done { border-color: rgba(7,136,95,.3); }
.flow-card.done span { background: rgba(7,136,95,.12); color: var(--ok); }
.flow-card.active { border-color: rgba(0,163,217,.65); box-shadow: var(--shadow); }
.flow-card.active span { background: var(--blue); color: white; }
.section { padding-top: 4.2rem; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.section-head h2 { font-size: clamp(1.8rem, 3vw, 2.65rem); }
.muted { color: var(--muted); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 1rem; }
.library-grid, .project-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1rem; margin-bottom: 1rem; }
.mini-step { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.mini-step span { width: 2rem; height: 2rem; border-radius: .7rem; display: grid; place-items: center; background: var(--blue); color: white; font-weight: 950; }
.mini-step strong { color: var(--dark); font-size: 1.05rem; }
.dropzone { position: relative; border: 2px dashed #b8dced; border-radius: var(--radius); background: #f7fcff; min-height: 160px; display: grid; place-items: center; text-align: center; padding: 1rem; transition: .15s ease; }
.dropzone.compact { min-height: 112px; }
.dropzone.drag, .dropzone:hover { border-color: var(--blue); background: #eaf8fe; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone strong { display: block; color: var(--dark); font-size: 1.1rem; }
.dropzone span { display: block; color: var(--muted); max-width: 560px; }
.file-preview { margin-top: .8rem; border-radius: var(--radius-sm); background: var(--bg); padding: .75rem; max-height: 160px; overflow: auto; }
.file-preview ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.button-row, .upload-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: .9rem; }
.btn { border: 0; border-radius: 999px; background: var(--blue); color: #fff; padding: .8rem 1.05rem; font-weight: 950; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: .4rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.light { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.danger, .btn.light.danger { color: var(--danger); }
.btn.big { padding: 1rem 1.25rem; font-size: 1.02rem; }
.result-box { margin-top: .8rem; border-radius: var(--radius-sm); background: var(--bg); padding: .9rem; }
.result-box.empty { color: var(--muted); }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin-top: .8rem; }
.result-grid div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .65rem; }
.result-grid strong { display: block; color: var(--blue-dark); font-size: 1.45rem; }
.browser-head, .panel-title { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.toolbar { display: flex; gap: .55rem; flex-wrap: wrap; }
.toolbar.compact input, .toolbar.compact select { min-width: 180px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: .78rem .85rem; color: var(--text); background: #fff; outline: none; font: inherit; font-weight: 520; }
textarea { min-height: 106px; resize: vertical; line-height: 1.45; font-weight: 500; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,163,217,.12); }
.library-list { display: grid; gap: .65rem; }
.library-card { display: grid; grid-template-columns: auto 1fr auto; gap: .85rem; align-items: center; padding: .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.library-card.active { border-color: rgba(0,163,217,.5); background: #f8fcff; }
.library-card h4 { margin: 0; color: var(--dark); }
.library-card p { margin: .2rem 0 0; color: var(--muted); }
.library-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; }
.checkbox { width: 1.1rem; height: 1.1rem; }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .25rem .55rem; font-size: .75rem; font-weight: 950; background: #eaf7fd; color: var(--blue-dark); }
.badge.gray { background: #f2f4f7; color: var(--muted); }
.badge.ok { background: rgba(7,136,95,.12); color: var(--ok); }
.badge.warn { background: rgba(183,121,31,.13); color: var(--warn); }
.badge.danger { background: rgba(180,35,24,.1); color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.form-grid label, .editor-grid label { display: grid; gap: .35rem; font-weight: 850; color: var(--dark); }
.form-grid label span, .editor-grid label span { color: var(--muted); font-size: .85rem; }
.workbench { display: grid; grid-template-columns: 310px minmax(0, 1fr) 330px; gap: 1rem; align-items: start; }
.project-list-panel, .bom-panel { position: sticky; top: 94px; max-height: calc(100vh - 115px); overflow: auto; }
.project-doc-list { display: grid; gap: .55rem; }
.project-card { width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); padding: .75rem; cursor: pointer; }
.project-card.active { border-color: var(--blue); background: #f7fcff; }
.project-card h4 { color: var(--dark); margin: .25rem 0; }
.project-card p { margin: .15rem 0; color: var(--muted); font-size: .9rem; }
.editor h3 { font-size: 1.4rem; margin-bottom: .35rem; }
.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-top: 1rem; }
.wide { grid-column: 1 / -1; }
.suggestion-box { border: 1px solid #bae6fd; background: #f0faff; border-radius: var(--radius-sm); padding: .9rem; margin-top: 1rem; }
.suggestion-box h4 { margin: 0 0 .6rem; color: var(--dark); }
.suggestion-line { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-top: 1px solid rgba(0,163,217,.16); }
.suggestion-line:first-of-type { border-top: 0; }
.mini-btn { border: 1px solid var(--line); background: #fff; color: var(--blue-dark); border-radius: 999px; padding: .35rem .6rem; font-weight: 900; cursor: pointer; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: #f2f4f7; color: var(--text); border-radius: 999px; padding: .35rem .6rem; font-weight: 800; }
.chip input { width: auto; }
.pdf-preview { width: 100%; height: 430px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 1rem; background: #f8fafc; }
.delete-row { margin-top: .8rem; display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.bom-panel input { margin-bottom: .7rem; }
.bom-grid { display: grid; gap: .55rem; }
.bom-card { width: 100%; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; padding: .72rem; cursor: pointer; }
.bom-card:hover, .bom-card.active { border-color: var(--blue); background: #f7fcff; }
.bom-card strong { display: block; color: var(--dark); }
.bom-card span { color: var(--muted); display: block; font-size: .88rem; }
.export-card { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }
.checklist { padding-left: 0; list-style: none; display: grid; gap: .45rem; }
.checklist li { display: flex; align-items: center; gap: .55rem; }
.checklist li::before { content: ""; width: .9rem; height: .9rem; border-radius: 999px; background: var(--line); }
.checklist li.ok::before { background: var(--ok); }
.checklist li.warn::before { background: var(--warn); }
.export-actions { display: grid; gap: .65rem; }
.activity { color: var(--muted); }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; background: var(--dark); color: white; padding: .9rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); max-width: min(420px, calc(100vw - 2rem)); }
.empty { color: var(--muted); padding: 1rem; }
@media (max-width: 1180px) {
  .workbench { grid-template-columns: 1fr; }
  .project-list-panel, .bom-panel { position: static; max-height: none; }
  .library-grid, .project-grid, .export-card, .next-action { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .topbar nav { display: none; }
  .brand svg { width: 115px; }
  .brand small { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 4rem; }
  .workflow { grid-template-columns: 1fr; }
  .section-head, .browser-head { flex-direction: column; align-items: stretch; }
  .form-grid, .editor-grid { grid-template-columns: 1fr; }
  .library-card { grid-template-columns: auto 1fr; }
  .library-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* v0.8 multi-project additions */
.topbar { gap: 1rem; }
.project-switcher { display: flex; align-items: end; gap: .55rem; flex-wrap: wrap; }
.project-switcher label { display: grid; gap: .2rem; min-width: 260px; font-weight: 850; color: var(--dark); }
.project-switcher label span { color: var(--muted); font-size: .78rem; }
.compact-hero { min-height: 340px; }
.multi-status { grid-template-columns: auto auto; min-width: 310px; }
.mode-explain { margin-top: -2rem; position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.mode-explain article { background: var(--bg); border-radius: var(--radius-sm); padding: .85rem; display: grid; gap: .3rem; }
.mode-explain strong { color: var(--dark); }
.mode-explain span { color: var(--muted); }
.subset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.compact-doc-list { display: grid; gap: .55rem; margin-top: .8rem; max-height: 560px; overflow: auto; }
.scope-card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; padding: .75rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .65rem; }
.scope-card strong { display: block; color: var(--dark); }
.scope-card span { display: block; color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.two-pane { grid-template-columns: 340px minmax(0,1fr); }
.editor-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.meta-section { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: .9rem; background: #fff; overflow: hidden; }
.meta-section summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto auto 1fr; gap: .55rem; align-items: center; padding: .85rem 1rem; background: #f8fafc; }
.meta-section summary::-webkit-details-marker { display: none; }
.meta-section summary span { color: var(--blue-dark); font-weight: 950; }
.meta-section summary strong { color: var(--dark); }
.meta-section summary small { color: var(--muted); justify-self: end; }
.meta-section .editor-grid, .meta-section > p, .meta-section .suggest-line { margin-left: 1rem; margin-right: 1rem; }
.meta-section .editor-grid { margin-bottom: 1rem; }
.project-meta summary { background: #eefaff; }
.check-row { display: flex !important; grid-template-columns: auto 1fr !important; align-items: center; background: var(--bg); border-radius: var(--radius-sm); padding: .8rem; }
.check-row input { width: 1.2rem; height: 1.2rem; }
.suggestion-inline { display: flex; justify-content: space-between; align-items: center; gap: .8rem; background: #f0faff; border: 1px solid #bae6fd; border-radius: var(--radius-sm); padding: .65rem; }
.editor-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: .9rem; padding: .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.project-card { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: .55rem; }
.project-card strong { display: block; }
.project-card small, .project-card em { display: block; color: var(--muted); font-style: normal; font-size: .85rem; margin-top: .16rem; }
.status-dot-mini { width: .8rem; height: .8rem; border-radius: 999px; margin-top: .18rem; background: var(--line); }
.status-dot-mini.ok { background: var(--ok); }
.status-dot-mini.warn { background: var(--warn); }
.status-dot-mini.danger { background: var(--danger); }
.btn.light.danger, .mini-btn.danger { color: var(--danger); }
.small-card { grid-template-columns: auto 1fr; }
.small-card .library-actions { grid-column: 1 / -1; justify-content: flex-start; }
.align-end { display: flex; align-items: end; }
@media (max-width: 1180px) {
  .project-switcher { width: 100%; }
  .mode-explain, .subset-grid, .two-pane { grid-template-columns: 1fr; }
  .editor-header { flex-direction: column; }
}
@media (max-width: 820px) {
  .project-switcher label { min-width: 100%; }
  .scope-card { grid-template-columns: 1fr; }
  .meta-section summary { grid-template-columns: auto 1fr; }
  .meta-section summary small { grid-column: 2; justify-self: start; }
}

/* v0.9 UX polish: clean HUBER workflow navigation */
:root {
  --nav-bg: rgba(255,255,255,.88);
  --surface: #ffffff;
  --surface-soft: #F7FAFD;
  --focus: 0 0 0 4px rgba(0,163,217,.16);
}
body { background: linear-gradient(180deg, #F7FBFE 0, #F4F8FB 380px, #F4F8FB 100%); }
.topbar {
  min-height: 78px;
  box-shadow: 0 4px 18px rgba(22,46,74,.04);
}
.brand svg { width: 126px; }
.brand strong { font-size: 1.05rem; letter-spacing: -.01em; }
.project-switcher {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .35rem;
  align-items: center;
}
.project-switcher label {
  min-width: 285px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .18rem .3rem .18rem .85rem;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .55rem;
}
.project-switcher label span { white-space: nowrap; }
.project-switcher select {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: .42rem 1.6rem .42rem .25rem;
  font-weight: 850;
}
.project-switcher .btn { padding: .62rem .95rem; }
.hero.compact-hero {
  min-height: auto;
  padding: 2.2rem max(1rem, calc((100% - var(--max))/2)) 3rem;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  align-items: center;
  background:
    radial-gradient(circle at 78% 30%, rgba(111,226,255,.28), transparent 34%),
    linear-gradient(120deg, #0B4053 0%, #0A86AD 60%, #08A7D8 100%);
}
.hero.compact-hero h1 {
  font-size: clamp(2.25rem, 4.2vw, 4rem);
  max-width: 980px;
  letter-spacing: -.035em;
}
.hero.compact-hero p { font-size: 1.1rem; line-height: 1.55; max-width: 920px; }
.status-card.multi-status {
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: .65rem;
  min-width: 0;
}
.status-card.multi-status strong,
.status-card.multi-status span { display: block; margin: 0; }
.status-card.multi-status strong {
  font-size: 1.75rem;
  line-height: 1;
  color: var(--blue-dark);
  letter-spacing: -.025em;
}
.status-card.multi-status span {
  color: var(--muted);
  font-size: .79rem;
  font-weight: 850;
  margin-top: .2rem;
}
.mode-explain.panel {
  margin-top: -1.55rem;
  padding: .85rem;
  border-radius: 24px;
  box-shadow: var(--shadow);
  background: rgba(255,255,255,.96);
}
.mode-explain article {
  background: linear-gradient(180deg, #F7FAFD, #FFFFFF);
  border: 1px solid var(--line);
  min-height: 118px;
}
.mode-explain article strong { font-size: 1rem; }
.mode-explain article span { font-size: .95rem; }
.wizard {
  max-width: var(--max);
  margin: 1rem auto 0;
  padding: .55rem;
  position: sticky;
  top: 79px;
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .45rem;
  background: var(--nav-bg);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 16px 42px rgba(22,46,74,.10);
  backdrop-filter: blur(16px);
}
.step {
  position: relative;
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 20px;
  padding: .78rem .8rem .78rem 3.25rem;
  min-height: 74px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
  display: grid;
  align-content: center;
  gap: .12rem;
}
.step:hover { background: #fff; border-color: var(--line); box-shadow: 0 8px 20px rgba(22,46,74,.07); transform: translateY(-1px); }
.step:focus-visible { outline: none; box-shadow: var(--focus); }
.step span {
  position: absolute;
  left: .72rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border-radius: .8rem;
  display: grid;
  place-items: center;
  background: #ECF2F7;
  color: var(--muted);
  font-weight: 950;
  font-size: .94rem;
}
.step strong {
  color: var(--dark);
  font-size: .98rem;
  line-height: 1.1;
  letter-spacing: -.012em;
}
.step small {
  color: var(--muted);
  font-weight: 750;
  font-size: .82rem;
  line-height: 1.2;
}
.step.done span { background: rgba(7,136,95,.12); color: var(--ok); font-size: 0; }
.step.done span::before { content: '✓'; font-size: .98rem; }
.step.next:not(.active) { background: #F0FAFF; border-color: #B9E6FE; }
.step.next:not(.active) span { background: #DFF5FF; color: var(--blue-dark); }
.step.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 12px 28px rgba(0,163,217,.24);
}
.step.active span { background: rgba(255,255,255,.22); color: #fff; }
.step.active strong,
.step.active small { color: #fff; }
.section { padding-top: 3rem; scroll-margin-top: 180px; }
.section-head { margin-bottom: 1.1rem; }
.section-head h2 { letter-spacing: -.028em; }
.panel { border-radius: 22px; }
.btn { box-shadow: 0 8px 18px rgba(0,163,217,.16); }
.btn.light { box-shadow: none; }
.btn:hover, .mini-btn:hover { transform: translateY(-1px); }
input, select, textarea { border-radius: 14px; }
.activity-section { padding-bottom: 3rem; }
@media (max-width: 1180px) {
  .wizard { grid-template-columns: repeat(3, minmax(0,1fr)); position: static; }
  .hero.compact-hero { grid-template-columns: 1fr; }
  .status-card.multi-status { grid-template-columns: repeat(5, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .project-switcher { border-radius: 22px; align-items: stretch; }
  .project-switcher label { min-width: 100%; grid-template-columns: 1fr; border-radius: 18px; }
  .project-switcher .btn { flex: 1 1 auto; }
  .wizard { grid-template-columns: 1fr; border-radius: 22px; }
  .step { min-height: 62px; }
  .status-card.multi-status { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .mode-explain.panel { grid-template-columns: 1fr; }
}

/* v0.10: focused BOM assignment and bulk selection */
.filter-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(150px, auto);
  gap: .55rem;
  align-items: center;
}
.filter-row select:last-child:nth-child(3) { grid-column: 1 / -1; }
.bulkbar {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  margin: .65rem 0 .35rem;
  padding: .55rem;
  background: #F6FAFD;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.bulkbar span {
  margin-left: auto;
  color: var(--muted);
  font-weight: 850;
  font-size: .88rem;
}
.muted-btn { color: var(--muted); }
.selectable-card {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}
.selection-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  flex: 0 0 auto;
}
.mapping-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 180px)) minmax(260px, 1fr);
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.summary-metric {
  background: #F6FAFD;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: .8rem .95rem;
}
.summary-metric strong {
  display: block;
  color: var(--blue-dark);
  font-size: 1.45rem;
  line-height: 1;
}
.summary-metric span, .summary-hint {
  color: var(--muted);
  font-weight: 800;
  font-size: .9rem;
}
.mapping-grid {
  display: grid;
  grid-template-columns: 330px minmax(360px, 1fr) 420px;
  gap: 1rem;
  align-items: start;
}
.mapping-panel {
  min-height: 540px;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}
.map-tree,
.map-doc-pool {
  display: grid;
  gap: .45rem;
  overflow: auto;
  max-height: 620px;
  padding-right: .2rem;
}
.map-bom-card {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 16px;
  padding: .65rem .7rem .65rem calc(.7rem + (var(--level, 0) * 14px));
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: .35rem .55rem;
  align-items: center;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.map-bom-card:hover { border-color: #B9E6FE; transform: translateY(-1px); }
.map-bom-card.active { border-color: var(--blue); background: #F0FAFF; box-shadow: var(--focus); }
.map-bom-card span {
  color: var(--blue-dark);
  font-weight: 950;
}
.map-bom-card strong {
  color: var(--dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-bom-card small {
  grid-column: 2 / -1;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-bom-card em {
  background: #ECF2F7;
  color: var(--muted);
  font-style: normal;
  font-weight: 950;
  min-width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.selected-bom {
  background: #F0FAFF;
  border: 1px solid #B9E6FE;
  border-radius: 18px;
  padding: .95rem;
}
.selected-bom h3 { margin: .15rem 0 .3rem; }
.map-block { margin-top: .9rem; }
.map-block h4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .7rem;
  margin: 0 0 .55rem;
}
.map-mini-doc,
.map-doc-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .7rem;
  display: grid;
  gap: .55rem;
}
.map-mini-doc {
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  margin-bottom: .45rem;
}
.map-mini-doc strong,
.map-doc-card strong { color: var(--dark); display: block; }
.map-mini-doc span,
.map-doc-card span,
.map-doc-card small { color: var(--muted); font-weight: 750; display: block; }
.map-doc-card {
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
}
.map-card-actions {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  align-items: end;
}
.scope-card .selection-checkbox,
.project-card .selection-checkbox,
.map-doc-card .selection-checkbox { justify-self: start; }
.project-card { grid-template-columns: auto auto minmax(0,1fr); }
.project-card .selection-checkbox { margin-right: .15rem; }
@media (max-width: 1280px) {
  .mapping-grid { grid-template-columns: 1fr; }
  .mapping-panel { min-height: 0; }
  .map-tree, .map-doc-pool { max-height: 430px; }
  .mapping-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .filter-row { grid-template-columns: 1fr; }
  .bulkbar span { width: 100%; margin-left: 0; }
  .mapping-summary { grid-template-columns: 1fr; }
  .map-doc-card, .scope-card, .project-card { grid-template-columns: auto minmax(0,1fr); }
  .map-card-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; }
}

/* v1.1 content-summary guidance */
.summary-field textarea { min-height: 96px; }
.field-help { display: block; color: var(--muted); font-weight: 650; font-size: .84rem; margin-top: .2rem; }
.field-action { justify-self: start; margin-top: .35rem; }

/* v1.2: compact library overview and explicit BOM selector */
.library-stack {
  display: grid;
  gap: 1rem;
}
.upload-strip-panel {
  padding: .9rem 1rem;
}
.upload-strip-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: .7rem;
}
.upload-strip-head .mini-step { margin-bottom: 0; }
.upload-strip-head .muted { margin: 0; max-width: 620px; }
.upload-strip {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(260px, .8fr) auto;
  gap: .75rem;
  align-items: stretch;
}
.strip-dropzone {
  min-height: 92px;
  padding: .8rem;
}
.strip-dropzone strong { font-size: 1rem; }
.strip-dropzone span { font-size: .9rem; }
.upload-strip .file-preview {
  margin-top: 0;
  max-height: 92px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.upload-strip .file-preview ul { margin-top: .25rem; }
.upload-strip .upload-actions {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  min-width: 220px;
}
.library-browser-panel { padding-top: 1rem; }
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 1.45rem;
  padding: 0 .55rem;
  margin-left: .35rem;
  border-radius: 999px;
  background: #EAF7FD;
  color: var(--blue-dark);
  font-size: .82rem;
  font-weight: 950;
  vertical-align: middle;
}
.library-list.dense {
  display: block;
  margin-top: .5rem;
}
.library-table {
  display: grid;
  gap: .35rem;
}
.library-row {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(170px, .5fr) minmax(220px, .7fr) minmax(300px, auto);
  gap: .65rem;
  align-items: center;
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  min-height: 58px;
}
.library-row.table-head {
  min-height: 0;
  padding: .35rem .65rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.lib-main {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 0;
}
.doc-icon.small {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: .75rem;
  font-size: .78rem;
  flex: 0 0 auto;
}
.lib-title {
  display: block;
  color: var(--dark);
  line-height: 1.18;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-file {
  display: block;
  color: var(--muted);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: .12rem;
}
.lib-meta,
.lib-status {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
  font-size: .88rem;
}
.library-row .library-actions {
  justify-content: flex-end;
  gap: .35rem;
}
.library-row .mini-btn {
  padding: .34rem .56rem;
  font-size: .82rem;
}
.mapping-toolbar {
  align-items: end;
  justify-content: flex-end;
}
.mapping-bom-picker {
  display: grid;
  gap: .25rem;
  min-width: min(520px, 46vw);
  font-weight: 900;
  color: var(--dark);
}
.mapping-bom-picker span {
  color: var(--muted);
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.mapping-bom-picker select {
  min-height: 44px;
  font-weight: 900;
  background: #fff;
}
@media (max-width: 1280px) {
  .upload-strip { grid-template-columns: 1fr; }
  .upload-strip .upload-actions { flex-direction: row; justify-content: flex-start; min-width: 0; }
  .library-row { grid-template-columns: minmax(260px, 1fr) minmax(140px, auto) minmax(190px, auto); }
  .library-row .library-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .library-row.table-head { display: none; }
  .mapping-bom-picker { min-width: 100%; }
}
@media (max-width: 760px) {
  .upload-strip-head { flex-direction: column; align-items: flex-start; }
  .library-row { grid-template-columns: 1fr; }
  .lib-title, .lib-file { white-space: normal; }
  .lib-main { align-items: flex-start; }
}
.doc-icon.small {
  display: grid;
  place-items: center;
  background: #EAF7FD;
  color: var(--blue-dark);
  font-weight: 950;
}

/* v1.3: cleaner dense lists; no overlapping columns */
:root { --max: 1440px; }
body { overflow-x: hidden; }
.library-browser-panel { overflow: hidden; }
.library-list.dense { width: 100%; }
.library-table {
  width: 100%;
  display: grid;
  gap: .45rem;
}
.library-row {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(170px, 260px) minmax(330px, auto);
  gap: .7rem;
  align-items: center;
  min-height: 54px;
  padding: .58rem .72rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(22,46,74,.035);
}
.library-row > * { min-width: 0; }
.library-row.table-head {
  grid-template-columns: 42px minmax(0, 1fr) minmax(170px, 260px) minmax(330px, auto);
  min-height: 0;
  padding: .18rem .72rem .22rem;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.doc-icon.small {
  width: 2.45rem;
  height: 2.45rem;
  border-radius: .72rem;
  display: grid;
  place-items: center;
  background: #EAF7FD;
  color: var(--blue-dark);
  font-weight: 950;
  font-size: .77rem;
  letter-spacing: .01em;
}
.lib-copy {
  min-width: 0;
  display: grid;
  gap: .1rem;
}
.lib-title,
.lib-file,
.lib-meta-line {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-title {
  color: var(--dark);
  font-weight: 900;
  line-height: 1.2;
  font-size: .98rem;
}
.lib-file {
  color: var(--muted);
  font-weight: 700;
  font-size: .84rem;
}
.lib-meta-line {
  color: var(--muted);
  font-weight: 850;
  font-size: .78rem;
}
.lib-meta { display: none !important; }
.lib-status {
  display: flex;
  gap: .32rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.lib-status .badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-row .library-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: .32rem;
  min-width: 0;
}
.library-row .mini-btn {
  padding: .4rem .62rem;
  font-size: .82rem;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}
.browser-head { align-items: center; }
.browser-head h3 { display: flex; align-items: center; gap: .35rem; }
.map-doc-card,
.map-mini-doc,
.scope-card,
.project-card { min-width: 0; }
.map-doc-card > div,
.map-mini-doc > div,
.scope-card > div,
.project-card > span { min-width: 0; }
.map-doc-card strong,
.map-mini-doc strong,
.scope-card strong,
.project-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-card-actions { min-width: max-content; }
@media (max-width: 1180px) {
  .library-row,
  .library-row.table-head { grid-template-columns: 42px minmax(0, 1fr) minmax(145px, 210px); }
  .library-row .library-actions { grid-column: 2 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .library-row.table-head { display: none; }
}
@media (max-width: 720px) {
  .library-row { grid-template-columns: 38px minmax(0, 1fr); gap: .6rem; }
  .lib-status, .library-row .library-actions { grid-column: 2 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .lib-title, .lib-file { white-space: normal; }
}
