/* ==========================================================================
   App window mockup (illustrative interface concept).
   Mirrors the working model's layout: title/menu bar, properties bar,
   left panel strip + panel, document tabs, page view, right tool strip,
   status bar and the Markup Table. Re-skinned dark charcoal + green.
   ========================================================================== */
.app {
  --a-title: #05080b;
  --a-chrome: #151d24;
  --a-raised: #1b252d;
  --a-hover: #22303a;
  --a-work: #222c34;
  --a-div: #0b1014;
  --a-sect: #10171c;
  --a-text: #e6edf1;
  --a-dim: #8d9ba5;
  --a-acc: var(--accent);
  --a-acc-sub: rgba(166, 255, 0, 0.16);
  position: relative; z-index: 2;
  max-width: 1180px; margin: 0 auto;
  border-radius: 14px; overflow: hidden;
  background: var(--a-chrome);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 50px 120px -40px rgba(0,0,0,0.9), 0 0 0 1px rgba(0,0,0,0.6), 0 0 120px -40px var(--accent-glow);
  font-family: "Segoe UI", var(--font); font-size: 11.5px; color: var(--a-text); line-height: 1.3;
  user-select: none; text-align: left;
}
.app svg.i { width: 14px; height: 14px; }
.app button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: default; }

/* Title + menu bar */
.app-title { display: flex; align-items: center; height: 30px; background: var(--a-title); padding: 0 0 0 10px; gap: 2px; }
.app-title .tile { width: 18px; height: 18px; display: grid; place-items: center; margin-right: 8px; flex: none; }
/* brand.logo is already a finished tile (charcoal + lime), so show it as the app icon unchanged */
.app-title .tile img { width: 18px; height: 18px; }
.app-menu { display: flex; gap: 0; }
.app-menu span { padding: 5px 9px; border-radius: 4px; color: #cfd8de; }
.app-menu span:first-child { font-weight: 600; color: #fff; }
.app-title .spacer { flex: 1; }
.app-profile { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; margin-right: 10px; border: 1px solid #26313a; border-radius: 4px; color: var(--a-dim); }
.app-profile b { color: var(--a-text); font-weight: 600; }
.app-win { display: flex; height: 100%; }
.app-win i { width: 42px; display: grid; place-items: center; color: #9aa7b0; font-style: normal; font-size: 12px; }

/* Properties toolbar */
.app-props { display: flex; align-items: center; gap: 14px; height: 36px; padding: 0 10px; border-bottom: 1px solid var(--a-div); background: var(--a-chrome); white-space: nowrap; overflow: hidden; }
.app-props .grp { display: flex; align-items: center; gap: 6px; color: var(--a-dim); }
.app-props .grp b { color: var(--a-text); font-weight: 500; }
.app-props .sep { width: 1px; height: 18px; background: #2a353e; }
.app-props .ib { width: 26px; height: 24px; display: grid; place-items: center; border-radius: 3px; color: #d5dde2; }
.app-props .field { background: var(--a-sect); border: 1px solid #26313a; border-radius: 3px; padding: 3px 8px; color: var(--a-text); }
.app-props .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(255,255,255,0.25); }

/* Body grid */
.app-body { display: grid; grid-template-columns: 36px 212px 1fr 36px; height: 452px; }
.app-strip { background: var(--a-chrome); border-right: 1px solid var(--a-div); display: flex; flex-direction: column; align-items: center; padding-top: 4px; gap: 2px; }
.app-strip.right { border-right: 0; border-left: 1px solid var(--a-div); }
.app-strip .tb { width: 30px; height: 28px; display: grid; place-items: center; color: #c9d3d9; border-radius: 3px; position: relative; }
.app-strip .tb.on { background: var(--a-acc-sub); color: var(--accent-hi); }
.app-strip .tb.on::before { content: ""; position: absolute; left: -3px; top: 5px; bottom: 5px; width: 2px; background: var(--a-acc); border-radius: 2px; }
.app-strip.right .tb.on::before { left: auto; right: -3px; }
.app-strip hr { width: 20px; border: 0; border-top: 1px solid #2a353e; margin: 4px 0; }

/* Left panel: Tool Palette */
.app-panel { background: var(--a-chrome); border-right: 1px solid var(--a-div); display: flex; flex-direction: column; min-width: 0; }
.app-panel-head { height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; font-weight: 700; font-size: 12.5px; border-bottom: 1px solid var(--a-div); }
.app-panel-head span { color: var(--a-dim); font-weight: 400; font-size: 11px; }
.app-set { padding: 8px 10px 4px; color: var(--a-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; display: flex; justify-content: space-between; }
.app-tool { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-left: 2px solid transparent; }
.app-tool .glyph { width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center; background: var(--a-sect); border: 1px solid #26313a; }
.app-tool .glyph svg { width: 13px; height: 13px; }
.app-tool .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-tool .nm small { display: block; color: var(--a-dim); font-size: 10px; }
.app-tool .q { font-family: var(--mono); font-size: 10.5px; color: var(--a-dim); }
.app-tool.on { background: var(--a-acc-sub); border-left-color: var(--a-acc); }
.app-tool.on .q { color: var(--accent-hi); }

/* Center: tabs + page view */
.app-center { display: flex; flex-direction: column; min-width: 0; background: var(--a-work); }
.app-tabs { display: flex; height: 30px; background: var(--a-chrome); border-bottom: 1px solid var(--a-div); }
.app-tabs span { display: flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--a-dim); border-right: 1px solid var(--a-div); white-space: nowrap; }
.app-tabs span.on { background: var(--a-work); color: var(--a-text); box-shadow: inset 0 2px 0 var(--a-acc); }
.app-tabs span i { font-style: normal; opacity: 0.5; }
.app-view { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.app-view svg.sheet { position: absolute; left: 14px; top: 14px; width: calc(100% - 28px); height: calc(100% - 28px); filter: drop-shadow(0 10px 24px rgba(0,0,0,0.5)); }

/* Status bar */
.app-status { display: flex; align-items: center; gap: 12px; height: 30px; padding: 0 10px; background: var(--a-chrome); border-top: 1px solid var(--a-div); color: var(--a-dim); white-space: nowrap; overflow: hidden; }
.app-status .pg { display: inline-flex; align-items: center; gap: 6px; }
.app-status .pg b { background: var(--a-sect); border: 1px solid #26313a; border-radius: 3px; padding: 1px 6px; color: var(--a-text); font-weight: 500; }
.app-status .spacer { flex: 1; }
.app-status .chip { background: var(--a-acc-sub); color: var(--accent-hi); border: 1px solid rgba(196, 255, 77,0.3); border-radius: 3px; padding: 2px 8px; font-family: var(--mono); font-size: 10.5px; }
.app-status .scale { color: var(--a-text); border: 1px solid #26313a; border-radius: 3px; padding: 2px 8px; }
.app-status .dim { display: inline-flex; align-items: center; gap: 6px; }
.app-status .dim i { width: 54px; height: 3px; background: #2a353e; border-radius: 2px; position: relative; }
.app-status .dim i::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 40%; background: var(--a-dim); border-radius: 2px; }

/* Markup Table */
.app-table { background: var(--a-chrome); border-top: 1px solid var(--a-div); }
.app-table-head { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-bottom: 1px solid var(--a-div); white-space: nowrap; overflow: hidden; }
.app-table-head b { font-weight: 700; font-size: 12px; }
.app-table-head .count { color: var(--a-dim); }
.app-table-head .search { background: var(--a-sect); border: 1px solid #26313a; border-radius: 3px; padding: 3px 8px; color: var(--a-dim); width: 150px; display: inline-flex; gap: 6px; align-items: center; }
.app-table-head .btnx { border: 1px solid #26313a; border-radius: 3px; padding: 3px 8px; color: var(--a-text); }
.app-table-head .spacer { flex: 1; }
.app-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.app-grid th { text-align: left; font-weight: 600; color: var(--a-dim); background: var(--a-sect); padding: 6px 10px; border-right: 1px solid #1f2930; font-size: 10.5px; white-space: nowrap; overflow: hidden; }
.app-grid td { padding: 6px 10px; border-top: 1px solid #1d272e; border-right: 1px solid #1f2930; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-grid td.n { text-align: right; font-family: var(--mono); font-size: 10.5px; }
.app-grid .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: -1px; }
.app-grid tr.sel td { background: var(--a-acc-sub); }
.app-grid tr.tot td { background: var(--a-sect); font-weight: 600; color: var(--a-text); border-top: 1px solid #2a353e; }
.app-grid tr.tot td.n { color: var(--accent-hi); }
.app-grid .fx { color: var(--accent-hi); font-family: var(--mono); font-size: 10px; margin-left: 4px; opacity: 0.8; }
.app-grid .st { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 10px; background: rgba(56,189,248,0.12); color: #7dd3fc; }
.app-grid .st.ok { background: var(--a-acc-sub); color: var(--accent-hi); }

/* Sheet drawing (SVG) */
.sheet .paper { fill: #eef1f3; }
.sheet .wall { fill: none; stroke: #20262b; stroke-width: 5; stroke-linejoin: miter; }
.sheet .wall-thin { fill: none; stroke: #2b3238; stroke-width: 2.4; }
.sheet .door { fill: none; stroke: #4a545c; stroke-width: 1; }
.sheet .grid-ln { stroke: #9aa5ad; stroke-width: 0.8; stroke-dasharray: 10 4 2 4; }
.sheet .bubble { fill: #eef1f3; stroke: #4a545c; stroke-width: 1.2; }
.sheet .bt { font: 600 11px var(--font); fill: #2b3238; text-anchor: middle; dominant-baseline: central; }
.sheet .rm { font: 600 9px var(--font); fill: #4a545c; text-anchor: middle; letter-spacing: 0.08em; }
.sheet .dimt { font: 8px var(--font); fill: #5d6871; text-anchor: middle; }
.sheet .tb-line { stroke: #4a545c; stroke-width: 1; fill: none; }
.sheet .tb-t { font: 700 13px var(--font); fill: #20262b; }
.sheet .tb-s { font: 8px var(--font); fill: #5d6871; letter-spacing: 0.06em; }
.sheet .hatch { stroke: #c3cad0; stroke-width: 0.7; }

/* Takeoff markups + animation */
.mk-area { fill: rgba(166, 255, 0, 0.24); stroke: #659E06; stroke-width: 2.4; }
.mk-len { fill: none; stroke: #1f7ae0; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.mk-cnt circle { fill: #f59e0b; stroke: #92400e; stroke-width: 1.2; }
.mk-cnt text { font: 700 7.5px var(--font); fill: #1f1300; text-anchor: middle; dominant-baseline: central; }
.mk-door rect { fill: none; stroke: #d6338a; stroke-width: 2; }
.mk-label rect { fill: #0e1519; stroke: rgba(196, 255, 77,0.6); stroke-width: 1; }
.mk-label text { font: 600 10px var(--mono); fill: #e6edf1; text-anchor: middle; dominant-baseline: central; }
.mk-label.blue rect { stroke: rgba(96,165,250,0.7); }
.mk-label.amber rect { stroke: rgba(245,158,11,0.7); }
.mk-cursor { stroke: #0e1519; stroke-width: 1; }

.draw-in { stroke-dasharray: var(--len, 1600); stroke-dashoffset: var(--len, 1600); animation: drawIn 1.5s var(--ease) forwards; animation-delay: var(--d, 0s); }
.fill-in { fill-opacity: 0; animation: fillIn 0.6s ease forwards; animation-delay: var(--d, 0s); }
.pop-in { opacity: 0; transform-box: fill-box; transform-origin: center; animation: popIn 0.35s var(--ease) forwards; animation-delay: var(--d, 0s); }
.row-in td { animation: rowIn 0.5s ease both; animation-delay: var(--d, 0s); }
@keyframes drawIn { to { stroke-dashoffset: 0; } }
@keyframes fillIn { to { fill-opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }
@keyframes rowIn { from { opacity: 0; } to { opacity: 1; } }
.app-hl { animation: hl 1.2s ease both; animation-delay: var(--d, 0s); }
@keyframes hl { 0% { background: transparent; } 30% { background: rgba(166, 255, 0,0.3); } 100% { background: var(--a-acc-sub); } }

/* Responsive: drop chrome progressively; the sheet stays readable */
@media (max-width: 1100px) { .app-body { grid-template-columns: 36px 180px 1fr 36px; } .app-props .opt { display: none; } }
@media (max-width: 900px) {
  .app-body { grid-template-columns: 36px 1fr 36px; height: 380px; }
  .app-panel { display: none; }
  .app-menu span:nth-child(n+6) { display: none; }
  .app-grid .c-status, .app-grid .c-page { display: none; }
}
@media (max-width: 640px) {
  .app { border-radius: 10px; font-size: 10.5px; }
  .app-body { grid-template-columns: 1fr; height: 250px; }
  .app-strip { display: none; }
  .app-menu span:nth-child(n+3), .app-profile, .app-props .opt2, .app-table-head .search, .app-table-head .btnx, .app-status .opt { display: none; }
  .app-grid .c-cost { display: none; }
  .app-view svg.sheet { left: 6px; top: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
}

@media (prefers-reduced-motion: reduce) {
  .draw-in { stroke-dashoffset: 0; animation: none; }
  .fill-in { fill-opacity: 1; animation: none; }
  .pop-in, .row-in td { opacity: 1; animation: none; }
  .app-hl { animation: none; background: var(--a-acc-sub); }
}
