/* estimate — 1.4.0 Detailed Estimate (Timberline-style spreadsheet, import reconciliation, panels) */
.est-page{max-width:none}
.est-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px;margin-bottom:14px}
.est-stat{display:flex;flex-direction:column;gap:2px;padding:12px 14px}
.est-stat>span{color:var(--muted);font-size:12px}
.est-stat b{font-size:21px;font-weight:650;letter-spacing:-.3px}
.est-stat b.acc{color:var(--accent)}
.est-stat small{color:var(--muted);font-size:11.5px;min-height:14px}
.est-tabs{margin-bottom:10px}
.est-badge{display:inline-block;margin-left:6px;min-width:16px;padding:0 5px;border-radius:8px;background:var(--surface2);border:1px solid var(--line);font-size:10.5px;line-height:15px;color:var(--muted)}
.est-badge.ok{background:var(--green-soft);color:var(--green);border-color:transparent}
.est-badge.bad{background:var(--red-soft);color:var(--red);border-color:transparent}
.est-tools{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:8px}
.est-tl{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--muted)}
.est-tl select{padding:4px 6px;max-width:220px}
.est-tl.chk{cursor:pointer;user-select:none}
.est-search{width:180px;padding:5px 8px}
.est-selbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:6px 10px;margin-bottom:8px;background:var(--accent-soft);border-radius:8px}
.est-only{display:flex;align-items:center;gap:8px;margin-bottom:8px}

/* spreadsheet */
.eg-wrap{overflow:auto;max-height:calc(100vh - 330px);min-height:240px;border:1px solid var(--line);border-radius:8px;background:var(--surface)}
table.eg{border-collapse:separate;border-spacing:0;table-layout:fixed;font-size:12px;font-variant-numeric:tabular-nums}
table.eg th{position:sticky;top:0;z-index:3;background:var(--surface2);color:var(--muted);font-weight:600;font-size:11px;text-align:left;padding:6px 6px;border-bottom:1px solid var(--line);border-right:1px solid var(--line2);white-space:normal;line-height:1.2;vertical-align:bottom}
table.eg th.r{text-align:right}
table.eg th .eg-rsz{position:absolute;right:-3px;top:0;bottom:0;width:7px;cursor:col-resize;z-index:4}
table.eg td{padding:3px 6px;border-bottom:1px solid var(--line2);border-right:1px solid var(--line2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;height:24px}
table.eg td.r{text-align:right}
table.eg .eg-rh{position:sticky;left:0;z-index:2;background:var(--surface2);text-align:left;padding:2px 4px;white-space:nowrap}
table.eg th.eg-rh{z-index:5}
.eg-rh input{margin:0 3px 0 0;vertical-align:middle}
.eg-no{font-size:10px;color:var(--muted);vertical-align:middle}
.eg-clip{color:var(--copper);margin-left:3px;vertical-align:middle}
.eg-tog{border:0;background:none;cursor:pointer;color:var(--muted);font-size:12px;width:20px;padding:0}
tr.eg-over td{background:var(--accent-soft);font-weight:650;color:var(--ink)}
tr.eg-over.d0 td{background:color-mix(in srgb,var(--accent) 16%,var(--surface));color:var(--accent);font-size:12.5px;border-top:1px solid color-mix(in srgb,var(--accent) 30%,transparent)}
tr.eg-over.d1 td{background:color-mix(in srgb,var(--accent) 7%,var(--surface))}
tr.eg-over.d2 td,tr.eg-over.d3 td{background:var(--surface2)}
.eg-oc{font-weight:650}
.eg-ol{overflow:visible!important}
.eg-cnt{font-weight:400;color:var(--muted);font-size:11px}
tr.eg-line td.ed{cursor:cell}
tr.eg-line td[data-k="total"],tr.eg-line td[data-k="grand"]{font-weight:600}
tr.eg-line:hover td{background:color-mix(in srgb,var(--hover) 70%,var(--surface))}
tr.eg-line:hover .eg-rh{background:var(--hover)}
tr.eg-line.sel td{background:var(--accent-soft)}
tr.eg-line.excl td{color:var(--muted);font-style:italic}
tr.eg-line.excl td[data-k="total"]{text-decoration:line-through}
tr.eg-line.hlrow td{background:color-mix(in srgb,var(--hl) 22%,var(--surface))}
tr.eg-line.hlrow .eg-rh{box-shadow:inset 4px 0 0 var(--hl)}
tr.eg-line td.hlcell{background:color-mix(in srgb,var(--hc) 38%,var(--surface))!important;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--hc) 70%,transparent)}
tr.eg-line td.fx{color:var(--accent);font-style:italic}
tr.eg-line td.editing{padding:0;overflow:visible;background:var(--surface)!important}
.eg-in{width:100%;height:23px;border:2px solid var(--accent);border-radius:0;padding:1px 5px;font-size:12px;background:var(--surface);outline:none}
.eg-in.r{text-align:right}
table.eg tfoot td{position:sticky;bottom:0;z-index:2;background:var(--surface2);font-weight:700;border-top:2px solid var(--line)}
table.eg tfoot .eg-rh{z-index:3}

