/* Contour by SJS — shared styles (portal + viewer). Colours and font from the Contour brand pack. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/inter-400.woff) format("woff"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500 600; font-display: swap; src: url(/static/fonts/inter-600.woff) format("woff"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 650 800; font-display: swap; src: url(/static/fonts/inter-700.woff) format("woff"); }
:root {
  --accent: #f4a62a;       /* primary amber */
  --accent-ink: #0f1d2b;   /* text on amber */
  --navy: #0f1d2b;         /* dark navy / ink */
  --ok: #21865a;
  --warn: #d78a14;
  --err: #c63d3d;
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --stage-bg: #eef1f4;
  --topbar: #fff url(/static/brand/topbar.svg) repeat-x 0 0 / 1440px 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.pad { padding: 12px 14px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 1000; right: 16px; bottom: 44px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 90vw); }
.toast { background: #1f2933; color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.35);
  border-left: 4px solid #5b8def; transition: opacity .35s, transform .35s; font-size: 13px; }
.toast.error { border-color: var(--err); } .toast.warn { border-color: var(--warn); } .toast.ok { border-color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast a { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
.spin.big { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Contour lockup: mark + wordmark + byline (portal header and viewer header) */
.lockup { display: flex; align-items: center; gap: 12px; flex: none; text-decoration: none; }
.lockup .logo-full { height: 34px; width: auto; display: block; }
.lockup .logo-sym { display: none; width: 30px; height: 30px; }
.lockup .by { font-size: 12.5px; color: var(--muted); padding-top: 6px; margin-left: -4px; white-space: nowrap; }
.vsep { width: 1px; height: 26px; background: var(--line); flex: none; }

/* =====================================================================  VIEWER  */
body.viewer {
  --bg: #f5f7f9; --panel: #ffffff; --panel2: #f1f4f7; --panel3: #f8fafc; --line: #e3e8ee; --hl: #c9d2dc; --text: #17212b; --muted: #687584;
  background: var(--bg); color: var(--text); display: flex; flex-direction: column; overflow: hidden;
  overscroll-behavior: none;
}
#top { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 14px; background: var(--topbar); border-bottom: 1px solid var(--line); box-shadow: 0 1px 3px rgba(16,30,45,.05); flex: none; z-index: 2; }
#top .back { display: flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; padding: 6px 8px; border-radius: 6px; }
#top .back:hover { background: var(--panel2); color: var(--text); }

#title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
#title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#title span { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 4px 8px; border-radius: 99px; background: #eef2f6; color: #4b5866; }
.btngroup { display: flex; gap: 4px; }
.btngroup button { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 7px 9px; color: var(--muted); }
.btngroup button:hover { background: var(--panel2); color: var(--text); }
.btngroup button.active { background: #fff7ea; color: #b86e00; border-color: #f6d9a8; }
.panel-toggle { display: none !important; }

#main { flex: 1; display: flex; min-height: 0; position: relative; }
#tools { width: 70px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 1px; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: #cdd5de transparent; }
.tabpane, #details { scrollbar-width: thin; scrollbar-color: #cdd5de transparent; }
#tools button { width: 60px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0 4px; flex: none; background: none; border: 0; border-radius: 8px; color: var(--muted); font-size: 10.5px; }
#tools button:hover { background: var(--panel2); color: var(--text); }
#tools button.active { background: var(--accent); color: var(--accent-ink); }
#tools .sep { width: 36px; height: 1px; background: var(--line); margin: 6px 0; }
#tools .grp { width: 100%; text-align: center; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: #9aa5b1; margin: 9px 0 2px; padding-top: 8px; border-top: 1px solid var(--line); }

#stage { flex: 1; position: relative; min-width: 0; background: var(--stage-bg); overflow: hidden; }
#gl, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { touch-action: none; cursor: grab; }
#overlay:active { cursor: grabbing; }
#loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--stage-bg); color: var(--muted); z-index: 5; }
#loading.hidden { display: none; }
#loading .empty { text-align: center; max-width: 360px; color: var(--muted); }
#loading .empty h3 { color: var(--text); margin: 12px 0 6px; }
#loading .empty .ic { margin: 0 auto; }

#hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,30,45,.14); max-width: calc(100% - 24px); z-index: 3; }
#hint .txt { font-size: 13px; color: var(--text); min-width: min(340px, 48vw); }
#hint button { display: flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; color: var(--text); white-space: nowrap; font-size: 12.5px; }
#hint button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
#hint button:disabled { opacity: .4; cursor: default; }
#compass { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.95); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(16,30,45,.12);
  color: #17212b; display: flex; align-items: center; justify-content: center; z-index: 3; padding: 0; }
#compass .ic path:first-child { color: #e03131; }

#profile { position: absolute; left: 10px; right: 10px; bottom: 10px; background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,30,45,.14); z-index: 4; padding: 6px 8px 4px; }
#profile .chart svg { display: block; width: 100%; height: 200px; }
#profile .grid { stroke: #e6ebf0; stroke-width: 1; }
#profile .vtx { stroke: #b4bec9; stroke-dasharray: 3 3; }
#profile .ser { fill: none; stroke-width: 2; }
#profile .cur { stroke: #17212b; stroke-width: 1; }
#profile text { fill: var(--muted); font-size: 11px; }
#profile .plegend { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12px; padding: 2px 4px 4px; }
#profile .plegend i { display: inline-block; width: 12px; height: 3px; margin-right: 5px; vertical-align: middle; }
#profile .readout { flex: 1; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

#panel { width: 360px; flex: none; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; background: var(--panel3); }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 2px 7px; color: var(--muted); font-size: 11px; }
#tabs button:hover { color: var(--text); }
#tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
#tabs button.active .ic { color: var(--accent); }
.tabpane { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.ib { background: none; border: 0; color: var(--muted); padding: 5px; border-radius: 6px; display: inline-flex; }
.ib:hover { background: var(--panel2); color: var(--text); }

/* layers */
.layer { padding: 11px 12px 10px 14px; border-bottom: 1px solid var(--line); position: relative; }
.layer .lh { display: flex; align-items: center; gap: 8px; }
.layer .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.layer .meta { color: var(--muted); font-size: 11.5px; margin: 3px 0 7px; }
.layer.pending .meta { margin-bottom: 0; }
.layer .subs { display: flex; flex-wrap: wrap; gap: 5px; }
.layer .sub { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 7px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.layer .sub:hover { border-color: var(--hl); color: var(--text); }
.layer .sub.on { background: #fff7ea; border-color: #f2c47a; color: var(--text); }
.layer .sub input { width: 13px; height: 13px; }
.layer .menu { position: absolute; right: 10px; top: 38px; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 5px; min-width: 250px;
  box-shadow: 0 14px 34px rgba(16,30,45,.16); display: flex; flex-direction: column; }
.layer .menu button { text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; color: var(--text); font-size: 12.5px; }
.layer .menu button:hover { background: var(--panel2); }
.layer .menu .msep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 8px 10px 3px; border-top: 1px solid var(--line); margin-top: 4px; }
.badge { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 4px; background: #e3eefb; color: #1f5fa8; flex: none; }
.badge.mesh { background: #efe7fb; color: #6a3fb5; }
.badge.ortho { background: #e3f4e8; color: #1e7a3c; }
.badge.dtm { background: #fff1d9; color: #8a5a00; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; }

/* lists */
.items-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.items-head select { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font-size: 12px; }
.btnrow { display: flex; gap: 5px; flex-wrap: wrap; }
.pad2 { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.itemlist .ghead { padding: 10px 14px 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--panel3); border-bottom: 1px solid var(--line); }
.itemlist .row { display: flex; align-items: center; gap: 9px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.itemlist .row:hover { background: var(--panel2); }
.itemlist .row.sel { background: #fff7ea; box-shadow: inset 3px 0 0 var(--accent); }
.itemlist .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.itemlist .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.itemlist .nm em { color: var(--warn); font-style: normal; font-size: 11px; }
.itemlist .nm em.mat { color: var(--muted); }
.itemlist .nm small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.itemlist .val { color: #34414e; font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; max-width: 52%; overflow: hidden; text-overflow: ellipsis; }
.itemlist .cc { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; }
.ref { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 22px; padding: 0 6px; border-radius: 5px; color: #fff; font-weight: 700; font-size: 11.5px; flex: none; font-variant-numeric: tabular-nums; }
.st { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 99px; white-space: nowrap; background: #fff1e0; color: #a34f00; }
.st.st-in-progress { background: #e3eefb; color: #1f5fa8; }
.st.st-resolved, .st.st-closed { background: #e3f6ed; color: #127047; }
.sevs { display: flex; gap: 4px; }
.sev { display: inline-flex; align-items: center; gap: 5px; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px 3px 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.sev i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.sev.on { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
button.small { display: inline-flex; align-items: center; gap: 5px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; font-size: 12px; color: var(--text); }
button.small:hover { border-color: var(--hl); }
button.small.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.small:disabled { opacity: .45; cursor: default; }

/* stock */
.stockcard { margin: 10px 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.stockcard .sh { display: flex; align-items: baseline; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.stockcard .sh .muted { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stockcard .sh .val { font-weight: 700; color: var(--accent); }
table.stock { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.stock th { text-align: right; color: var(--muted); font-weight: 500; padding: 6px 12px 4px; font-size: 11px; }
table.stock th:first-child, table.stock td:first-child { text-align: left; }
table.stock td { text-align: right; padding: 5px 12px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.stock td .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; }
table.stock tr.tot td { font-weight: 700; color: var(--text); }
table.stock td.up { color: #127047; } table.stock td.down { color: #b42318; }

/* details */
#details { border-bottom: 1px solid var(--line); padding: 10px 12px 14px; overflow-y: auto; max-height: 64%; flex: none; background: var(--panel3); }
.dhead { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.dhead .ty { color: var(--accent); margin-right: 2px; }
.dhead input.title { flex: 1; min-width: 0; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 6px; font-weight: 600; font-size: 14px; }
.dhead input.title:hover, .dhead input.title:focus { border-color: var(--line); background: var(--panel2); outline: none; }
.dhead input[type=color] { width: 26px; height: 26px; border: 0; background: none; padding: 0; cursor: pointer; }
table.metrics { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.metrics th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 6px 4px 0; width: 46%; vertical-align: top; }
table.metrics td { padding: 4px 0; font-variant-numeric: tabular-nums; }
table.metrics tr:first-child td { font-weight: 700; color: var(--text); }
table.metrics.hist tr:first-child td { font-weight: 500; }
.vform { display: grid; gap: 7px; margin: 4px 0 10px; }
.vform label, #details label.field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.vform label.chk, label.chk { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 12.5px; }
label.chk.inl { margin: 6px 0; }
.vform .lbl { font-size: 12px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.vform select, .vform input:not([type=checkbox]), #details textarea, #details label.field input, .set select, .zrange input, .vdialog input:not([type=checkbox]), .vdialog select, .vdialog textarea, #hint select, #hint input {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; color: var(--text); width: 100%; min-width: 0; }
.vform input:disabled, .vform select:disabled, #details textarea:disabled { opacity: .7; }
#details label.field { margin-bottom: 8px; }
#details textarea { resize: vertical; margin-top: 6px; }
.matform { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.dref { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.sevpick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sevpick button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 0; font-size: 12px; color: var(--muted); }
.sevpick button.on { background: var(--c); border-color: var(--c); color: #fff; font-weight: 600; }
.photos .pgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.photos .pgrid a, .photos .addphoto { aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: #eef2f6; display: block; }
.photos .pgrid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .addphoto { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); cursor: pointer; border-style: dashed; }
.photos .addphoto:hover { color: var(--text); border-color: var(--accent); }
.discuss .cmt { background: var(--panel2); border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; font-size: 12.5px; }
.discuss .ch { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.discuss .ch .muted { flex: 1; font-size: 11px; }
.discuss .cb { white-space: pre-wrap; line-height: 1.45; }
.discuss textarea { margin: 2px 0 6px !important; }
.busy { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 6px 0; }
.err { background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.4); color: #b42318; padding: 7px 9px; border-radius: 6px; margin: 6px 0; font-size: 12.5px; }
.warn { background: #fff8e6; border: 1px solid #f2d48a; color: #8a5a00; padding: 7px 9px; border-radius: 6px; margin: 6px 0; font-size: 12px; }
.heat { margin-top: 8px; }
.heat img { width: 100%; max-height: 220px; object-fit: contain; image-rendering: pixelated; background: #f3f5f8; border-radius: 6px; border: 1px solid var(--line); }
.heat .legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.heat .legend .cut { color: #1f5fa8; } .heat .legend .fill { color: #c2410c; }
.tip { font-size: 11.5px; margin: 8px 0 0; }
#details h5.sub { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* in-viewer dialogs */
.vdialog { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(400px, calc(100% - 24px)); max-height: calc(100% - 80px); display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 60px rgba(16,30,45,.22); z-index: 30; }
.vdialog.modeless { left: auto; right: 12px; top: 62px; transform: none; width: min(330px, calc(100% - 24px)); }
.vd-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--line); }
.vd-body { padding: 12px 16px; overflow-y: auto; display: grid; gap: 10px; font-size: 13px; }
.vd-body p { margin: 0; line-height: 1.45; font-size: 12.5px; }
.vd-body label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.vd-body label.chk { display: flex; color: var(--text); }
.vd-body .boxed, .vform .boxed { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; }
.vd-foot { display: flex; justify-content: flex-end; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
#hint .extra { display: contents; }
#hint .extra select { width: auto; padding: 4px 6px; font-size: 12.5px; }
#hint .extra label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
#hint .extra input { padding: 4px 6px; }

/* photo viewer */
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(5,8,12,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox .cap { color: #c9d4e0; font-size: 13px; }
.lightbox button, .lightbox a { position: absolute; background: rgba(255,255,255,.08); border: 0; color: #fff; border-radius: 50%; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.lightbox button:hover, .lightbox a:hover { background: rgba(255,255,255,.18); }
.lightbox .lb-prev { left: 16px; top: 50%; } .lightbox .lb-next { right: 16px; top: 50%; transform: scaleX(-1); }
.lightbox .lb-close { right: 16px; top: 16px; } .lightbox .lb-dl { right: 70px; top: 16px; } .lightbox .lb-del { right: 124px; top: 16px; }

#pane-settings { padding: 4px 14px 16px; }
#pane-settings h4 { margin: 16px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.set { display: grid; grid-template-columns: 1fr 120px 44px; align-items: center; gap: 8px; margin: 6px 0; font-size: 12.5px; }
.set select { grid-column: 2 / span 2; }
.set.chk { display: flex; }
.set output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
input[type=range] { accent-color: var(--accent); width: 100%; }
.zrange { display: flex; gap: 8px; } .zrange label { flex: 1; display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.ramp { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.ramp i { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #2646a0, #2896c8, #46be78, #ebd246, #dc5a32); }
.bgs { display: flex; gap: 8px; margin-bottom: 12px; }
.bgs .bg { width: 28px; height: 28px; border-radius: 6px; border: 2px solid var(--line); }
.bgs .bg.sel { border-color: var(--accent); }
.help p { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 4px 0; }

#status { display: flex; gap: 18px; align-items: center; height: 28px; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
#status b { color: var(--text); font-weight: 600; }
#st-xyz { min-width: 330px; } #st-load { flex: 1; } #st-crs { overflow: hidden; text-overflow: ellipsis; }
#st-by { color: #9aa5b1; padding-left: 14px; border-left: 1px solid var(--line); letter-spacing: .02em; }

.fatal { max-width: 480px; margin: 18vh auto; text-align: center; padding: 20px; color: var(--text); }
.fatal a { color: var(--accent); }

/* ---- small screens: toolbar along the bottom, panel as a sheet ---- */
@media (max-width: 760px) {
  #top { height: 52px; gap: 8px; padding: 0 10px; }
  #brand .logo-full, #brand .by, .vsep, .btngroup button span { display: none; }
  #brand .logo-sym { display: block; width: 28px; height: 28px; }
  .panel-toggle { display: flex !important; }
  #main { flex-direction: column; }
  #tools { order: 3; width: auto; height: 62px; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 0 6px; overflow-x: auto; overflow-y: hidden; justify-content: flex-start; }
  #tools button { width: 58px; flex: none; }
  #tools .sep { width: 1px; height: 32px; margin: 0 4px; }
  #tools .grp { width: auto; writing-mode: vertical-rl; transform: rotate(180deg); border-top: 0; border-left: 1px solid var(--line); margin: 0 2px; padding: 0 4px 0 0; height: 48px; }
  #tabs button span { font-size: 10px; }
  .vdialog.modeless { top: auto; bottom: 8px; right: 8px; left: 8px; width: auto; }
  #main { overflow: hidden; }
  #panel { position: absolute; left: 0; right: 0; bottom: 62px; width: auto; height: 52%; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0; transform: translateY(calc(100% + 80px)); transition: transform .25s; z-index: 10; box-shadow: 0 -10px 30px rgba(16,30,45,.16); }
  .btngroup .opt { display: none !important; }
  #readonly { font-size: 10px; padding: 3px 6px; }
  #title b { font-size: 14px; }
  body.panel-open #panel, body.has-details #panel { transform: none; }
  #details { max-height: 70%; }
  #status { display: none; }
  #hint { top: 8px; flex-wrap: wrap; justify-content: center; }
  #hint .txt { width: 100%; text-align: center; font-size: 12px; }
  #profile { bottom: 8px; }
}

/* =====================================================================  PORTAL  */
body.portal { --bg: #f5f7f9; --card: #fff; --line: #e1e6ec; --text: #17212b; --muted: #66727f; background: var(--bg); color: var(--text); }
.portal header.bar { background: var(--topbar); color: var(--text); display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 60px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.portal header.bar .brand { text-decoration: none; color: var(--text); }
.portal header.bar nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.portal header.bar nav a, .portal header.bar nav button { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 8px 10px; border-radius: 6px; display: flex; align-items: center; gap: 6px; }
.portal header.bar nav a:hover, .portal header.bar nav button:hover { background: #f1f4f7; color: var(--text); }
.portal main { max-width: 1180px; margin: 0 auto; padding: 26px 22px 60px; }
.portal h1 { font-size: 22px; margin: 0; }
.portal h2 { font-size: 16px; margin: 0 0 12px; }
.portal .pagehead { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.portal .pagehead .grow { flex: 1; }
.portal .crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.portal .crumbs a { color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--text);
  text-decoration: none; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #c5ced8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.04); }
.btn.dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.danger { color: #b42318; }
.btn.small { padding: 5px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.pcard:hover { box-shadow: 0 10px 28px rgba(16,30,45,.12); transform: translateY(-1px); }
.pcard .thumb { height: 150px; background: #1a222c center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: #4f5f70; }
.pcard .body { padding: 12px 14px 14px; }
.pcard .body b { display: block; font-size: 15px; margin-bottom: 2px; }
.pcard .body span { color: var(--muted); font-size: 12.5px; }
.pcard .stats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.pcard .stats span { white-space: nowrap; }
.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list td .sub { color: var(--muted); font-size: 12px; }
.status { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.status.ready { background: #e3f6ed; color: #127047; } .status.error { background: #fde8e8; color: #b42318; }
.status.queued, .status.processing { background: #fff4dc; color: #8a5a00; }
.bar-prog { height: 6px; background: #edf0f3; border-radius: 3px; overflow: hidden; margin-top: 5px; min-width: 120px; }
.bar-prog i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.drop { display: block; cursor: pointer; border: 2px dashed #c9d2dc; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); background: #fafbfc; transition: .15s; }
.drop.over { border-color: var(--accent); background: #fff8ec; color: var(--text); }
.drop .ic { margin: 0 auto 6px; color: #9aa7b4; }
.drop > span { display: block; }
.drop input { display: none; }
.uprow { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.uprow .bar-prog { grid-column: 1 / -1; }
form.stack { display: grid; gap: 12px; }
form.stack label, .field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
form.stack input, form.stack select, form.stack textarea, .field input, .field select {
  border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; background: #fff; color: var(--text); font-size: 14px; }
form.stack input:focus, form.stack textarea:focus { outline: 2px solid rgba(244,166,42,.35); border-color: var(--accent); }
.row-actions { display: flex; gap: 4px; flex-wrap: nowrap; justify-content: flex-end; }
table.list td.nw { white-space: nowrap; }
.login { max-width: 380px; margin: 10vh auto; }
.login .logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; font-weight: 700; font-size: 18px; }
.formerr { color: #b42318; font-size: 13px; min-height: 18px; }
.share { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.share .url { display: flex; gap: 6px; margin-top: 6px; }
.share .url input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; background: #f8fafc; }
.portal dialog { border: 0; border-radius: 14px; padding: 22px; width: min(480px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.portal dialog::backdrop { background: rgba(10,20,30,.45); }
.portal dialog h2 { margin-bottom: 14px; }
.portal dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .ic { margin: 0 auto 10px; color: #a8b4c0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.portal footer.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
.portal footer.foot a { color: var(--muted); }

/* ---- portal: v2 additions ---- */
.portal header.bar nav a.on { background: #fff7ea; color: #b86e00; }
body.portal.signin { background: #f8fafb url(/static/brand/signin-bg.svg) center / cover fixed; }
body.signin .login .card { box-shadow: 0 20px 50px rgba(16,30,45,.10); }
.login-brand { display: flex; justify-content: center; margin: 8px 0 8px; }
.login-brand img { height: 56px; width: auto; }
.login-by { text-align: center; color: var(--muted); font-size: 13px; margin: -2px 0 16px; }
.ptabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -6px 0 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.ptabs a { display: flex; align-items: center; gap: 7px; padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.ptabs a:hover { color: var(--text); }
.ptabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.ptabs a.on .ic { color: var(--accent); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar p { margin: 0; max-width: 620px; font-size: 13px; }
.toolbar .grow { flex: 1; }
.toolbar input, .toolbar select { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; background: #fff; }
h2.sec { margin: 22px 0 10px; font-size: 15px; }
h2.sec .muted { font-weight: 400; font-size: 13px; }
.card.flush { padding: 4px 6px; overflow-x: auto; }
.matcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.matcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; border-top: 4px solid var(--c); }
.matcard .mn { font-size: 13px; color: var(--muted); font-weight: 600; }
.matcard .mv { font-size: 22px; font-weight: 750; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.matcard .ms { font-size: 12.5px; color: var(--muted); }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
table.list td select, select.mini { border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; background: #fff; font-size: 13px; max-width: 190px; }
table.list th.r, table.list td.r { text-align: right; }
td.num { font-variant-numeric: tabular-nums; }
td.up { color: #127047; font-weight: 600; } td.down { color: #b42318; font-weight: 600; }
.dref-tag { display: inline-block; min-width: 46px; text-align: center; padding: 3px 7px; border-radius: 6px; color: #fff; font-weight: 700; font-size: 12px; }
.sevtag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.sevtag::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.sevsum { display: flex; gap: 14px; }
td.overdue { color: #b42318; font-weight: 600; }
.act { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: 0; }
.act .dot { width: 28px; height: 28px; border-radius: 50%; background: #eef2f6; color: #5b6b7c; display: flex; align-items: center; justify-content: center; flex: none; }
.act .dot.comment { background: #fff4dc; color: #8a5a00; }
.act .ab { font-size: 13.5px; min-width: 0; }
.act .ab a { color: inherit; font-weight: 600; }
.act .quote { margin: 5px 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: #fafbfc; color: #34414e; white-space: pre-wrap; }
.act .sub, .logorow .sub { color: var(--muted); font-size: 12px; }
.perm { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef2f6; color: #4b5866; }
.perm.collab { background: #fff4dc; color: #8a5a00; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
form.stack label.inline { display: flex; align-items: center; gap: 8px; color: var(--text); }
form.stack input[type=color] { height: 40px; padding: 4px; }
.logorow { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.logorow:last-child { border-bottom: 0; }
.logoprev { width: 170px; height: 70px; border-radius: 8px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; padding: 8px; flex: none; }
.logoprev img { max-width: 100%; max-height: 100%; object-fit: contain; }
table.mats td { padding: 5px 4px; }
table.mats input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 7px; font-size: 13px; }
table.mats input[type=color] { width: 34px; height: 30px; padding: 2px; }
table.mats { table-layout: fixed; }
table.mats th:nth-child(1) { width: 48px; } table.mats th:nth-child(3), table.mats th:nth-child(4), table.mats th:nth-child(5) { width: 96px; } table.mats th:nth-child(6) { width: 52px; }
tr.derived td:first-child b::before { content: '↳ '; color: var(--muted); font-weight: 400; }
.tagd { color: #b42318; font-weight: 600; }
label.btn { cursor: pointer; }

/* narrow screens: symbol only in the portal header */
@media (max-width: 640px) {
  .portal header.bar { padding: 0 12px; gap: 8px; }
  .portal header.bar .lockup .logo-full, .portal header.bar .lockup .by { display: none; }
  .portal header.bar .lockup .logo-sym { display: block; }
  .portal header.bar nav a { font-size: 0; gap: 0; padding: 8px; }
}

/* desktop edition */
.warn-note { background: #fff8e6; border: 1px solid #f2d48a; color: #8a5a00; padding: 8px 10px; border-radius: 7px; font-size: 13px; margin-top: 8px; }
label.stackl { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.stackl input { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; font-size: 14px; color: var(--text); }

/* 2D / 3D switch and segmented controls */
.seg { display: inline-flex; background: #eef2f6; border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; flex: none; }
.seg button { border: 0; background: none; border-radius: 7px; padding: 6px 14px; font-weight: 700; font-size: 13.5px; color: var(--muted); cursor: pointer; letter-spacing: .02em; }
.seg button:hover { color: var(--text); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16,30,45,.15); }
#viewseg button.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
#viewseg { margin-right: 6px; }
.seg.small button { padding: 4px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.set .seg { grid-column: 2 / span 2; justify-self: end; }
h5.sub2 { margin: 12px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
#st-mode { font-weight: 700; color: var(--text); padding-right: 12px; border-right: 1px solid var(--line); }
.ramp.r1 i { background: linear-gradient(90deg, #0000ff, #00ffff, #00ff00, #ffff00, #ff0000); }
.ramp.r2 i { background: linear-gradient(90deg, #1a5c33, #6b9e47, #d9cc85, #9e734d, #f7f7f7); }
.ramp.r3 i { background: linear-gradient(90deg, #0d0d0d, #f2f2f2); }
.ramp.r4 i { background: linear-gradient(90deg, #440154, #3b528b, #21918c, #5ec962, #fde725); }

/* survey tab rows */
.portal .srow { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.portal .srow:last-of-type { border-bottom: 0; }
.portal .srow a b { color: var(--text); }
.portal .small { font-size: 12.5px; }

/* drop files anywhere */
.dropveil { position: fixed; inset: 0; z-index: 3000; background: rgba(15,29,43,.55); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.dropveil.hidden { display: none; }
.dropveil div { background: #fff; border: 2px dashed var(--accent); border-radius: 12px; padding: 30px 40px; font-size: 16px; font-weight: 600; color: #1f2933; max-width: 520px; text-align: center; line-height: 1.5; }
#upl-host { position: fixed; right: 16px; bottom: 16px; z-index: 2500; display: flex; flex-direction: column; gap: 8px; width: 320px; }
.upl-toast { background: #fff; border: 1px solid #dfe3e8; border-radius: 10px; box-shadow: 0 6px 24px rgba(15,29,43,.14); padding: 10px 12px; font-size: 13px; display: grid; gap: 4px; }
.upl-toast .btn { justify-self: end; }

/* viewer inside the desktop workspace */
body.embed #top { display: none; }

/* notes and mark-ups: who made what */
.mk-sw { display: inline-flex; gap: 4px; align-items: center; margin-right: 6px; }
.mk-sw .c { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); padding: 0; cursor: pointer; }
.mk-sw .c.on { box-shadow: 0 0 0 2px var(--accent, #e85d04); }
.mk-row { display: flex; align-items: center; gap: 8px; }
.people { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 2px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 2px 9px 2px 2px; font-size: 12px; cursor: pointer; }
.pchip.on { border-color: var(--accent, #e85d04); background: #fff7ea; }
.pchip i, .itemlist .row .who, .who-line .who { width: 22px; height: 22px; border-radius: 50%; color: #fff; font: 700 9.5px system-ui, sans-serif; display: inline-grid; place-items: center; font-style: normal; flex: none; }
.pchip em { font-style: normal; color: #6b7785; }
.itemlist.notes .row .nm { display: grid; gap: 1px; min-width: 0; }
.itemlist.notes .row .nm small { color: #6b7785; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.itemlist.notes .row .nm .tx { color: #1f2933; }
.itemlist.notes .row.done { opacity: .62; }
.who-box { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2, #f6f8fa); font-size: 12.5px; }
.who-line { display: flex; align-items: center; gap: 8px; }
.who-box .hist { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.who-box .hist li { display: flex; align-items: center; gap: 6px; }
.who-box .hist .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* viewer ribbon (desktop): tabs of commands along the top */
#ribbon { display: none; }
@media (min-width: 761px) {
  body.viewer #ribbon { display: block; flex: none; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1; }
  body.viewer #tools { display: none; }
}
.rb-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--panel2); }
.rb-tabs button { border: 0; background: none; padding: 6px 14px 5px; font-size: 12.5px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.rb-tabs button:hover { color: var(--text); }
.rb-tabs button.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); background: var(--panel); }
.rb-body { display: flex; align-items: stretch; gap: 0; padding: 4px 8px 2px; overflow-x: auto; scrollbar-width: thin; }
.rb-grp { display: flex; flex-direction: column; padding: 0 5px; border-right: 1px solid var(--line); }
.rb-grp:last-child { border-right: 0; }
.rb-btns { display: flex; gap: 2px; flex: 1; }
.rb-btns button { width: auto; min-width: 48px; padding-left: 5px !important; padding-right: 5px !important; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px 4px; background: none; border: 0; border-radius: 8px; color: var(--muted); font-size: 10.5px; line-height: 1.15; cursor: pointer; white-space: nowrap; }
.rb-btns button:hover { background: var(--panel2); color: var(--text); }
.rb-btns button.active { background: var(--accent); color: var(--accent-ink); }
.rb-btns button.on { background: #fff1d6; color: var(--text); box-shadow: inset 0 0 0 1px #f2c47a; }
.rb-cap { text-align: center; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: #9aa5b1; padding: 1px 0 2px; }
.layer .bulb { color: #b6bfc9; }
.layer .bulb.on { color: #f5a400; }

/* layer manager (left) and closable side panels */
#tree { display: none; }
#open-tree, #open-panel, #panel-close { display: none; }
.tree { padding: 4px 0 10px; font-size: 12.5px; }
.tree-tools { padding: 4px 10px 6px; }
.trow { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 4px; min-height: 30px; position: relative; }
.trow:hover { background: var(--panel2); }
.trow .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.trow.ds .name { font-weight: 600; }
.trow.off .name { color: var(--muted); }
.trow .caret { width: 18px; height: 22px; flex: none; border: 0; background: none; color: var(--muted); font-size: 11px; padding: 0; cursor: pointer; transition: transform .12s; }
.trow .caret.open { transform: rotate(90deg); }
.trow .ib { width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: 6px; color: var(--muted); flex: none; }
.trow .ib:hover { background: var(--panel3); color: var(--text); }
.trow .bulb { color: #b6bfc9; }
.trow .bulb.on { color: #f5a400; }
.trow .badge { font-size: 9.5px; padding: 1px 5px; }
.trow .cnt { color: var(--muted); font-size: 11px; flex: none; }
.trow .sic { color: var(--muted); display: inline-flex; flex: none; }
.tkids .trow { padding-left: 24px; }
.tkids .trow.part .sic { color: #c97a00; }
.trow.selp { background: #fff3df; }
.trow.pending { color: var(--muted); gap: 8px; padding-left: 12px; }
.tree .menu { margin: 0 8px 6px 30px; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 5px; display: flex; flex-direction: column; box-shadow: 0 6px 22px rgba(15, 25, 35, .12); }
.tree .menu.hidden { display: none; }
.tree .menu button { text-align: left; background: none; border: 0; padding: 6px 10px; border-radius: 6px; color: var(--text); font-size: 12.5px; }
.tree .menu button:hover { background: var(--panel2); }
.tree .menu .msep { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 7px 10px 3px; border-top: 1px solid var(--line); margin-top: 4px; }
.tree .menu .msep:first-child { border-top: 0; margin-top: 0; }
@media (min-width: 761px) {
  body.viewer #tree { display: flex; flex-direction: column; width: 270px; flex: none; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
  #tree .side-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel3);
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; flex: none; }
  #tree .side-head .ib, #panel-close { width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: 6px; color: var(--muted); }
  #tree .side-head .ib:hover, #panel-close:hover { background: var(--panel2); color: var(--text); }
  #tree-body { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; scrollbar-width: thin; scrollbar-color: #cdd5de transparent; }
  body.viewer #tabs button[data-tab="layers"] { display: none; }
  #panel { position: relative; }
  #panel-close { display: inline-flex; position: absolute; top: 4px; right: 4px; z-index: 2; }
  #tabs { padding-right: 30px; }
  body.tree-closed #tree, body.panel-closed #panel { display: none !important; }
  .edge-tab { position: absolute; top: 50%; transform: translateY(-50%); z-index: 6; width: 22px; height: 64px; padding: 0; display: none; align-items: center; justify-content: center;
    background: var(--panel); border: 1px solid var(--line); color: var(--muted); box-shadow: 0 2px 8px rgba(15, 25, 35, .12); cursor: pointer; }
  .edge-tab:hover { color: var(--text); background: var(--panel2); }
  .edge-tab.left { left: 0; border-left: 0; border-radius: 0 8px 8px 0; }
  .edge-tab.right { right: 0; border-right: 0; border-radius: 8px 0 0 8px; }
  body.tree-closed #open-tree, body.panel-closed #open-panel { display: inline-flex; }
  #viewbtns .side-toggle.on { color: var(--accent); }
}
@media (max-width: 760px) { #viewbtns .side-toggle { display: none; } }
.btncol { display: flex; flex-direction: column; gap: 4px; justify-content: flex-end; }

/* quick colour switch at the bottom of the view */
#colourbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; max-width: calc(100% - 300px); }
#colourbar.hidden { display: none; }
#colourbar > * { pointer-events: auto; }
.cb-seg { display: flex; background: rgba(18, 22, 28, .86); border: 1px solid rgba(255, 255, 255, .14); border-radius: 9px; padding: 3px; gap: 2px; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); backdrop-filter: blur(6px); }
.cb-seg button { border: 0; background: none; color: #c8d0d9; font-size: 12.5px; padding: 5px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.cb-seg button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.cb-seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cb-seg button.na { color: #6f7883; }
.cb-key { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; background: rgba(18, 22, 28, .82); color: #dfe5eb; font-size: 11.5px; padding: 5px 10px; border-radius: 8px; }
.cb-key span { display: inline-flex; align-items: center; gap: 5px; }
.cb-key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cb-key.ramp { flex-wrap: nowrap; align-items: center; gap: 8px; }
.cb-key.ramp i { width: 140px; height: 8px; border-radius: 4px; }
@media (max-width: 760px) { #colourbar { max-width: calc(100% - 20px); } .cb-seg button { padding: 5px 7px; font-size: 11.5px; } }
.cb-key.ramp { margin-top: 0; color: #dfe5eb; font-size: 11.5px; }
#hint .seg.mini button { padding: 4px 9px; font-size: 12px; }

.vdialog.modeless .vd-head { cursor: move; user-select: none; touch-action: none; }
.vdialog.modeless .vd-head .ib + .ib { margin-left: 0; }
.vdialog.folded .vd-body, .vdialog.folded .vd-foot { display: none; }
.vdialog.folded .vd-head .ib:first-of-type svg { transform: rotate(180deg); }
.vdialog.modeless .vd-head b { flex: 1; }

/* filter, analysis and alignment panels */
.chklist { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; max-height: 210px; overflow-y: auto; }
.chklist .chk { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.chklist .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none; }
.rowhead { display: flex; justify-content: space-between; align-items: baseline; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
table.kv { display: table; width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0 8px; }
table.kv th { text-align: left; font-weight: 500; color: var(--muted); padding: 3px 8px 3px 0; white-space: nowrap; }
table.kv td { padding: 3px 0; }
table.align { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 6px 0; }
table.align th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 4px; font-size: 11px; }
table.align td { padding: 2px 4px; vertical-align: middle; }
table.align td input:not([type=checkbox]) { width: 100%; min-width: 0; font-size: 11.5px; padding: 3px 5px; }
table.align td button.small { font-size: 11px; padding: 3px 6px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.align tr.bad td { color: #c2410c; font-weight: 600; }
#dlg-align { width: min(470px, calc(100% - 24px)); }
#dlg-align .seg { margin-bottom: 8px; }
.cb-key.dev { flex-wrap: nowrap; align-items: center; gap: 8px; }
.cb-key.dev i.bar { width: 160px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #2649f2, #1abff2, #33cc4d, #ffd926, #ed382e); }
.cb-key.dev i.bar.slope { background: linear-gradient(90deg, #33cc4d, #ffd926, #ed382e); }
.cb-key.dev button { border: 0; background: rgba(255, 255, 255, .12); color: #fff; border-radius: 5px; font-size: 11px; padding: 2px 7px; cursor: pointer; }

/* Drafting | Site data: the project's two workspaces */
.wsswitch { display: inline-flex; align-items: center; gap: 2px; background: #eef1f4; border-radius: 8px; padding: 3px; flex: none; }
.wsswitch > * { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: #4a5562; text-decoration: none; white-space: nowrap; }
.wsswitch a:hover { background: rgba(255, 255, 255, .7); color: var(--text); }
.wsswitch .on { background: #fff; color: #1f2933; box-shadow: 0 1px 3px rgba(15, 29, 43, .12); }
.wsswitch svg { opacity: .8; }
@media (max-width: 760px) { .wsswitch { display: none; } }
/* top bar buttons keep their size; on narrower screens they lose their words, not their icons */
#top .btngroup button { flex: none; white-space: nowrap; }
#top .btngroup button svg { flex: none; overflow: visible; }
@media (max-width: 1500px) { body.survey #toolbar button span { display: none; } body.survey #toolbar button { padding: 7px 8px; } }

/* survey video beside the map (road condition drive-overs), linked to the defects */
.vdialog.modeless.vp { width: min(560px, calc(100% - 24px)); left: 12px; right: auto; top: auto; bottom: 12px; max-height: calc(100% - 24px); }
.vp .vd-foot:empty { display: none; }
.vp .vd-body { gap: 8px; }
.vp-wrap { position: relative; background: #000; border-radius: 8px; overflow: hidden; }
.vp-wrap video { display: block; width: 100%; max-height: 46vh; background: #000; }
.vp-boxes { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
.vp-boxes.drawing { pointer-events: auto; cursor: crosshair; background: rgba(34, 211, 238, .08); bottom: 44px; }
.vp-boxes .vb { position: absolute; border: 2px solid #d78a14; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.vp-boxes .vb.low { border-color: #21865a; } .vp-boxes .vb.high { border-color: #e8590c; } .vp-boxes .vb.critical { border-color: #c63d3d; }
.vp-boxes .vb.sel { border-width: 3px; }
.vp-boxes .vb.live { border: 2px dashed #22d3ee; }
.vp-boxes .vb span { position: absolute; left: -2px; bottom: 100%; margin-bottom: 2px; background: rgba(15, 29, 43, .85); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.vp-strip { position: relative; height: 18px; background: #eef2f6; border-radius: 4px; margin: 0 2px; }
.vp-strip .ph { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: #0e7490; pointer-events: none; }
.vp-strip .sy { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fbbf24; }
.vp-strip .dm { position: absolute; top: 3px; width: 10px; height: 12px; margin-left: -5px; padding: 0; border-radius: 2px; border: 1px solid rgba(0, 0, 0, .35); background: #d78a14; cursor: pointer; }
.vp-strip .dm.low { background: #21865a; } .vp-strip .dm.high { background: #e8590c; } .vp-strip .dm.critical { background: #c63d3d; }
.vp-strip .dm.est { opacity: .5; }
.vp-strip .dm.sel { outline: 2px solid #0e7490; outline-offset: 1px; z-index: 1; }
.vp-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vp-tools .chk { margin-left: auto; display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); }
.vp-tools button.on { background: #cffafe; border-color: #22d3ee; }
.vp-sethead { display: flex; width: 100%; align-items: center; gap: 6px; background: none; border: 0; padding: 4px 0; cursor: pointer; text-align: left; color: var(--text); font: inherit; }
.vp-sethead .muted { margin-left: auto; }
.vp-setup .boxed { margin-top: 4px; }
.vp-sync { display: grid; gap: 2px; font-size: 12px; }
.vp .warnbox { background: #fff7e6; border: 1px solid #f5c26b; padding: 8px 10px; border-radius: 6px; font-size: 12px; }
.vline { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 4px; }
.vline span:nth-child(2) { flex: 1; }
.badge.video { background: #cffafe; color: #0e7490; }
.itemlist .cc.vt { color: #0e7490; }
.itemlist .cc.vt.est { opacity: .6; }

/* the video docked beside the map: side by side or one above the other, with a split to drag */
#stagewrap { flex: 1; display: flex; min-width: 0; min-height: 0; position: relative; }
#stagewrap.dock-rows { flex-direction: column; }
#stagewrap.dock-cols.dock-swap { flex-direction: row-reverse; }
#stagewrap.dock-rows.dock-swap { flex-direction: column-reverse; }
#vdock { flex: 0 0 50%; min-width: 0; min-height: 0; display: flex; background: var(--panel); overflow: hidden; }
#vsplit { flex: none; background: var(--line); touch-action: none; }
#stagewrap.dock-cols #vsplit { width: 5px; cursor: col-resize; }
#stagewrap.dock-rows #vsplit { height: 5px; cursor: row-resize; }
#vsplit:hover { background: var(--accent); }
.vdialog.vp.docked { position: relative; left: auto; right: auto; top: auto; bottom: auto; transform: none; width: 100%; height: 100%; max-height: none;
  border: 0; border-radius: 0; box-shadow: none; z-index: auto; }
.vp.docked .vd-head { cursor: default; }
.vp.docked .ib.fold { display: none; }
.vp.docked .vd-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vp.docked .vd-body > * { flex: none; }
.vp.docked .vd-body > .vp-wrap { flex: 1 1 auto; min-height: 150px; }
.vp.docked .vp-wrap video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.vp-lay { display: inline-flex; gap: 1px; margin-right: 2px; }
.vp-lay .ib.on { color: var(--accent); background: var(--panel2); }

/* defects listed in Layers */
.badge.defects { background: #fdebe3; color: #c2410c; }
.tkids.defs .trow { padding-left: 22px; gap: 6px; cursor: pointer; min-height: 28px; }
.trow.def .ref { min-width: 34px; height: 18px; font-size: 10px; padding: 0 4px; border-radius: 4px; }
.trow.def .name { font-weight: 500; }
.trow.def .who { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 8.5px; font-style: normal; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center; flex: none; }
.trow.def .st { font-size: 9.5px; padding: 1px 6px; flex: none; }
.trow.def.sel { background: #fff3df; }
.trow.def.off .name { color: var(--muted); }

/* closing and reopening the side panels and the ribbon */
@media (min-width: 761px) {
  .edge-tab { width: 26px; height: auto; padding: 10px 0; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text); }
  .edge-tab span { writing-mode: vertical-rl; transform: rotate(180deg); }
  .edge-tab.right span { transform: none; }
  .edge-tab:hover { color: var(--accent); }
}
.rb-tabs .rb-min { margin-left: auto; padding: 4px 8px; display: inline-flex; align-items: center; }
body.ribbon-closed .rb-body { display: none; }
body.ribbon-closed .rb-tabs { border-bottom: 0; }

/* one above the other: the controls go beside the video, so it can be as big as the space allows */
.vp-side { display: grid; gap: 8px; align-content: start; }
.vp.docked .vd-body > .vp-side { flex: none; }
.vp.docked.dock-wide .vd-body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr) auto; gap: 8px 14px; overflow: hidden; }
.vp.docked.dock-wide .vd-body > .vp-wrap { grid-column: 1; grid-row: 1; min-height: 0; }
.vp.docked.dock-wide .vd-body > .vp-strip { grid-column: 1; grid-row: 2; }
.vp.docked.dock-wide .vd-body > .vp-side { grid-column: 2; grid-row: 1 / 3; overflow-y: auto; min-height: 0; }
/* side by side: the video at its own shape at the top, the controls straight under it */
.vp.docked:not(.dock-wide) .vd-body > .vp-wrap { flex: 0 1 auto; }
.vp.docked:not(.dock-wide) .vp-wrap video { height: auto; max-height: 100%; }

/* tagging on the video: click the defect (crosshair), its box follows it */
.vp-boxes.picking { pointer-events: auto; cursor: crosshair; bottom: 44px; box-shadow: inset 0 0 0 2px #22d3ee; }
.vp-boxes .vb.new { border: 2px dashed #22d3ee; }
.vp-side { position: relative; }
.vp-side .vp-side-x { position: absolute; top: -2px; right: -4px; width: 22px; height: 22px; z-index: 1; }
.vp-side .vp-status { padding-right: 22px; }
.vp.no-controls .vp-side { display: none !important; }
.vp.docked.dock-wide.no-controls .vd-body { grid-template-columns: minmax(0, 1fr); }
.vp-sidebox { margin: 8px 12px; display: grid; gap: 6px; }
.vp-sidebox .vp-sbhead { display: flex; align-items: center; gap: 6px; }
.vp-sidebox .vp-tools .chk { margin-left: 0; }
