/* The hidden attribute always wins, even over display rules on styled elements */
[hidden] { display: none !important; }

/* ============ Shell — red page ground → dark rounded frame → light canvas ============ */
.shell {
  display: flex; min-height: 100vh;
  background: var(--frame);
}
.sidebar {
  display: flex; flex-direction: column; gap: 26px;
  width: 252px; flex-shrink: 0;
  color: #fff;
  padding: 30px 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 800; letter-spacing: .02em; padding: 0 8px; }
.brand img { height: 40px; }
.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  color: #d8d8d4; text-decoration: none;
  padding: 12px 16px; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 14.5px;
}
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active { background: #fff; color: var(--ink); }
.userbox {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  color: #bbb; font-size: 13px;
  border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px;
}
.userbox .avatar {
  width: 34px; height: 34px; border-radius: var(--radius-pill); flex-shrink: 0;
  background: var(--red); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.userbox .user-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.userbox .user-name { color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .user-role { color: #8a8a86; font-size: 11px; }
.userbox .cog {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--radius-pill); color: #8a8a86;
}
.userbox .cog svg { width: 18px; height: 18px; }
.userbox .cog:hover { background: rgba(255,255,255,.1); color: #fff; }
.userbox .cog.active { background: var(--red); color: #fff; }
.userbox form { width: 100%; }
.userbox form button { width: 100%; background: #2c2c2a; color: #d8d8d4; border: 0; }
.userbox form button:hover { background: #3a3a38; color: #fff; }
.main {
  flex: 1; min-width: 0;
  background: var(--grey);
  padding: 38px 44px 80px;
}
.main > * { max-width: var(--maxw); }
.main > .wizard-overlay { max-width: none; }

/* Narrow screens: sidebar collapses back to a top bar */
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar {
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px 20px;
    width: auto; height: auto; position: static; overflow: visible;
    padding: 14px 16px;
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { padding: 8px 14px; }
  .nav a svg { display: none; }
  .userbox { border-top: 0; padding-top: 0; flex-wrap: nowrap; margin-left: auto; }
  .userbox .user-id { flex: 0 1 auto; }
  .userbox form { width: auto; }
  .userbox form button { width: auto; }
  .main { padding: 22px 18px 60px; }
}

/* ============ Buttons / forms — everything is a pill ============ */
.btn {
  display: inline-block; border: 1.5px solid transparent; border-radius: var(--radius-pill);
  padding: 10px 22px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: none; text-align: center;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #c9151b; }
.btn-secondary { background: #fff; color: var(--ink); }
.btn-secondary:hover { background: #f3f3f1; }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.3); }
.btn-sm { padding: 6px 16px; font-size: 13px; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-danger { background: var(--pink); color: var(--red-dark); }
.btn-danger:hover { background: #ffdfe1; }

label { display: block; font-weight: 700; font-size: 12.5px; color: var(--muted); letter-spacing: .01em; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], textarea, select {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 18px; font: inherit; color: var(--ink);
  border: 1.5px solid #DDDDD9; border-radius: var(--radius-pill); background: #fff;
}
textarea { border-radius: 18px; }
input:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: var(--red); }
.stack > * + * { margin-top: 14px; }
.field-err { color: var(--red-dark); font-size: 13px; font-weight: 600; margin-top: 4px; }
.field-warn { color: var(--warn); font-size: 13px; font-weight: 600; margin-top: 4px; }

/* ============ Cards / misc ============ */
.card { background: var(--paper); border-radius: var(--radius); padding: 26px; }
.card-dark { background: var(--frame); color: #fff; }
.card-dark .muted, .card-dark p { color: #b9b9b5; }
.card-dark b { color: #fff; }
.muted { color: var(--muted); }
.alert { border-radius: 14px; padding: 10px 16px; font-weight: 600; font-size: 14px; }
.alert-error { background: var(--pink); color: var(--red-dark); }
.alert-warn { background: #FFF7E8; border: 1px solid var(--yellow); color: #5a4300; }
.btn-back { display: inline-block; margin-bottom: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-head h1 { margin: 0; font-size: 40px; font-weight: 800; letter-spacing: -1px; line-height: 1.05; }
/* Flux signature: big page titles end with a red full stop */
.page-head h1::after { content: '.'; color: var(--red); }

.badge { display: inline-block; border-radius: var(--radius-pill); padding: 4px 12px; font-size: 12px; font-weight: 700; }
.badge-draft { background: #EDEDEB; color: var(--ink); }
.badge-approved { background: var(--frame); color: #fff; }
.badge-archived { background: #eee; color: var(--meta); }
.badge-suggested { background: var(--yellow); color: var(--black); }
.badge-sheet { background: #E8EEF7; color: #2B4A78; }
.badge-liquid { background: var(--pink); color: var(--red-dark); }
.badge-warn { background: var(--yellow); color: var(--ink); }
.badge-issued { background: var(--red); color: #fff; }
.badge-pending { background: var(--yellow); color: var(--ink); }
.badge-ws { background: #E8EEF7; color: #2B4A78; }
.badge-ts { background: #EFEAF8; color: #5B3A8A; }
.badge-assoc { background: #E6F4F1; color: #1F6E5E; }

/* ============ Forspec tables (WPS style) — rounded, dark-red header, zebra ============ */
table.fs {
  border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px;
  border-radius: 14px; overflow: hidden;
}
table.fs th {
  background: var(--red-dark); color: #fff; font-weight: 700;
  text-align: left; padding: 11px 16px;
}
table.fs td { padding: 11px 16px; vertical-align: top; }
table.fs tbody tr:nth-child(even) { background: var(--zebra); }

/* ============ Login ============ */
.login-wrap { display: grid; place-items: center; min-height: 70vh; }
.login-card { width: 420px; text-align: center; padding: 40px 36px; }
.login-card h1 { margin: 14px 0 2px; font-weight: 800; font-size: 30px; letter-spacing: -.5px; }
.login-card h1::after { content: '.'; color: var(--red); }
.login-logo { height: 52px; }
.login-card form { text-align: left; margin-top: 20px; }

/* ============ Wizard ============ */
.wizard-overlay {
  position: fixed; inset: 0; background: rgba(14,14,14,.55);
  display: grid; place-items: center; padding: 24px; z-index: 50;
}
.wizard {
  background: #fff; border-radius: var(--radius); width: min(880px, 100%);
  max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,.3);
}
.wizard-head {
  background: var(--frame); color: #fff; padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between;
}
.wizard-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.wizard-head h2::after { content: '.'; color: var(--red); }
.wizard-progress { display: flex; gap: 6px; }
.wizard-progress span { width: 26px; height: 6px; border-radius: 999px; background: #3a3a38; }
.wizard-progress span.done { background: var(--yellow); }
.wizard-progress span.current { background: var(--red); }
.wizard-body { padding: 24px; overflow-y: auto; flex: 1; }
.wizard-body h3 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.wizard-body .step-hint { color: var(--muted); margin: 0 0 18px; }
.wizard-foot {
  padding: 14px 24px; border-top: 1px solid #e5e5e5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}

/* Editable product name (page heading) */
#prod-name { border-radius: 8px; padding: 0 6px; margin-left: -6px; cursor: text; }
#prod-name:hover { background: #f2f2ee; }
#prod-name:focus { outline: 2px solid var(--red); background: #fff; }

/* ============ Document preview (TDS/SDS in-app) ============ */
.docprev-overlay {
  position: fixed; inset: 0; background: rgba(14,14,14,.55);
  display: grid; place-items: center; padding: 24px; z-index: 60;
}
.docprev {
  background: #fff; border-radius: var(--radius); width: min(980px, 100%);
  height: 92vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,.3);
}
.docprev-head {
  background: var(--frame); color: #fff; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.docprev-name {
  font-weight: 700; font-size: 14px; margin-right: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.docprev-close {
  background: none; border: 0; color: #fff; font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0 2px;
}
.docprev-close:hover { color: var(--yellow); }
.docprev-frame { border: 0; flex: 1; width: 100%; background: #525659; }

.opt-list { display: grid; gap: 12px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1.5px solid #DDDDD9; border-radius: 18px; padding: 14px 20px; cursor: pointer;
  background: #FAFAF8;
}
.opt:hover { border-color: #aaa; }
.opt.selected { border-color: var(--red); background: var(--pink); }
.opt input { margin-top: 4px; accent-color: var(--red); }
.opt .opt-name { font-weight: 700; }
.opt .opt-desc { color: var(--muted); font-size: 13px; }
.opt .badges { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.opt-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .opt-cols { grid-template-columns: 1fr; } }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 700px) { .form-grid, .form-grid-3 { grid-template-columns: 1fr; } }
.req { color: var(--red-dark); }
/* Beats .cust-nologo's width/height:100% (defined later in this file) on specificity */
.opt .opt-thumb.cust-nologo { width: 40px; height: 40px; min-height: 0; display: grid; font-size: 16px; }

.qty-row { display: flex; gap: 16px; margin-top: 18px; }
.qty-row + #primer-list, .qty-row + #np-list, #membrane-qty-holder:not(:empty) + #membrane-list { margin-top: 18px; }
.qty-row label { flex: 1; }
.subq { margin-top: 22px; padding-top: 18px; border-top: 1px dashed #ccc; }

/* ============ System detail / editor ============ */
.sys-meta { display: flex; flex-wrap: wrap; gap: 26px; margin: 6px 0 18px; color: var(--muted); font-size: 14px; }
.sys-meta b { color: var(--ink); }
.section-card { margin-top: 16px; }
.section-card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.section-card textarea { min-height: 120px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.55; }
.section-tools { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.flag-list { margin: 8px 0 0; padding: 8px 12px; background: #FFF7E8; border-radius: 12px; font-size: 13px; color: var(--warn); }
.save-state { font-size: 12px; color: var(--meta); }

/* ---- ITP structured editor (hold_points card) ---- */
.itp-hint { font-size: 12px; margin: 4px 0 10px; }
.itp-head, .itp-row {
  display: grid;
  grid-template-columns: 22px 30px 150px 1fr 26px;
  gap: 8px; align-items: center;
}
.itp-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--meta); margin-bottom: 4px; }
.itp-row { margin-bottom: 6px; }
.itp-row .itp-letter { font-weight: 800; font-size: 13px; text-align: center; }
.itp-row .itp-check { justify-self: center; width: 15px; height: 15px; }
.itp-row input[type="text"], .itp-row select { font-size: 13px; padding: 6px 8px; }
.itp-row .itp-remove {
  border: 1px solid #ddd; background: #fff; border-radius: 999px; cursor: pointer;
  width: 26px; height: 26px; line-height: 1; font-size: 15px; color: var(--meta);
}
.itp-row .itp-remove:hover { color: var(--red); border-color: currentColor; }

/* ---- Customisable sections (associated drafts) ---- */
.sec-struct { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.sec-btn {
  border: 1px solid #ddd; background: #fff; border-radius: 999px; cursor: pointer;
  min-width: 26px; height: 26px; padding: 0 8px; line-height: 1; font-size: 13px;
  font-weight: 700; color: var(--meta);
}
.sec-btn:hover:not(:disabled) { color: var(--ink); border-color: currentColor; }
.sec-btn:disabled { opacity: .35; cursor: default; }
.sec-btn.sec-del:hover:not(:disabled) { color: var(--red); }
.sec-btn.sec-itp { font-size: 11px; letter-spacing: .04em; }
.sec-btn.sec-itp.active { background: var(--red); border-color: var(--red); color: #fff; }
.sec-title[contenteditable] { border-bottom: 1px dashed #ccc; outline: none; min-width: 60px; }
.sec-title[contenteditable]:focus { border-bottom-color: var(--red); }
.lock-banner { background: #FFF7E8; border: 1px solid var(--yellow); font-size: 14px; }
#add-section-card { margin-top: 16px; }

/* ============ Product library ============ */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.prod-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.prod-card.prod-archived { opacity: .55; }
.prod-imgwrap { display: block; background: #fff; border-bottom: 1px solid #eee; }
.prod-imgwrap img { width: 100%; aspect-ratio: 1; object-fit: contain; padding: 14px; display: block; }
.prod-noimg {
  aspect-ratio: 1; display: grid; place-items: center;
  color: var(--meta); font-size: 13px; font-weight: 600; background: var(--grey);
}
.prod-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.prod-name { font-weight: 700; color: var(--ink); text-decoration: none; line-height: 1.3; }
.prod-name:hover { color: var(--red-dark); }
.prod-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.prod-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.chip {
  display: inline-block; border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: 4px 12px; font-size: 12px; font-weight: 600; text-decoration: none; color: var(--ink);
  background: var(--pink);
}
a.chip:hover { border-color: var(--red); color: var(--red-dark); }
.chip-rev { font-weight: 400; color: var(--meta); }
.chip-none { border-style: dashed; color: var(--meta); font-weight: 400; }
.view-toggle { display: inline-flex; gap: 6px; }
.prod-rows { display: grid; gap: 10px; }
.prod-row { display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.prod-row.prod-archived { opacity: .55; }
.prod-row-thumb { flex-shrink: 0; width: 56px; height: 56px; }
.prod-row-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.prod-row-thumb .prod-noimg { width: 100%; height: 100%; aspect-ratio: auto; font-size: 9px; border-radius: 6px; }
.prod-row-main { flex: 1; min-width: 0; }
.prod-row-desc { font-size: 13px; line-height: 1.35; }
.prod-row .prod-meta { flex-shrink: 0; justify-content: flex-end; max-width: 280px; }
.prod-row .prod-chips { flex-shrink: 0; justify-content: flex-end; max-width: 340px; margin-top: 0; }
@media (max-width: 900px) {
  .prod-row { flex-wrap: wrap; }
  .prod-row .prod-meta, .prod-row .prod-chips { justify-content: flex-start; max-width: none; }
}

.prod-detail { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.prod-detail-img { width: 260px; flex-shrink: 0; }
.prod-detail-img img { width: 100%; aspect-ratio: 1; object-fit: contain; }
@media (max-width: 760px) { .prod-detail { flex-direction: column; } .prod-detail-img { width: 100%; } }
.doc-upload { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
.doc-upload label { flex: 1; min-width: 140px; }
.img-preview { max-width: 180px; max-height: 180px; object-fit: contain; border: 1px solid #ddd; border-radius: 6px; }
.opt-thumb { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }

/* ============ Dashboard ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-tile { display: flex; flex-direction: column; gap: 4px; padding: 22px 24px; text-decoration: none; color: inherit; }
a.stat-tile:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.stat-num { font-size: 42px; font-weight: 800; line-height: 1.05; letter-spacing: -1px; }
.stat-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-sub { font-size: 12px; color: var(--meta); }
.stat-tile.stat-warn .stat-num { color: var(--warn); }
.stat-tile.stat-ok .stat-num { color: var(--ink); }
.dash-heading { margin: 34px 0 14px; font-size: 22px; font-weight: 800; letter-spacing: -.3px; }

/* ============ Systems list ============ */
.sys-grid { display: grid; gap: 12px; }
.sys-row { display: flex; align-items: center; gap: 18px; text-decoration: none; color: inherit; }
.sys-row:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.sys-row .code { font-weight: 800; font-size: 17px; min-width: 64px; }
.sys-row .name { font-weight: 600; flex: 1; }
.sys-row .meta { color: var(--meta); font-size: 13px; }
.sys-row a.name { color: inherit; text-decoration: none; }
.sys-row .sys-pick, .sys-row .sys-pick-gap { width: 18px; flex: none; margin: 0; }
.sys-row .sys-row-err { display: block; font-weight: 400; font-size: 13px; }
.sys-row .sys-row-err:empty { display: none; }
.sys-bulk { display: flex; align-items: center; gap: 14px; margin: 0 0 12px; flex-wrap: wrap; }
.sys-bulk-all { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ============ Specs list ============ */
.spec-search { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.spec-search input[type=search] {
  flex: 1; min-width: 240px; margin-top: 0;
  padding: 11px 20px; font: inherit; color: var(--ink);
  border: 1.5px solid #DDDDD9; border-radius: var(--radius-pill); background: #fff;
}
.mode-chips { display: flex; gap: 6px; }
.mode-chip { display: inline-block; cursor: pointer; }
.mode-chip input { position: absolute; opacity: 0; pointer-events: none; }
.mode-chip span {
  display: inline-block; border: 1.5px solid #ccc; border-radius: 999px;
  padding: 7px 16px; font-size: 13px; font-weight: 700; color: var(--ink); background: #fff;
}
.mode-chip:hover span { border-color: #999; }
.mode-chip:has(:checked) span { background: var(--red); border-color: var(--red); color: #fff; }
.mode-chip:has(:focus-visible) span { outline: 2px solid var(--red); outline-offset: 2px; }
.spec-row { display: flex; align-items: center; gap: 18px; text-decoration: none; color: inherit; }
a.spec-row:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.spec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.spec-main .name { font-weight: 700; }
.spec-main .addr { font-size: 14px; color: var(--muted); }
.spec-main .meta { color: var(--meta); font-size: 13px; }
.prod-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 46%; }
.badge-prod { background: var(--grey); color: var(--ink); font-weight: 600; }
.badge-imported { background: #E8EEF7; color: #2B4A78; }

/* ============ Spec detail (Material Allocation) ============ */
.ma-heading { margin: 30px 0 6px; font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.loc-card { margin-top: 14px; }
.loc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.loc-code { font-weight: 800; font-size: 17px; color: var(--red-dark); }
.loc-name { font-weight: 600; flex: 1; min-width: 200px; }
.loc-tools { display: flex; gap: 8px; }
.form-grid-loc { display: grid; grid-template-columns: 140px 1fr 260px; gap: 14px; }
@media (max-width: 700px) { .form-grid-loc { grid-template-columns: 1fr; } }
/* Drawing field: input + Browse button, then the library picker panel below */
.dwg-input-row { display: flex; gap: 6px; align-items: center; }
.dwg-input-row input { flex: 1; min-width: 0; }
.dwg-input-row .btn { margin-top: 6px; flex-shrink: 0; }
.dwg-picker { margin-top: 14px; border-radius: 16px; padding: 14px 16px; background: #FAFAF8; }
.dwg-picker-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.dwg-picker-head input[type=search] { flex: 1; margin-top: 0; }
.dwg-picker-list { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; }
.dwg-mini-crumbs { font-size: 13.5px; margin: 2px 0 4px; }
/* Back button lives inside the crumbs nav — keep .btn colours, not crumb-link colours */
.dwg-crumbs a.btn { color: #fff; }
.dwg-crumbs a.btn:hover { color: #fff; text-decoration: none; }
.dwg-mini-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  border: 1px solid transparent; border-radius: 12px; cursor: pointer; background: #fff;
}
.dwg-mini-row:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.dwg-mini-row.dwg-mini-selected { background: #FDECEC; border-color: var(--red); }
.dwg-mini-thumb {
  flex-shrink: 0; width: 54px; height: 38px; display: grid; place-items: center;
  background: var(--grey); border-radius: 6px;
  color: var(--meta); font-size: 11px; font-weight: 800; letter-spacing: .04em;
}
.dwg-mini-thumb.dwg-thumb-folder { font-size: 20px; background: #FDECEC; }
.dwg-mini-thumb.dwg-mini-thumb-img { background: #fff; border: 1px solid #e5e5e5; overflow: hidden; }
.dwg-mini-thumb.dwg-mini-thumb-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dwg-mini-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dwg-mini-name { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.dwg-mini-desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dwg-mini-tick { flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--meta); }
.dwg-mini-selected .dwg-mini-tick { color: var(--red-dark); }
.dwg-picker-hint { font-size: 12.5px; margin: 10px 0 0; }
.ma-system { margin-top: 14px; padding-top: 14px; border-top: 1px solid #e5e5e5; }
.ma-system-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ma-system-head .ma-sysname { font-weight: 600; flex: 1; min-width: 200px; }
/* Composite members: one sub-block per member inside the attachment card */
.ma-member { margin-top: 10px; padding-left: 12px; border-left: 3px solid var(--line, #e3e3e3); }
.ma-member-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.ma-member-head .ma-sysname { font-weight: 500; flex: 1; min-width: 160px; color: var(--muted, #666); }
.ma-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px; margin-top: 10px;
}
.ma-cell {
  background: var(--pink); border-radius: 16px; padding: 12px 14px;
  font-size: 13px; line-height: 1.4; display: flex; flex-direction: column; gap: 4px;
}
.ma-label { font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--red-dark); }
.ma-assoc {
  background: var(--zebra); border-radius: 14px; padding: 10px 12px; margin-top: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.ma-assoc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ma-assoc-chip { font-size: 12.5px; font-weight: 400; background: #fff; }
.ma-comments { margin-top: 10px; }
/* Standalone collapsible Coverage / Consumption card (specCoverage.js) —
   one per spec, derived from the whole material allocation. */
.coverage-card summary {
  cursor: pointer; font-weight: 700; font-size: 16px; list-style: none;
}
.coverage-card summary::before { content: '▸'; display: inline-block; margin-right: 8px; transition: transform .15s; }
.coverage-card[open] summary::before { transform: rotate(90deg); }
.coverage-card summary::-webkit-details-marker { display: none; }
.coverage-card summary .muted { font-weight: 400; font-size: 13px; }
.coverage-card-body {
  margin-top: 12px; display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px;
}
.coverage-card-body .ma-coverage-table { flex: 0 1 380px; }
.coverage-card-body .ma-coverage-membranes { flex: 1 1 100%; display: flex; flex-direction: column; gap: 6px; }
.coverage-card-body table.fs { font-size: 12.5px; margin-top: 6px; }
.coverage-card-body table.fs th, .coverage-card-body table.fs td { padding: 5px 10px; }
.ma-coverage-line, .ma-coverage-table { line-height: 1.5; }

/* Per-location layer tweaks editor */
.lt-editor { margin-top: 12px; }
.lt-head, .lt-row {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: 170px minmax(180px, 1fr) 76px 90px 76px auto;
}
.lt-head {
  font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin-bottom: 6px;
}
.lt-row { margin-top: 6px; }
.lt-row select, .lt-row input { margin-top: 0; font-size: 13px; }
.lt-tools { display: flex; gap: 4px; }
.lt-cond { margin-top: 4px; padding-left: 178px; }
.lt-cond input { margin-top: 0; font-size: 12.5px; width: 100%; max-width: 460px; }
@media (max-width: 900px) { .lt-cond { padding-left: 0; } }
.lt-hint { font-size: 12.5px; margin: 8px 0 0; }
@media (max-width: 900px) {
  .lt-head { display: none; }
  .lt-row { grid-template-columns: 1fr 1fr; }
  .lt-row select[data-ltf=product_slug] { grid-column: span 2; }
}
.finalise-form { display: flex; gap: 8px; align-items: center; flex: 1; flex-wrap: wrap; }
.finalise-form input[type=text] { flex: 1; min-width: 240px; margin-top: 0; }
.ma-comments textarea { resize: none; overflow: hidden; min-height: 38px; font-size: 13px; }

/* ============ Customers ============ */
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cust-card { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: inherit; }
.cust-card:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.cust-logowrap { width: 56px; height: 56px; flex-shrink: 0; }
.cust-logowrap img { width: 100%; height: 100%; object-fit: contain; }
.cust-nologo {
  width: 100%; height: 100%; min-height: 56px; display: grid; place-items: center;
  background: var(--grey); color: var(--meta); border-radius: 14px;
  font-size: 22px; font-weight: 800;
}
.cust-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cust-name { font-weight: 700; line-height: 1.3; }
.cust-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cust-logocard img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.cust-logocard .cust-nologo { aspect-ratio: 1; font-size: 64px; }
.customer-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--meta); }
.customer-link:hover { color: var(--red-dark); border-bottom-color: var(--red-dark); }

/* ============ Drawings library (list rows, Product Library style) ============ */
.dwg-crumbs { font-weight: 700; font-size: 15px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; min-width: 0; }
.dwg-crumbs a { color: inherit; text-decoration: none; }
.dwg-crumbs a:hover { color: var(--red-dark); text-decoration: underline; }
.dwg-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.dwg-toolbar input[type=search] {
  padding: 9px 18px; font: inherit; font-size: 14px; color: var(--ink);
  border: 1.5px solid #DDDDD9; border-radius: var(--radius-pill); background: #fff;
}
.dwg-rows { display: grid; gap: 10px; }
.dwg-row {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  text-decoration: none; color: inherit; cursor: pointer;
}
.dwg-row:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.dwg-thumb {
  flex-shrink: 0; width: 56px; height: 56px; display: grid; place-items: center;
  background: var(--grey); border-radius: 14px;
  color: var(--meta); font-size: 12px; font-weight: 800; letter-spacing: .04em;
}
.dwg-thumb.dwg-thumb-folder { font-size: 26px; background: #FDECEC; }
.dwg-thumb.dwg-thumb-pdf { color: var(--red-dark); background: var(--pink); }
/* Drawing sheets are landscape — a wider box previews the whole sheet */
.dwg-thumb.dwg-thumb-img { width: 84px; background: #fff; border: 1px solid #e5e5e5; overflow: hidden; }
.dwg-thumb.dwg-thumb-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dwg-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dwg-row-name { font-weight: 700; line-height: 1.3; }
.dwg-row-desc { font-size: 13px; line-height: 1.35; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dwg-row-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; max-width: 44%; }
.dwg-row-tools { display: flex; gap: 6px; flex-shrink: 0; }
/* Grid (icon) view — Product-Library-style cards, toggled from the toolbar */
.dwg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.dwg-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; color: inherit; text-decoration: none; }
.dwg-card:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.dwg-card-thumb {
  display: grid; place-items: center; aspect-ratio: 4 / 3; width: 100%;
  background: var(--grey); border-bottom: 1px solid #eee;
  color: var(--meta); font-size: 16px; font-weight: 800; letter-spacing: .04em;
}
.dwg-card-thumb.dwg-thumb-folder { font-size: 48px; background: #FDECEC; }
.dwg-card-thumb.dwg-thumb-pdf { color: var(--red-dark); background: var(--pink); }
.dwg-card-thumb.dwg-card-thumb-img { background: #fff; }
.dwg-card-thumb.dwg-card-thumb-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dwg-card-body { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 12px; }
.dwg-card-body .dwg-row-desc { white-space: normal; }
.dwg-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dwg-card-tools { display: flex; gap: 6px; margin-top: 3px; }
.dwg-span-all { grid-column: 1 / -1; }
.dwg-inline-form { max-width: 680px; margin-bottom: 16px; }
.dwg-edit-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; flex: 1; }
.dwg-edit-form label { min-width: 120px; flex: 1; }
.dwg-edit-form label:first-child { max-width: 140px; }
.dwg-dropping { outline: 3px dashed var(--red); outline-offset: 6px; border-radius: 8px; }
@media (max-width: 900px) {
  .dwg-row { flex-wrap: wrap; }
  .dwg-row-meta { justify-content: flex-start; max-width: none; }
}

/* Customer mini profile popover (spec page) */
.pop-anchor { position: relative; display: inline-block; }
.customer-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 40;
  width: 320px; padding: 14px 16px; font-size: 13.5px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18); border-radius: 18px;
}
.pop-head { display: flex; align-items: center; gap: 10px; }
.pop-logo { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.pop-logo.cust-nologo { min-height: 44px; font-size: 18px; display: grid; }
.pop-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pop-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.pop-row { margin: 10px 0 0; }
.pop-specs { margin-top: 10px; display: grid; gap: 4px; }
.pop-spec {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  text-decoration: none; color: inherit; padding: 4px 8px; border-radius: 6px;
}
.pop-spec:hover { background: var(--grey); }
.pop-spec-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-new { max-width: 520px; margin-bottom: 20px; }
.cust-rows { display: grid; gap: 10px; }
.cust-row { display: flex; align-items: center; gap: 16px; padding: 10px 16px; text-decoration: none; color: inherit; }
.cust-row:hover { outline: 2px solid var(--red); outline-offset: -2px; }
.cust-row .cust-logowrap { width: 40px; height: 40px; }
.cust-row .cust-nologo { min-height: 40px; font-size: 16px; }
.cust-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cust-row-notes { font-size: 13px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-row .cust-meta { flex-shrink: 0; }

/* ============ Systems library tabs / Associated System form — pill segments ============ */
.tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.tabs a {
  padding: 10px 22px; font-weight: 700; font-size: 14px; color: var(--muted); text-decoration: none;
  background: var(--paper); border-radius: var(--radius-pill);
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: #fff; background: var(--red); }

.assoc-row { display: grid; grid-template-columns: 1fr 130px 220px 34px; gap: 8px; align-items: center; }
.assoc-row select, .assoc-row input { margin-top: 0; }
.assoc-row .assoc-remove { padding: 6px 0; }

/* ============ Composite System two-pane member picker ============ */
.picker { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.picker-pane { min-width: 0; }
.picker-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.picker-tab { border: 0; font: inherit; font-weight: 700; font-size: 13.5px; cursor: pointer;
  padding: 8px 18px; border-radius: var(--radius-pill); background: var(--grey); color: var(--muted); }
.picker-tab.active { background: var(--red); color: #fff; }
.picker-search { width: 100%; margin: 0 0 10px; }
.picker-lib { max-height: 440px; overflow-y: auto; overflow-x: hidden; gap: 10px; }
.picker-opt { width: 100%; text-align: left; font: inherit; align-items: center; }
.picker-opt-main { min-width: 0; }
.picker-opt .opt-name, .picker-opt .opt-desc { overflow-wrap: anywhere; }
.picker-order-head { font-weight: 700; font-size: 13.5px; margin-bottom: 10px; }
.picker-rows { display: grid; gap: 8px; }
.picker-row { display: grid; grid-template-columns: 26px auto 1fr auto; gap: 10px; align-items: center;
  border: 1.5px solid #DDDDD9; border-radius: 18px; padding: 10px 14px; background: #FAFAF8; }
.picker-num { font-weight: 800; color: var(--red-dark); text-align: center; }
.picker-row-name { min-width: 0; overflow-wrap: anywhere; }
.picker-row-tools { display: flex; gap: 6px; }
.picker-row-tools .btn { padding: 7px 13px; }
.picker-empty { margin: 0; padding: 18px; border: 1.5px dashed #ccc; border-radius: 18px; }
.picker-row-name { display: flex; flex-direction: column; gap: 2px; }
.picker-row-sub { font-size: 12.5px; }
.picker-chips { color: var(--muted); }
.picker-qty-warn { color: var(--warn); font-weight: 700; }
.picker-qty { margin: -2px 0 6px 36px; padding: 14px 16px; border: 1.5px dashed #ccc; border-radius: 16px; background: #FAFAF8; }
.picker-qty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.picker-qty-grid input { margin-top: 4px; }
.picker-qty-foot { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
@media (max-width: 700px) { .picker-qty-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .picker { grid-template-columns: 1fr; } .picker-lib { max-height: 300px; } }

/* New-category mini-form on the Associated System page */
.assoc-cat-line { display: flex; gap: 8px; align-items: center; }
.assoc-cat-line select { margin-top: 4px; flex: 1; }
.assoc-cat-line .btn { white-space: nowrap; }
.assoc-cat-new { margin-top: 10px; padding: 12px; border: 1.5px dashed #ccc; border-radius: 16px;
  display: grid; grid-template-columns: 1fr 170px auto auto; gap: 8px; align-items: center; }
.assoc-cat-new input { margin-top: 0; }
.assoc-cat-new .field-err, .assoc-cat-new p { grid-column: 1 / -1; }

/* 24 Sep 2026 meeting: wizard product search, location chips */
.opt-search { width: 100%; margin: 0 0 12px; }
.opt[hidden] { display: none; }
.chip-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line, #ddd);
  border-radius: 999px; font-size: 13px; cursor: pointer; background: #fff; }
.chip-check input { accent-color: var(--red); margin: 0; }
.sys-filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.sys-filter-row select { max-width: 220px; }
.tag-chip { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: #f1f1f1; color: #444; margin-left: 4px; }
tr.doc-superseded td { opacity: .6; }
.sec-mode { margin: 4px 0 10px; font-size: 13px; }
.sec-mode > label { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-weight: 600; cursor: pointer; }
.sec-mode > label input { accent-color: var(--red); margin: 0; }
.sec-notes { margin-top: 8px; }
.sec-notes textarea { min-height: 70px; }

/* Document Text card (new-format specs, public/js/specTexts.js) */
.text-group { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--meta); }
.text-block { border: 1px solid #E4E4E0; border-radius: 16px; padding: 12px 14px; margin: 8px 0; }
.text-block-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.text-block textarea { width: 100%; font: inherit; font-size: 14px; }
.text-card-field { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.text-flags { margin: 6px 0; padding-left: 18px; font-size: 13px; color: var(--red-dark); }
