/* =====================================================================
   Takeoff – workspace.css   (index.html: the project workspace)
   Requires base.css
   ===================================================================== */
:root{--ribbon-h:96px;--font-size:12.5px}
html,body{overflow:hidden}
.titlebar .avatar{width:22px;height:22px;background:#475569;color:var(--chrome-text);font-size:10px}

.app{display:grid;grid-template-rows:auto auto auto auto minmax(0,1fr) auto;height:100vh}
/* Title bar */
.titlebar{background:var(--chrome);color:var(--chrome-text);display:flex;align-items:center;height:34px;padding:0 10px;gap:10px}
.logo{display:flex;align-items:center;gap:8px;font-weight:600;letter-spacing:.2px}
.logo i{width:20px;height:20px;border-radius:5px;background:linear-gradient(135deg,#3b82f6,#8b5cf6);display:grid;place-items:center}
.logo i svg{width:12px;height:12px;stroke:#fff}
.titlebar .quick{display:flex;gap:2px;opacity:.8}
.titlebar .title{flex:1;text-align:center;opacity:.85;font-size:12px}
.titlebar button{padding:5px;border-radius:5px;display:grid;place-items:center}
.titlebar button:hover{background:rgba(255,255,255,.12)}
/* Ribbon tabs */
.tabs{background:var(--chrome);display:flex;padding:0 10px;gap:2px}
.tab{padding:7px 14px;color:#aab1c2;border-radius:6px 6px 0 0;font-size:12.5px}
.tab:hover{color:#fff}
.tab.active{background:var(--panel);color:var(--text);font-weight:600}
.tab.file{background:var(--accent);color:#fff;border-radius:6px 6px 0 0;margin-right:6px}
/* Ribbon */
.ribbon{background:var(--panel);border-bottom:1px solid var(--border);height:var(--ribbon-h);display:flex;align-items:stretch;padding:6px 8px;overflow-x:auto;overflow-y:hidden}
.ribbon.collapsed{display:none}
.group{display:flex;flex-direction:column;padding:0 8px;border-right:1px solid var(--border);min-width:max-content}
.group:last-child{border-right:0}
.group .items{flex:1;display:flex;align-items:center;gap:2px}
.group .label{text-align:center;color:var(--muted);font-size:11px;padding-top:2px}
.rbtn{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:6px 9px;border-radius:var(--radius);min-width:54px;height:100%}
.rbtn svg{width:24px;height:24px}
.rbtn span{font-size:11.5px;line-height:1.15;text-align:center}
.rbtn:hover:not(:disabled){background:var(--hover)}
.rbtn:disabled{opacity:.38;cursor:default}
.rbtn.primary svg{color:var(--accent)}
.stack{display:flex;flex-direction:column;justify-content:center;gap:1px}
.sbtn{display:flex;align-items:center;gap:7px;padding:4px 9px;border-radius:5px;text-align:left;white-space:nowrap}
.sbtn:hover:not(:disabled){background:var(--hover)}
.sbtn:disabled{opacity:.38;cursor:default}
.caret{width:10px!important;height:10px!important;opacity:.6}
.fmt{display:flex;flex-direction:column;gap:6px;justify-content:center}
.fmt .row{display:flex;gap:3px;align-items:center}
.fmt select,.fmt input{height:24px;border:1px solid var(--border-strong);border-radius:5px;background:#fff;font:inherit;padding:0 6px}
.fmt .ib{width:26px;height:24px;border-radius:5px;display:grid;place-items:center;font-weight:600}
.fmt .ib:hover{background:var(--hover)}
/* View tabs */
.viewtabs{background:var(--bg);display:flex;gap:4px;padding:6px 8px 0;border-bottom:1px solid var(--border)}
.vtab{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid transparent;border-bottom:0;border-radius:6px 6px 0 0;color:var(--muted)}
.vtab:hover{color:var(--text)}
.vtab.active{background:var(--panel);border-color:var(--border);color:var(--text);font-weight:600;margin-bottom:-1px}
.vtab.active svg{color:var(--accent)}
.spacer{flex:1}
.collapse{align-self:center;padding:4px;border-radius:5px;color:var(--muted)}
.collapse:hover{background:var(--hover)}
/* Main layout */
.main{display:flex;min-height:0;background:var(--bg)}
.sidebar{width:320px;min-width:200px;max-width:70vw;display:flex;flex-direction:column;background:var(--panel);border-right:1px solid var(--border);min-height:0}
.pane{display:flex;flex-direction:column;min-height:60px;min-width:0;overflow:hidden}
#paneTop{height:35%}
#paneBottom{flex:1}
.panehead{display:flex;align-items:center;gap:6px;padding:6px 8px;border-bottom:1px solid var(--border);background:var(--row-alt);font-weight:600}
.panehead .grow{flex:1}
.iconbtn{padding:4px;border-radius:5px;color:var(--muted);display:grid;place-items:center}
.iconbtn:hover{background:var(--hover);color:var(--text)}
/* Splitters */
.vsplit{width:7px;margin:0 -3px;cursor:col-resize;position:relative;z-index:5;flex:none}
.hsplit{height:7px;margin:-3px 0;cursor:row-resize;position:relative;z-index:5;flex:none}
.vsplit::after,.hsplit::after{content:"";position:absolute;background:transparent;transition:background .12s;border-radius:2px}
.vsplit::after{left:2px;right:2px;top:0;bottom:0}
.hsplit::after{top:2px;bottom:2px;left:0;right:0}
.vsplit:hover::after,.hsplit:hover::after,.dragging::after{background:var(--accent)}
.grip{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none}
.grip b{display:block;background:var(--border-strong);border-radius:2px}
.vsplit .grip b{width:3px;height:28px}
.hsplit .grip b{height:3px;width:28px}
body.resizing{user-select:none}
body.resizing.col{cursor:col-resize}
body.resizing.row{cursor:row-resize}
/* Tables */
.tablewrap{flex:1;overflow:auto;min-height:0}
table{border-collapse:collapse;width:100%}
th{position:sticky;top:0;background:var(--row-alt);text-align:left;font-weight:600;color:var(--muted);padding:6px 8px;border-bottom:1px solid var(--border);white-space:nowrap}
td{padding:5px 8px;border-bottom:1px solid #eef0f3;white-space:nowrap}
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums}
tbody tr:hover{background:var(--hover)}
tbody tr.sel{background:var(--accent-soft)}
.ico{display:inline-flex;vertical-align:middle;margin-right:6px;color:var(--muted)}
.link{color:var(--link)}
.tw{display:inline-block;width:14px;color:var(--muted);cursor:pointer;text-align:center;font-size:9px;user-select:none}
/* Sidebar sub-tabs */
.subtabs{display:grid;grid-template-columns:repeat(4,1fr);border-bottom:1px solid var(--border)}
.stab{padding:6px 4px;text-align:center;color:var(--muted);border-bottom:2px solid transparent;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stab:hover{color:var(--text);background:var(--hover)}
.stab.active{color:var(--accent);border-bottom-color:var(--accent);font-weight:600;background:var(--panel)}
.filter{display:flex;align-items:center;gap:6px;padding:5px 8px;border-bottom:1px solid var(--border);color:var(--muted)}
.filter input{flex:1;border:0;outline:0;background:transparent;font:inherit;color:var(--text)}
.filter em{font-style:normal;font-size:11px}
/* Workspace */
.workspace{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--panel)}
.canvas{flex:1;position:relative;background-color:#fff;
    background-image:radial-gradient(circle,#d9dde5 1px,transparent 1px);background-size:20px 20px;
    display:grid;place-items:center;min-height:0}
.empty{text-align:center;color:var(--muted);max-width:340px}
.empty .big{width:64px;height:64px;border-radius:16px;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;margin:0 auto 14px}
.empty .big svg{width:30px;height:30px}
.empty h2{margin:0 0 6px;color:var(--text);font-size:16px}
.empty p{margin:0 0 14px;line-height:1.5}

.floating{position:absolute;right:14px;top:14px;display:flex;flex-direction:column;background:var(--panel);border:1px solid var(--border);border-radius:8px;box-shadow:0 4px 14px rgba(20,30,60,.08);padding:3px}
.floating button{padding:7px;border-radius:5px;color:var(--muted)}
.floating button:hover{background:var(--hover);color:var(--text)}
/* View switching */
.vp{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}
body[data-view="dim"] .view-wb{display:none!important}
body[data-view="wb"] .view-dim{display:none!important}
.subtabs.c3{grid-template-columns:repeat(3,1fr)}
.subtabs.c4{grid-template-columns:repeat(4,1fr)}
.current{display:flex;align-items:center;gap:8px;padding:5px 8px;border-bottom:1px solid var(--border);color:var(--muted)}
.current select{flex:1;height:24px;border:1px solid var(--border-strong);border-radius:5px;background:#fff;font:inherit;padding:0 6px;color:var(--text)}
.sw{display:inline-block;width:12px;height:12px;border-radius:3px;vertical-align:middle}
tr.g td{font-weight:600;background:var(--row-alt)}
tr.c td:first-child{padding-left:30px}
tr.c td .ico svg{width:14px;height:14px}
.canvas.dark{background-color:#0b0d12;background-image:none}
.canvas.dark .empty{color:#9aa3b5}
.plan{position:absolute;inset:0;width:100%;height:100%;stroke-width:1.2}
.coords{position:absolute;left:12px;bottom:10px;color:#8b94a7;font:11px ui-monospace,Consolas,monospace}
/* Worksheet placeholder */
.fbar{display:flex;align-items:center;gap:8px;padding:6px 10px;border-bottom:1px solid var(--border);background:var(--row-alt)}
.fbar .ref{min-width:56px;text-align:center;font-weight:600;border:1px solid var(--border-strong);border-radius:5px;padding:3px 6px;background:#fff}
.fbar svg{color:var(--muted)}
.fbar input{flex:1;height:26px;border:1px solid var(--border-strong);border-radius:5px;padding:0 8px;font:inherit;background:#fff;color:var(--text)}
.sheetwrap{flex:1;overflow:auto;min-height:0;background:#fff}
table.sheet{border-collapse:separate;border-spacing:0;width:100%;table-layout:fixed;min-width:760px}
.sheet th{position:sticky;top:0;z-index:2;text-align:center;background:var(--row-alt);color:var(--muted);font-weight:500;border-right:1px solid var(--border);border-bottom:1px solid var(--border-strong);padding:5px 6px}
.sheet th span{display:block;font-size:11px;color:var(--text);font-weight:600}
.sheet th.rh{width:42px;left:0;z-index:3}
.sheet tbody th.rh{position:sticky;top:auto;border-bottom:1px solid var(--border);font-weight:400}
.sheet col.c0{width:34%}
.sheet td.cell{height:30px;padding:0 8px;border-right:1px solid #eceff3;border-bottom:1px solid #eceff3;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;position:relative;transition:background .12s,box-shadow .12s}
.sheet tbody tr:hover{background:none}
.sheet td.cell.sel,.sheet td.cell:focus{box-shadow:inset 0 0 0 2px var(--accent)}
.lnk{display:inline-flex;align-items:center;gap:6px;background:var(--accent-soft);color:var(--accent);padding:2px 8px;border-radius:6px;font-weight:600;max-width:100%}
.lnk i{width:8px;height:8px;border-radius:2px;flex:none}
.lnk small{font-weight:500;opacity:.75}
.lnk.pop{animation:fillpop .38s cubic-bezier(.2,1.4,.4,1)}
@keyframes fillpop{0%{transform:scale(.5);opacity:0}100%{transform:none;opacity:1}}
.twb td.flash{animation:cellflash .9s ease-out}
@keyframes cellflash{from{background:rgba(34,197,94,.4)}to{background:transparent}}
/* Drag & drop */
tr.c{cursor:grab;user-select:none}
tr.c.drag-src{opacity:.35}
body.dnd,body.dnd *{cursor:grabbing!important;user-select:none!important}
body.dnd .twb td[data-a1]{background:rgba(37,99,235,.035);box-shadow:inset 0 0 0 1px rgba(37,99,235,.22)}
body.dnd .twb td[data-a1].over{background:var(--accent-soft);box-shadow:inset 0 0 0 2px var(--accent),0 0 0 4px rgba(37,99,235,.18);z-index:1;animation:cellpulse 1s ease-in-out infinite}
@keyframes cellpulse{50%{box-shadow:inset 0 0 0 2px var(--accent),0 0 0 7px rgba(37,99,235,.1)}}
body.dnd .vtab:not(.active){box-shadow:0 0 0 2px rgba(37,99,235,.35);color:var(--accent)}
.vtab{position:relative;overflow:hidden}
.vtab.hot::after{content:"";position:absolute;left:0;bottom:0;height:3px;background:var(--accent);animation:tabfill .55s linear forwards}
@keyframes tabfill{from{width:0}to{width:100%}}
.ghost{position:fixed;left:0;top:0;z-index:2000;pointer-events:none;display:flex;align-items:center;gap:8px;padding:7px 8px 7px 9px;
    background:rgba(255,255,255,.94);backdrop-filter:blur(6px);border:1px solid var(--accent);border-radius:10px;font-weight:500;white-space:nowrap;
    box-shadow:0 14px 30px rgba(37,99,235,.28),0 3px 8px rgba(20,30,60,.18);transform-origin:24px 50%;will-change:transform;transition:box-shadow .15s,border-radius .15s}
.ghost .g-sw{width:10px;height:10px;border-radius:3px}
.ghost .g-ic{display:inline-flex;color:var(--muted)}
.ghost .g-ic svg{width:14px;height:14px}
.ghost .g-qty{background:var(--accent);color:#fff;border-radius:999px;padding:1px 9px;font-size:11px;font-weight:600}
.ghost .g-hint{font-size:11px;color:var(--accent);font-weight:600;max-width:0;overflow:hidden;transition:max-width .2s}
.ghost.armed{box-shadow:0 0 0 4px rgba(37,99,235,.22),0 16px 34px rgba(37,99,235,.38);border-radius:999px}
.ghost.armed .g-hint{max-width:110px}
.trail{position:fixed;z-index:1999;pointer-events:none;border-radius:50%}
.ring{position:fixed;z-index:1999;pointer-events:none;border:2px solid var(--accent);border-radius:8px}
/* Status bar */
.statusbar{display:flex;align-items:center;gap:16px;height:26px;padding:0 10px;background:var(--panel);border-top:1px solid var(--border);color:var(--muted);font-size:11.5px}
.statusbar .item{display:flex;align-items:center;gap:5px}
.statusbar .item svg{width:12px;height:12px}

/* ---- Integrated PDF viewer + workbook ---- */
#viewer{position:absolute;inset:0;background:#2a2f3a;cursor:default}
#viewer.tool{cursor:crosshair}
.canvas.dark .empty{position:relative;z-index:1;pointer-events:auto}
.canvas.dark .empty svg{width:34px;height:34px;margin-bottom:6px;stroke:currentColor;fill:none;stroke-width:1.6}
.canvas.dark.has-pdf .empty{display:none}
.canvas.dark .empty small{display:block;margin-top:10px;font-size:12px;opacity:.7}
.canvas.dark.dragover{outline:2px dashed var(--accent);outline-offset:-6px}
.floating,.coords,.toolhint{z-index:2}
.coords{pointer-events:none}
.toolhint{position:absolute;left:50%;bottom:10px;transform:translateX(-50%);background:rgba(15,18,26,.85);color:#e5e9f2;font-size:12px;padding:4px 10px;border-radius:6px;pointer-events:none;white-space:nowrap}
.toolhint:empty{display:none}
#wb{flex:1;min-height:0;min-width:0;display:flex;flex-direction:column}
#wb .twb{height:100%}

/* tree: folder drop target while dragging, toggled ribbon buttons, save status */
#dimBody tr.g.droptgt td,#groups tr.g.droptgt td{background:var(--accent-soft);box-shadow:inset 0 0 0 2px var(--accent)}
.rbtn.on,.sbtn.on{background:var(--accent-soft);color:var(--accent);box-shadow:inset 0 0 0 1px rgba(37,99,235,.35)}
tr.d td{font-size:12px}
tr.d.sel td{background:var(--accent-soft)}
.mdl-err{color:var(--danger-text)}