/* popup menu */
.est-menu{position:fixed;z-index:1000;min-width:210px;background:var(--surface);border:1px solid var(--line);border-radius:8px;box-shadow:var(--shadow);padding:4px;font-size:12.5px}
.est-mi{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:5px;cursor:pointer;position:relative;white-space:nowrap}
.est-mi:hover{background:var(--hover)}
.est-mi.off{opacity:.45;cursor:default}
.est-mi.has{justify-content:space-between}
.est-sub{display:none;position:absolute;left:100%;top:-4px;min-width:200px;max-height:60vh;overflow:auto;background:var(--surface);border:1px solid var(--line);border-radius:8px;box-shadow:var(--shadow);padding:4px}
.est-mi.has:hover>.est-sub{display:block}
.est-msep{height:1px;background:var(--line2);margin:4px 2px}
.est-msw{padding:5px 10px}
.est-msw .row{gap:5px;margin-top:4px;flex-wrap:nowrap}
.est-sw{width:20px;height:20px;border-radius:4px;border:1px solid rgba(0,0,0,.15);cursor:pointer;padding:0}
.est-sw.clear{background:var(--surface2);color:var(--muted);line-height:16px}

/* import + reconciliation */
.tl-review .tl-file{display:flex;align-items:center;gap:8px;margin-bottom:10px}
.tl-cards{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:10px}
.tl-card{display:flex;flex-direction:column;gap:2px;padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:var(--surface2)}
.tl-card span{font-size:11.5px;color:var(--muted)}
.tl-card b{font-size:18px}
.tl-card small{font-size:11px;color:var(--muted)}
.tl-card.ok b{color:var(--green)}
.tl-card.bad b{color:var(--red)}
.tl-status{display:flex;align-items:flex-start;gap:8px;padding:9px 12px;border-radius:8px;margin-bottom:10px;font-size:12.5px}
.tl-status.ok{background:var(--green-soft);color:var(--green)}
.tl-status.bad{background:var(--red-soft);color:var(--red)}
.tl-status span{color:var(--ink)}
.tl-review details{margin:8px 0}
.tl-review summary{cursor:pointer;font-weight:600;padding:4px 0}
tr.tl-g td{background:var(--surface2);font-weight:600}
.tl-opts{display:flex;flex-direction:column;gap:6px;margin-top:12px;padding-top:10px;border-top:1px solid var(--line2)}
.tl-opts label{gap:8px;cursor:pointer}
.est-pick tr{cursor:pointer}
.est-pick tr:hover td{background:var(--hover)}
.est-pick tr.sel td{background:var(--accent-soft)}

