
#factory-page{padding:26px 0 42px}
.factory-controls{display:flex;align-items:flex-end;gap:18px;padding:20px;border:1px solid var(--line);border-radius:5px;background:#fff;margin:22px 0}
.factory-controls>label{margin:0;font-size:11px;color:#587482}
.factory-controls>label:first-child{flex:1}
.factory-controls input,.factory-controls select,.factory-dialog-label input,.factory-dialog-label select{display:block;width:100%;border:1px solid var(--line);padding:9px 12px;border-radius:3px;background:#fcfdfe;color:var(--ink);font-size:12px;margin-top:6px}
.factory-rate-control{display:flex;align-items:center;gap:9px}
.factory-rate-control input{width:125px}
.factory-rate-control span{font:10px var(--mono);white-space:nowrap;color:var(--muted)}
.factory-controls .primary{margin-bottom:0;height:39px}
#factory-error{padding:14px 18px;border:1px solid #e9c1b7;color:#a64937;background:#fff4ed;border-radius:4px}
.factory-summary{display:grid;grid-template-columns:2fr 1fr 1fr;border:1px solid var(--line);border-radius:5px;background:#fff;margin-bottom:24px}
.factory-summary>div{padding:16px 20px;border-right:1px solid var(--line)}
.factory-summary>div:last-child{border:0}
.factory-summary small{display:block;font:9px var(--mono);letter-spacing:1px;color:var(--muted);margin-bottom:8px}
.factory-summary strong{display:block;font-size:22px;font-weight:500}
.factory-summary span{font-size:11px;color:var(--muted)}
.factory-map-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;background:#fff;border:1px solid var(--line);border-bottom:0;border-radius:5px 5px 0 0;padding:11px 15px}
.factory-map-toolbar>span{font:10px var(--mono);letter-spacing:1px}
.factory-map-toolbar small{display:block;letter-spacing:0;font:10px "Segoe UI",sans-serif;color:var(--muted);margin-top:4px}
.factory-map-toolbar>div{display:flex;align-items:center;gap:4px}
#factory-zoom-label{font:10px var(--mono);width:44px;text-align:center}
.factory-board{height:620px;max-height:75vh;min-height:380px;overflow:auto;border:1px solid #c4dce7;border-radius:0 0 5px 5px;background-color:#f2f8fb;background-image:linear-gradient(#dceaf140 1px,transparent 1px),linear-gradient(90deg,#dceaf140 1px,transparent 1px);background-size:25px 25px;cursor:grab;overscroll-behavior:contain}
.factory-board:active{cursor:grabbing}
#factory-stage{position:relative}
.factory-flows{position:absolute;inset:0;overflow:visible;pointer-events:none}
.factory-flow{fill:none;stroke:#52aacf;stroke-width:2}
.factory-flow.liquid{stroke:#a2a749;stroke-dasharray:6 4}
#factory-arrow path{fill:#52aacf}
.factory-flow-label rect{fill:#fff;stroke:#c3dfe9;stroke-width:1}
.factory-flow-label text{font:10px "Segoe UI",sans-serif;fill:#536f7e}
.factory-flow-label .flow-amount{font:11px Consolas,monospace;fill:#147ba6;font-weight:bold}
.factory-node{position:absolute;background:#fff;border:1px solid #a9d4e6;border-radius:5px;padding:12px;box-shadow:0 3px 12px #375b6810}
.factory-node.source{border-color:#b9cfd8;background:#fbfdfe}
.factory-node.target{border-color:#dbc252;background:#fffdf2}
.factory-node-title{display:flex;gap:10px;align-items:center;min-height:55px;margin-bottom:12px}
.factory-node-title .item-icon{width:44px;height:44px;flex-shrink:0}
.factory-node-title .item-icon .hd-icon{width:38px;height:38px}
.factory-node-title h3{font-size:13px;font-weight:600;line-height:1.3;margin:0 0 5px}
.factory-node-title span:not(.item-icon){font:10px var(--mono);color:#3185a8}
.factory-machine-grid{display:grid;grid-template-columns:repeat(8,34px);gap:1px;align-content:start;margin:10px 0 14px;background:#daecf2;border:1px solid #b9dce9;width:max-content}
.factory-machine-tile{width:34px;height:34px;border:0;border-radius:0;background:#f7fcff;padding:3px;display:grid;place-items:center}
.factory-machine-tile:hover{background:#d6f1fc;outline:1px solid #309ec8;position:relative;z-index:1}
.factory-machine-tile .hd-icon.tiny-thumb{width:28px;height:28px;margin:0}
.factory-machine-tile.partial{background:#fff1b5}
.factory-node-count strong{display:block;font-size:12px;margin-top:9px}
.factory-node-count small{display:block;font-size:10px;color:#78909e;margin-top:4px}
.factory-configure{margin-top:9px;padding:4px 0;font-size:10px}
.factory-legend{display:flex;flex-wrap:wrap;gap:16px;padding:15px 0;font-size:10px;color:#71828d}
.factory-legend span{display:flex;align-items:center;gap:5px}
.factory-legend i{width:9px;height:9px;border:1px solid #9bbecf}
.legend-source{background:#fff}.legend-machine{background:#d9f1fc}.legend-target{background:#f9df75}
.factory-warning{font-size:12px;padding:10px 14px;background:#fff9e1;border:1px solid #e8d797;border-radius:4px;color:#7c6925}
.factory-inventory,.factory-saved{border:1px solid var(--line);border-radius:4px;background:white;margin-top:18px;padding:16px}
.factory-inventory summary,.factory-saved summary{cursor:pointer;font-size:14px;font-weight:500}
.factory-inventory .search,.factory-saved .search{max-width:500px;margin:16px 0}
#factory-inventory{overflow:auto}
#factory-inventory table{border-collapse:collapse;width:100%;font-size:12px}
#factory-inventory td,#factory-inventory th{border-bottom:1px solid #e8eef1;text-align:left;padding:10px}
#factory-inventory th{font:10px var(--mono);color:#71828d}
#factory-inventory td:first-child{white-space:nowrap}
.factory-dialog-label{display:block;font-size:12px;color:#587482;margin:18px 0}
.factory-applied-recipe{padding:15px;background:#f5fbfe;border:1px solid #d3e7f0;border-radius:4px;margin-top:20px}
.factory-applied-recipe h3{font-size:17px;margin:0 0 15px;font-weight:500}
.factory-applied-recipe>div{display:flex;align-items:center;flex-wrap:wrap;gap:6px}
.factory-saved-plan{display:flex;width:100%;justify-content:space-between;gap:15px;padding:12px;border:1px solid var(--line);border-radius:3px;background:#fbfdfe;margin:8px 0;text-align:left}
.factory-saved-plan strong{font-size:12px;font-weight:500}.factory-saved-plan small{font:10px var(--mono);color:#147ba6}
@media(max-width:900px){.factory-controls{flex-wrap:wrap}.factory-controls>label:first-child{flex-basis:100%}.factory-summary{grid-template-columns:1fr 1fr}.factory-summary>div:first-child{grid-column:1 / -1;border-bottom:1px solid var(--line)}.factory-map-toolbar{flex-wrap:wrap}.factory-board{height:500px}.factory-summary strong{font-size:18px}}


.factory-node-title{cursor:grab;touch-action:none;user-select:none}
.factory-node-title:active{cursor:grabbing}

.factory-item-link{border:0;background:transparent;padding:0;text-align:left;color:inherit;font:inherit;cursor:pointer}
.factory-item-link:hover{color:#147ba6;text-decoration:underline}
.factory-flow-label{pointer-events:auto;cursor:pointer}
.factory-flow-label:hover rect,.factory-flow-label:focus rect{stroke:#147ba6;fill:#effaff}

.factory-product-control{flex:1;min-width:240px;font-size:11px;color:#587482}
.factory-product-control>label{margin:0}
.factory-product-picker{position:relative;margin-top:6px}
#factory-product-trigger{display:flex;align-items:center;gap:10px;width:100%;min-height:44px;background:#fcfdfe;border:1px solid var(--line);border-radius:3px;padding:6px 12px;text-align:left;color:var(--ink);font-size:12px}
#factory-product-trigger .picker-chevron{margin-left:auto;color:#3185a8}
#factory-product-options{position:absolute;top:calc(100% + 4px);left:0;right:0;max-height:320px;overflow:auto;overscroll-behavior:contain;background:#fff;border:1px solid #a9d4e6;border-radius:4px;box-shadow:0 8px 24px #375b6825;z-index:20;padding:4px}
#factory-product-options[hidden]{display:none}
#factory-product-options button{display:flex;align-items:center;gap:10px;width:100%;min-height:45px;padding:6px 10px;background:white;border:1px solid transparent;text-align:left;color:var(--ink);font-size:12px}
#factory-product-options button:hover,#factory-product-options button:focus{background:#effaff;border-color:#b9dce9;outline:none}
#factory-product-options button[aria-selected=true]{background:#fff8dd}
#factory-product-options .tiny-thumb,#factory-product-trigger .tiny-thumb{width:32px;height:32px;margin:0;flex-shrink:0}
#factory-product-options small,#factory-product-trigger small{color:var(--muted)}
@media(max-width:900px){.factory-product-control{flex-basis:100%}}

.factory-thumbnail-link{display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;background:#fff;padding:0;border-radius:3px;cursor:pointer;flex-shrink:0;vertical-align:middle}
.factory-thumbnail-link:hover,.factory-thumbnail-link:focus-visible{border-color:#52aacf;background:#effaff;outline:none}
.factory-applied-recipe .ingredient{display:inline-flex;align-items:center;gap:6px}
.factory-thumbnail-link .tiny-thumb{margin:0}
.factory-flow-label{pointer-events:none;cursor:default}
.factory-flow-label foreignObject{pointer-events:auto}
.factory-flow-label:hover rect{stroke:#c3dfe9;fill:#fff}
.factory-flow-label .factory-thumbnail-link{width:32px;height:32px}
.factory-flow-label .tiny-thumb{width:28px;height:28px}

/* Coins harmonisés des blocs et panneaux. */
.card,.home-shortcut,.machine-tile,.use-result,.flow-box,.production,.unlock-section,.ingredient-origin,.science-filters,.object-type-filters,.factory-controls,.factory-summary,.factory-node,.factory-warning,.factory-inventory,.factory-saved,.factory-applied-recipe,.factory-saved-plan,#factory-error,#factory-product-options{border-radius:10px}
dialog{border-radius:10px}
.factory-map-toolbar{border-radius:10px 10px 0 0}
.factory-board{border-radius:0 0 10px 10px}


/* Arrondis des contrôles de l’interface. */
button,input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea,.search,.chip,.ingredient,.factory-controls input,.factory-controls select,.factory-dialog-label input,.factory-dialog-label select,#detail-machine,.list-search input,.select-search>input,.ingredient-variant select,.machine-link,.completion-button,#factory-product-trigger,#factory-product-options button,.factory-thumbnail-link,.factory-machine-tile{border-radius:10px}


body button,body input:not([type=checkbox]):not([type=radio]):not([type=hidden]),body select,body textarea{border-radius:10px!important}


.production #plan-from-objective{display:inline-flex;align-items:center;justify-content:center;margin:16px 0 2px;padding:10px 16px;min-height:40px;border:1px solid #d2b54c;background:#fffdf3;color:#65531b;font-size:12px;font-weight:600;line-height:1.4;box-shadow:none}
.production #plan-from-objective:hover{background:#fff3bc;border-color:#b99a2f}


.factory-rate-field{font-size:11px;color:#587482}
.factory-rate-field>label{margin:0}
.factory-unit-toggle{display:flex;gap:4px;margin-top:7px}
.factory-unit-toggle button{padding:5px 10px;border:1px solid var(--line);background:white;color:#587482;font-size:11px}
.factory-unit-toggle button[aria-pressed=true]{background:#e8f7ff;border-color:#73c9ed;color:#147ba6}

.factory-port{position:absolute;width:10px;height:10px;border:1px solid #288bb4;background:#e9f8ff;border-radius:50%;z-index:3;pointer-events:none}
.factory-port.out{background:#f4d45e;border-color:#b59523}
.factory-port.right{right:-5px;transform:translateY(-50%)}
.factory-port.left{left:-5px;transform:translateY(-50%)}
.factory-port.top{top:-5px;transform:translateX(-50%)}
.factory-port.bottom{bottom:-5px;transform:translateX(-50%)}
.factory-port.right.port-0,.factory-port.left.port-0{top:25%}
.factory-port.right.port-1,.factory-port.left.port-1{top:50%}
.factory-port.right.port-2,.factory-port.left.port-2{top:75%}
.factory-port.top.port-0,.factory-port.bottom.port-0{left:25%}
.factory-port.top.port-1,.factory-port.bottom.port-1{left:50%}
.factory-port.top.port-2,.factory-port.bottom.port-2{left:75%}

/* Les ancrages restent disponibles ; seuls les liens actifs ont un repère. */
.factory-port{visibility:hidden;width:5px;height:5px;border:0;background:#52aacf}
.factory-port.connected{visibility:visible}
.factory-port.out{background:#52aacf}
.factory-port.right{right:-2.5px}.factory-port.left{left:-2.5px}
.factory-port.top{top:-2.5px}.factory-port.bottom{bottom:-2.5px}

/* Grand espace de travail pour le plan d’usine. */
.factory-board{height:calc(100vh - 120px);max-height:none;min-height:700px}
@media(max-width:900px){.factory-board{height:calc(100vh - 100px);min-height:550px}}


/* Frontière visible de placement ; le plan grandit avec les boîtes. */
#factory-stage:before{content:'';position:absolute;inset:10px;border:1px dashed #73afc7;pointer-events:none;border-radius:10px;background:#e7f5fb30}
#factory-stage:after{content:'Zone de placement';position:absolute;left:18px;top:-10px;padding:3px 8px;background:#f2f8fb;color:#578499;font:11px Consolas,monospace;border-radius:5px;pointer-events:none}


/* L’interface ne sélectionne pas le texte pendant les interactions. */
body,body *{-webkit-user-select:none;user-select:none}
input,textarea{-webkit-user-select:text;user-select:text}


.factory-machine-tile.factory-add-machine{color:#1685b1;background:#eaf8ff;border:1px dashed #75bfdc;font:500 25px/1 "Segoe UI",sans-serif;padding:0;transition:background .15s,color .15s}
.factory-machine-tile.factory-add-machine:hover{background:#fff1b5;color:#7c661b;border-color:#d0b64f;outline:none}

.factory-machine-tile.factory-add-machine{position:relative;display:grid;place-items:center;gap:0;font-size:0;line-height:0}
.factory-add-machine:before,.factory-add-machine:after{content:'';position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);background:currentColor;border-radius:2px;pointer-events:none}
.factory-add-machine:before{width:16px;height:2px}
.factory-add-machine:after{width:2px;height:16px}


/* Macro : interfaces externes des plans enregistrés. */
#factory-macro[hidden]{display:none}
#factory-page.macro-active> :not(#factory-macro):not(#factory-view-tabs){display:none!important}
#factory-page:not(.macro-active)>#factory-macro{display:none}
.macro-nav{margin-right:8px}
#factory-macro>.search{max-width:520px;margin:20px 0}
#macro-board{position:relative;height:calc(100vh - 180px);min-height:650px;overflow:hidden;border:1px solid #c4dce7;border-radius:0 0 10px 10px;background-color:#f2f8fb;background-image:linear-gradient(#dceaf150 1px,transparent 1px),linear-gradient(90deg,#dceaf150 1px,transparent 1px);background-size:25px 25px;overscroll-behavior:contain;cursor:grab;touch-action:none}
#macro-board:active{cursor:grabbing}
#macro-stage{position:absolute;inset:0;transform-origin:0 0}
.macro-flows{position:absolute;left:0;top:0;width:1px;height:1px;overflow:visible;pointer-events:none}
.macro-flow-text{font:11px Consolas,monospace;fill:#147ba6;paint-order:stroke;stroke:#f2f8fb;stroke-width:5px;stroke-linejoin:round}
.macro-factory{position:absolute;border:1px solid #9ccbdd;border-radius:10px;background:#fff;box-shadow:0 4px 16px #375b6814;cursor:pointer;overflow:visible}
.macro-factory:hover,.macro-factory:focus-visible{border-color:#2795bf;outline:2px solid #8bd5f040}
.macro-handle{height:64px;padding:13px 16px;border-bottom:1px solid #e2edf2;cursor:grab;background:#f9fcff;border-radius:10px 10px 0 0;box-sizing:border-box}
.macro-handle h3{margin:0 0 5px;font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.macro-handle small{font-size:10px;color:#78909e}
.macro-io{display:grid;grid-template-columns:1fr 1fr;gap:12px;padding:18px 10px 18px 0;align-items:center}
.macro-inputs{display:grid;gap:0}
.macro-product{position:relative;display:flex;gap:7px;align-items:center;min-height:48px;font-size:11px}
.macro-product strong{font-size:10px;font-weight:500;display:block;max-width:124px;line-height:1.25}
.macro-product small{display:block;color:#147ba6;font:10px Consolas,monospace;margin-top:4px}
.macro-resource-icon{display:grid;place-items:center;width:38px;height:38px;border:1px solid #d4e5ec;border-radius:8px;background:white;flex-shrink:0}
.macro-resource-icon .hd-icon{width:32px;height:32px}
.macro-input{padding-left:10px}
.macro-input:before{content:'';position:absolute;left:-3px;top:50%;width:6px;height:6px;border-radius:50%;background:#52aacf}
.macro-output{flex-direction:row-reverse;text-align:right}
.macro-output:after{content:'';position:absolute;right:-13px;top:50%;width:6px;height:6px;border-radius:50%;background:#c8a934}
.macro-product .macro-external{font:9px "Segoe UI",sans-serif;color:#85969f}
.macro-byproducts{position:absolute;bottom:0;left:0;right:0;min-height:66px;padding:6px 12px;border-top:1px solid #eee5be;background:#fffdf2;border-radius:0 0 10px 10px;display:flex;align-items:center;gap:10px}
.macro-byproducts>small{font:8px Consolas,monospace;color:#8c7a40}
.macro-byproduct{flex:1;min-width:0}
.macro-byproduct:after{content:'';position:absolute;bottom:-7px;left:50%;width:6px;height:6px;border-radius:50%;background:#c8a934}
.macro-byproduct .macro-resource-icon{width:28px;height:28px}.macro-byproduct .hd-icon{width:24px;height:24px}
.macro-empty{padding:35px;width:460px;background:white;border:1px solid #c4dce7;border-radius:10px;cursor:default}
.macro-empty p{font-size:13px;color:#78909e}

.macro-handle{display:block}.macro-handle h3{max-width:100%}.macro-handle>small{display:block}


.macro-product .macro-balance{font-weight:600}
.macro-product .macro-balance.surplus{color:#23854c}
.macro-product .macro-balance.shortage{color:#c4453e}
.macro-product .macro-primary.balanced{color:#147ba6;font-weight:600}

#factory-view-tabs{display:flex;gap:6px;padding:6px;margin:0 0 24px;border:1px solid #c4dce7;border-radius:10px;background:#fff;width:fit-content}
#factory-view-tabs a{padding:12px 20px;color:#587482;text-decoration:none;font-size:13px;border-radius:8px;border:1px solid transparent}
#factory-page.macro-active .factory-view-macro,#factory-page:not(.macro-active) .factory-view-detail{background:#e7f6ff;color:#147ba6;border-color:#a9d4e6;font-weight:600}
.factory-save-help{padding:12px 16px;border:1px solid #e7d68e;border-radius:10px;background:#fffbea;color:#7c6925;font-size:12px}
#factory-page>.section-title>div:last-child{display:flex;flex-wrap:wrap;align-items:center;gap:8px}

/* Les plans occupent la fenêtre, sans ajouter un défilement de page. */
html:has(#factory-page:not([hidden])),body:has(#factory-page:not([hidden])){height:100%;overflow:hidden}
body:has(#factory-page:not([hidden])) .workspace{height:100dvh;display:flex;flex-direction:column;min-height:0}
body:has(#factory-page:not([hidden])) .workspace>header{flex:0 0 76px}
body:has(#factory-page:not([hidden])) main{flex:1;min-height:0;width:100%;overflow:hidden}
#factory-page:not([hidden]){position:relative;height:100%;min-height:0;padding:12px 0 76px;display:flex;flex-direction:column}
#factory-page:not([hidden])>*{flex-shrink:0}
#factory-page #factory-view-tabs{margin-bottom:10px}
#factory-page>.section-title{margin:0 0 8px}
#factory-page .section-title h2{margin:5px 0;font-size:23px}
#factory-page .section-title p{margin:4px 0}
#factory-page .factory-save-help{margin:0 0 8px;padding:7px 12px}
#factory-page .factory-controls{margin:0 0 10px;padding:10px 14px;gap:12px}
#factory-page .factory-summary{margin-bottom:10px}
#factory-page .factory-summary>div{padding:8px 14px}
#factory-page .factory-summary small{margin-bottom:3px}
#factory-page .factory-summary strong{font-size:18px}
#factory-page .factory-map-toolbar{padding:7px 12px}
#factory-page #factory-board{height:auto;min-height:0;max-height:none;flex:1 1 0;scrollbar-width:none}
#factory-board::-webkit-scrollbar{display:none}
#factory-page .factory-legend{padding:5px 0;gap:12px}
#factory-page #factory-warnings{max-height:60px;overflow:auto}
#factory-page .factory-warning{margin:4px 0;padding:5px 10px}
#factory-page .factory-inventory,#factory-page .factory-saved{position:absolute;bottom:30px;width:calc(50% - 6px);max-height:min(45dvh,420px);overflow:auto;margin:0;padding:10px 14px;z-index:5;box-shadow:0 -4px 14px #375b6810}
#factory-page .factory-inventory{left:0}
#factory-page .factory-saved{right:0}
#factory-page>.source-note{position:absolute;bottom:0;left:0;right:0;font-size:9px;line-height:1.25;margin:4px 0;max-height:25px;overflow:auto}
#factory-page.macro-active{padding-bottom:12px}
#factory-page.macro-active #factory-macro{display:flex;flex-direction:column;flex:1;min-height:0}
#factory-macro>*{flex-shrink:0}
#factory-macro>.section-title{margin:0 0 8px}
#factory-macro>.search{margin:0 0 10px}
#factory-macro #macro-board{height:auto;min-height:0;flex:1 1 0}
#factory-macro>p.muted{font-size:10px;line-height:1.35;margin:6px 0 0}
#factory-macro #macro-errors{max-height:45px;overflow:auto}
@media(max-height:800px){
 #factory-page .section-title .eyebrow,#factory-page .section-title p,#factory-page .factory-save-help{display:none}
 #factory-page #factory-view-tabs a{padding:6px 14px}
 #factory-page .factory-controls{padding:7px 10px}
 #factory-page .factory-map-toolbar small{display:none}
}


#factory-macro>.search{flex:0 0 auto;min-height:40px}
@media(max-height:800px){
 #factory-page:not(.macro-active){padding-bottom:58px}
 #factory-page:not(.macro-active) .factory-legend,#factory-page>.source-note{display:none}
 #factory-page .factory-inventory,#factory-page .factory-saved{bottom:8px}
 #factory-page .factory-summary span{display:none}
 #factory-page .factory-summary>div{padding:5px 12px}
 #factory-page .factory-product-control{display:grid;grid-template-columns:1fr 1fr;gap:0 8px;align-items:end}
 #factory-page .factory-product-control>label{grid-column:1/-1}
 #factory-page .factory-product-picker{margin:6px 0 0}
 #factory-page .factory-rate-field{display:grid;grid-template-columns:auto auto;gap:2px 5px;align-items:center}
 #factory-page .factory-unit-toggle{margin:0}
 #factory-page .factory-rate-control{grid-column:1/-1}
 #factory-page #factory-view-tabs{margin-bottom:5px}
}


.factory-mining-controls{margin:12px 0;padding-top:10px;border-top:1px solid #d9e9ef;cursor:default}
.factory-mining-controls label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:10px;color:#587482;margin:8px 0}
.factory-mining-controls input{width:75px;padding:6px;border:1px solid #c4dce7;background:white;color:#203744;font-size:11px}
.factory-mining-controls small{display:block;font-size:10px;color:#147ba6;margin-top:8px}

.factory-blank-message{position:absolute;left:35px;top:35px;margin:0;padding:18px 22px;border:1px dashed #a9cddc;border-radius:10px;background:#ffffffd9;color:#587482;font-size:14px}

.factory-node-actions{display:flex;flex-direction:column;align-items:flex-start;gap:7px;margin-top:12px}
.factory-action-icon,.factory-node-actions .factory-configure{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;margin:0;border:1px solid #c2dfeb;background:#f3fbff;color:#3185a8;cursor:pointer}
.factory-action-icon:hover{border-color:#64b9dc;background:#e3f5ff;color:#147ba6}
.factory-action-icon:focus-visible{outline:2px solid #52aacf;outline-offset:2px}
.factory-action-icon svg{display:block;flex-shrink:0}

/* Actions compactes, indépendantes de la hauteur du contenu. */
.factory-node-actions{position:absolute;top:10px;right:10px;margin:0;gap:5px;z-index:4}
.factory-node-actions .factory-action-icon{width:27px;height:27px}
.factory-node-actions svg{width:17px;height:17px}
.factory-node-title{padding-right:34px}


#macro-new{cursor:grab;touch-action:none}#macro-new:active{cursor:grabbing}
.macro-drop-ghost{position:fixed;z-index:9999;pointer-events:none;padding:15px 22px;border:1px dashed #52aacf;border-radius:10px;background:#f6fcffed;box-shadow:0 8px 25px #375b6825;color:#147ba6;font-size:13px;transform:translate(10px,10px)}
.macro-drop-ghost[hidden]{display:none}
#macro-board.macro-drop-ready{outline:2px dashed #52aacf;outline-offset:-6px}
.macro-draft-hint{font-size:12px;color:#147ba6;line-height:1.6;padding:8px}

#macro-new{display:inline-flex;flex-direction:column;gap:5px;white-space:nowrap;min-width:180px}#macro-new small{font-size:10px;font-weight:400;opacity:.75}


/* Empêche les marges de caméra de sortir du conteneur de défilement. */
#factory-size{display:flow-root;position:relative}


.factory-board{overflow-anchor:none}


/* Le bouton d’ajout reste en première position dans chaque grille. */
.factory-machine-grid>.factory-add-machine{order:-1}


#factory-view-tabs span.factory-view-detail{display:inline-block;padding:12px 20px;font-size:13px;border-radius:8px;border:1px solid #a9d4e6;background:#e7f6ff;color:#147ba6;font-weight:600}

#factory-analysis[hidden]{display:none}
#factory-page.analysis-active>:not(#factory-analysis):not(#factory-view-tabs){display:none!important}
#factory-page:not(.analysis-active)>#factory-analysis{display:none}
#factory-page.analysis-active #factory-view-tabs .factory-view-analysis{background:#e7f6ff;color:#147ba6;border-color:#a9d4e6;font-weight:600}
.analysis-section{margin:24px 0;padding:20px;border:1px solid #d3e4ec;border-radius:10px;background:white}
.analysis-section>h3{font-size:18px;font-weight:500;margin:0 0 16px}.analysis-section>summary{cursor:pointer;font-size:16px}
.analysis-section>.search{max-width:500px;margin:16px 0}
.analysis-table-wrap{overflow:auto}.analysis-table{border-collapse:collapse;width:100%;font-size:12px}
.analysis-table th{font:10px Consolas,monospace;color:#71828d;text-align:left;white-space:nowrap}
.analysis-table th,.analysis-table td{padding:13px 10px;border-bottom:1px solid #e4edf2;vertical-align:top}
.analysis-table td:nth-child(2),.analysis-table td:nth-child(3),.analysis-table td:nth-child(4){white-space:nowrap;font:11px Consolas,monospace}
.analysis-item{display:flex;gap:10px;align-items:center;min-width:175px}.analysis-item strong{font-weight:500}.analysis-item .hd-icon{width:38px;height:38px}
.analysis-surplus-amount{color:#23854c;font-weight:600!important}.analysis-shortage-amount{color:#c4453e;font-weight:600!important}
.analysis-adjustment{display:flex;flex-direction:column;gap:5px;min-width:175px;margin-bottom:12px}.analysis-adjustment strong{font-weight:600;font-size:12px}.analysis-adjustment a{color:#147ba6;text-decoration:none;font-size:11px}

#macro-auto{display:inline-flex;align-items:center;gap:7px;white-space:nowrap}#macro-layout-undo{white-space:nowrap}
#macro-layout-undo:disabled{opacity:.4;cursor:default}

.personal-needs-form{display:flex;gap:14px;align-items:flex-end;flex-wrap:wrap;margin:18px 0}.personal-needs-form>label:first-child{flex:1;min-width:240px}.personal-needs-form>label:nth-child(2){width:190px}.personal-needs-form button{margin-bottom:10px}.personal-covered{color:#23854c}.personal-missing{color:#c4453e}.personal-breakdown{display:block;margin-top:6px;font:10px Segoe UI,sans-serif;color:#71828d}.personal-reserve{display:block;margin-top:10px;border-color:#c4dce7;background:#f2faff;color:#147ba6}


/* L'analyse défile dans l'espace disponible sous les onglets. */
#factory-page.analysis-active{padding-bottom:12px}
#factory-page.analysis-active>#factory-analysis{flex:1 1 0;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-right:10px}

.factory-analysis-shortcut{display:inline-flex;align-items:center;justify-content:center;padding:9px 13px;border:1px solid #c4dce7;border-radius:10px;color:#147ba6;background:#f2faff;text-decoration:none;font-size:12px;white-space:nowrap}.factory-analysis-shortcut:hover{background:#e3f5ff;border-color:#73bddb}


.analysis-finished-actions{display:flex;align-items:center;justify-content:space-between;gap:12px}
.analysis-factory-links{display:flex;flex-direction:column;gap:7px;min-width:140px}
.analysis-factory-links a{font-size:11px;color:#147ba6;text-decoration:none}.analysis-factory-links a:hover{text-decoration:underline}
.personal-reserve.personal-reserve-icon{display:flex;align-items:center;justify-content:center;width:32px;height:32px;min-width:32px;margin:8px 0 0 auto;padding:0}
.analysis-finished-actions .personal-reserve-icon{margin-top:0}
.personal-reserve-icon svg{display:block;flex-shrink:0}

.analysis-ingredient-link{width:42px;height:42px}.analysis-ingredient-link:hover{border-color:#52aacf;background:#effaff}

/* Les vignettes suivent l’arrondi des contrôles. */
.hd-icon,.game-thumb,.factory-thumbnail-link img,.analysis-ingredient-link img{border-radius:10px}
.factory-thumbnail-link{overflow:hidden}


#factory-stage:after{content:none}


/* Machines partiellement utilisées : jaune plus contrasté, lisible au dézoom. */
.factory-machine-tile.partial{background:#ffe06b;box-shadow:inset 0 0 0 2px #e5a800,0 0 8px 2px #ffc82b80;position:relative;z-index:1}
.factory-machine-tile.partial:hover{background:#ffd23f;box-shadow:inset 0 0 0 2px #c58c00,0 0 11px 3px #ffc82ba6}


/* Survol des connexions : zone confortable et premier plan pour trait + texte. */
.flow-hit{fill:none;stroke:transparent;stroke-width:14;pointer-events:stroke}
.flow-connection .factory-flow{pointer-events:stroke}
.flow-connection .macro-flow-text,.flow-connection .factory-flow-label{pointer-events:auto}
.factory-flows.flow-hover-active,.macro-flows.flow-hover-active{z-index:20}
.flow-connection.flow-highlight .factory-flow{stroke:#067ba8;stroke-width:4;filter:drop-shadow(0 0 3px #59c9ef)}
.flow-connection.flow-highlight .macro-flow-text{fill:#055c80;stroke:#fff3ac;stroke-width:7px;font-weight:700}
.flow-connection.flow-highlight .factory-flow-label rect{fill:#fff3ac;stroke:#067ba8;stroke-width:2}
.flow-connection.flow-highlight .factory-flow-label text{fill:#055c80;font-weight:700}

.disk-save-status{font-size:11px;color:#568394}.disk-save-status.disk-save-error{color:#bc432e}

/* Options de copie locale facultative, indépendantes du serveur. */
#workspace-backup{width:min(620px,calc(100vw - 40px));max-height:85vh;overflow:auto;padding:26px;color:#294957}
#workspace-backup p{font-size:13px;line-height:1.6}
.workspace-file-settings{border:1px solid #c8e0eb;border-radius:10px;padding:16px;margin:20px 0;background:#f7fcff}
.workspace-file-settings h3{margin:0 0 8px;font-size:15px}
.workspace-backup-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px}
.workspace-backup-actions button{padding:10px 14px}
#workspace-backup [hidden]{display:none!important}
