/* BAKE v3.0 · 도구 전환 + 발주 */

/* 좌측 상단 도구 전환 버튼 */
.mast-left{display:flex;align-items:center;gap:10px;min-width:0}
body:not(.tool-order) header.mast{flex-wrap:nowrap}
@media(max-width:430px){body:not(.tool-order) .mast-left .brand span{display:none}}
.tool-wrap{position:relative;flex:none}
.tool-btn{width:40px;height:40px;border-radius:50%;border:1px solid #dfe5db;background:#fff;display:grid;place-items:center;padding:0;color:#466d53;box-shadow:0 1px 4px #1b34200d;transition:background .15s,transform .1s}
.tool-btn svg{width:18px;height:18px;fill:currentColor}
.tool-btn:active{transform:scale(.94)}
.tool-btn[aria-expanded="true"]{background:#2f4c39;color:#fff;border-color:#2f4c39}
.tool-menu{position:absolute;top:48px;left:0;z-index:120;min-width:226px;background:#fff;border:1px solid #e3e9e1;border-radius:16px;padding:6px;box-shadow:0 12px 32px #13251a24}
.tool-menu[hidden]{display:none}
.tool-menu button{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:56px;border:0;background:transparent;border-radius:11px;padding:9px 12px;text-align:left;color:#2c3d30}
.tool-menu button:hover,.tool-menu button:focus-visible{background:#f2f5f0}
.tool-menu b{display:block;font-size:15px;font-weight:850}
.tool-menu small{display:block;font-size:12px;color:#8a978b;margin-top:2px}
.tool-menu i{font-style:normal;font-weight:900;color:#2f4c39;opacity:0}
.tool-menu [aria-checked="true"] i{opacity:1}
.tool-menu [aria-checked="true"]{background:#eef3ec}

/* 발주 모드일 때 기존 화면 숨김 (기존 코드는 그대로) */
#orderRoot{display:none}
body.tool-order #orderRoot{display:block}
body.tool-order main.app > :not(.mast):not(#orderRoot){display:none!important}
body.tool-order .mast .topactions{display:none}
body.ord-locked{overflow:hidden}

/* 발주 화면 */
.ord-root{padding-bottom:calc(96px + env(safe-area-inset-bottom))}
.ord-top{position:sticky;top:0;z-index:20;background:#f7f7f3;padding:4px 0 8px;margin:0 -19px;padding-left:19px;padding-right:19px}
.ord-search{position:relative;display:flex;align-items:center}
.ord-search svg{position:absolute;left:14px;width:18px;height:18px;fill:none;stroke:#8a988b;stroke-width:2;stroke-linecap:round;pointer-events:none}
.ord-search input{width:100%;height:50px;border:1px solid #dce5da;border-radius:14px;background:#fff;padding:0 44px 0 42px;font-size:16px;color:#223324;-webkit-appearance:none;appearance:none}
.ord-search input::placeholder{color:#a3ada2}
.ord-search input::-webkit-search-cancel-button{display:none}
.ord-search input:focus{outline:none;border-color:#6f9278;box-shadow:0 0 0 3px #6f927822}
.ord-search button{position:absolute;right:4px;width:42px;height:42px;border:0;background:transparent;font-size:22px;color:#8a988b;border-radius:10px}
.ord-tabs{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;margin-top:9px;padding-bottom:1px}
.ord-tabs::-webkit-scrollbar{display:none}
.ord-tabs button{flex:none;min-height:40px;padding:0 14px;border-radius:20px;border:1px solid #dce5da;background:#fff;color:#5b6b5c;font-size:14px;font-weight:780;white-space:nowrap}
.ord-tabs button.on{background:#2f4c39;border-color:#2f4c39;color:#fff}
.ord-tabs button b{display:inline-block;min-width:20px;height:20px;line-height:20px;border-radius:10px;background:#c2492f;color:#fff;font-size:12px;text-align:center;padding:0 5px;margin-left:3px}
.ord-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:2px 1px 6px;min-height:36px}
.ord-status{font-size:12px;color:#6d806f;line-height:1.4}
.ord-status.good:before{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;background:#5c9a6b;margin-right:6px;vertical-align:1px}
.ord-status.warn{color:#9a5d33}
.ord-status.loading{color:#8a948a}
.ord-edit-toggle{flex:none;border:0;background:none;color:#5e7a64;font-size:13px;font-weight:800;min-height:40px;padding:0 4px}
.ord-edit-toggle.on{color:#fff;background:#2f4c39;border-radius:10px;padding:0 14px}
.ord-additem{width:100%;min-height:50px;border:1.5px dashed #b9cbb9;border-radius:14px;background:#fbfcfa;color:#3e6247;font-weight:850;font-size:14px;margin:0 0 8px}

.ord-vendor{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin:20px 2px 4px;font-size:19px;letter-spacing:-.04em}
.ord-vendor:first-child{margin-top:6px}
.ord-vendor em{font-style:normal;font-size:12px;font-weight:750;color:#7c8c7e;letter-spacing:0}
.ord-vendor em.closed{color:#b0532f}
.ord-cat{font-size:12px;font-weight:800;color:#8a978b;margin:12px 3px 5px;letter-spacing:.02em}
.ord-row{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:58px;padding:7px 8px 7px 14px;background:#fff;border:1px solid #e9ede6;border-radius:14px;margin-bottom:6px}
.ord-row.on{border-color:#aecbb3;background:#f4f9f3}
.ord-row.editing{cursor:pointer}
.ord-row.editing:active{background:#f2f5f0}
.ord-name{min-width:0}
.ord-name b{display:block;font-size:15px;font-weight:780;line-height:1.3;overflow-wrap:anywhere;color:#223324}
.ord-name small{display:block;font-size:12px;color:#8d998e;margin-top:2px}
.ord-name small.lead{color:#b0532f}
.ord-add{flex:none;min-width:72px;height:44px;border-radius:12px;border:1px solid #d5e2d4;background:#f3f7f2;color:#335a3e;font-weight:850;font-size:14px;padding:0 12px;white-space:nowrap}
.ord-add:active{background:#e3ede1}
.ord-stepper{flex:none;display:flex;align-items:center;background:#2f4c39;border-radius:12px;height:44px;overflow:hidden}
.ord-stepper button{border:0;background:transparent;color:#fff;height:44px;min-width:42px;font-size:22px;font-weight:700;padding:0}
.ord-stepper button:active{background:#ffffff1f}
.ord-stepper .ord-qty{min-width:58px;font-size:17px;font-weight:880;font-variant-numeric:tabular-nums;letter-spacing:-.02em;padding:0 2px}
.ord-qty small{font-size:11px;font-weight:700;margin-left:2px;opacity:.8}
.ord-qty-input{width:132px;height:44px;border:2px solid #2f4c39;border-radius:12px;text-align:center;font-size:18px;font-weight:850;background:#fff}
.ord-edit-hint{flex:none;font-size:12px;font-weight:800;color:#6d8a73;padding:0 8px}
.ord-empty{text-align:center;padding:46px 12px;color:#879487;font-size:14px;line-height:1.7}
.ord-link{border:0;background:none;color:#2f6a43;font-weight:850;text-decoration:underline;min-height:40px;font-size:14px}

/* 하단 고정 바 */
.ord-bar{position:fixed;left:50%;transform:translateX(-50%);bottom:0;z-index:60;width:min(100%,560px);display:grid;grid-template-columns:auto 1fr;gap:8px;padding:10px 16px calc(10px + env(safe-area-inset-bottom));background:linear-gradient(#f7f7f300,#f7f7f3 16px)}
.ord-clear{min-height:56px;min-width:96px;border-radius:15px;border:1px solid #dce5da;background:#fff;color:#5b6b5c;font-weight:820;font-size:14px;padding:0 16px;transition:background .15s,color .15s}
.ord-clear.armed{white-space:pre-line;font-size:12px;line-height:1.3;padding:0 10px}
.ord-clear.armed{background:#b5482f;border-color:#b5482f;color:#fff}
.ord-export{min-height:56px;border:0;border-radius:15px;background:#2f4c39;color:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;box-shadow:0 4px 14px #2f4c3933}
.ord-export span{font-size:16px;font-weight:880}
.ord-export small{font-size:12px;color:#c9dacd;font-weight:700}
.ord-export:disabled{opacity:.5;box-shadow:none}

/* 시트 */
.ord-overlay{position:fixed;inset:0;z-index:150;background:#13251a8c;display:flex;align-items:flex-end;justify-content:center;opacity:0;pointer-events:none;transition:opacity .16s}
.ord-overlay.open{opacity:1;pointer-events:auto}
.ord-sheet{width:min(100%,560px);max-height:92dvh;overflow-y:auto;background:#fafbf8;border-radius:22px 22px 0 0;padding:18px 18px calc(22px + env(safe-area-inset-bottom));transform:translateY(16px);transition:transform .18s}
.ord-overlay.open .ord-sheet{transform:none}
.ord-sheet-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.ord-sheet-head h2{margin:0;font-size:20px;letter-spacing:-.04em}
.ord-text{width:100%;min-height:260px;max-height:52dvh;border:1px solid #d9e3d8;border-radius:14px;padding:14px;font:inherit;font-size:15px;line-height:1.65;background:#fff;color:#1f2c21;resize:vertical}
.ord-text:focus{outline:none;border-color:#6f9278}
.ord-sheet-actions{display:grid;gap:8px;margin-top:10px}
.ord-sheet-actions.two{grid-template-columns:1fr 1fr}
.ord-primary{min-height:54px;border:0;border-radius:14px;background:#2f4c39;color:#fff;font-weight:880;font-size:16px;width:100%}
.ord-secondary{min-height:54px;border:0;border-radius:14px;background:#fae100;color:#3a1d1d;font-weight:880;font-size:15px}
.ord-danger{min-height:48px;border:0;border-radius:13px;background:#f6ebe8;color:#a2473a;font-weight:820;width:100%;margin-top:8px}
.ord-danger.armed{background:#b5482f;color:#fff}
.ord-sheet-note{font-size:12px;color:#879487;line-height:1.6;margin:10px 2px 0}
.ord-warn{font-size:13px;line-height:1.5;color:#8f4a26;background:#fff0e3;border-radius:11px;padding:10px 12px;margin:0 0 8px}
.ord-lead{font-size:13px;line-height:1.5;color:#5d5420;background:#fbf6dd;border-radius:11px;padding:10px 12px;margin:0 0 8px}
.ord-form{display:flex;flex-direction:column;gap:12px}
.ord-form label{display:block;font-size:13px;font-weight:850;color:#3c4d3f}
.ord-form label small{font-weight:650;color:#8a978b}
.ord-form .field{margin-top:6px}
.ord-form select.field{-webkit-appearance:none;appearance:none}
.ord-form-row{display:grid;grid-template-columns:1fr 1fr;gap:10px}

/* 토스트 */
.ord-toast{position:fixed;left:50%;bottom:calc(88px + env(safe-area-inset-bottom));transform:translate(-50%,12px);z-index:200;display:flex;align-items:center;gap:12px;width:max-content;max-width:calc(100% - 32px);white-space:nowrap;background:#1f2d23;color:#fff;border-radius:13px;padding:11px 14px;font-size:14px;font-weight:650;box-shadow:0 8px 24px #0003;opacity:0;pointer-events:none;transition:opacity .16s,transform .16s}
.ord-toast.show{opacity:1;transform:translate(-50%,0);pointer-events:auto}
.ord-toast button{border:0;background:none;color:#9fdcae;font-weight:880;font-size:14px;min-height:36px;padding:0 4px;white-space:nowrap}

@media(max-width:360px){.ord-add{min-width:64px;padding:0 9px}.ord-stepper button{min-width:38px}.ord-clear{padding:0 12px}}
@media(prefers-reduced-motion:reduce){.ord-overlay,.ord-sheet,.ord-toast,.tool-btn{transition:none}}
@media(max-width:380px){body:not(.tool-order) .mast-left .brand{display:none}}
.mast-left{flex:none}

/* v3.1.1 팝업: 손잡이 · 고정 머리글 · 쓸어내려 닫기 */
.ord-sheet{padding-top:0}
.ord-grab{display:flex;justify-content:center;align-items:center;width:100%;height:26px;border:0;background:#fafbf8;padding:0;position:sticky;top:0;z-index:3;cursor:pointer}
.ord-grab span{width:44px;height:5px;border-radius:3px;background:#cfd6cd}
.ord-sheet-head{position:sticky;top:26px;z-index:2;background:#fafbf8;padding:2px 0 8px;margin-bottom:6px!important}
.ord-sheet-head .xbtn{width:48px;height:48px;font-size:26px;flex:none}
.ord-toast{cursor:pointer}
@media(hover:hover){.ord-grab:hover span{background:#aab5a8}}
