:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --ink: #142235;
  --muted: #66758a;
  --line: #dbe4ee;
  --line-strong: #c3d0de;
  --blue: #1267d8;
  --blue-strong: #084caa;
  --blue-soft: #e8f2ff;
  --green: #17966f;
  --amber: #c98213;
  --danger: #d93a46;
  --shadow: 0 22px 70px rgba(21, 39, 63, .14);
  --shadow-soft: 0 10px 30px rgba(21, 39, 63, .09);
  --radius: 8px;
  --rail: 72px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(18, 103, 216, .09), transparent 30%),
    linear-gradient(135deg, #f6f9fc 0%, #e9f0f7 56%, #dde8f2 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.brand-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 12px;
  background: #091a2e;
  color: white;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .08);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1072e8, #23a2c7);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .03em;
}

.rail-button,
.icon-button,
.tool-button,
.small-button,
.primary-button {
  border: 1px solid transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

.rail-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .76);
  font-weight: 800;
  font-size: 12px;
}

.nav-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid #091a2e;
  border-radius: 999px;
  background: #f6a623;
  color: #081b2f;
  font-size: 10px;
  font-weight: 900;
}

.rail-button:hover,
.rail-button.is-active {
  background: rgba(255, 255, 255, .18);
  color: #ffffff;
  transform: translateY(-1px);
}

.workspace {
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  padding: 18px 18px 18px 0;
}

.catalog-layer,
.admin-layer,
.rfq-layer {
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(180, 194, 211, .7);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(250px, .8fr) minmax(220px, 520px) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
}

.topbar-left,
.topbar-controls,
.details-top,
.panel-heading,
.viewer-toolbar,
.tool-cluster {
  display: flex;
  align-items: center;
}

.topbar-left {
  gap: 12px;
  min-width: 0;
}

.topbar-controls {
  justify-content: flex-end;
  gap: 10px;
}

.topbar h1,
.panel-heading h2,
.viewer-toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.1;
}

.viewer-toolbar h2,
.panel-heading h2 {
  font-size: 17px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border-color: var(--line);
  background: #fff;
  color: #203247;
  font-size: 21px;
  box-shadow: 0 6px 18px rgba(32, 50, 71, .06);
}

.icon-button:hover,
.tool-button:hover,
.small-button:hover {
  transform: translateY(-1px);
  border-color: #a9bed5;
  box-shadow: 0 9px 22px rgba(21, 39, 63, .1);
}

.global-search,
.filter-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.global-search input,
.filter-box input,
.marker-form input,
.marker-form select,
.marker-form textarea,
.topbar select,
.breadcrumbs select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.marker-form textarea {
  min-height: 78px;
  padding: 10px 12px;
  resize: vertical;
}

.global-search input {
  height: 42px;
  padding: 0 14px;
}

.filter-box input,
.marker-form input,
.marker-form select {
  height: 40px;
  padding: 0 12px;
}

.topbar select,
.breadcrumbs select {
  height: 38px;
  padding: 0 30px 0 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(18, 103, 216, .65);
  box-shadow: 0 0 0 4px rgba(18, 103, 216, .12);
}

.catalog-grid {
  display: grid;
  grid-template-columns: 360px minmax(420px, 1fr) 330px;
  min-height: 0;
}

.left-panel,
.details-panel,
.admin-sidebar,
.admin-detail {
  min-height: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, .82);
}

.left-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.breadcrumbs span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumbs select {
  max-width: 124px;
  font-size: 12px;
}

.preview-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff, #f4f8fc);
  box-shadow: var(--shadow-soft);
}

.preview-diagram {
  display: grid;
  place-items: center;
  height: 72px;
  overflow: hidden;
  border-radius: 8px;
  background: #e9f2fc;
}

.preview-card strong,
.preview-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-card span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
}

.count-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 800;
}

.parts-table {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.parts-header,
.part-row {
  display: grid;
  grid-template-columns: 58px 104px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
}

.parts-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.parts-list {
  height: 100%;
  max-height: 100%;
  overflow: auto;
}

.part-row {
  width: 100%;
  min-height: 62px;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid #edf2f6;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.part-row:hover {
  background: #f8fbff;
}

.part-row.is-selected {
  background: var(--blue-soft);
  box-shadow: inset 3px 0 0 var(--blue);
}

.part-row.is-filtered {
  background: #fff8e8;
}

.part-pos {
  color: var(--blue-strong);
  font-weight: 900;
}

.part-pn {
  font-size: 12px;
  font-weight: 800;
}

.part-desc {
  min-width: 0;
  color: #31435a;
  font-size: 13px;
}

.part-desc strong,
.part-desc span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-desc span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.qty-pill {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #eef4fa;
  color: #32485f;
  font-size: 12px;
  font-weight: 800;
}

.viewer-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 18px;
  background: #edf3f8;
}

