/* Diderot3 – responsive stylesheet (no external dependencies) */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #6b7385;
  --line: #e2e5eb;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --danger: #c8372d;
  --ok: #1f8a4c;
  --c-actions: #d9480f;
  --c-entities: #2f5bea;
  --c-attributes: #0b8a6a;
  --c-file: #6b7280;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --panel: #1a1e27; --text: #e6e8ee; --muted: #9aa2b4; --line: #2b313d;
    --accent: #6d8dff; --c-actions: #ff8a4c; --c-entities: #7d9cff; --c-attributes: #3fd0a7; --c-file: #a3abba;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; padding: 2rem 1rem; }
.inline { display: inline; margin: 0; }

/* ---------- top bar ---------- */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 1rem; padding: .55rem 1.2rem; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { color: var(--accent); }
.mainnav { display: flex; align-items: center; gap: .25rem; flex: 1; flex-wrap: wrap; }
.mainnav a, .linklike { color: var(--text); padding: .4rem .7rem; border-radius: 7px; font: inherit; }
.mainnav a:hover, .linklike:hover { background: var(--bg); text-decoration: none; }
.mainnav a.active { background: var(--accent); color: var(--accent-ink); }
.nav-sep { flex: 1; }
.linklike { background: none; border: 0; cursor: pointer; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 7px; font-size: 1.2rem; padding: .2rem .6rem; color: var(--text); cursor: pointer; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .mainnav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .5rem; }
  .mainnav.open { display: flex; }
  .mainnav .inline, .mainnav .linklike { width: 100%; text-align: left; }
  .nav-sep { display: none; }
}

/* ---------- layout ---------- */
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 1.2rem; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 620px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.page-head h1 { margin: 0; }
/* breadcrumbs */
.crumbs { font-size: .88rem; color: var(--muted); margin: -.2rem 0 .8rem; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; row-gap: .2rem; }
.crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.crumbs li + li::before { content: "›"; margin: 0 .45rem; color: var(--muted); opacity: .7; }
.crumbs a, .crumbs [aria-current] { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .35rem; border-radius: 6px; max-width: 22ch; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); text-decoration: none; }
.crumbs [aria-current] { color: var(--text); font-weight: 600; max-width: 40ch; }
.crumb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-icon { font-size: .95em; line-height: 1; }
.crumbs li:first-child .crumb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }  /* Home: icon only, label for screen readers */
.crumbs li:first-child .crumb-icon { font-size: 1.15em; }
.crumb-more { display: none !important; }
.crumb-more button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 6px; padding: 0 .45rem; cursor: pointer; font: inherit; line-height: 1.4; }
@media (max-width: 760px) {
  .crumbs.collapsible:not(.expanded) li.mid { display: none; }
  .crumbs.collapsible:not(.expanded) .crumb-more { display: inline-flex !important; }
  .crumbs a { max-width: 14ch; }
  .crumbs [aria-current] { max-width: 24ch; }
}
.description { white-space: normal; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .82rem; margin: .8rem 0 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.disabled { opacity: .4; pointer-events: none; }
.btn-row { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 500; font-size: .92rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; }
label.check { display: flex !important; align-items: center; gap: .45rem; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; display: grid; gap: .7rem; margin: 0; }
legend { padding: 0 .4rem; font-weight: 600; font-size: .92rem; }
.picker-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .6rem; }
.picker-list label.check { padding: .18rem 0; white-space: pre; font-size: .92rem; }
.picker-list label.check.hidden { display: none !important; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.searchbar input { flex: 1; min-width: 180px; }
.auth-box { max-width: 400px; margin: 3rem auto; }

/* ---------- flash ---------- */
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .8rem; border: 1px solid; }
.flash-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.flash-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); }