/* panels */
.est-totals td{vertical-align:middle}
.est-totals .cell.num{width:110px}
.est-totals tr.est-grand td{background:var(--accent);color:var(--accent-ink);font-weight:700;font-size:13.5px}
.est-cats{display:inline-flex;gap:6px;margin-left:6px;font-size:11.5px}
.est-cats label{display:inline-flex;align-items:center;gap:2px;cursor:pointer}
.nowrap{white-space:nowrap}
.est-note{width:100%;font-size:13px;line-height:1.5}
.est-vaout td{color:var(--muted)}
.est-crew{padding:10px 12px}
.est-crew input{max-width:200px}
.est-colwrap{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.est-colwrap h4{margin:0 0 6px;font-size:12px;color:var(--muted)}
.est-collist{display:flex;flex-direction:column;gap:3px;max-height:52vh;overflow:auto}
.est-colrow{display:flex;align-items:center;gap:6px;padding:4px 8px;border:1px solid var(--line2);border-radius:6px;background:var(--surface)}
.est-colrow .iconbtn{padding:2px 4px}
.est-grip{cursor:grab;color:var(--muted)}
@media (max-width:1250px){ .tl-cards{grid-template-columns:repeat(2,1fr)} .est-colwrap{grid-template-columns:1fr} }

/* 1.4 additions: virtual rows, WBS, totals layout */
tr.eg-sp td{padding:0!important;border:0!important;background:transparent!important}
tr.eg-line,tr.eg-over{height:25px}
table.eg td{height:24px;box-sizing:border-box;line-height:17px}
.est-tagsel,.est-filt{padding:4px 6px;font-size:12px;max-width:170px}
.est-wbsgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(440px,1fr));gap:12px}
.est-wbs{padding:12px 14px}
.est-totals{table-layout:auto}
table.grid.est-totals td{vertical-align:middle}
.est-totals td:nth-child(2){min-width:210px}
.est-totals td:nth-child(2) input.cell{width:100%;min-width:200px}
.est-totals td:nth-child(5){min-width:150px;white-space:nowrap}
.est-totals td:nth-child(5) .row{flex-wrap:nowrap}
.est-totals td:nth-child(6){min-width:150px}
.est-totals td:nth-child(6) select.cell{width:150px}
.est-totals td .est-cats{display:flex;margin:4px 0 0}
.est-set-crews{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:10px;margin-bottom:6px}
.est-set-crew{border:1px solid var(--line);border-radius:8px;padding:8px 10px;background:var(--surface)}
.est-set-tags{display:flex;flex-direction:column;gap:5px}
.est-set-addons td{vertical-align:middle}
.est-info{grid-template-columns:repeat(4,minmax(0,1fr))}
/* Vista cost codes (1.4.3) */
table.eg td[data-k="vista"]{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
table.eg td.vx-ambiguous{box-shadow:inset 3px 0 0 #e0a100}
table.eg td.vx-none{box-shadow:inset 3px 0 0 #d64545}
table.eg td.vx-manual{box-shadow:inset 3px 0 0 #2f6fd6}
.vx-sug{border:1px solid var(--line);border-radius:8px;padding:8px 10px;margin-bottom:8px;background:var(--surface2)}
.vx-list{max-height:46vh;overflow:auto;border:1px solid var(--line);border-radius:8px;margin-top:8px}
.vx-row{display:flex;align-items:center;gap:10px;padding:5px 10px;cursor:pointer;border-bottom:1px solid var(--line);font-size:13px}
.vx-row b{min-width:58px;font-variant-numeric:tabular-nums}
.vx-row:hover{background:var(--hover)}
.vx-row.on{background:var(--active);box-shadow:inset 3px 0 0 var(--accent)}
.est-xw-stats{display:flex;flex-wrap:wrap;gap:8px;margin:6px 0 10px}
.est-xw-stat{border:1px solid var(--line);border-radius:8px;padding:6px 12px;min-width:110px;display:flex;flex-direction:column}
.est-xw-stat b{font-size:18px}.est-xw-stat span{font-size:11px;color:var(--muted)}
.est-xw-stat.ok b{color:var(--green)}.est-xw-stat.warn b{color:var(--amber)}.est-xw-stat.bad b{color:var(--red)}
/* 1.6: zoom, customize, drag, profit pockets, standards */
.eg-wrap{zoom:var(--egz,1);max-height:calc((100vh - 330px) / var(--egz,1))}
.est-zoom{display:inline-flex;align-items:center;gap:2px;border:1px solid var(--line);border-radius:8px;padding:0 2px}
.est-zoom .est-zl{border:0;background:none;font-size:12px;min-width:44px;cursor:pointer;color:inherit}
.est-tabs{display:flex;align-items:center}.est-tabs .est-cust{margin-left:auto}
.eg-line .eg-no{cursor:grab}.eg-line.dragging{opacity:.5}
.eg-line.drop-before td{box-shadow:inset 0 2px 0 var(--accent)}.eg-line.drop-after td{box-shadow:inset 0 -2px 0 var(--accent)}
.est-cust,.est-std{display:grid;grid-template-columns:1fr 1fr;gap:20px}
.est-cust-row{display:flex;align-items:center;gap:8px;padding:3px 0;border-bottom:1px solid var(--line)}.est-cust-row.off{opacity:.55}
.est-addlib{max-height:220px;overflow:auto;border:1px solid var(--line);border-radius:8px;padding:6px 10px}
.pp-head{display:flex;gap:20px;align-items:flex-start;flex-wrap:wrap;margin-bottom:12px;padding:12px 14px}
.pp-sum{flex:1;min-width:320px;display:grid;gap:6px}.pp-sum>div{display:grid;grid-template-columns:80px 130px 1fr;align-items:center;gap:8px}
.pp-bar{height:10px;background:var(--line);border-radius:5px;overflow:hidden}.pp-bar>div{height:100%}
.pp-t{background:#6b7c93}.pp-ok{background:var(--green,#1f7a4a)}.pp-short{background:var(--amber,#d99a1e)}
.pp-sum .pp-gap{display:block!important;font-weight:600}.pp-gap.short{color:var(--amber,#b26b00)}.pp-gap.ok{color:var(--green,#1f7a4a)}
/* 1.6.2 versions & bid day recap */
.est-vername{margin-left:10px;font-size:13px;font-weight:600;color:#fff;background:var(--accent);padding:3px 9px;border-radius:12px;vertical-align:middle;cursor:pointer}
.est-versions .card,.est-recap .card{margin-bottom:12px}
.est-curver td{background:rgba(0,60,122,.05)}
.est-up{color:var(--red,#b42318)}.est-down{color:var(--green,#1f7a4a)}
.est-plugs .viewtoggle button{padding:3px 10px}
.est-compare .tabs{margin-top:12px}
.est-contcard{position:relative}.est-contsel{margin-top:4px;font-size:11px;padding:1px 4px;max-width:100%}
/* 1.6.7: active line, range selection, status bar, custom overline colors */
tr.eg-line.active td{background:color-mix(in srgb,var(--copper) 13%,var(--surface))}
tr.eg-line.active .eg-rh{box-shadow:inset 3px 0 0 var(--copper)}
.eg-in{border:1px solid var(--copper);color:var(--ink)}
.eg-in::selection{background:color-mix(in srgb,var(--copper) 25%,transparent);color:inherit}
table.eg td.rsel{background:color-mix(in srgb,var(--accent) 18%,var(--surface))!important;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 45%,transparent)}
table.eg td.ranch{box-shadow:inset 0 0 0 2px var(--accent)!important}
table.eg th[data-ci]{cursor:pointer}
table.eg{user-select:none}table.eg .eg-in{user-select:text}
tr.eg-over.ovc td{background:color-mix(in srgb,var(--ovc) 45%,var(--surface))!important}
.eg-status{display:flex;gap:14px;align-items:center;padding:6px 10px;margin-top:6px;border:1px solid var(--line);border-radius:8px;background:var(--surface2);font-size:12.5px;min-height:32px;flex-wrap:wrap}
/* 1.6.8: the spreadsheet tab fits the window — only the estimate grid scrolls, so the summary cards never scroll away */
#main:has(> .est-page.est-fit), #main:has(.est-page.est-fit){overflow:hidden}
.est-page.est-fit{height:100%;box-sizing:border-box;display:flex;flex-direction:column;padding-bottom:10px;overflow:hidden}
.est-page.est-fit > .phead, .est-page.est-fit > .est-stats, .est-page.est-fit > .est-tabs{flex:none}
.est-page.est-fit > .est-body{flex:1;min-height:0;display:flex;flex-direction:column}
.est-page.est-fit > .est-body > div{flex:1;min-height:0;display:flex;flex-direction:column}
.est-page.est-fit > .est-body > div > .est-tools, .est-page.est-fit > .est-body > div > .est-selbar, .est-page.est-fit > .est-body > div > .est-only, .est-page.est-fit > .est-body > div > .eg-status{flex:none}
.est-page.est-fit .eg-wrap{flex:1;min-height:160px;max-height:none}
.est-ur{display:inline-flex;gap:2px}
.est-ur .btn[disabled]{opacity:.45}
.est-views h4{margin:10px 0 4px;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
.est-vrow{display:flex;align-items:center;gap:8px;padding:5px 8px;border:1px solid var(--line);border-radius:6px;margin:4px 0;background:var(--surface)}
.est-vrow .grow{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