.viewer-toolbar {
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  min-width: 0;
}

.tool-cluster {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.tool-button,
.small-button,
.primary-button {
  min-height: 36px;
  border-radius: 8px;
  font-weight: 800;
}

.tool-button,
.small-button {
  border-color: var(--line);
  background: #fff;
  color: #24374d;
}

.tool-button {
  min-width: 38px;
  padding: 0 12px;
}

.small-button {
  padding: 0 12px;
  font-size: 13px;
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  box-shadow: 0 10px 24px rgba(18, 103, 216, .22);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--blue-strong);
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
}

.danger-button:hover {
  background: #b92b36;
}

.danger-text {
  color: var(--danger);
}

.tool-button.is-active {
  border-color: rgba(18, 103, 216, .55);
  background: var(--blue-soft);
  color: var(--blue-strong);
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #31435a;
  font-size: 12px;
  font-weight: 800;
}

.diagram-viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(120, 145, 172, .09) 1px, transparent 1px),
    linear-gradient(0deg, rgba(120, 145, 172, .09) 1px, transparent 1px),
    #f8fbfd;
  background-size: 32px 32px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), var(--shadow-soft);
  touch-action: none;
}

.diagram-viewport::after {
  content: "Drag to pan · wheel or controls to zoom";
  position: absolute;
  left: 16px;
  bottom: 14px;
  padding: 7px 10px;
  border: 1px solid rgba(177, 194, 211, .8);
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.diagram-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1200px;
  height: 820px;
  transform-origin: center center;
  transition: transform .18s ease;
}

.diagram-viewport.is-panning .diagram-stage,
.editor .diagram-stage {
  transition: none;
}

.technical-diagram {
  display: block;
  width: 1200px;
  height: 820px;
  user-select: none;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 13px 28px rgba(18, 103, 216, .27);
  font-size: 11px;
  font-weight: 900;
  pointer-events: auto;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
}

.hotspot::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(18, 103, 216, .28);
  border-radius: inherit;
}

.hotspot:hover {
  transform: scale(1.12);
  box-shadow: 0 14px 34px rgba(18, 103, 216, .38);
}

.hotspot.is-selected {
  background: #f6a623;
  box-shadow: 0 0 0 8px rgba(246, 166, 35, .22), 0 18px 38px rgba(201, 130, 19, .34);
  animation: pulse 1.8s ease-in-out infinite;
}

.hotspot.is-filter-match:not(.is-selected) {
  background: var(--green);
}

.hotspot.is-muted {
  opacity: .24;
}

.hotspot .hotspot-label {
  pointer-events: none;
}

.hotspot-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: 210px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #081b2f;
  color: white;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.hotspot:hover .hotspot-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hide-labels .hotspot .hotspot-label {
  display: none;
}

.hide-hotspots .hotspot {
  display: none;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.details-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 18px;
  border-left: 1px solid var(--line);
}

#partDetails {
  min-height: 0;
  overflow: hidden;
}

