*{box-sizing:border-box}
body{margin:0;font:14px/1.4 system-ui,sans-serif;color:#1c2430;background:#f4f5f7}
header{display:flex;gap:8px;align-items:center;padding:8px 16px;background:#14213d;color:#fff}
header h1{font-size:16px;margin:0 16px 0 0}
header button{background:transparent;color:#fff;border:0;padding:8px 14px;border-radius:6px;cursor:pointer}
header button.on{background:#fca311;color:#14213d;font-weight:600}
header .sp{flex:1}
#tabs{display:contents}#tabs #exp,#tabs #impb{order:2} /* desktop: Export/Import stay at the right, after Install and Cloud */
header .sm{border:1px solid #556;font-size:12px;padding:5px 10px}
section{display:none;padding:12px 16px}
section.on{display:block}
button,input,select,textarea{font:inherit}
.btn{padding:6px 12px;border:1px solid #bbc;background:#fff;border-radius:6px;cursor:pointer}
.btn.on{background:#14213d;color:#fff;border-color:#14213d}
input,textarea,select{padding:5px 7px;border:1px solid #bbc;border-radius:5px;background:#fff}
#take.on{display:grid;grid-template-columns:300px 1fr;gap:12px;height:calc(100vh - 90px)}
#side{overflow:auto;background:#fff;border-radius:8px;padding:12px;display:flex;flex-direction:column;gap:10px}
#side label{display:flex;flex-direction:column;gap:2px;font-size:12px;color:#556}
.row{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
#view{overflow:auto;background:#d9dce1;border-radius:8px;padding:8px;touch-action:pan-x pan-y} /* one finger scrolls, two fingers zoom the plan (not the page) */
#mbar{display:none}
#wrap{position:relative;display:inline-block}
#ov{position:absolute;left:0;top:0;cursor:crosshair}
#mlist div{display:flex;justify-content:space-between;gap:6px;padding:3px 0;border-bottom:1px solid #eee;font-size:12px}
#mlist .mg{background:#eef0f4;border-radius:4px;padding:4px 6px;margin-top:6px;cursor:pointer;border-bottom:0}
#mlist .in{padding-left:14px}
#mlist .x{cursor:pointer;color:#c33;border:0;background:none}
.hint{font-size:12px;color:#667}
table{border-collapse:collapse;width:100%;background:#fff}
th,td{padding:5px 8px;border-bottom:1px solid #e3e5ea;text-align:left}
th{background:#eef0f4;font-size:12px}
#dash th[data-s],#est th[data-e]{cursor:pointer;user-select:none;white-space:nowrap}
#sortsel,#esort{display:none}
td input{width:100%}
td.r,th.r{text-align:right}
.tot{max-width:420px;margin-left:auto;margin-top:12px}
.tot td{border:0}
.tot tr:last-child td{font-weight:700;border-top:2px solid #14213d}
#doc{background:#fff;max-width:820px;margin:12px auto;padding:36px;box-shadow:0 1px 6px #0002}
#doc h2{margin:0 0 4px}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:8px;max-width:820px;margin:auto}
.grid label{display:flex;flex-direction:column;font-size:12px;color:#556;gap:2px}
.sig{display:flex;gap:40px;margin-top:48px}
.sig>div{flex:1}
.sigimg{height:70px;display:flex;align-items:flex-end}
.sigimg img{max-height:70px;max-width:100%}
.sigline{border-top:1px solid #000;padding-top:4px;font-size:12px}
#sigpad{border:1px dashed #889;border-radius:6px;width:100%;max-width:480px;touch-action:none;background:#fff;cursor:crosshair}
dialog{border:0;border-radius:10px;padding:16px;box-shadow:0 8px 30px #0006;width:min(520px,95vw)}
dialog::backdrop{background:#0006}
@media screen and (max-width:760px){
 body{font-size:15px}
 header{flex-wrap:wrap;padding:8px 10px;gap:4px}
 header h1{font-size:15px;margin:0 6px 0 0}
 header .sp{display:none}
 /* phone: title and cloud on the first row, the tabs on one scrolling row below (it used to take four rows) */
 header h1{order:1}#install,#cloud{order:2}
 #tabs{display:flex;order:3;flex:0 0 100%;gap:4px;overflow-x:auto;white-space:nowrap;-webkit-overflow-scrolling:touch}
 #tabs>*{flex:none}#tabs #exp,#tabs #impb{order:0}
 #cur{margin:0 8px;max-width:none;display:flex;align-items:center}
 header button{min-height:40px;padding:6px 12px}
 header .sm{min-height:34px}
 section{padding:8px}
 input,select,textarea,.btn{min-height:40px;font-size:16px}
 /* takeoff: controls on top, drawing below; tap to place points, drag to pan */
 #take.on{display:flex;flex-direction:column;height:auto}
 #side{overflow:visible}
 #view{order:-1;height:50vh;min-height:260px}
 #mlist{max-height:150px;overflow:auto}
 /* sticky toolbar: tools, item name, undo/finish stay on screen while you scroll the plan and the lists */
 #mbar{display:block;order:-2;position:sticky;top:0;z-index:30;background:#14213d;color:#fff;margin:-8px -8px 8px;padding:6px 8px;border-radius:0 0 8px 8px}
 #mbar .mtools{display:flex;gap:4px;overflow-x:auto;white-space:nowrap;padding-bottom:4px;-webkit-overflow-scrolling:touch}
 #mbar .btn{flex:none;min-height:36px;padding:4px 10px}
 #mbar .mact{display:flex;gap:4px;align-items:center}
 #mbar .mact input{flex:1;min-width:0;min-height:36px}
 #mbar .mctx{font-size:12px;color:#cdd3e0;display:flex;gap:6px;align-items:center;flex-wrap:wrap;padding-top:4px;min-height:20px}
 #mbar .mctx label{display:flex;gap:6px;align-items:center;color:#fff}
 #mbar .mctx input[type=number]{min-height:32px;width:84px}
 #mbar .mctx input[type=range]{min-height:24px;width:110px}
 #mbar [hidden]{display:none!important}
 #mbar .btn.on{background:#fca311;color:#14213d;border-color:#fca311;font-weight:600}
 .desk,#scanbox{display:none!important}
 #kpis{grid-template-columns:repeat(2,1fr)!important}
 /* estimate lines become cards */
 #est>table:not(.tot),#lines{display:block;background:none}
 #est>table:not(.tot) thead{display:none}
 #lines tr{display:grid;grid-template-columns:1fr 1fr;gap:6px 8px;background:#fff;border-radius:8px;padding:10px;margin-bottom:8px}
 #lines td{display:flex;flex-direction:column;padding:0;border:0}
 #lines td::before{font-size:11px;color:#778}
 #lines td:nth-child(1),#lines td:nth-child(2){grid-column:1/-1}
 #lines td:nth-child(2)::before{content:'Section'}
 #lines td:nth-child(3)::before{content:'Unit'}
 #lines td:nth-child(4)::before{content:'Qty'}
 #lines td:nth-child(5)::before{content:'Waste %'}
 #lines td:nth-child(6)::before{content:'Unit cost (₱)'}
 #lines td:nth-child(7){justify-content:center;font-size:16px;font-weight:600}
 #lines td:nth-child(7)::before{content:'Amount'}
 #lines td:nth-child(8){align-items:flex-end}
 .tot{max-width:none}
 /* dashboard projects become cards */
 #sortsel,#esort{display:inline-block}
 #dash>table,#plist{display:block;background:none}
 #dash>table thead{display:none}
 #plist tr{display:grid;grid-template-columns:1fr 1fr;gap:6px 8px;background:#fff;border-radius:8px;padding:10px;margin-bottom:8px}
 #plist td{display:flex;flex-direction:column;padding:0;border:0;text-align:left}
 #plist td:empty{display:none}
 #plist td::before{font-size:11px;color:#778}
 #plist td:nth-child(1){grid-column:1/-1;font-size:16px}
 #plist td:nth-child(2)::before{content:'Client'}
 #plist td:nth-child(3)::before{content:'Status'}
 #plist td:nth-child(4)::before{content:'Due'}
 #plist td:nth-child(5)::before{content:'Total (incl. VAT)'}
 #plist td:nth-child(6)::before{content:'Updated'}
 #plist td:nth-child(7){grid-column:1/-1;flex-direction:row;gap:8px}
 #doc{padding:14px;margin:8px 0;overflow-x:auto}
 #doc table{font-size:12px}
 .sig{gap:16px}
}
#vers{margin-top:20px;background:#fff;border-radius:8px;padding:12px}
#v-result{overflow-x:auto;margin-top:8px}
.v-added td{background:#e8f6ee}.v-removed td{background:#fde8e8}.v-changed td{background:#fff4d6}
.panel{max-width:820px;margin:8px auto;background:#fff;border-radius:8px;padding:8px 12px}
.panel summary{cursor:pointer;font-weight:600}
.panel .grid{max-width:none}
.asm td input,.asm td select{width:100%}
#cd-list .btn{flex:none}
.drow{display:flex;justify-content:space-between;align-items:center;gap:6px;padding:4px 0;border-bottom:1px solid #eee;font-size:12px}
.neg{color:#c0392b}.pm-bar{display:inline-block;width:90px;height:8px;background:#e5e8ee;border-radius:4px;vertical-align:middle}.pm-bar i{display:block;height:100%;background:#2e7d32;border-radius:4px}.pm-bar i.neg{background:#c0392b}
#side .lay{flex-direction:row;align-items:center;gap:6px;font-size:12px;padding:1px 0;color:#333}.lay i{width:10px;height:10px;border:1px solid #999;flex:none}.lay span:nth-of-type(1){flex:1;overflow:hidden;text-overflow:ellipsis}
#pm select{max-width:100%;min-width:0}#pm .panel{min-width:0}@media screen and (max-width:760px){#pm .row>.row{width:100%;min-width:0}#pm-base{width:100%;max-width:calc(100vw - 70px);text-overflow:ellipsis}}
@media print{
 header,.noprint,section:not(#prop){display:none!important}
 body{background:#fff}#prop{padding:0}#doc{box-shadow:none;margin:0;max-width:none}
}