/* ---------- type colors ---------- */
.ticon { display: inline-block; width: 1.1em; text-align: center; }
.t-actions .ticon, .ticon.t-actions, .t-actions > .ticon { color: var(--c-actions); }
.t-entities .ticon, .ticon.t-entities { color: var(--c-entities); }
.t-attributes .ticon, .ticon.t-attributes { color: var(--c-attributes); }
.tbadge { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 .45rem; font-weight: 600; vertical-align: middle; }
.tcount { font-size: .75rem; background: var(--bg); color: var(--muted); border-radius: 99px; padding: .05rem .5rem; font-weight: 600; margin-left: .3rem; }
.role { font-size: .78rem; border-radius: 99px; padding: .05rem .55rem; font-weight: 600; background: var(--bg); }
.role-admin { color: var(--danger); }
.role-editor { color: var(--accent); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; border-bottom: 1px solid var(--line); }
.tab { padding: .5rem .85rem; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ---------- tree ---------- */
.tree-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tree-tools input { flex: 1; min-width: 180px; }
.legend { font-size: .85rem; margin: 0 0 .8rem; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: .85rem; padding-left: .9rem; border-left: 1px dashed var(--line); }
.tree li { margin: .1rem 0; }
.tree li.hidden { display: none; }
.tree li.match > .tnode a, .tree li.match > details > summary .tnode a { background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 4px; }
.tree summary { cursor: pointer; list-style: none; display: flex; align-items: flex-start; padding: .18rem .3rem; border-radius: 6px; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--muted); width: 1rem; flex: none; transition: transform .15s; display: inline-block; line-height: 1.5; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary:hover { background: var(--bg); }
.tree li.leaf { padding: .18rem .3rem .18rem 1.3rem; }
.tnode { display: inline-flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; min-width: 0; }
.tnode a { font-weight: 500; }
.tdesc { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.t-actions > .ticon { color: var(--c-actions); }
.t-entities > .ticon { color: var(--c-entities); }
.t-attributes > .ticon { color: var(--c-attributes); }
.t-file .ticon { color: var(--c-file); }
@media (max-width: 600px) { .tdesc { display: none; } .tree ul { margin-left: .4rem; padding-left: .6rem; } }

/* ---------- chips ---------- */
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; border: 1px solid var(--line); border-radius: 99px; padding: .2rem .7rem; color: var(--text); font-size: .9rem; }
.chip:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.list th, .list td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); white-space: nowrap; }
.list tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.list tr.inactive { opacity: .55; }
.list td.desc { color: var(--muted); max-width: 360px; }
@media (max-width: 760px) {
  .list.responsive thead { display: none; }
  .list.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem .2rem; }
  .list.responsive td { display: flex; gap: .8rem; border: 0; padding: .2rem .8rem; }
  .list.responsive td::before { content: attr(data-label); flex: 0 0 38%; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
  .list td.desc { max-width: none; }
}
.pager { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: center; margin: 1rem 0; }
.pager a { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.pager a.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- files ---------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.file-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.thumb { height: 150px; background: var(--bg); display: flex; align-items: center; justify-content: center; flex-direction: column; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { text-decoration: none; }
.big-icon { font-size: 3rem; line-height: 1; }
.ext { font-size: .75rem; font-weight: 700; color: var(--muted); margin-top: .3rem; }
.file-info { padding: .6rem .75rem; display: grid; gap: .2rem; overflow-wrap: anywhere; }
.file-info .btn-row { margin-top: .3rem; }
.upload-box > summary { list-style: none; display: inline-flex; }
.upload-box > summary::-webkit-details-marker { display: none; }
.upload-box[open] > summary { margin-bottom: .8rem; }
.upload-box .form { max-width: 560px; }

/* ---------- viewer ---------- */
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.viewer-title { display: flex; gap: .6rem; align-items: center; min-width: 0; overflow-wrap: anywhere; }
.viewer-title .big { font-size: 1.8rem; }
.viewer-desc { padding: .6rem 1rem; margin: 0; border-bottom: 1px solid var(--line); }
.viewer-body { background: var(--bg); min-height: 50vh; }
.pdf-frame { width: 100%; height: calc(100vh - 210px); min-height: 480px; border: 0; display: block; }
.img-stage { overflow: auto; height: calc(100vh - 210px); min-height: 360px; display: flex; align-items: center; justify-content: center; cursor: zoom-in; touch-action: pan-x pan-y pinch-zoom; }
.img-stage img { max-width: 100%; max-height: 100%; transition: transform .15s; transform-origin: center; background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 0 0 / 16px 16px; }
.img-stage.zoomed { display: block; cursor: zoom-out; }
.img-stage.zoomed img { max-width: none; max-height: none; }
.preview-note { padding: .5rem 1rem 0; margin: 0; }
.doc-preview { background: var(--panel); color: var(--text); max-width: 860px; margin: 1rem auto; padding: 2rem 2.4rem; border-radius: 4px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow-wrap: anywhere; }
.doc-preview img { max-width: 100%; height: auto; }
.doc-preview p { margin: 0 0 .6rem; }
.doc-preview .doc-empty { min-height: .6rem; }
.doc-preview .doc-li { padding-left: 1.2rem; }
.doc-preview table.grid { margin: .6rem 0; }
table.grid td, table.grid th { border: 1px solid var(--line); padding: .3rem .5rem; vertical-align: top; }
table.grid p { margin: 0; }
.sheet-preview { padding: 1rem; }
.sheet-preview .table-wrap { background: var(--panel); max-height: calc(100vh - 300px); overflow: auto; border: 1px solid var(--line); }
table.sheet { font-size: .85rem; width: auto; }
table.sheet th { background: var(--bg); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
table.sheet tbody th { position: sticky; left: 0; text-align: right; }
table.sheet td { white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
table.sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
.slides-preview { padding: 1rem; display: grid; gap: 1rem; max-width: 900px; margin: 0 auto; }
.slide { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.2rem 1.5rem; aspect-ratio: 16 / 9; overflow: auto; box-shadow: var(--shadow); }
.slide-no { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.slide img { max-width: 45%; max-height: 50%; margin: .4rem .4rem 0 0; }
@media (max-width: 600px) {
  .container { padding: .7rem; }
  .card { padding: .9rem; }
  .doc-preview { padding: 1rem; margin: .5rem; }
  .slide { aspect-ratio: auto; }
  .pdf-frame, .img-stage { height: 70vh; }
}

/* ---------- CAD (DXF) viewer ---------- */
.thumb img.cad { object-fit: contain; background: #1e2127; }
.viewer-dxf { background: #1e2127; }
.cad-wrap { position: relative; height: calc(100vh - 200px); min-height: 420px; overflow: hidden; }
.cad-stage { position: absolute; inset: 0 0 1.9rem 0; cursor: grab; touch-action: none; user-select: none; }
.cad-stage.dragging { cursor: grabbing; }
.cad-stage svg { width: 100%; height: 100%; display: block; }
.cad-wrap.light, .cad-wrap.light .cad-stage { background: #ffffff; }
.cad-wrap.light svg.dxf { color: #111111; }
.cad-wrap.light svg.dxf .bg { fill: #ffffff; }
.cad-layers { position: absolute; top: .6rem; right: .6rem; bottom: 2.4rem; width: min(260px, 70vw); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.25); display: flex; flex-direction: column; z-index: 2; }
.cad-layers[hidden] { display: none; }
.cad-layers-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
.cad-layers [data-layer-list] { overflow: auto; padding: .3rem .7rem; }
.cad-layers label.check { padding: .15rem 0; font-size: .88rem; overflow-wrap: anywhere; }
.swatch { width: .85rem; height: .85rem; border-radius: 3px; border: 1px solid rgba(127,127,127,.6); flex: none; }
.cad-status { position: absolute; left: 0; right: 0; bottom: 0; padding: .3rem .8rem; background: rgba(0,0,0,.55); color: #e8e8e8; display: flex; gap: 1.2rem; flex-wrap: wrap; font-variant-numeric: tabular-nums; pointer-events: none; }
@media (max-width: 600px) { .cad-wrap { height: 70vh; } }

/* ---------- picking entities in DXF graphics ---------- */
.cad-stage.show-linked path.lnk:not(.f):not(.hl):not(.sel) { stroke: #00d68f !important; }
.cad-stage.show-linked text.lnk:not(.hl):not(.sel), .cad-stage.show-linked path.f.lnk:not(.hl):not(.sel) { fill: #00d68f !important; }
.cad-stage path.hl:not(.f) { stroke: #ffb300 !important; stroke-width: 2.5px !important; }
.cad-stage text.hl, .cad-stage path.f.hl { fill: #ffb300 !important; }
.cad-stage path.sel:not(.f) { stroke: #ff3d00 !important; stroke-width: 3px !important; }
.cad-stage text.sel, .cad-stage path.f.sel { fill: #ff3d00 !important; }
.cad-pick { position: absolute; top: .6rem; left: .6rem; bottom: 2.4rem; width: min(310px, 82vw); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.25); display: flex; flex-direction: column; z-index: 3; }
.cad-pick[hidden] { display: none; }
.cad-pick-body { overflow: auto; padding: .4rem .75rem .8rem; }
.cad-pick .flash { margin: .4rem 0; font-size: .85rem; padding: .4rem .6rem; }
.pick-sec { padding: .5rem 0; border-bottom: 1px solid var(--line); display: grid; gap: .35rem; }
.pick-sec:last-child { border-bottom: 0; }
.pick-title { font-weight: 600; overflow-wrap: anywhere; }
.pick-linked { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pick-form { border: 1px solid var(--line); border-radius: 8px; padding: .35rem .55rem; }
.pick-form[open] { display: grid; gap: .4rem; }
.pick-form summary { cursor: pointer; font-size: .88rem; font-weight: 500; }
.pick-form label { display: grid; gap: .2rem; font-size: .85rem; }
.pick-form select, .pick-form input { font-size: .88rem; padding: .3rem .45rem; }
.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.pick-list .linklike { padding: .1rem .2rem; text-align: left; }
.pick-list .linklike:hover { color: var(--accent); }
.drawing-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }

/* ---------- attribute values ---------- */
:root { --chart: #0b8a6a; }
@media (prefers-color-scheme: dark) { :root { --chart: #1fa883; } }
.latest-values { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: 1rem; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; min-width: 150px; }
.stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 1rem; font-weight: 500; color: var(--muted); }
.stat-time { font-size: .8rem; color: var(--muted); }
.value-chart { margin: 0 0 1rem; }
.value-chart figcaption { font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.chart-host { position: relative; width: 100%; }
.chart-host svg { display: block; }
.chart-host .grid { stroke: var(--line); stroke-width: 1; }
.chart-host .baseline { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.chart-host .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-host .series { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-host .marker { fill: var(--chart); stroke: var(--panel); stroke-width: 2; }
.chart-host .marker.active { r: 5; }
.chart-host .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.15); padding: .35rem .6rem; font-size: .82rem; white-space: nowrap; z-index: 2; }
.list td.num, .list th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn-row, .row-actions form { display: inline; }
.value-actions { margin-top: .9rem; align-items: flex-start; }
.value-actions details { flex: 1 1 100%; }
.value-actions details:not([open]) { flex: 0 0 auto; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }
@media (max-width: 760px) {
  .list.responsive td.num { justify-content: flex-start; text-align: left; }
  .list.responsive td:empty { display: none; }
  .row-actions { justify-content: flex-start; padding-top: .4rem !important; }
  .row-actions::before { content: none !important; }
}
.tval { font-size: .82rem; font-weight: 600; color: var(--c-attributes); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- item tooltip & popup ---------- */
.item-tip { position: fixed; z-index: 50; max-width: min(360px, 92vw); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 22px rgba(0,0,0,.18); padding: .55rem .7rem; font-size: .85rem; pointer-events: none; display: grid; gap: .25rem; }
.item-tip[hidden] { display: none; }
.item-tip-head { display: flex; align-items: baseline; gap: .35rem; flex-wrap: wrap; overflow-wrap: anywhere; }
.item-tip-head b { font-size: .92rem; }
.item-tip-value { font-weight: 600; color: var(--c-attributes); font-variant-numeric: tabular-nums; }
.item-tip-desc { white-space: pre-line; overflow-wrap: anywhere; }
.item-tip-hint { font-size: .72rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .25rem; margin-top: .1rem; }
.item-pop { position: fixed; z-index: 60; width: min(440px, 94vw); max-height: min(70vh, 560px); overflow: auto; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: .9rem 1rem 1rem; display: grid; gap: .6rem; }
.item-pop[hidden] { display: none; }
.item-pop.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100%; max-height: 75vh; border-radius: 14px 14px 0 0; }
.item-pop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.item-pop-head h2 { display: inline; font-size: 1.15rem; margin: 0 .4rem 0 0; overflow-wrap: anywhere; outline: none; }
.item-pop-close { border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: .2rem .4rem; border-radius: 6px; }
.item-pop-close:hover { background: var(--bg); color: var(--text); }
.item-pop-desc { white-space: pre-line; overflow-wrap: anywhere; max-height: 40vh; overflow: auto; line-height: 1.55; }
.item-pop-values { display: flex; flex-wrap: wrap; gap: .4rem; }
.item-pop-values .chip { cursor: default; font-variant-numeric: tabular-nums; }
h1[data-item] { cursor: default; }

/* ---------- templates: attribute types & sets ---------- */
.num-input { width: 5.5rem; }
.set-items input[type=text], .set-items input:not([type]) { min-width: 12rem; }
.add-item .form-row { align-items: end; }
.set-status { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .8rem; }
.set-status-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.set-status-head h3 { margin: 0; font-size: 1rem; }
.progress { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 600; }
.progress-bar { width: 110px; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--chart); border-radius: 99px; }
.progress.done { color: var(--ok); }
.badge-req { font-size: .7rem; font-weight: 700; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); border-radius: 99px; padding: 0 .4rem; margin-left: .3rem; text-transform: uppercase; letter-spacing: .03em; }
.badge-range { font-size: .72rem; font-weight: 700; color: #a15c00; background: color-mix(in srgb, #f0a000 18%, transparent); border-radius: 99px; padding: .05rem .45rem; margin-left: .35rem; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .badge-range { color: #ffc46b; } }
.missing { color: var(--muted); font-style: italic; }
.type-info { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .6rem; font-size: .88rem; }
.flash-warn { color: #8a5300; border-color: color-mix(in srgb, #f0a000 50%, transparent); background: color-mix(in srgb, #f0a000 10%, transparent); }
@media (prefers-color-scheme: dark) { .flash-warn { color: #ffc46b; } }
.badge-req, .badge-range { display: inline-block; vertical-align: middle; line-height: 1.5; }

/* ---------- graphics editor ---------- */
.ed { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.ed-toolbar { display: flex; flex-wrap: wrap; gap: .35rem .8rem; align-items: center; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.ed-group { display: flex; gap: .2rem; align-items: center; flex-wrap: wrap; }
.ed-group > button:not(.btn) { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 7px; padding: .3rem .55rem; font: inherit; font-size: .88rem; cursor: pointer; min-width: 2.1rem; }
.ed-group > button:not(.btn):hover { border-color: var(--muted); }
.ed-group > button:not(.btn).active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ed-group > button:disabled { opacity: .4; cursor: default; }
.ed-snaps label { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; }
.ed-snaps input[type=text] { width: 4.5rem; padding: .2rem .4rem; font-size: .85rem; }
.ed-save { margin-left: auto; }
.ed-dirty { color: #c77700; font-size: .8rem; font-weight: 600; }
.ed-main { flex: 1; display: flex; min-height: 0; }
.ed-canvas { flex: 1; position: relative; background: #1e2127; color: #eeeeee; outline: none; overflow: hidden; touch-action: none; user-select: none; cursor: crosshair; }
.ed-canvas[data-tool=select] { cursor: default; }
.ed-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ed-grid .minor { stroke: rgba(255,255,255,.05); stroke-width: 1; }
.ed-grid .major { stroke: rgba(255,255,255,.11); stroke-width: 1; }
.ed-grid .axis { stroke: rgba(255,255,255,.22); stroke-width: 1; }
.ed-world path, .ed-world circle { fill: none; stroke-width: 1.3px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.ed-world path.f { stroke: none; }
.ed-world text { stroke: none; font-family: Arial, Helvetica, sans-serif; white-space: pre; }
.ed-bg { opacity: .55; }
.ed-bg .ed-deleted { display: none; }
.ed-bg .ed-lsel { opacity: 1; stroke: #ff3d00 !important; stroke-width: 2.5px !important; }
.ed-bg text.ed-lsel, .ed-bg path.f.ed-lsel { fill: #ff3d00 !important; stroke: none !important; }
.ed-shapes .hov { stroke-width: 2.5px; }
.ed-shapes text.hov { opacity: .8; }
.ed-shapes .sel { stroke: #4aa3ff !important; stroke-width: 2.2px; stroke-dasharray: 6 3; }
.ed-shapes text.sel { fill: #4aa3ff !important; stroke: none !important; stroke-dasharray: none; }
.ed-preview path, .ed-preview circle { stroke: #ffb300; stroke-width: 1.3px; stroke-dasharray: 5 4; }
.ed-ui .grip { fill: #4aa3ff; stroke: #fff; stroke-width: 1; cursor: move; }
.ed-ui .grip.center { fill: #fff; stroke: #4aa3ff; }
.ed-ui .selbox { fill: rgba(74,163,255,.12); stroke: #4aa3ff; stroke-width: 1; }
.ed-ui .selbox.crossing { fill: rgba(0,214,143,.12); stroke: #00d68f; stroke-dasharray: 5 3; }
.ed-ui .snapmark { fill: none; stroke: #ffb300; stroke-width: 2; }
.ed-side { width: 300px; flex: none; overflow: auto; border-left: 1px solid var(--line); background: var(--panel); }
.ed-sec { padding: .7rem .85rem; border-bottom: 1px solid var(--line); display: grid; gap: .45rem; }
.ed-sec h3 { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ed-sec label { display: grid; gap: .2rem; font-size: .85rem; font-weight: 500; }
.ed-sec input, .ed-sec select, .ed-sec textarea { font-size: .88rem; padding: .3rem .45rem; }
.ed-sec .invalid, .ed .invalid { border-color: var(--danger); outline: 2px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.ed-layers { display: grid; gap: .15rem; max-height: 220px; overflow: auto; }
.ed-layer { display: grid; grid-template-columns: auto auto auto 1fr 7.5rem; gap: .35rem; align-items: center; padding: .15rem .25rem; border-radius: 6px; font-size: .86rem; }
.ed-layer.current { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ed-layer.off .ed-lname { opacity: .45; text-decoration: line-through; }
.ed-layer select { padding: .1rem .2rem; font-size: .8rem; }
.ed-lname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.ed-eye { border: 0; background: none; color: var(--text); cursor: pointer; padding: 0 .15rem; font-size: .8rem; }
.ed-addlayer { display: flex; gap: .3rem; }
.ed-addlayer input { flex: 1; }
.ed-field { display: grid; gap: .15rem; }
.ed-field > span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.ed-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .5rem; }
.ed-vertices { display: grid; gap: .3rem; max-height: 260px; overflow: auto; padding-right: .2rem; }
.ed-help { line-height: 1.55; }
.ed-status { padding: .3rem .7rem; border-top: 1px solid var(--line); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; min-height: 1.8rem; }
.new-drawing { margin-right: .4rem; }
@media (max-width: 900px) {
  .ed { height: auto; }
  .ed-main { flex-direction: column; }
  .ed-canvas { height: 60vh; flex: none; }
  .ed-side { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .ed-group > button span { display: none; }
  .ed-save { margin-left: 0; }
}

/* ---------- language menu ---------- */
.lang-menu { position: relative; order: 3; }
.lang-menu > summary { list-style: none; cursor: pointer; padding: .35rem .55rem; border-radius: 7px; font-size: .88rem; color: var(--text); white-space: nowrap; }
.lang-menu > summary::-webkit-details-marker { display: none; }
.lang-menu > summary:hover { background: var(--bg); }
.lang-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: .3rem; display: grid; min-width: 9rem; z-index: 40; }
.lang-list a { padding: .4rem .7rem; border-radius: 6px; color: var(--text); }
.lang-list a:hover { background: var(--bg); text-decoration: none; }
.lang-list a.active { font-weight: 700; color: var(--accent); }
.topbar .mainnav { order: 2; }
@media (max-width: 820px) { .lang-menu { margin-left: auto; } .nav-toggle { margin-left: 0; } .topbar .mainnav { order: 4; } }

/* tree: keep the icon with the name; a long name wraps inside, not away from its icon */
.thead { min-width: 0; overflow-wrap: anywhere; }
.tree summary .tcount { margin-top: .1rem; }
.form label .hint { font-weight: 400; }

/* login motto */
.motto { text-wrap: balance; margin: 1.6rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--line); text-align: center; }
.motto blockquote { margin: 0; font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 1.05rem; line-height: 1.45; color: var(--text); }
.motto figcaption { margin-top: .45rem; font-size: .8rem; color: var(--muted); }

/* update page */
.big-version { font-size: 2rem; font-weight: 700; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
.update-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.update-badge { font-size: .78rem; font-weight: 600; border-radius: 99px; padding: .12rem .6rem; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.update-badge.state-success { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.update-badge.state-failed, .update-badge.state-rolled_back { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.update-badge.state-running, .update-badge.state-queued { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.update-steps { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.update-steps li { color: var(--muted); font-size: .9rem; }
.update-steps li::before { content: "○"; display: inline-block; width: 1.3em; }
.update-steps li.done { color: var(--text); }
.update-steps li.done::before { content: "✓"; color: var(--ok); }
.update-steps li.current { color: var(--accent); font-weight: 600; }
.update-steps li.current::before { content: "◐"; animation: upd-spin 1s linear infinite; }
@keyframes upd-spin { to { transform: rotate(360deg); } }
.update-msg:empty { display: none; }
.update-log pre { max-height: 22rem; overflow: auto; background: #0f172a; color: #e2e8f0; padding: .8rem; border-radius: 8px; font-size: .8rem; white-space: pre-wrap; }
.update-log summary { cursor: pointer; font-weight: 500; }
.update-status { margin-top: 1rem; }
.maint-box { margin: 4rem auto 0; text-align: center; }
.update-steps li.error { color: var(--danger); font-weight: 600; }
.update-steps li.error::before { content: "✗"; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; background: color-mix(in srgb, var(--line) 50%, transparent); padding: .05rem .3rem; border-radius: 4px; overflow-wrap: anywhere; }

/* login logo (Diderot signature) */
.auth-logo { display: block; width: 144px; height: auto; margin: .2rem auto 1.1rem; }

/* ------------------------------------------------------------------
   Type colours as backgrounds: actions / entities / attributes / files
   (tints of the type colours; work in light and dark mode)
   ------------------------------------------------------------------ */
:root {
  --bg-actions:    color-mix(in srgb, var(--c-actions) 11%, var(--panel));
  --bg-entities:   color-mix(in srgb, var(--c-entities) 10%, var(--panel));
  --bg-attributes: color-mix(in srgb, var(--c-attributes) 11%, var(--panel));
  --bg-file:       color-mix(in srgb, var(--c-file) 14%, var(--panel));
  --bd-actions:    color-mix(in srgb, var(--c-actions) 35%, var(--panel));
  --bd-entities:   color-mix(in srgb, var(--c-entities) 35%, var(--panel));
  --bd-attributes: color-mix(in srgb, var(--c-attributes) 35%, var(--panel));
  --bd-file:       color-mix(in srgb, var(--c-file) 35%, var(--panel));
}
.tnode.t-actions,    .chip.t-actions,    .card.t-actions,    .item-tip.t-actions,    .item-pop.t-actions    { --tbg: var(--bg-actions);    --tbd: var(--bd-actions); }
.tnode.t-entities,   .chip.t-entities,   .card.t-entities,   .item-tip.t-entities,   .item-pop.t-entities   { --tbg: var(--bg-entities);   --tbd: var(--bd-entities); }
.tnode.t-attributes, .chip.t-attributes, .card.t-attributes, .item-tip.t-attributes, .item-pop.t-attributes { --tbg: var(--bg-attributes); --tbd: var(--bd-attributes); }
.tnode.t-file,       .chip.t-file,       .card.t-file,       .file-card                                    { --tbg: var(--bg-file);       --tbd: var(--bd-file); }

/* tree: each node is a tinted pill */
.tnode[class*="t-"] { background: var(--tbg); border: 1px solid var(--tbd); border-radius: 7px; padding: .06rem .5rem; }
.tnode .tbadge { background: var(--panel); }
/* chips (linked items, drawings) */
.chip[class*="t-"] { background: var(--tbg); border-color: var(--tbd); }
.chip[class*="t-"]:hover { border-color: var(--accent); }
/* item page header, list of one type, file viewer header */
.card.t-actions, .card.t-entities, .card.t-attributes, .card.t-file { background: var(--tbg); border-color: var(--tbd); }
.card.t-actions .list th, .card.t-entities .list th, .card.t-attributes .list th, .card.t-file .list th { background: color-mix(in srgb, var(--tbd) 45%, var(--tbg)); }
.card.t-file .viewer-bar { background: var(--tbg); }
.card.viewer.t-file { background: var(--panel); }
/* files */
.file-card { background: var(--tbg); border-color: var(--tbd); }
.file-card .thumb { background: color-mix(in srgb, var(--tbd) 40%, var(--tbg)); }
/* tooltip and popup */
.item-tip[class*="t-"], .item-pop[class*="t-"] { background: var(--tbg); border-color: var(--tbd); }

/* report page */
.report-grid { align-items: start; }
.report-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.radio-row { border: 0; padding: 0; margin: 0 0 .4rem; }
.radio-row legend { font-weight: 500; margin-bottom: .2rem; }
.radio-row .check { display: inline-flex; margin-right: 1rem; }
.report-outline { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .25rem; }
.report-outline li { padding-left: calc(var(--lvl, 0) * 1.1rem); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.report-outline li.ref .tnode { opacity: .6; }
.form .radio-row { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
.form .radio-row legend { width: 100%; }
.form .radio-row label.check { display: inline-flex; flex-direction: row; align-items: center; gap: .4rem; width: auto; margin: 0; }
.form .radio-row label.check input { width: auto; margin: 0; }
.report-outline li { flex-wrap: nowrap; align-items: flex-start; }
.report-outline li > .muted.small:first-child { flex-shrink: 0; padding-top: .15rem; min-width: 2.2rem; }
.report-outline .tnode { flex-wrap: nowrap; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .report-outline li { padding-left: calc(var(--lvl, 0) * .55rem); } }

/* graphical report */
.gr-layer-list { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.gr-layer-item { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; background: var(--panel); }
.gr-layer-item label.check { flex-wrap: wrap; }
.gr-hatch-swatch { width: 1.4rem; height: 1rem; border-radius: 3px; border: 1px solid var(--line); flex-shrink: 0;
  background: repeating-linear-gradient(calc(90deg - var(--a)), #6b7280 0 1.5px, transparent 1.5px 5px); }
.gr-legend { margin-top: .45rem; display: grid; gap: .2rem; }
.gr-scale { display: grid; grid-template-columns: repeat(5, 1fr); height: .8rem; border-radius: 4px; overflow: hidden; }
.gr-scale-ticks { display: flex; justify-content: space-between; color: var(--muted); }
.gr-chip { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; }
.gr-chip-out { background: transparent; border: 2px dashed #B42318; }
.gr-out-badge { display: inline-block; min-width: 1.1rem; text-align: center; border-radius: 99px; background: #B42318; color: #fff; font-weight: 700; font-size: .75rem; }
.gr-options { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: center; margin-top: .8rem; }
.gr-drawing { margin-top: 1rem; overflow: hidden; }
.gr-title { margin: 0; font-size: 1.05rem; }
.gr-wrap { height: min(68vh, 640px); min-height: 340px; }
.gr-wrap .gr-stage { inset: 0; }
.gr-stage svg { width: 100%; height: 100%; }
.gr-overlay .gr-edge { stroke-width: 2px; vector-effect: non-scaling-stroke; }
.gr-overlay .gr-out .gr-edge { stroke-width: 3px; stroke-dasharray: 6 4; }
.gr-overlay .gr-none .gr-edge { stroke-dasharray: 2 3; stroke-width: 1px; }
.gr-overlay .gr-el:hover .gr-tint, .gr-overlay .gr-el.gr-hi .gr-tint { fill-opacity: .55; }
.gr-overlay .gr-el.gr-hi .gr-edge { stroke-width: 4px; }
.gr-overlay text.gr-label { text-anchor: middle; dominant-baseline: central; font-family: Arial, Helvetica, sans-serif; font-weight: 700;
  fill: #111827; stroke: #fff; stroke-width: 3px; paint-order: stroke; vector-effect: non-scaling-stroke; pointer-events: none; }
.gr-overlay text.gr-label-out { fill: #B42318; }
.gr-no-labels .gr-labels { display: none; }
.gr-table td.num { white-space: nowrap; }
@media print {
  .no-print, .topbar, .crumbs, .footer, .gr-options { display: none !important; }
  .gr-drawing { break-inside: avoid; }
  .gr-wrap { height: 16cm; }
  .card { box-shadow: none; }
}

/* graphical report: pictures */
.gr-thumbs-row { display: inline-flex; gap: .3rem; margin-left: .5rem; vertical-align: middle; }
.gr-thumb { width: 3rem; height: 2.25rem; padding: 0; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--panel); cursor: zoom-in; }
.gr-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gr-thumb:hover, .gr-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.gr-thumb-more { font-size: .8rem; font-weight: 600; color: var(--muted); }
.gr-overlay .gr-thumb-svg { cursor: zoom-in; }
.gr-overlay .gr-thumb-frame { fill: #fff; stroke: #374151; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
/* SVG measures outlines and shadows in drawing units – they would be huge; the frame shows focus instead */
.gr-overlay .gr-thumb-svg:focus, .gr-overlay .gr-thumb-svg:focus-visible { outline: none; }
.gr-overlay .gr-thumb-svg:hover .gr-thumb-frame, .gr-overlay .gr-thumb-svg:focus .gr-thumb-frame { stroke: var(--accent); stroke-width: 3px; }
.gr-overlay .gr-thumb-badge { fill: #1f2937; stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.gr-overlay text.gr-thumb-count { fill: #fff; font-family: Arial, Helvetica, sans-serif; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.gr-no-pictures .gr-thumbs { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 12, 16, .88); display: flex; align-items: center; justify-content: center; padding: 3rem 4.5rem; }
.lightbox[hidden] { display: none; }
.lb-open { overflow: hidden; }
.lb-figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.lb-figure img { max-width: 100%; max-height: calc(100vh - 9rem); object-fit: contain; border-radius: 6px; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lb-figure figcaption { color: #f3f4f6; text-align: center; display: flex; flex-wrap: wrap; gap: .3rem .8rem; justify-content: center; align-items: center; }
.lb-figure figcaption .muted { color: #c7cbd3; }
.lb-tools { display: inline-flex; gap: .6rem; align-items: center; }
.lb-close, .lb-nav { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 999px; cursor: pointer; }
.lb-close { top: 1rem; right: 1rem; width: 2.6rem; height: 2.6rem; font-size: 1.2rem; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 3rem; height: 3rem; font-size: 2rem; line-height: 1; }
.lb-prev { left: 1rem; } .lb-next { right: 1rem; }
.lb-close:hover, .lb-nav:hover, .lb-close:focus-visible, .lb-nav:focus-visible { background: rgba(255,255,255,.28); outline: none; }
@media (max-width: 600px) { .lightbox { padding: 3.5rem .6rem; } .lb-nav { top: auto; bottom: .8rem; transform: none; } }
@media print { .gr-thumb { border: 0; } .lightbox { display: none !important; } }

/* graphical report: download links on pictures */
.gr-thumb-wrap { position: relative; display: inline-block; }
.gr-thumb-wrap .gr-thumb { display: block; }
.gr-thumb-dl-link { position: absolute; right: -5px; bottom: -5px; width: 1.15rem; height: 1.15rem; border-radius: 99px; background: #1f2937; color: #fff;
  border: 1.5px solid #fff; font-size: .68rem; line-height: 1rem; text-align: center; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.gr-thumb-dl-link:hover, .gr-thumb-dl-link:focus-visible { background: var(--accent); color: #fff; outline: none; }
.gr-overlay .gr-thumb-dl { cursor: pointer; }
.gr-overlay .gr-thumb-dl circle { fill: #1f2937; stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.gr-overlay .gr-thumb-dl path { fill: none; stroke: #fff; stroke-width: 1.6px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.gr-overlay .gr-thumb-dl:hover circle { fill: var(--accent); }
@media print { .gr-thumb-dl-link, .gr-overlay .gr-thumb-dl { display: none; } }

/* camera */
.cam { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; }
.cam-shots { display: flex; flex-wrap: wrap; gap: .4rem; width: 100%; }
.cam-shots[hidden] { display: none; }
.cam-shot { position: relative; width: 4.5rem; height: 3.4rem; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.cam-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-shot-rm { position: absolute; top: 2px; right: 2px; width: 1.3rem; height: 1.3rem; border-radius: 99px; border: 0; background: rgba(17,24,39,.75); color: #fff; font-size: .7rem; cursor: pointer; }
.cam-dialog { padding: 0; border: 0; border-radius: 12px; background: #000; color: #fff; width: min(960px, 96vw); max-height: 96vh; overflow: hidden; }
.cam-dialog::backdrop { background: rgba(0,0,0,.75); }
.cam-view { position: relative; background: #000; aspect-ratio: 4 / 3; max-height: calc(96vh - 5rem); display: flex; align-items: center; justify-content: center; }
.cam-view video { width: 100%; height: 100%; object-fit: contain; }
.cam-view video.mirror { transform: scaleX(-1); }
.cam-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; padding: 1.5rem; text-align: center; background: #111827; }
.cam-msg[hidden] { display: none; }
.cam-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem; padding: .7rem 1rem; background: #111; }
.cam-bar .btn { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.cam-bar .btn.primary { background: var(--accent); }
.cam-right { justify-self: end; display: flex; align-items: center; gap: .7rem; }
.cam-shutter { width: 3.6rem; height: 3.6rem; border-radius: 99px; border: 4px solid #fff; background: #fff; box-shadow: inset 0 0 0 3px #111; cursor: pointer; }
.cam-shutter:disabled { opacity: .35; cursor: default; }
.cam-shutter:not(:disabled):active { transform: scale(.94); }
.cam-dialog.flash .cam-view::after { content: ""; position: absolute; inset: 0; background: #fff; animation: cam-flash .25s ease-out forwards; pointer-events: none; }
@keyframes cam-flash { from { opacity: .85; } to { opacity: 0; } }
.cam-bar [data-cam-switch] { justify-self: start; width: auto; }
.cam > .btn { width: auto; }
@media (max-width: 600px) {
  .cam-dialog { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; border-radius: 0; }
  .cam-dialog[open] { display: flex; flex-direction: column; }
  .cam-view { flex: 1; aspect-ratio: auto; max-height: none; min-height: 0; }
  .cam-bar { padding: .8rem .7rem calc(.8rem + env(safe-area-inset-bottom)); gap: .4rem; }
  .cam-switch-label { display: none; }
  .cam-right { gap: .4rem; }
}

/* ---- two-factor authentication */
.badge { display: inline-block; font-size: .78rem; font-weight: 700; border-radius: 99px; padding: .1rem .6rem; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge-ok { color: #1f7a3a; background: color-mix(in srgb, #2da44e 14%, transparent); border-color: color-mix(in srgb, #2da44e 40%, transparent); }
@media (prefers-color-scheme: dark) { .badge-ok { color: #6fdc8c; } }
.mfa-steps { padding-left: 1.3rem; }
.mfa-steps li { margin: .6rem 0; }
.qr { margin: .6rem 0; }
.qr svg { display: block; width: 200px; height: 200px; border-radius: 6px; }
code.secret { font-size: 1.05rem; letter-spacing: .08em; user-select: all; word-break: break-all; }
.otp-input { font-family: ui-monospace, monospace; font-size: 1.3rem; letter-spacing: .25em; text-align: center; max-width: 14rem; }
.mfa-codes { border: 2px dashed var(--accent); border-radius: 8px; padding: .4rem 1rem 1rem; margin-bottom: 1rem; }
.mfa-codes h2 { margin-top: .5rem; }
.code-list { columns: 2; font-size: 1.1rem; padding-left: 1.6rem; }
.code-list li { margin: .2rem 0; }
.code-list code { user-select: all; }
.badge-2fa { font-size: .68rem; font-weight: 700; color: #1f7a3a; border: 1px solid color-mix(in srgb, #2da44e 45%, transparent); border-radius: 99px; padding: 0 .4rem; margin-left: .35rem; vertical-align: middle; }
@media (prefers-color-scheme: dark) { .badge-2fa { color: #6fdc8c; } }
@media print { .mfa-codes { border: 0; } .mfa-codes .btn-row { display: none; } }

/* ---- delete with dependent items */
.del-option { display: flex; gap: .7rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; margin: .6rem 0 0; cursor: pointer; font-weight: normal; }
.del-option:has(input:checked) { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--panel)); }
.del-option input { margin-top: .25rem; }
.del-body { display: flex; flex-direction: column; gap: .2rem; }
.del-sum { font-weight: 600; color: var(--danger); }
.del-kept { font-size: .9rem; color: var(--muted); }
.del-details { margin: .2rem 0 .4rem 2.2rem; }
.del-details summary { cursor: pointer; font-size: .9rem; color: var(--accent); }
.del-group h4 { margin: .6rem 0 .2rem; font-size: .9rem; }
.del-details .chips { max-height: 14rem; overflow: auto; }
p.flash { margin-top: 0; }
.form label.del-option { display: flex; flex-direction: row; gap: .7rem; }
.form .del-option input[type=radio] { width: auto; flex: none; margin: .2rem 0 0; }

/* =========================================================================================
   Usability (1.11)
   ========================================================================================= */
/* global search in the top bar */
.nav-search { margin: 0 .3rem 0 .6rem; }
.nav-search input { width: 11rem; padding: .35rem .6rem; border-radius: 7px; font-size: .9rem; transition: width .15s; }
.nav-search input:focus { width: 16rem; }
@media (max-width: 1100px) { .nav-search input { width: 8rem; } .nav-search input:focus { width: 12rem; } }
@media (max-width: 820px) { .nav-search { margin: .3rem 0; } .nav-search input, .nav-search input:focus { width: 100%; } }
mark { background: color-mix(in srgb, #ffd400 45%, transparent); color: inherit; border-radius: 2px; padding: 0 .05em; }
.search-results { display: grid; gap: 1rem; }
.search-results h2 .count { font-size: .8rem; color: var(--muted); font-weight: 600; }
.hits { list-style: none; padding: 0; margin: 0 0 .5rem; }
.hits li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.hits li:last-child { border-bottom: 0; }

/* drop-down menu (item page "More") */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + .3rem); z-index: 30; min-width: 14rem; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: .3rem; display: flex; flex-direction: column; }
.menu-list a { padding: .5rem .7rem; border-radius: 6px; color: var(--text); white-space: nowrap; }
.menu-list a:hover, .menu-list a:focus-visible { background: var(--bg); text-decoration: none; }
.menu-list a.danger { color: var(--danger); }
.menu-list hr { margin: .3rem 0; border: 0; border-top: 1px solid var(--line); }
@media (max-width: 600px) { .menu-list { right: auto; left: 0; } }

/* actions inside a detail section */
.section-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }

/* sortable, clickable list rows */
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort:hover { color: var(--accent); }
th a.sort.active { color: var(--accent); }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
[data-live-region][aria-busy] { opacity: .55; transition: opacity .15s; }

/* messages */
.flash { position: relative; padding-right: 2.2rem; }
.flash-close { position: absolute; top: .35rem; right: .45rem; border: 0; background: none; font-size: 1.2rem; line-height: 1; color: inherit; opacity: .6; cursor: pointer; padding: .15rem .35rem; border-radius: 5px; }
.flash-close:hover { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
.flash.fade { opacity: 0; transition: opacity .6s; }
p.flash { padding-right: .9rem; }

/* link pickers */
.picker-tools { display: flex; gap: .8rem; align-items: center; }
.picker-tools input[type=search] { flex: 1; }
.picker-tools label.check { white-space: nowrap; font-weight: normal; }
fieldset.picker:target { outline: 2px solid var(--accent); outline-offset: 3px; }

/* value form */
.linklike.small { font-size: .8rem; padding: .1rem .3rem; justify-self: start; color: var(--accent); }

/* tree tabs: one scrollable row on phones instead of wrapping */
@media (max-width: 600px) {
  .tabs.tabs-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs.tabs-nav > * { flex: none; }
}

/* item page: buttons stay on one line on phones where possible */
@media (max-width: 600px) { .item-actions .btn { padding-inline: .7rem; } }
.sort-select { display: none; }
@media (max-width: 760px) {
  .searchbar { flex-wrap: wrap; }
  .sort-select { display: block; flex-basis: 100%; }
}
@media (max-width: 820px) { .nav-search { order: -1; } }

/* ---- template builder & sample gallery */
.tb-table td { vertical-align: top; }
.tb-table input { width: 100%; }
.tb-table .tb-unit { min-width: 5rem; }
.tb-table .tb-num { min-width: 5rem; text-align: right; }
.tb-table td:nth-child(2) { min-width: 15rem; }
.tb-handle { white-space: nowrap; width: 1%; }
.tb-handle .btn { padding: .15rem .45rem; }
.tb-handle .btn:disabled { opacity: .3; cursor: default; }
.tb-existing { display: none; color: var(--muted); margin-top: .2rem; }
.tb-row.is-existing .tb-existing { display: block; }
.tb-row.is-existing input[readonly] { background: var(--bg); color: var(--muted); }
.tb-error { display: block; color: var(--danger); margin-top: .2rem; }
.tb-row.has-error input[data-tb-name] { border-color: var(--danger); }
@media (max-width: 760px) {
  .tb-table td:nth-child(2) { min-width: 0; }
  .tb-handle { width: auto; }
}
.sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 1rem; }
.sample-card { display: flex; flex-direction: column; margin: 0; }
.sample-card h2 { margin-top: 0; display: flex; gap: .5rem; align-items: center; }
.sample-icon { font-size: 1.4rem; }
.sample-items { list-style: none; padding: 0; margin: .3rem 0 .6rem; flex: 1; }
.sample-items li { display: flex; gap: .5rem; align-items: baseline; padding: .25rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sample-items li:last-child { border-bottom: 0; }
.si-name { flex: 1; }
.si-req { color: var(--danger); font-weight: 700; }
.si-ex { color: var(--accent); border: 1px solid currentColor; border-radius: 99px; padding: 0 .4rem; }
.sample-card .btn-row { margin-top: auto; align-items: center; }
.sample-card form { display: inline; }
/* template builder on phones: each row a compact card –
   name across the full width, then unit / min / max side by side, then required, order and remove */
@media (max-width: 760px) {
  .list.responsive.tb-table tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem .5rem; padding: .7rem .2rem; }
  .list.responsive.tb-table td { display: block; padding: 0 .3rem; min-width: 0; }
  .list.responsive.tb-table td::before { display: block; margin-bottom: .15rem; font-size: .7rem; }
  .list.responsive.tb-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
  .list.responsive.tb-table td:nth-child(3), .list.responsive.tb-table td:nth-child(4), .list.responsive.tb-table td:nth-child(5) { grid-row: 2; }
  .list.responsive.tb-table td:nth-child(6) { grid-row: 3; grid-column: 1; align-self: center; }
  .list.responsive.tb-table td:nth-child(6)::before, .list.responsive.tb-table td.tb-handle::before { display: none; }
  .list.responsive.tb-table td.tb-handle { grid-row: 3; grid-column: 2; align-self: center; justify-self: center; }
  .list.responsive.tb-table td.row-actions { grid-row: 3; grid-column: 3; justify-self: end; align-self: center; }
  .tb-table .tb-unit, .tb-table .tb-num { min-width: 0; }
}
[hidden] { display: none !important; }
.template-pick { border: 1px dashed var(--line); border-radius: 8px; padding: .6rem .8rem; display: grid; gap: .4rem; }
.template-preview .chips { margin: .2rem 0; }

/* ---- working context */
.ctx-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin: 0 0 .8rem; padding: .45rem .7rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; }
.ctx-label { color: var(--muted); font-weight: 600; }
.ctx-item { display: inline-flex; align-items: center; gap: .1rem; }
.ctx-item form { display: inline; }
.ctx-clear { border: 0; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: .1rem .35rem; border-radius: 5px; cursor: pointer; }
.ctx-clear:hover { color: var(--danger); background: var(--bg); }
.ctx-sep { color: var(--muted); }
.ctx-hint { margin-left: auto; }
@media (max-width: 760px) { .ctx-hint { display: none; } }
.ctx-link { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: color-mix(in srgb, var(--accent) 5%, var(--panel));
  border-radius: 8px; padding: .55rem .8rem; display: grid; gap: .2rem; }
.ctx-link label.check { font-weight: 600; flex-wrap: wrap; }
