:root{
  --gap:8px;
  --button-h:36px;
  --header-h:88px;
  --border:#9ca3af;
  --orange:#fed7aa;
  --orange-hover:#ffedd5;
  --black:#050505;
  --blue:#1557a5;
  --blue-hover:#0f4688;
  --blue-surface:#f3f8ff;
  --yellow:#6d28d9;
  --yellow-hover:#5b21b6;
  --yellow-surface:#faf7ff;
  --red:#c2410c;
  --red-hover:#9a3412;
  --red-surface:#fff8f2;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;background:#fff;color:#111}
body{overflow:hidden}
.pbs-shell{height:var(--header-h);position:relative;z-index:50;border-bottom:1px solid #222;background:#fff;display:flex;overflow:visible}
.control-panel{width:50%;min-width:0;padding:5px 8px;display:grid;grid-template-rows:36px 36px;gap:6px;overflow:hidden;background:var(--black);color:#fff}
.identity-row{display:grid;grid-template-columns:auto minmax(120px,1fr) auto;align-items:center;gap:8px;min-width:0}
.brand{text-align:center;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#fff}
.project-number{font-weight:600;white-space:nowrap;color:#fff;font-size:14.5px}
.shell-btn,.mode-btn{height:var(--button-h);min-height:var(--button-h);max-height:var(--button-h);min-width:0;border:1px solid rgba(0,0,0,.35);border-radius:4px;padding:0 9px;font-weight:700;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:6px;line-height:1;font-family:inherit;font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;box-sizing:border-box}
.shell-btn:focus-visible,.mode-btn:focus-visible,.context-btn:focus-visible,.drop-control:focus-visible{outline:3px solid #60a5fa;outline-offset:2px}
.shell-btn:disabled{opacity:.45;cursor:not-allowed}
.save-btn{background:#fff;color:#111;border-color:#d1d5db}
.save-btn:hover{background:#f3f4f6}
.save-btn:active{background:#e5e7eb}
.btn-icon{width:16px;height:16px;flex:0 0 16px;display:inline-block;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.mode-row{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;min-width:0;overflow:hidden}
.mode-btn{background:#3f3f46;color:#fff;border-color:#606067}
.mode-btn:hover{background:#52525b}
.mode-btn[data-mode="rooms-openings"].active{background:var(--blue);border-color:var(--blue);color:#fff}
.mode-btn[data-mode="rooms-openings"].active:hover{background:var(--blue-hover)}
.mode-btn[data-mode="boundaries"].active{background:#c59b00;border-color:#c59b00;color:#fff}
.mode-btn[data-mode="boundaries"].active:hover{background:#a98200}
.mode-btn[data-mode="fire-hazard"].active{background:var(--yellow);border-color:var(--yellow);color:#fff}
.mode-btn[data-mode="fire-hazard"].active:hover{background:var(--yellow-hover)}
.mode-btn[data-mode="fire-compartments"].active{background:var(--red);border-color:var(--red);color:#fff}
.mode-btn[data-mode="fire-compartments"].active:hover{background:var(--red-hover)}
.drop-control{position:absolute;right:0;top:0;height:var(--header-h);width:50%;border-left:1px solid var(--border);background:var(--orange);cursor:pointer;transition:width .18s ease,background .18s ease,box-shadow .18s ease;overflow:hidden;z-index:55}
.drop-control.loaded{width:var(--header-h);background:#fff;border:1px solid var(--border)}
.drop-control.loaded.expanded{width:50%;box-shadow:-8px 4px 20px rgba(0,0,0,.2)}
.drop-control.drag-active{width:50%;background:var(--orange-hover);border:3px dashed #f97316;box-shadow:-8px 4px 20px rgba(0,0,0,.2)}
.drop-inner{height:100%;display:flex;align-items:center;justify-content:center;gap:10px;padding:8px;white-space:nowrap}
.drop-icon{font-size:28px;font-weight:700;flex:0 0 auto}
.drop-copy{display:flex;flex-direction:column;min-width:0}
.drop-copy small{margin-top:4px;overflow:hidden;text-overflow:ellipsis}
.loaded:not(.expanded):not(.drag-active) .drop-copy{display:none}
.context-toolbar{height:42px;padding:5px 8px;display:flex;align-items:center;gap:8px;border-bottom:1px solid #cbd5e1;position:relative;z-index:20;transition:background-color .15s ease}
body.mode-rooms-openings .context-toolbar{background:var(--blue-surface)}
body.mode-boundaries .context-toolbar{background:#fff4b8}
body.mode-fire-hazard .context-toolbar{background:var(--yellow-surface)}
body.mode-fire-compartments .context-toolbar{background:var(--red-surface)}
/* Context controls intentionally retain the exact legacy button geometry. */
.context-btn{height:32px;min-height:32px;max-height:32px;border:none;border-radius:4px;cursor:pointer;font-weight:700;transition:background .1s;display:inline-flex;align-items:center;gap:5px;padding:0 14px;font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;font-size:13.5px;line-height:1;white-space:nowrap;box-sizing:border-box}
.context-btn .btn-icon{width:16px!important;height:16px!important;flex:0 0 16px!important}
.context-btn.openings{background:#3b82f6;color:#fff}
.context-btn.openings:hover{background:#2563eb;color:#fff}
.context-btn.hazard{background:#8b5cf6!important;color:#fff!important}
.context-btn.hazard:hover{background:#7c3aed!important;color:#fff!important}
.context-btn.compartment-gray,.context-btn.compartment-toggle{height:32px;min-height:32px;max-height:32px;line-height:1;padding:0 14px;gap:6px;font-weight:700;box-sizing:border-box}
.context-btn.compartment-gray{background:#f97316;color:#fff;border:1px solid #ea580c}
.context-btn.compartment-gray:hover{background:#ea580c}
.context-btn.compartment-toggle{background:#f97316;color:#fff;border:1px solid #ea580c}
.context-btn.compartment-toggle:hover{background:#ea580c;color:#fff}
.context-btn em{font-style:italic}
.context-btn sub{font-size:.75em;line-height:0;position:relative;vertical-align:baseline;bottom:-.25em}
.context-checkmark{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;min-width:16px;background:#fff;border:1px solid #64748b;border-radius:3px;color:#0f2a05;font-weight:900;line-height:1}
.workspace{height:calc(100vh - var(--header-h) - 42px);position:relative;transition:background-color .15s ease;padding:8px}
body.mode-rooms-openings .workspace{background:var(--blue-surface)}
body.mode-boundaries .workspace{background:#fff4b8}
body.mode-fire-hazard .workspace{background:var(--yellow-surface)}
body.mode-fire-compartments .workspace{background:var(--red-surface)}
.module-frame{position:absolute;inset:8px;width:calc(100% - 16px);height:calc(100% - 16px);border:0;background:transparent;display:none}
.module-frame.active{display:block}
.toast{position:fixed;right:16px;bottom:16px;z-index:100;padding:10px 14px;background:#111827;color:#fff;border-radius:6px;opacity:0;pointer-events:none;transform:translateY(8px);transition:.2s}
.toast.show{opacity:1;transform:none}
@media(max-width:850px){:root{--header-h:88px;--button-h:36px}.control-panel{width:calc(100% - var(--header-h))}.identity-row{grid-template-columns:auto 1fr}.brand{text-align:center}.project-number{grid-column:2;text-align:right;font-size:12px}.drop-control.empty,.drop-control.loaded.expanded,.drop-control.drag-active{width:70%}.save-btn span{display:none}.context-toolbar{overflow-x:auto}}
@media(prefers-reduced-motion:reduce){.drop-control,.toast,.context-toolbar,.workspace{transition:none}}

/* v1.0.3 visual containment and hierarchy */
.identity-row > *{min-width:0}
.save-btn{flex-shrink:0}
.brand{font-size:14px}
.project-number{font-size:14.5px;overflow:hidden;text-overflow:ellipsis}
.mode-btn{width:100%;max-width:100%}
@media(max-width:1100px){.mode-btn{font-size:13.5px;padding-inline:6px}.brand{font-size:13px}.project-number{font-size:14.5px}.save-btn{padding-inline:8px}}

/* v1.0.7: contextual controls use one foreground color in every mode. */
.context-btn,
.context-btn:hover,
.context-btn:active,
.context-btn:focus-visible,
.context-btn.compartment-toggle,
.context-btn.compartment-toggle:hover { color:#ffffff !important; }
.context-btn .context-checkmark {
  color:#ffffff !important;
  border-color:#ffffff !important;
  background:transparent !important;
}
.context-btn .context-checkmark.checked::after {
  content:'✓';
  font-size:15px;
  line-height:1;
  font-weight:900;
}

/* v1.0.16 mode surfaces match the corresponding table-row surfaces. */
:root{
  --blue-surface:rgb(192,225,255);
  --yellow-surface:#ede9fe;
  --red-surface:#ffedd5;
}


/* Editable project number keeps the header geometry unchanged. */
.project-number{cursor:text;display:flex;align-items:center;justify-content:flex-end;gap:4px;min-width:92px}
.project-number-input{width:42px;height:26px;margin:0;padding:1px 4px;border:1px solid #93c5fd;border-radius:3px;background:#fff;color:#111;font:600 14.5px/1 'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;text-align:center;outline:none}
.project-number-input:focus{border-color:#60a5fa;box-shadow:0 0 0 2px rgba(96,165,250,.35)}

/* v1.0.58: Obvody contextual control follows the yellow mode palette. */
body.mode-boundaries .context-btn.compartment-toggle {
  background:#c59b00 !important;
  border-color:#a98200 !important;
  color:#ffffff !important;
}
body.mode-boundaries .context-btn.compartment-toggle:hover {
  background:#a98200 !important;
  border-color:#8a6d00 !important;
  color:#ffffff !important;
}

/* v1.0.59: Obvody generation action uses the mode yellow. */
body.mode-boundaries .context-btn.boundary-action{background:#c59b00!important;border:1px solid #a98200!important;color:#fff!important}
body.mode-boundaries .context-btn.boundary-action:hover{background:#a98200!important;border-color:#8a6d00!important}

/* v1.0.64: three-column top control table with overlaying drop tile. */
:root{--header-h:88px;--header-square:88px}
.pbs-shell{height:var(--header-h);display:block;position:relative;overflow:visible;background:#fff}
.header-base{height:100%;display:grid;grid-template-columns:var(--header-square) minmax(0,1fr) var(--header-square);background:#fff}
.control-panel{width:auto;height:100%;padding:5px 8px;display:grid;grid-template-rows:36px 36px;gap:6px;overflow:hidden;background:var(--black);color:#fff}
.identity-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px;min-width:0}
.brand{text-align:left;padding-left:4px}
.save-tile{width:var(--header-square)!important;height:var(--header-square)!important;min-width:var(--header-square)!important;max-width:var(--header-square)!important;min-height:var(--header-square)!important;max-height:var(--header-square)!important;border-radius:0!important;border:1px solid var(--border)!important;background:#fff!important;color:#111!important;padding:0!important}
.save-tile .btn-icon{width:42px!important;height:42px!important;flex:0 0 42px!important;stroke-width:1.7!important}
.save-tile:hover:not(:disabled){background:#f3f4f6!important}.save-tile:active:not(:disabled){background:#e5e7eb!important}
.drop-tile-placeholder{width:var(--header-square);height:var(--header-square);background:#fff;border-left:1px solid var(--border)}
.drop-control{top:0;right:0;width:var(--header-square);height:var(--header-square);border:1px solid var(--border);border-radius:0;transition:width .18s ease,background .18s ease,box-shadow .18s ease;z-index:60}
.drop-control.empty{background:var(--orange)}
.drop-control.loaded{width:var(--header-square);height:var(--header-square);background:#fff}
.drop-control.expanded,.drop-control.loaded.expanded,.drop-control.empty.expanded,.drop-control.drag-active{width:75%;box-shadow:-8px 4px 20px rgba(0,0,0,.22)}
.drop-control.drag-active{background:var(--orange-hover);border:3px dashed #f97316}
.drop-control:not(.expanded):not(.drag-active) .drop-copy{display:none}
.drop-control:not(.expanded):not(.drag-active) .drop-icon{font-size:34px}
.mode-row{grid-template-columns:repeat(var(--mode-count,4),minmax(0,1fr))}
@media(max-width:850px){.header-base{grid-template-columns:var(--header-square) minmax(0,1fr) var(--header-square)}.control-panel{width:auto}.drop-control.expanded,.drop-control.loaded.expanded,.drop-control.empty.expanded,.drop-control.drag-active{width:82%}.save-tile{display:flex}.identity-row{grid-template-columns:minmax(0,1fr) auto}.project-number{grid-column:auto}.brand{text-align:left}}
/* Mode buttons share the middle-row width equally for any button count. */
.mode-row{grid-template-columns:none!important;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr)}
/* v1.0.64: Openings quantity-display toggle follows the blue mode palette. */
body.mode-rooms-openings .context-btn.openings-toggle{background:#3b82f6!important;border:1px solid #2563eb!important;color:#fff!important}
body.mode-rooms-openings .context-btn.openings-toggle:hover{background:#2563eb!important}

/* v1.0.77 */
.icon-btn:disabled,button:disabled,[aria-disabled="true"]{pointer-events:auto!important}


/* v1.0.77: inset rounded save/drop tiles. */
.save-tile,
.save-tile:hover:not(:disabled),
.save-tile:active:not(:disabled){
  background:#050505!important;
  color:#fff!important;
  border:0!important;
  border-radius:0!important;
}
.save-tile .save-icon{
  width:44px!important;
  height:44px!important;
  flex:0 0 44px!important;
  stroke:currentColor!important;
  stroke-width:1.8!important;
  stroke-linecap:round!important;
  stroke-linejoin:round!important;
  fill:none!important;
}
.drop-tile-placeholder{
  background:#050505!important;
  border-left:0!important;
}
.drop-control,
.drop-control.empty,
.drop-control.loaded,
.drop-control.expanded,
.drop-control.loaded.expanded,
.drop-control.empty.expanded,
.drop-control.drag-active{
  background:#050505!important;
  border:0!important;
  border-radius:0!important;
  padding:6px!important;
  overflow:hidden!important;
}
.drop-control .drop-inner{
  width:100%;
  height:100%;
  padding:8px;
  border:2px dashed #f97316;
  border-radius:11px;
  background:var(--orange);
  transition:background .18s ease,border-color .18s ease;
  overflow:hidden;
}
.drop-control.loaded:not(.expanded):not(.drag-active) .drop-inner{
  border-color:#fff;
  background:#9ca3af;
}
.drop-control.empty:not(.expanded):not(.drag-active) .drop-inner{
  border-color:#f97316;
  background:var(--orange);
}
.drop-control.expanded .drop-inner,
.drop-control.loaded.expanded .drop-inner,
.drop-control.empty.expanded .drop-inner{
  border-color:#f97316;
  background:var(--orange);
}
.drop-control.drag-active .drop-inner{
  border-color:#f97316;
  background:var(--orange-hover);
}
.drop-icon{
  width:40px;
  height:40px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 40px;
  color:#7c2d12;
}
.drop-icon svg{
  width:100%;
  height:100%;
  fill:none;
  stroke:currentColor;
  stroke-width:2.2;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.drop-control.loaded:not(.expanded):not(.drag-active) .drop-icon{color:#fff}
.drop-control:not(.expanded):not(.drag-active) .drop-icon{font-size:0}
.drop-control.expanded .drop-icon,.drop-control.drag-active .drop-icon{width:34px;height:34px;flex-basis:34px}


/* v1.0.77: balanced header spacing and clearer save/drop symbols. */
.header-base{
  gap:6px!important;
  background:#050505!important;
}
.save-tile{
  margin:0!important;
  padding:6px!important;
}
.save-tile .save-icon{
  width:42px!important;
  height:42px!important;
  flex-basis:42px!important;
  stroke-width:1.9!important;
  stroke-linecap:round!important;
  stroke-linejoin:round!important;
}
.drop-control{
  right:0!important;
  padding:6px!important;
}
.drop-icon{position:relative}
.drop-icon .drop-loaded-icon{display:none}
.drop-control.loaded .drop-icon .drop-upload-icon{display:none}
.drop-control.loaded .drop-icon .drop-loaded-icon{display:block}
.drop-control.loaded.expanded .drop-inner{
  border-color:#fff;
  background:#9ca3af;
}
.drop-control.loaded.expanded .drop-icon{color:#fff}


/* v1.0.77: exact outer-tile geometry and classic floppy icon. */
.header-base{
  gap:0!important;
  grid-template-columns:var(--header-square) minmax(0,1fr) var(--header-square)!important;
}
.control-panel{
  padding:5px 0!important;
}
.identity-row{
  padding-left:0!important;
  padding-right:0!important;
}
.brand{
  padding-left:0!important;
}
.project-number{
  margin-right:0!important;
  padding-right:0!important;
  justify-self:end!important;
}
.mode-row{
  margin-left:0!important;
  margin-right:0!important;
}
.mode-row .mode-btn:first-child{margin-left:0!important}
.mode-row .mode-btn:last-child{margin-right:0!important}
.save-tile{
  width:var(--header-square)!important;
  height:var(--header-square)!important;
  min-width:var(--header-square)!important;
  max-width:var(--header-square)!important;
  min-height:var(--header-square)!important;
  max-height:var(--header-square)!important;
  padding:6px!important;
}
.save-tile .save-icon{
  width:46px!important;
  height:46px!important;
  flex:0 0 46px!important;
  stroke-width:1.75!important;
  stroke-linecap:round!important;
  stroke-linejoin:round!important;
}
.drop-tile-placeholder,
.drop-control{
  width:var(--header-square)!important;
  height:var(--header-square)!important;
  min-width:var(--header-square)!important;
  min-height:var(--header-square)!important;
}
.drop-control{padding:6px!important}
.drop-control.expanded,
.drop-control.loaded.expanded,
.drop-control.empty.expanded,
.drop-control.drag-active{
  width:75%!important;
}


/* v1.0.80: five-cell centered identity row. */
.identity-row{
  --identity-logo-width:clamp(170px,22vw,220px);
  --identity-pbs-width:48px;
  display:grid!important;
  grid-template-columns:minmax(0,1fr) var(--identity-pbs-width) var(--identity-logo-width) var(--identity-pbs-width) minmax(0,1fr)!important;
  align-items:center!important;
  column-gap:0!important;
  width:100%;
  min-width:0;
  height:36px;
  padding:0!important;
  overflow:hidden;
}
.identity-flex-left,.identity-balance{min-width:0;height:100%}
.identity-logo-cell{
  width:var(--identity-logo-width);
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.identity-logo{
  display:block;
  width:100%;
  height:auto;
  max-height:31px;
  object-fit:contain;
  object-position:center;
}
.identity-pbs{
  width:var(--identity-pbs-width);
  min-width:var(--identity-pbs-width);
  height:100%;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  padding-left:5px;
  color:#fff;
  font-weight:700;
  font-size:18px;
  white-space:nowrap;
}
.identity-row .project-number{
  width:100%;
  min-width:0;
  height:100%;
  margin:0!important;
  padding:0!important;
  display:flex;
  align-items:center;
  justify-content:flex-end!important;
  justify-self:stretch!important;
  white-space:nowrap;
  overflow:visible;
}
.identity-row .project-number-input{flex:0 0 42px}
@media(max-width:760px){
  .identity-row{--identity-logo-width:150px;--identity-pbs-width:42px}
  .identity-logo{max-height:27px}
}

/* v1.0.89: Facade mode uses an unused teal palette. */
:root{--facade:#0f766e;--facade-hover:#115e59;--facade-surface:#ccfbf1}
.mode-btn[data-mode="facade"].active{background:var(--facade);border-color:var(--facade);color:#fff}
.mode-btn[data-mode="facade"].active:hover{background:var(--facade-hover)}
body.mode-facade .context-toolbar{background:var(--facade-surface)}
body.mode-facade .workspace{background:var(--facade-surface)}
body.mode-facade .context-btn.facade-action,body.mode-facade .context-btn.facade-toggle{background:var(--facade)!important;border:1px solid var(--facade-hover)!important;color:#fff!important}
body.mode-facade .context-btn.facade-action:hover,body.mode-facade .context-btn.facade-toggle:hover{background:var(--facade-hover)!important}