.details-top {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.part-card {
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.part-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: 0;
}

.part-card .description {
  margin: 0 0 18px;
  color: #32475d;
  line-height: 1.45;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.status-chip {
  padding: 7px 10px;
  border-radius: 999px;
  background: #f0f5f9;
  color: #334960;
  font-size: 12px;
  font-weight: 800;
}

.status-chip.green {
  background: #e7f7f1;
  color: #137253;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.detail-item {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.detail-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-grid .primary-button,
.action-grid .small-button {
  width: 100%;
  justify-content: center;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.admin-grid {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 320px;
  min-height: 0;
}

.admin-sidebar,
.admin-detail {
  padding: 18px;
  border-right: 1px solid var(--line);
}

.admin-detail {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.assembly-cards,
.upload-stack,
.marker-form {
  display: grid;
  gap: 10px;
}

.assembly-card,
.upload-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.assembly-card {
  text-align: left;
}

.assembly-card.is-active {
  border-color: rgba(18, 103, 216, .48);
  background: var(--blue-soft);
}

.assembly-card strong,
.upload-card strong {
  color: #23384d;
  font-size: 13px;
}

.assembly-card span,
.upload-card span,
.upload-card input {
  color: var(--muted);
  font-size: 12px;
}

.upload-stack {
  margin-top: 18px;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 18px;
  background: #edf3f8;
}

.editor-stage {
  cursor: crosshair;
}

#editorDiagramClone svg {
  display: block;
  width: 1200px;
  height: 820px;
}

#editorDiagramArtwork svg,
#diagramArtwork svg,
#previewDiagram svg {
  display: block;
}

#editorDiagramArtwork svg,
#diagramArtwork svg {
  width: 1200px;
  height: 820px;
}

#previewDiagram svg {
  width: 100%;
  height: 100%;
}

.editor .hotspot {
  cursor: grab;
}

.editor .hotspot:active {
  cursor: grabbing;
}

.marker-form {
  margin-top: 8px;
}

.marker-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.coordinate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-box,
.mock-preview {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafc;
  color: #43576c;
  font-size: 13px;
  line-height: 1.45;
}

.mock-preview {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 26px;
  bottom: 24px;
  z-index: 30;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #071b30;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.admin-topbar {
  grid-template-columns: minmax(310px, .9fr) minmax(240px, 460px) auto;
}

.dirty-pill {
  align-self: center;
  padding: 7px 10px;
  border: 1px solid rgba(201, 130, 19, .24);
  border-radius: 999px;
  background: #fff5df;
  color: #8b5a0b;
  font-size: 12px;
  font-weight: 900;
}

.admin-grid {
  grid-template-columns: 340px minmax(0, 1fr) 380px;
  overflow: hidden;
}

.admin-editor-panel {
  grid-template-rows: auto minmax(380px, 1fr) auto;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
}

.catalog-tree-panel,
.admin-detail {
  overflow: auto;
  min-width: 0;
  background: rgba(255, 255, 255, .9);
  position: relative;
  z-index: 2;
}

.admin-picker-stack {
  display: grid;
  gap: 10px;
  margin: 16px 0 12px;
}

.admin-picker-stack label,
.wizard-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-picker-stack select,
.wizard-form input,
.wizard-form select,
.wizard-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.admin-picker-stack select,
.wizard-form input,
.wizard-form select {
  height: 40px;
  padding: 0 12px;
}

.wizard-form textarea {
  padding: 10px 12px;
  resize: vertical;
}

.admin-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-actions-row .primary-button {
  grid-column: 1 / -1;
}

.assembly-tree {
  display: grid;
  gap: 12px;
}

.tree-system {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.tree-system-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
  color: var(--ink);
  text-align: left;
}

.tree-system-button span {
  font-weight: 900;
}

.tree-system-button small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tree-assemblies {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.assembly-card span:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assembly-card b,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef4fa;
  color: #42576f;
  font-size: 11px;
  font-weight: 900;
}

.status-published {
  background: #e7f7f1;
  color: #137253;
}

.status-review {
  background: #fff5df;
  color: #8b5a0b;
}

.status-draft {
  background: #eef4fa;
  color: #42576f;
}

.admin-bottom-panel {
  min-height: 210px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .84);
  box-shadow: var(--shadow-soft);
}

.part-editor-table {
  max-height: 230px;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.parts-edit-header,
.parts-edit-row {
  display: grid;
  grid-template-columns: 64px minmax(120px, 1fr) minmax(120px, 1fr) minmax(160px, 1.4fr) 44px 52px;
  gap: 10px;
  align-items: center;
}

.diagram-fallback {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  width: 1200px;
  height: 820px;
  border: 1px dashed var(--line-strong);
  border-radius: 34px;
  background: #f7fafc;
  color: var(--muted);
  text-align: center;
}

.diagram-fallback strong {
  color: var(--ink);
  font-size: 26px;
}

.parts-edit-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.parts-edit-row {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #edf2f6;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.parts-edit-row:hover,
.parts-edit-row.is-selected {
  background: var(--blue-soft);
}

.parts-edit-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 750;
}

.readonly-field {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafc;
}

.readonly-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.readonly-field strong {
  font-size: 13px;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.admin-summary-grid span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-summary-grid b {
  color: var(--ink);
  font-size: 18px;
}

.upload-stack.compact {
  margin-top: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(7, 20, 35, .44);
  backdrop-filter: blur(7px);
}

.modal-card,
.confirm-card {
  width: min(980px, 100%);
  max-height: min(90vh, 920px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.confirm-card {
  width: min(430px, 100%);
  padding: 20px;
}

.confirm-card h2 {
  margin: 0 0 8px;
}

.confirm-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-header h2,
.wizard-step h3 {
  margin: 0;
  letter-spacing: 0;
}

.wizard-form {
  display: grid;
  gap: 14px;
}

.wizard-step {
  margin: 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbfd;
}

.wizard-step:first-of-type {
  margin-top: 18px;
}

.step-label {
  margin: 0 0 4px;
  color: var(--blue-strong);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.span-2 {
  grid-column: 1 / -1;
}

.validation-box {
  margin: 0 18px;
  padding: 10px 12px;
  border: 1px solid rgba(217, 58, 70, .35);
  border-radius: var(--radius);
  background: #fff0f2;
  color: #9e2630;
  font-size: 13px;
  font-weight: 800;
}

.rfq-drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 35;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(430px, calc(100vw - 36px));
  border: 1px solid rgba(180, 194, 211, .9);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfd;
}

.drawer-header h2 {
  margin: 0;
}

.drawer-content {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.rfq-line {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafc;
}

.rfq-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.rfq-line strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.drawer-section {
  display: grid;
  gap: 10px;
}

.rfq-line-form,
.rfq-line-form label,
.sender-card label,
.email-editor label,
.rfq-edit-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.rfq-line-form {
  gap: 12px;
}

.rfq-line-form input,
.rfq-line-form select,
.rfq-line-form textarea,
.sender-card select,
.email-editor input,
.email-editor textarea,
.custom-recipient input,
.rfq-edit-grid input,
.rfq-edit-grid select,
.rfq-edit-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.rfq-line-form input,
.rfq-line-form select,
.sender-card select,
.email-editor input,
.custom-recipient input,
.rfq-edit-grid input,
.rfq-edit-grid select {
  height: 40px;
  padding: 0 12px;
}

.rfq-line-form textarea,
.email-editor textarea,
.rfq-edit-grid textarea {
  min-height: 78px;
  padding: 10px 12px;
  resize: vertical;
}

.drawer-sticky-cta {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .72), #fff 40%);
}

.rfq-topbar {
  position: relative;
  z-index: 2;
  grid-template-columns: minmax(260px, .65fr) minmax(260px, 1fr) auto;
}

.rfq-layer {
  grid-template-rows: auto minmax(0, 1fr);
}

.rfq-summary-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rfq-summary-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.rfq-summary-strip b {
  color: var(--blue-strong);
  font-size: 15px;
}

.rfq-cart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  min-height: 0;
  overflow: hidden;
}

.rfq-cart-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  background: #edf3f8;
}

.rfq-cart-items {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

.rfq-empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 460px;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .75);
  color: var(--muted);
  text-align: center;
}

.rfq-empty-state h2 {
  margin: 0;
  color: var(--ink);
}

.rfq-empty-state p {
  max-width: 420px;
  margin: 0;
  line-height: 1.45;
}

.rfq-item-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.rfq-item-top,
.rfq-item-actions,
.email-actions,
.manual-email-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rfq-item-top {
  justify-content: space-between;
}

.rfq-line-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.rfq-item-top h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.rfq-item-actions,
.email-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.send-panel-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 12px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .96) 28%);
}

.send-panel-actions .primary-button {
  width: min(240px, 100%);
}

.rfq-item-desc {
  margin: 0;
  color: #34485f;
  font-weight: 750;
}

.rfq-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.rfq-item-meta span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef4fa;
  color: #42576f;
  font-size: 12px;
  font-weight: 850;
}

.rfq-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.rfq-send-panel {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, .9);
}

#rfqSendPanel {
  display: grid;
  gap: 14px;
}

.sender-card,
.recipient-panel,
.email-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.compact-heading h2 {
  font-size: 16px;
}

.recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(18, 103, 216, .24);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 900;
}

.recipient-chip span {
  color: #52677f;
  font-weight: 750;
}

.muted-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.custom-recipient {
  display: grid;
  gap: 8px;
}

.manual-email-row input {
  min-width: 0;
}

.broker-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.broker-row {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.broker-row:hover,
.broker-row.is-selected {
  border-color: rgba(18, 103, 216, .42);
  background: var(--blue-soft);
}

.broker-row span,
.broker-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.email-editor textarea {
  min-height: 340px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  text-transform: none;
}

@media (max-width: 1260px) {
  body {
    overflow: auto;
  }

  .app-shell,
  .workspace,
  .catalog-layer,
  .admin-layer,
  .rfq-layer {
    height: auto;
    min-height: 100vh;
  }

  .catalog-grid,
  .admin-grid,
  .rfq-cart-grid {
    grid-template-columns: 320px minmax(420px, 1fr);
  }

  .details-panel,
  .admin-detail,
  .rfq-send-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .rfq-cart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .brand-rail {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    height: 62px;
    padding: 9px 12px;
  }

  .brand-mark {
    margin: 0 auto 0 0;
  }

  .workspace {
    padding: 0;
  }

  .catalog-layer,
  .admin-layer,
  .rfq-layer {
    border-radius: 0;
    border-right: 0;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    height: auto;
  }

  .catalog-grid,
  .admin-grid,
  .rfq-cart-grid {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .details-panel,
  .admin-sidebar,
  .admin-detail,
  .rfq-send-panel {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .rfq-edit-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .rfq-topbar {
    grid-template-columns: 1fr;
  }

  .viewer-panel,
  .editor-panel {
    min-height: 620px;
  }

  .diagram-viewport {
    min-height: 540px;
  }
}
