/* FORMWORK — the customizable project workspace. Identity per the blueprint:
   cast-concrete ground, steel ink, safety-orange accent, mono labels.
   UI STANDARD: all type in rem (resolution-free — browser zoom and user font
   settings scale everything), fluid widths via clamp(), ＋/− expander boxes,
   accent = action, danger = destructive only. */
:root{
  --ground:#ECEBE7; --panel:#FAFAF8; --panel2:#F3F2EE;
  --ink:#1F2833; --muted:#5C6670; --line:#C9C7C0; --line2:#DDDBD5;
  --accent:#D95510; --accent-ink:#FFFFFF; --danger:#B3261E;
  --chip:#E4E2DC; --computed:#6E7883;
  /* Reached only through a hardcoded fallback until now, which meant they
     never changed with the theme: --sel fell back to a pale blue that sat as
     a bright block on a dark panel. */
  --sel:#DEE4F0; --good:#2E7D4F;
  /* the critical path: a red that is not the orange of an ordinary bar */
  --crit:#C2183A; --calm:#7C93AD;
}
@media (prefers-color-scheme: dark){
  :root{
    --ground:#14171B; --panel:#1D2127; --panel2:#22262D;
    --ink:#E8E6E0; --muted:#9AA1A9; --line:#3A4049; --line2:#2C313A;
    --accent:#FF7A29; --accent-ink:#1A1408; --danger:#E5766F;
    --chip:#2B3038; --computed:#87919C;
    --sel:#2B3444; --good:#6BBF7F;
    --crit:#FF4468; --calm:#6F88A6;
  }
}
*{box-sizing:border-box}
html,body{height:100%;overflow:hidden}
body{margin:0;background:var(--ground);color:var(--ink);
  font-family:"Segoe UI",system-ui,sans-serif;font-size:.875rem;line-height:1.45}
/* color:inherit matters in DARK MODE. A bare <button style="background:none">
   — the ✎ / × / ↑ / ↓ affordances scattered through the designers and line
   rows — otherwise takes the browser's default near-black text and disappears
   against a dark panel. Ten of them were invisible. The .btn classes set their
   own colour and win on specificity, so they are untouched. */
button{font:inherit;cursor:pointer;color:inherit}
input,select,textarea{font:inherit;color:var(--ink);background:var(--panel);
  border:1px solid var(--line);border-radius:4px;padding:.4rem .5rem;width:100%}
input:focus,select:focus,textarea:focus,button:focus-visible{outline:2px solid var(--accent);outline-offset:1px}

#app{display:grid;grid-template-columns:var(--sidew, clamp(13rem,18vw,17.5rem)) 6px 1fr;
     grid-template-rows:auto 1fr;height:100dvh}
/* the bar spans every column: it belongs to the window, not to a pane */
#topbar{grid-column:1/-1;display:flex;align-items:center;gap:10px;padding:8px 12px;
        background:var(--panel);border-bottom:1px solid var(--line);position:relative;z-index:70}
#topbar .brand{margin:0 6px 0 0;white-space:nowrap}
#topbar #space-wrap{width:auto;margin:0}
#items-wrap,#tools-wrap,#who-wrap{position:relative}
/* one control, three copies: identical box, so they sit on one line and read
   as a set rather than as three things that happen to be near each other */
#topbar #space-btn,#items-btn,#tools-btn,#who-btn{display:flex;align-items:center;gap:8px;
        height:42px;padding:0 14px;width:auto;font:inherit;font-size:1.02rem;font-weight:600;
        background:var(--field);color:var(--ink);border:1px solid var(--line2);border-radius:7px;cursor:pointer}
/* the project and the item list are the two things every screen is ABOUT, and
   either name can be long — they get room, and ellipsis rather than reflow */
#topbar #space-btn{min-width:11rem;max-width:22rem}
#items-btn{min-width:8.5rem;max-width:18rem}
#topbar #space-btn #space-name,#items-btn #items-name{flex:1;text-align:left;
        overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#who-btn{padding:0 10px}
#wait-btn{display:flex;align-items:center;gap:6px;height:40px;padding:0 10px;border:1px solid var(--line);border-radius:8px;background:transparent;color:var(--ink);cursor:pointer;font:inherit}
#wait-btn:hover{border-color:var(--accent)}
#wait-btn .wait-count{min-width:1.4rem;padding:0 .4rem;border-radius:999px;background:var(--accent);color:var(--accent-ink);font-size:.78rem;font-weight:600;text-align:center;line-height:1.4rem}
#wait-btn.quiet .wait-count{background:var(--line2);color:var(--muted)}
#topbar #space-btn #space-icon,#topbar #space-btn #space-name{font-size:inherit;line-height:1}
#items-btn:hover,#tools-btn:hover,#who-btn:hover{border-color:var(--accent)}
#items-btn[aria-expanded="true"],#tools-btn[aria-expanded="true"],#who-btn[aria-expanded="true"]{border-color:var(--accent);background:var(--sel)}
.avatar{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;
        border-radius:50%;background:var(--sel);border:1px solid var(--line2);font-size:.72rem;font-weight:600}
#items-menu[hidden],#tools-menu[hidden],#who-menu[hidden],#space-menu[hidden]{display:none}
#items-menu,#tools-menu{position:absolute;z-index:75;top:calc(100% + 4px);left:0;display:flex;gap:0;
        min-width:min(18rem,92vw);max-height:min(60vh,30rem);overflow:hidden;
        background:var(--panel);border:1px solid var(--line2);border-radius:8px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
#items-menu .im-list,#tools-menu .im-list{flex:1;min-width:0;overflow:auto;padding:6px}
#items-menu button.im-item,#tools-menu button.im-item{display:flex;align-items:center;gap:8px;width:100%;
        background:none;border:0;color:var(--ink);text-align:left;padding:7px 9px;border-radius:6px;cursor:pointer}
#items-menu button.im-item:hover,#items-menu button.im-item.on,
#tools-menu button.im-item:hover:not([disabled]){background:var(--sel)}
/* Tools sits at the RIGHT end of the bar, so its menu hangs from that edge —
   dropped from the left it would run off the window. It is also the only one
   of the three whose entries can be unavailable, and a disabled entry keeps
   the arrow cursor so the title can explain why. */
#tools-menu{left:auto;right:0;min-width:min(20rem,92vw)}
#tools-menu button.im-item[disabled]{cursor:default}
#tools-btn{min-width:0}
#items-menu .im-folder{opacity:.85}
#items-menu .im-up{color:var(--muted);border-bottom:1px solid var(--line);border-radius:0;margin-bottom:4px}
#items-menu .im-drill{padding:0 .35rem;border-radius:4px;opacity:.55}
#items-menu .im-drill:hover{opacity:1;background:var(--line2)}
#items-menu .im-head{padding:0 0 6px;border-bottom:1px solid var(--line);margin-bottom:6px}
#items-menu .im-row{display:flex;justify-content:space-between;gap:10px;padding:5px 0;
        border-bottom:1px solid var(--line);cursor:pointer}
#items-menu .im-row:hover{color:var(--accent)}
#items-menu .im-row span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#who-menu{position:absolute;z-index:75;top:calc(100% + 4px);right:0;min-width:15rem;padding:6px;
        background:var(--panel);border:1px solid var(--line2);border-radius:8px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
#who-menu .who-head{display:flex;align-items:center;gap:10px;padding:8px 9px 10px;border-bottom:1px solid var(--line);margin-bottom:6px}
#who-menu button{display:flex;align-items:center;gap:9px;width:100%;background:none;border:0;
        color:var(--ink);text-align:left;padding:7px 9px;border-radius:6px;cursor:pointer}
#who-menu button:hover{background:var(--sel)}
#who-menu button.danger:hover{color:var(--accent)}
#side-grip{cursor:col-resize;background:transparent;margin-left:-3px;z-index:5}
#side-grip:hover,#side-grip.dragging{background:var(--accent);opacity:.4}

/* ── sidebar ── */
#sidebar{background:var(--panel);border-right:1px solid var(--line);
  padding:1rem .875rem;display:flex;flex-direction:column;gap:.75rem;overflow-y:auto}
.brand{font-size:1.375rem;font-weight:800;letter-spacing:-.02em}
.brand span{color:var(--accent)}
.mono-label{font-family:Consolas,ui-monospace,monospace;font-size:.66rem;
  letter-spacing:.14em;text-transform:uppercase;color:var(--muted)}
.project-row{display:flex;flex-direction:column;gap:.25rem}
#modules,#templates,#items{display:flex;flex-direction:column;gap:.25rem}
.side-head{display:flex;align-items:center;gap:.5rem;padding:.35rem .5rem .5rem;
  border-bottom:1px solid var(--line);margin-bottom:.35rem;font-weight:600}
.side-head[data-open]{cursor:pointer}
.side-head[data-open]:hover{color:var(--accent)}
.side-head.on{color:var(--accent)}
.side-up{background:none;border:0;color:var(--muted);cursor:pointer;font-size:1rem;padding:0 .25rem}
.side-up:hover{color:var(--accent)}
.module .into{background:none;border:0;color:var(--muted);cursor:pointer;padding:0 .25rem;border-radius:4px}
.module .into:hover{color:var(--accent);background:var(--line2)}
.module{display:flex;align-items:center;gap:.5rem;padding:.45rem .625rem;border-radius:5px;
  border:1px solid transparent;background:none;color:var(--ink);text-align:left;width:100%;
  cursor:pointer;min-height:1.9rem}
.module:hover{background:var(--panel2)}
.module.on{background:var(--panel2);border-color:var(--accent);
  box-shadow:inset 3px 0 0 var(--accent)}
/* While a read is running, the item you picked pulses its accent bar — the
   selection says WHICH one, this says it is still working on it. Scoped to the
   selected module so the whole tree does not throb. */
body.busy .module.on{animation:mod-working 1.1s ease-in-out infinite}
@keyframes mod-working{
  0%,100%{box-shadow:inset 3px 0 0 var(--accent)}
  50%    {box-shadow:inset 3px 0 0 color-mix(in srgb,var(--accent) 30%,transparent)}
}
@media (prefers-reduced-motion: reduce){
  body.busy .module.on{animation:none}
}
.module .ico{width:1.25rem;text-align:center}
.module .cnt{margin-left:auto;color:var(--muted);font-size:.75rem}
.module.tpl{opacity:.65;font-style:italic}
/* SPACE SWITCHER — top-left, the first thing read on the page. One control
   for a choice made once a session; it used to be a tab pair plus a dropdown. */
#space-wrap{position:relative;margin:0 0 10px;align-self:stretch;width:100%}
#space-btn{display:flex;align-items:center;gap:8px;width:100%;padding:9px 10px;
  background:var(--panel2);border:1px solid var(--line);border-radius:6px;
  font-weight:600;letter-spacing:.01em;text-align:left}
#space-btn:hover{border-color:var(--accent)}
#space-btn[aria-expanded="true"]{border-color:var(--accent);background:var(--sel)}
#space-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#space-btn .caret{opacity:.6;font-size:.8em}
#space-menu{position:absolute;z-index:60;top:calc(100% + 4px);left:0;min-width:max(100%,190px);
  max-height:60vh;overflow:auto;background:var(--panel);border:1px solid var(--line);
  border-radius:6px;box-shadow:0 10px 28px rgba(0,0,0,.28);padding:5px}
#space-menu .grp{padding:7px 9px 3px;font-size:.68rem;letter-spacing:.12em;
  text-transform:uppercase;opacity:.55}
#space-menu button{display:flex;align-items:center;gap:8px;width:100%;
  padding:7px 9px;border:0;background:none;border-radius:4px;text-align:left;
  white-space:nowrap}
#space-menu button:hover{background:var(--sel)}
#space-menu button.on{background:var(--sel);font-weight:600}
#space-menu button .tick{margin-left:auto;opacity:.7}
#space-menu hr{border:0;border-top:1px solid var(--line);margin:5px 2px}
#tab-project,#tab-library{display:flex;flex-direction:column;gap:.75rem;flex:1;min-height:0}
#tab-project[hidden],#tab-library[hidden]{display:none}
.tab-foot{margin-top:auto;display:flex;flex-direction:column;gap:.5rem}

/* expansion: the ＋/− box (tree-view idiom), not a caret glyph */
.caret{flex:none;width:.95rem;height:.95rem;display:inline-flex;align-items:center;
  justify-content:center;font-size:.7rem;line-height:1;color:var(--muted);
  border:1px solid var(--line);border-radius:2px;background:var(--panel2);
  cursor:pointer;user-select:none;font-family:Consolas,ui-monospace,monospace}
.caret:hover{color:var(--accent);border-color:var(--accent)}
.caret.none{visibility:hidden;cursor:default}

.row-menu{margin-left:auto;background:none;border:0;color:var(--muted);
  border-radius:4px;padding:0 .375rem;visibility:hidden;font-weight:700;min-width:1.4rem}
.module:hover .row-menu,.side-head:hover .row-menu{visibility:visible}
.row-menu:hover{color:var(--accent)}
#ctx-menu{position:fixed;z-index:50;min-width:11.5rem;display:flex;flex-direction:column;
  background:var(--panel);border:1px solid var(--line);border-radius:6px;
  box-shadow:0 8px 24px rgba(0,0,0,.18);padding:.25rem;gap:1px}
#ctx-menu button{background:none;border:0;color:var(--ink);text-align:left;
  padding:.45rem .625rem;border-radius:4px;font-size:.84rem}
#ctx-menu button:hover{background:var(--panel2)}
#ctx-menu button.danger{color:var(--danger)}

/* ── buttons ── */
.btn{background:var(--accent);color:var(--accent-ink);border:0;border-radius:4px;
  padding:.45rem .875rem;font-weight:600;min-height:2rem}
.btn.ghost{background:none;color:var(--ink);border:1px solid var(--line)}
.btn.danger{background:var(--danger);color:#fff}
.btn.wide{width:100%}
.btn:disabled{opacity:.5;cursor:default}

/* ── main / grid ── */
/* min-height:0 is load-bearing, not tidiness. A flex item defaults to
   min-height:auto and refuses to shrink below its content, so without it #main
   grows to fit every row, #grid-wrap's overflow:auto never engages, and the
   PAGE scrolls instead of the grid — taking the sidebar out of view and leaving
   a blank column (UI-9: scrolling inside the grid, never on the page body).
   min-width:0 was already here: someone hit the horizontal half of this same
   bug. The vertical half only shows once a grid is long enough. */
#main{display:flex;flex-direction:column;min-width:0;min-height:0}
#table-head{display:flex;align-items:center;gap:.875rem;padding:.875rem 1.25rem;
  border-bottom:1px solid var(--line);flex-wrap:wrap}
#table-head h1{font-size:1.25rem;margin:0;font-weight:700}
#table-head .btn{margin-left:auto}
/* Search sits between the count and the actions, and takes the slack — so the
   buttons stay right-aligned and the field grows with the window rather than
   being a fixed stub on a wide screen. */
#grid-search{flex:1 1 12rem;max-width:26rem;min-width:8rem;margin-left:auto}
#table-head #grid-search ~ .btn{margin-left:0}
#grid-search[hidden]{display:none}
/* Pager arrows live inside the count chip, so the header keeps one cluster
   rather than gaining a second row of controls. */
#table-count{display:inline-flex;align-items:center;gap:.25rem}
.pg{background:none;border:1px solid var(--line);color:var(--ink);border-radius:4px;
  min-width:1.4rem;height:1.4rem;line-height:1;padding:0;font-size:.9rem}
.pg:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}
.pg:disabled{opacity:.35;cursor:default}
#grid-wrap{overflow:auto;flex:1;padding:0 1.25rem 1.25rem}
#grid{border-collapse:collapse;width:100%;background:var(--panel);
  border:1px solid var(--line);font-size:.84rem;margin-top:1rem}
#grid th{font-family:Consolas,ui-monospace,monospace;font-size:.66rem;
  letter-spacing:.12em;text-transform:uppercase;color:var(--muted);
  background:var(--panel2);text-align:left;padding:.5rem .75rem;
  border-bottom:1px solid var(--line);position:sticky;top:0;white-space:nowrap;cursor:pointer}
#grid th.drag-over{box-shadow:inset 3px 0 0 var(--accent)}
#grid td{padding:.5rem .75rem;border-bottom:1px solid var(--line2);white-space:nowrap;
  max-width:21rem;overflow:hidden;text-overflow:ellipsis}
#grid tbody tr:hover{background:var(--panel2);cursor:pointer}
#grid td.num{text-align:right;font-variant-numeric:tabular-nums}
#grid td.computed{color:var(--computed);font-style:italic}
.th-del,.th-edit{background:none;border:0;color:var(--muted);margin-left:.25rem;
  padding:0 .125rem;visibility:hidden}
th:hover .th-del,th:hover .th-edit{visibility:visible}
.th-del:hover{color:var(--danger)}
.th-edit:hover{color:var(--accent)}
/* The sort caret is always visible on the sorted column — it is state, not an
   affordance, so hover must not be the only way to know it is there (UI-3). */
.th-sort{margin-left:.3rem;color:var(--accent);font-size:.7rem}
#empty-state{padding:3.75rem 1.25rem;color:var(--muted);text-align:center}

/* ── module entry point: child items with quick entry ── */

/* ── view tabs + renderers ── */
#view-bar{display:flex;gap:.5rem;align-items:center;padding:.5rem 1.25rem 0}
#view-bar[hidden]{display:none}
#view-bar .btn{min-height:1.75rem;padding:.3rem .625rem}
#view-tabs{display:flex;gap:.25rem;flex-wrap:wrap;flex:1}
.view-tab{background:none;border:1px solid transparent;color:var(--muted);
  border-radius:5px 5px 0 0;padding:.35rem .75rem;font-size:.84rem;display:flex;gap:.375rem;align-items:center}
.view-tab:hover{background:var(--panel2)}
.view-tab.on{background:var(--panel);border-color:var(--line);border-bottom-color:var(--panel);
  color:var(--ink);font-weight:600}
.view-tab.add{color:var(--accent)}
.view-x{color:var(--muted);visibility:hidden;padding:0 .125rem}
.view-tab.on .view-x{visibility:visible}
.view-x:hover{color:var(--danger)}
#view-wrap{overflow:auto;flex:1;padding:1rem 1.25rem}
.view-empty{color:var(--muted);padding:1rem 0;font-style:italic}
/* timeline */
.tl-head{display:flex;justify-content:space-between;font-family:Consolas,ui-monospace,monospace;
  font-size:.66rem;letter-spacing:.1em;color:var(--muted);padding:.125rem .75rem .375rem 13rem;
  border-bottom:1px solid var(--line2)}
.tl-today{position:absolute;top:0;bottom:0;width:2px;background:var(--accent);opacity:.6;
  transform:translateX(-1px);pointer-events:none}
/* fit-content lets the panel enclose rows wider than the viewport
   (many columns); min-width keeps it full-bleed when they are not */
.tl-body{background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:.5rem 0;
  width:fit-content;min-width:100%}
.tl-section{font-family:Consolas,ui-monospace,monospace;font-size:.66rem;letter-spacing:.12em;
  text-transform:uppercase;color:var(--muted);padding:.5rem .75rem .25rem;border-top:1px solid var(--line2)}
.tl-section:first-child{border-top:0}
.tl-cols-head{padding:.25rem .75rem;border-bottom:1px solid var(--line2)}
.tl-wbs{font-size:.75rem;font-weight:700;color:var(--ink);padding:.4rem .75rem .15rem;
  background:var(--panel2);border-top:1px solid var(--line2)}
.tl-col-h{font-family:Consolas,ui-monospace,monospace;font-size:.62rem;letter-spacing:.1em;
  text-transform:uppercase;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-right:.5rem}
.tl-cell{font-size:.78rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap;padding-right:.5rem}
.tl-row[style*="grid"] .tl-label{width:auto;min-width:0}
.tl-row{display:flex;align-items:center;gap:.5rem;padding:.2rem .75rem;cursor:pointer}
.tl-row:hover{background:var(--panel2)}
.tl-label{width:12rem;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8125rem}
.tl-track{position:relative;flex:1;height:.9rem;background:var(--panel2);border-radius:3px}
.tl-bar{position:absolute;top:0;bottom:0;background:var(--accent);border-radius:3px;min-width:3px}
.tl-milestone{position:absolute;top:50%;width:.55rem;height:.55rem;background:var(--accent);
  transform:translate(-50%,-50%) rotate(45deg)}
/* baseline, critical path, dependency lines */
.tl-legend{display:flex;gap:1.25rem;flex-wrap:wrap;font-size:.75rem;color:var(--muted);margin:0 0 .5rem}
.tl-legend .bad{color:var(--danger)}
.tl-key{display:inline-block;width:1.1rem;height:.5rem;border-radius:2px;margin-right:.35rem;vertical-align:middle}
.tl-key.crit{background:var(--crit)}
.tl-key.base{background:var(--muted);opacity:.6;height:.25rem}
.tl-key.link{height:0;border-top:1.5px solid var(--muted)}
/* with a baseline the bar gives up the bottom of its track to it */
.tl-body.has-base .tl-track{height:1.15rem;background:none}
.tl-body.has-base .tl-bar{bottom:42%}
.tl-body.has-base .tl-milestone{top:30%}
.tl-base{position:absolute;top:68%;bottom:6%;background:var(--muted);opacity:.55;border-radius:2px;min-width:2px}
/* the critical path stands out because everything else steps back: what is
   not critical turns a calm blue, what is finished fades */
.tl-body.show-crit .tl-bar:not(.crit),.tl-body.show-crit .tl-milestone:not(.crit){background:var(--calm) !important}
.tl-bar.crit,.tl-milestone.crit{background:var(--crit)}
.tl-body.show-crit .tl-bar.done,.tl-body.show-crit .tl-milestone.done{opacity:.4}
.tl-links{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
.tl-links path{fill:none;stroke:var(--muted);stroke-width:1.1;opacity:.75}
.tl-links path.crit{stroke:var(--crit);stroke-width:1.4;opacity:.9}
.tl-links marker path{fill:var(--muted);stroke:none;opacity:1}
.tl-links marker path.crit{fill:var(--crit)}
/* a look-ahead: the axis ruled by the week */
.tl-tick{position:absolute;top:0;bottom:0;width:1px;background:var(--line2);pointer-events:none}
.tl-tick span{position:absolute;top:.2rem;left:.3rem;font-family:Consolas,ui-monospace,monospace;font-size:.62rem;
  letter-spacing:.06em;color:var(--muted);white-space:nowrap}
.tl-body.windowed .tl-head span{visibility:hidden}
.tl-legend b{color:var(--ink)}
/* calendar */
.cal-bar{display:flex;gap:.4rem;align-items:center;margin-bottom:.6rem}
.cal-bar b{font-size:1.05rem;margin:0 .5rem}
.cal-bar .btn{min-height:1.75rem;padding:.3rem .7rem}
.cal-grid{border:1px solid var(--line);border-radius:6px;overflow:hidden;background:var(--panel)}
.cal-heads,.cal-week{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}
.cal-head{font-family:Consolas,ui-monospace,monospace;font-size:.62rem;letter-spacing:.12em;text-transform:uppercase;
  color:var(--muted);padding:.35rem .5rem;background:var(--panel2);border-bottom:1px solid var(--line)}
/* a week: the seven days lie underneath, from top to bottom; the bars lie
   over them, each in the lane it was given */
.cal-week{row-gap:2px;border-bottom:1px solid var(--line2);padding-bottom:.2rem}
.cal-week:last-child{border-bottom:0}
.cal-day{grid-row:1 / -1;border-right:1px solid var(--line2);min-width:0;margin-bottom:-.2rem}
.cal-day:nth-child(7){border-right:0}
.cal-day.off{background:color-mix(in srgb,var(--muted) 10%,var(--panel))}
.cal-day.other .cal-num{opacity:.4}
.cal-num{font-size:.75rem;color:var(--muted);padding:.2rem .45rem 0;font-variant-numeric:tabular-nums}
.cal-num span{font-size:.62rem;margin-left:.25rem}
.cal-day.today .cal-num{color:var(--accent);font-weight:700}
.cal-day.today{box-shadow:inset 0 2px 0 var(--accent)}
.cal-chip{font:inherit;font-size:.72rem;line-height:1.35rem;height:1.35rem;text-align:left;border:0;cursor:pointer;
  color:var(--accent-ink);background:var(--accent);border-radius:3px;margin:0 .25rem;padding:0 .4rem;overflow:hidden;
  text-overflow:ellipsis;white-space:nowrap;min-width:0;position:relative}
.cal-chip:hover{filter:brightness(1.12)}
/* it came in from last week, or runs on into the next */
.cal-chip.c-in{margin-left:0;border-top-left-radius:0;border-bottom-left-radius:0}
.cal-chip.c-out{margin-right:0;border-top-right-radius:0;border-bottom-right-radius:0}
.cal-more{font:inherit;font-size:.68rem;color:var(--muted);background:none;border:0;text-align:left;padding:0 .45rem;
  cursor:pointer;position:relative;white-space:nowrap}
.cal-more:hover{color:var(--ink)}
.cal-agenda{display:none}
.cal-when{font-family:Consolas,ui-monospace,monospace;font-size:.66rem;letter-spacing:.1em;text-transform:uppercase;
  color:var(--muted);padding:.6rem .25rem .2rem;border-top:1px solid var(--line2)}
.cal-when.today{color:var(--accent)}
.cal-when:first-child{border-top:0}
.cal-line{font:inherit;color:inherit;display:flex;gap:.5rem;align-items:baseline;width:100%;text-align:left;background:none;
  border:0;padding:.3rem .25rem;cursor:pointer;font-size:.8125rem}
.cal-line:hover{background:var(--panel2)}
.cal-line i{flex:none;width:.5rem;height:.5rem;border-radius:2px;background:var(--accent);transform:translateY(-1px)}
.cal-line span{flex:1;min-width:0}
.cal-line em{flex:none;font-style:normal;font-size:.72rem;color:var(--muted);white-space:nowrap}
@media (max-width: 48rem){
  /* seven columns on a phone are seven slivers: the month becomes a list */
  .cal-grid{display:none}
  .cal-agenda{display:block;background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:0 .5rem .4rem}
  .tl-tick span{font-size:.56rem}
}
/* waterfall */
.ch-zero{stroke:var(--muted);stroke-width:1.2}
.ch-join{stroke:var(--muted);stroke-width:1;stroke-dasharray:3 3;opacity:.8}
.ch-break{fill:none;stroke:var(--panel);stroke-width:3.5}
.ch-cut{fill:var(--accent)}
/* pivot */
.pv-title{font-weight:600;margin-bottom:.5rem}
.pv-scroll{overflow:auto;max-height:calc(100vh - 15rem);border:1px solid var(--line);border-radius:6px;background:var(--panel)}
.pv-table{border-collapse:separate;border-spacing:0;font-size:.8125rem;font-variant-numeric:tabular-nums;min-width:100%}
.pv-table th,.pv-table td{padding:.35rem .7rem;border-bottom:1px solid var(--line2);border-right:1px solid var(--line2);white-space:nowrap}
.pv-table thead th{position:sticky;top:0;z-index:2;background:var(--panel2);font-weight:600;font-size:.72rem;color:var(--muted);text-align:right}
.pv-table thead tr:nth-child(2) th{top:1.85rem}
.pv-table .pv-sub{font-weight:400}
/* the names stay put while the numbers scroll under them */
.pv-table .pv-row{position:sticky;left:0;z-index:1;background:var(--panel);text-align:left;font-weight:400;
  max-width:24rem;white-space:normal}
.pv-table thead .pv-corner{z-index:3;background:var(--panel2);text-align:left}
.pv-table .pv-d0 > .pv-row{font-weight:600}
.pv-table .pv-d1 > .pv-row{padding-left:1.9rem;color:var(--muted)}
.pv-table .pv-fold > .pv-row{cursor:pointer}
.pv-table .pv-fold > .pv-row i{display:inline-block;width:1rem;font-style:normal;color:var(--muted)}
.pv-cell{text-align:right;cursor:pointer}
.pv-cell.none{cursor:default}
.pv-cell.zero{color:var(--muted);opacity:.55}
/* with one measure there is one total, and it stays in sight */
.pv-one td.pv-tot,.pv-one thead th.pv-tot{position:sticky;right:0;box-shadow:inset 1px 0 0 var(--line)}
.pv-one tbody td.pv-tot{background:color-mix(in srgb,var(--muted) 8%,var(--panel))}
.pv-one thead th.pv-tot,.pv-one tfoot td.pv-tot{z-index:3;background:var(--panel2)}
.pv-cell:not(.none):hover{outline:1px solid var(--accent);outline-offset:-1px}
.pv-table .pv-d0 > .pv-cell{font-weight:600}
.pv-table .pv-d1 > .pv-cell{font-weight:400}
.pv-tot{background:color-mix(in srgb,var(--muted) 8%,var(--panel))}
.pv-table tfoot td,.pv-table tfoot th{position:sticky;bottom:0;z-index:1;background:var(--panel2);font-weight:700;border-top:1px solid var(--line)}
.pv-table tfoot .pv-row{z-index:3;background:var(--panel2)}
.pv-grand{color:var(--accent)}
#pv-detail{margin-top:.75rem}
@media (max-width: 48rem){
  .pv-table th,.pv-table td{padding:.3rem .45rem}
  .pv-table .pv-row{max-width:9.5rem}
  .pv-table .pv-d1 > .pv-row{padding-left:1.1rem}
}
/* revisions */
.rv-item{align-items:flex-start}
.rv-sub{font-size:.72rem;color:var(--muted)}
.rv-head{display:flex;gap:.75rem;align-items:baseline;flex-wrap:wrap}
.rv-head b{font-size:1.05rem}
button.sc-tile{font:inherit;color:inherit;text-align:left;cursor:pointer}
button.sc-tile:hover{border-color:var(--line)}
button.sc-tile.on{border-color:var(--accent);box-shadow:inset 0 -2px 0 var(--accent)}
.rv-fact{font-size:.8125rem;color:var(--muted);margin:.15rem 0}
.rv-fact b{color:var(--ink)}
.rv-table th.rv-sort{cursor:pointer}
.rv-table th.rv-sort.on{color:var(--ink);box-shadow:inset 0 -2px 0 var(--accent)}
.rv-table tr.rv-open{cursor:pointer}
.rv-table tr.rv-open:hover td{background:var(--panel2)}
.rv-delta{margin-left:.4rem;font-size:.72rem;color:var(--muted);font-variant-numeric:tabular-nums}
.rv-delta.late{color:var(--danger)}
.rv-delta.early{color:var(--good)}
.rv-new{font-size:.66rem;padding:0 .35rem;border-radius:8px;border:1px solid var(--good);color:var(--good);margin-left:.3rem}
/* the phone's text for a row: never shown beside a pane of columns */
.tl-dates,.tl-sub{display:none}
@media (max-width: 48rem){
  /* The inline styles are the desktop's grid (a column pane, then the bar).
     They are overridden here rather than computed twice in the script. */
  .tl-body{width:auto;min-width:0}
  .tl-head{padding-left:.75rem !important}
  .tl-cols-head{display:none !important}
  /* here the line crosses the text as well as the bars, so it is fainter */
  .tl-today{left:calc(.75rem + (100% - 1.5rem) * var(--tl-at)) !important;opacity:.28}
  .tl-tick{left:calc(.75rem + (100% - 1.5rem) * var(--tl-at)) !important;opacity:.55}
  .tl-row{display:grid !important;grid-template-columns:minmax(0,1fr) auto !important;
    gap:.05rem .6rem;padding:.4rem .75rem;border-top:1px solid var(--line2)}
  .tl-row .tl-cell{display:none}
  .tl-row .tl-label{grid-column:1 !important;width:auto;min-width:0;font-weight:600}
  .tl-dates{display:block;grid-column:2;grid-row:1;font-size:.75rem;color:var(--muted);
    white-space:nowrap;font-variant-numeric:tabular-nums}
  .tl-sub{display:block;grid-column:1 / -1;font-size:.75rem;color:var(--muted);
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .tl-row .tl-track{grid-column:1 / -1;height:.55rem;margin-top:.15rem}
  .tl-wbs{padding-left:.75rem !important}
  .tl-links,.tl-says-links{display:none}
  .tl-legend{gap:.6rem;font-size:.7rem}
  #view-wrap{padding:.75rem}
}
/* cards */
.cards-flat{display:grid;grid-template-columns:repeat(auto-fill,minmax(16rem,1fr));gap:.75rem}
.cards-board{display:flex;gap:.75rem;align-items:flex-start}
.cards-col{flex:1;min-width:14rem;background:var(--panel2);border:1px solid var(--line2);
  border-radius:8px;padding:.5rem;display:flex;flex-direction:column;gap:.5rem}
.cards-col-head{font-size:.78rem;color:var(--muted);display:flex;align-items:center;gap:.375rem;padding:.125rem .25rem}
.card{background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:.6rem .75rem;cursor:pointer}
.card:hover{border-color:var(--accent)}
.card-title{font-weight:600;margin-bottom:.25rem}
.card-line{display:flex;justify-content:space-between;gap:.5rem;font-size:.78rem;color:var(--muted)}
.card-line b{color:var(--ink);font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ── chips ── */
.chip{display:inline-block;background:var(--chip);border-radius:10px;
  padding:.06rem .55rem;font-size:.75rem;margin:0 .1875rem .125rem 0;white-space:nowrap}
.chip.link{border:1px solid var(--accent);color:var(--accent);background:transparent}
.chip.opt{color:#fff}
.opt-x{background:none;border:0;color:inherit;padding:0 0 0 .25rem;opacity:.7}
.opt-x:hover{opacity:1}
#fd-cur-opts{display:flex;flex-wrap:wrap;gap:.25rem;margin-bottom:.5rem}
#fd-expr-fields{display:flex;flex-wrap:wrap;gap:.25rem;margin-top:.375rem}
.expr-chip{border:1px solid var(--line);cursor:pointer;color:var(--ink)}
.expr-chip:hover{border-color:var(--accent);color:var(--accent)}

.hist{width:100%}
.hist-row{font-size:.75rem;color:var(--muted);padding:.25rem 0;border-top:1px solid var(--line2)}
.hist-date{width:auto;padding:.1rem .3rem;font-size:.7rem;display:inline-block}
.hist-snap{background:var(--panel2);border:1px solid var(--line2);border-radius:6px;
  padding:.5rem .625rem;margin:.375rem 0;display:flex;flex-direction:column;gap:.2rem}
/* compare view */
.cmp-head{font-size:.84rem;color:var(--muted);padding:.25rem 0 .625rem;display:flex;
  gap:.375rem;align-items:center;flex-wrap:wrap}
.cmp-head select{width:auto;padding:.2rem .4rem}
.cmp-chg{color:var(--accent);font-weight:600}
.cmp-row{display:flex;gap:.75rem;padding:.375rem .75rem;border-top:1px solid var(--line2);
  background:var(--panel)}
.cmp-key{flex:none;width:11rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;font-size:.8125rem}
.cmp-diffs{display:flex;flex-wrap:wrap;gap:.375rem .75rem;font-size:.78rem}
.cmp-d s{color:var(--muted)}
.cmp-d b{color:var(--accent)}
.cmp-add{color:var(--good);font-weight:600}
.cmp-del{color:var(--danger);font-weight:600}

/* ── dialog: the standard centered modal for forms and entry details ── */
/* display:flex below would override the hidden attribute's display:none —
   restate it, or the dialog can never close (the original "panel is dead"
   bug) */
#panel[hidden],#backdrop[hidden]{display:none!important}
/* above the top bar (70): a record, a file, a dialog own the screen — on a
   phone the sheet's title and ✕ sat UNDER the top bar */
#backdrop{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:72}
#panel{position:fixed;z-index:73;top:50%;left:50%;transform:translate(-50%,-50%);
  width:min(92vw,30rem);max-height:85dvh;background:var(--panel);
  border:1px solid var(--line);border-radius:10px;
  box-shadow:0 20px 60px rgba(0,0,0,.35);display:flex;flex-direction:column}
#panel header{display:flex;align-items:center;justify-content:space-between;
  padding:.875rem 1rem;border-bottom:1px solid var(--line)}
#panel h2{margin:0;font-size:1rem}
#panel-body{overflow-y:auto}
#panel-form{padding:.875rem 1rem;display:flex;flex-direction:column;gap:.75rem}
#panel-form .field label{display:block;font-size:.78rem;color:var(--muted);margin-bottom:.1875rem}
/* The record's own form: fields two to a row where there is room, one below
   that. Long text, a sketch and anything that is not a field (a line table, a
   notice) take the whole width. A new record leaves out the fields that hold
   nothing until it is saved. */
#panel-form.auto2{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,max(24rem,calc(50% - .5rem))),1fr));gap:.75rem 1rem;align-items:start}
#panel-form.auto2>*{grid-column:1/-1;min-width:0}
#panel-form.auto2>.field[data-kind]{grid-column:auto}
#panel-form.auto2>.field:is([data-kind="longtext"],[data-kind="sketch"]),#panel-form.auto2>.field:has(img,canvas){grid-column:1/-1}
#panel-form.is-new>.field:is([data-kind="rollup"],[data-kind="stamp"],[data-kind="autonumber"]){display:none}
/* A line table inside a record: a heading that opens and closes it, then one
   grid for the column names, the lines there and the row being typed. */
.lines-sec{border-top:1px solid var(--line2);padding-top:.25rem}
.ln-title{display:flex;align-items:center;gap:.45rem;padding:.3rem 0;user-select:none}
.ln-title[role=button]{cursor:pointer}
.ln-title .mono-label{margin:0}
.ln-caret{display:inline-block;font-size:.7rem;color:var(--muted);transition:transform .12s}
.ln-title[aria-expanded="false"] .ln-caret{transform:rotate(-90deg)}
.ln-count{font-size:.72rem;color:var(--muted);border:1px solid var(--line2);border-radius:999px;padding:0 .45rem}
.ln-note{font-size:.8rem;color:var(--muted);margin:.1rem 0 .35rem}
.ln-head,.ln-row{display:grid;grid-template-columns:var(--ln-cols);gap:.3rem .5rem;align-items:start}
.ln-head{font-size:.72rem;color:var(--muted);padding-bottom:.25rem}
.ln-body:not(:has(.ln-row)) .ln-head{display:none}
.ln-row{margin-bottom:.25rem}
.ln-row.ln-read{padding:.35rem 0;border-top:1px solid var(--line2);margin:0}
.ln-c{display:flex;flex-direction:column;min-width:0;font-size:.85rem;overflow-wrap:anywhere}
.ln-read .ln-c{white-space:pre-line}
.ln-act{display:flex;gap:.1rem;justify-content:flex-end;align-items:center}
.ln-row>.line-computed{grid-column:1/-1}
textarea.ln-ta{resize:none;overflow:hidden;min-height:1.9rem;line-height:1.35;font-family:inherit;width:100%;box-sizing:border-box}
/* no room for the columns: each line is a card, a label over each value */
.lines-sec.ln-cards .ln-head{display:none}
.lines-sec.ln-cards .ln-row{grid-template-columns:repeat(auto-fill,minmax(9.5rem,1fr));gap:.45rem .75rem;border:1px solid var(--line2);border-radius:8px;padding:.5rem .6rem;margin:0 0 .4rem}
.lines-sec.ln-cards .ln-c::before{content:attr(data-label);font-size:.68rem;color:var(--muted);margin-bottom:.1rem}
.lines-sec.ln-cards .ln-c.ln-wide{grid-column:1/-1}
.lines-sec.ln-cards .ln-read .ln-c:empty{display:none}
.lines-sec.ln-cards .ln-row{position:relative;padding-right:3.4rem}
.lines-sec.ln-cards .ln-act{position:absolute;top:.3rem;right:.35rem}
#panel-form .field label .req{color:var(--danger)}
#panel-form .computed-val{color:var(--computed);font-style:italic;padding:.375rem 0}
#panel-form .held-as-of{display:block;font-size:.72rem;color:var(--muted);font-style:normal;margin-top:2px}
#panel-error{margin:.625rem 1rem 0;padding:.55rem .75rem;background:color-mix(in srgb,var(--danger) 12%,transparent);
  border:1px solid var(--danger);border-radius:4px;color:var(--danger);font-size:.8125rem}
#conn-label{padding:.375rem 1rem 0}
#panel-backlinks{padding:.375rem 1rem;display:flex;flex-wrap:wrap;gap:.25rem}
/* a long connection keeps to the dialog's width: on a phone it used to push the whole record sideways */
#panel-backlinks .chip{max-width:100%;overflow:hidden;text-overflow:ellipsis}
/* a document a completed record refers to: not replaced */
/* a link drawn as a button is a button: no underline */
a.btn{text-decoration:none;display:inline-block}
/* the documents list: a name reads as text, not as a browser's blue link */
#docs-files a{color:var(--ink);text-decoration:none}
#docs-files a:hover{color:var(--accent);text-decoration:underline}
/* the documents table takes the records grid's look: it had none of its own */
#docs-files table.grid{border-collapse:collapse;width:100%;background:var(--panel);border:1px solid var(--line);font-size:.84rem}
#docs-files table.grid th{font-family:Consolas,ui-monospace,monospace;font-size:.66rem;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);background:var(--panel2);text-align:left;padding:.5rem .75rem;border-bottom:1px solid var(--line);white-space:nowrap}
#docs-files table.grid td{padding:.45rem .75rem;border-bottom:1px solid var(--line2);vertical-align:middle}
#docs-files table.grid tbody tr:hover{background:var(--panel2)}
.doc-status{white-space:nowrap}
.doc-sealed{display:inline-block;padding:.05rem .5rem;border:1px solid var(--line);border-radius:10px;font-size:.8rem;color:var(--muted);white-space:nowrap;cursor:help}
/* 082: a document open for editing on somebody's drive */
.doc-held{display:inline-block;padding:.05rem .5rem;border:1px solid var(--warn,#e0a030);border-radius:10px;font-size:.8rem;color:var(--ink);white-space:nowrap;cursor:help}
.doc-release{margin-left:.35rem;padding:.05rem .5rem;font-size:.8rem;background:none;color:var(--ink);border:1px solid var(--line);border-radius:10px;cursor:pointer}
#panel footer{padding:.75rem 1rem;border-top:1px solid var(--line);
  display:flex;gap:.5rem;align-items:center}
#panel footer .spacer{flex:1}
/* A record is a page: the same dialog element, moved into the main area in
   place of the list while a record is open (enterRecordPage). It fills the
   area, loses the window's frame, and gets a way back in place of the cross. */
[data-rec-hidden]{display:none!important}
#panel:not(.as-page) #panel-back{display:none}
#panel.as-page{position:static;inset:auto;transform:none;width:auto!important;height:auto!important;max-height:none!important;
  max-width:96rem;flex:1;min-height:0;min-width:0;border:none;border-radius:0;box-shadow:none;background:transparent;z-index:auto}
#panel.as-page>header{justify-content:flex-start;gap:.75rem;padding:.875rem 1.25rem}
#panel.as-page>header h2{font-size:1.25rem;font-weight:700}
#panel.as-page #panel-close,#panel.as-page #panel-grip{display:none}
#panel.as-page #panel-form{padding:1rem 1.25rem}
#panel.as-page>footer{padding:.75rem 1.25rem}
/* what a record mounts above its form (the files and lines buttons, the workflow, draft and lock notices) lines up with the form */
#panel.as-page #panel-body>:is(#panel-zip,#panel-openin,#wf-strip,#draft-strip,#lock-strip,#void-strip){margin-left:1.25rem;margin-right:1.25rem}
#panel.as-page #panel-body>:first-child:not(form){margin-top:.75rem}
.link-pick{display:flex;flex-direction:column;gap:.25rem;max-height:9.5rem;overflow-y:auto;
  border:1px solid var(--line);border-radius:4px;padding:.375rem .5rem;background:var(--panel)}
.link-pick label{display:flex;gap:.4375rem;align-items:center;font-size:.8125rem;color:var(--ink)!important;margin:0!important}
.link-pick input{width:auto}
/* picking several: a drop-down with a check box for each option */
.mpick{position:relative;min-width:0}
.mpick-btn{width:100%;display:flex;align-items:center;gap:.375rem;text-align:left;cursor:pointer;
  padding:.375rem .5rem;border:1px solid var(--line);border-radius:4px;background:var(--panel);color:var(--ink);font:inherit}
.mpick-btn:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.mpick.open .mpick-btn{border-color:var(--accent)}
.mpick-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:inherit}
.mpick-none{color:var(--muted)}
.mpick-caret{flex:none;font-size:.7em;color:var(--muted)}
.mpick-list{position:fixed;z-index:1200;display:flex;flex-direction:column;gap:.125rem;overflow-y:auto;
  padding:.375rem .5rem;border:1px solid var(--line);border-radius:6px;background:var(--panel);color:var(--ink);
  box-shadow:0 10px 30px rgba(0,0,0,.35)}
.mpick-list[hidden]{display:none}
.mpick-list label{display:flex;gap:.4375rem;align-items:center;font-size:.8125rem;margin:0;padding:.2rem .125rem;cursor:pointer;white-space:nowrap}
.mpick-list label:hover{background:color-mix(in srgb, var(--accent) 12%, transparent)}
.mpick-list input{width:auto;margin:0}
.sh-in.mpick .mpick-btn,[data-kind].mpick[style] .mpick-btn{border:0;background:transparent;padding:.2rem .3rem}
.grid-note td,.pv-note{font-size:.75rem;font-weight:400;color:var(--muted);padding:.25rem .75rem}
.pv-note{padding:.25rem 0 0}
/* rich link options: primary field + muted context line */
.lp-rich label{align-items:flex-start;padding:.125rem 0}
.lp-rich input{margin-top:.2rem}
.lp-txt{display:flex;flex-direction:column;min-width:0}
.lp-main{font-size:.8125rem}
.lp-sum{font-size:.7rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lp-filter{margin-bottom:.25rem}
#panel.wide{width:min(94vw,44rem)}
#panel.has-lines{width:min(94vw,72rem)}
#panel-body{flex:1 1 auto;min-height:0}
#panel-grip{position:absolute;right:1px;bottom:1px;width:1rem;height:1rem;cursor:nwse-resize;border-bottom-right-radius:9px;
  background:linear-gradient(135deg,transparent 50%,var(--muted) 50% 58%,transparent 58% 70%,var(--muted) 70% 78%,transparent 78%);opacity:.55;touch-action:none}
#panel-grip:hover{opacity:1}
#panel.wide .link-pick{max-height:13rem}
.lib-row{display:flex;align-items:center;gap:.375rem;padding:.1875rem 0;cursor:pointer}
.lib-row input{width:auto;margin:0}

/* ── busy: a moving bar across the top, plus a cursor ────────────────────────
   A bar rather than a modal spinner, because the app stays usable while a read
   runs — blocking the screen would make a slow read feel like a frozen one. */
#busy-bar{position:fixed;top:0;left:0;right:0;height:2px;z-index:80;
  background:transparent;overflow:hidden;pointer-events:none;opacity:0;
  transition:opacity .15s}
body.busy #busy-bar{opacity:1}
#busy-bar::after{content:"";position:absolute;inset:0;width:35%;
  background:linear-gradient(90deg,transparent,var(--accent),transparent);
  animation:busy-slide 1.05s ease-in-out infinite}
@keyframes busy-slide{0%{transform:translateX(-100%)}100%{transform:translateX(385%)}}
body.busy{cursor:progress}
@media (prefers-reduced-motion: reduce){
  #busy-bar::after{animation:none;width:100%;opacity:.5}
}

#toast{position:fixed;bottom:1.25rem;left:50%;transform:translateX(-50%);z-index:95;
  background:var(--panel);color:var(--ink);border:1px solid var(--line);border-radius:6px;
  padding:.55rem 1rem;font-size:.84rem;box-shadow:0 8px 24px rgba(0,0,0,.25);
  /* messages that LIST what failed keep their line breaks, as alert() did */
  white-space:pre-line;max-width:min(38rem,92vw);cursor:pointer}
/* The error form. Same recipe as #panel-error so the app has ONE error look,
   but over --panel rather than transparent because a toast floats above
   arbitrary content and a 12% tint of nothing is not a background. */
#toast.bad{background:color-mix(in srgb,var(--danger) 12%,var(--panel));
  border-color:var(--danger);color:var(--danger)}

/* narrow screens: the sidebar narrows; the dialog is already an overlay */
@media (max-width: 56rem){
  #app{grid-template-columns:var(--sidew, clamp(11rem,30vw,13rem)) 6px 1fr}
}

/* ── PHONES ────────────────────────────────────────────────────────────────
   Nobody in the field uses a laptop, and until this block the app was
   unusable on a phone: at 375px the three-column grid gave the sidebar 176px
   and left 193px for the entire workspace. Narrowing the sidebar (above) is
   not enough — below this width it has to LEAVE, and come back on demand.

   Deliberately additive. Every rule here is inside the media query, so the
   desktop layout, the drag-to-resize grip and the centred dialog are exactly
   as they were. ── */
#nav-toggle,#nav-scrim,#view-more{display:none}

@media (max-width: 48rem){
  /* one column: the sidebar is out of the flow entirely, not squeezed */
  #app{grid-template-columns:1fr}
  #topbar .brand{display:none}
  #items-menu{min-width:min(96vw,30rem);flex-direction:column}
  #items-menu .im-list,#items-menu .im-subs{flex:none;border-right:0;border-bottom:1px solid var(--line)}
  #side-grip{display:none}          /* drag-to-resize is meaningless here */

  #sidebar{
    position:fixed;top:0;bottom:0;left:0;z-index:62;
    width:min(19rem,84vw);
    transform:translateX(-100%);
    transition:transform .18s ease-out;
    box-shadow:0 0 2.5rem rgba(0,0,0,.4);
  }
  body.nav-open #sidebar{transform:none}
  /* Someone who has asked their device for less motion gets the drawer
     instantly rather than sliding. Also makes the open/closed state testable
     without waiting on an animation clock. */
  @media (prefers-reduced-motion: reduce){
    #sidebar{transition:none}
  }

  #nav-scrim{position:fixed;inset:0;z-index:61;background:rgba(0,0,0,.45)}
  body.nav-open #nav-scrim{display:block}

  /* Top-left because that is where a hamburger is looked for, even though the
     bottom is easier to reach — familiarity beats ergonomics for a control
     people must find before they know the app. */
  /* In the top bar now — it lived pinned over the page and the top bar
     (z-index 70) covered it, so the drawer could not be opened at all. */
  #nav-toggle{
    display:flex;align-items:center;justify-content:center;flex:none;
    width:36px;height:36px;font-size:1.05rem;padding:0;
    background:var(--field);color:var(--ink);
    border:1px solid var(--line2);border-radius:7px;
  }

  /* A centred dialog on a phone is a small window inside a small window.
     Full sheet instead — and 100dvh, not vh, so the browser's own chrome
     does not crop the footer buttons out of reach. */
  #panel-grip{display:none}
  #panel,#panel.wide,#panel.has-lines{
    top:0;left:0;transform:none;
    width:100vw;max-width:100vw;
    height:100dvh;max-height:100dvh;
    border:0;border-radius:0;
  }
  /* The pickers can breathe now that the sheet is full height. */
  #panel .link-pick,#panel.wide .link-pick{max-height:40dvh}

  /* Tighter gutters: 1.25rem each side of a 375px screen is 20% of it. */
  #grid-wrap{padding:0 .75rem 1rem}
  #table-head{gap:.5rem;padding-top:.625rem;padding-bottom:.625rem}
  #view-bar{padding-left:.75rem;padding-right:.75rem}
}

/* form view: printing shows the sheet alone */
@media print {
  body.printing-form > *:not(#main):not(main) { display: none !important; }
  body.printing-form #sidebar, body.printing-form nav, body.printing-form header,
  body.printing-form #view-wrap > div:first-child { display: none !important; }
  body.printing-form .fm-sheet { border: none !important; max-width: 100% !important; }
}

/* docs: the main pane swaps between tables and the file manager */
[data-docs-hidden] { display: none !important; }
[data-page-hidden] { display: none !important; }

/* ── WORKSPACE PAGES (UI-4 as amended) ────────────────────────────────────
   Same skeleton as the grid side: a header that does not scroll, a body that
   does. min-height:0 on the body is the flex trap that bit #main last week —
   without it the page scrolls instead of the content, and the header leaves. */
/* display:flex below overrides the hidden attribute's display:none — restate
   it, exactly as #panel has to. Without this, Back hides nothing and the grid
   renders UNDERNEATH the page header. Same bug, same cause, second time. */
#page-wrap[hidden]{display:none!important}
#page-wrap{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}
#page-head{display:flex;align-items:center;gap:.75rem;padding:.875rem 1.25rem;
  border-bottom:1px solid var(--line);flex-wrap:wrap}
#page-head h1{font-size:1.25rem;margin:0;font-weight:700}
#page-back{min-width:2rem;font-size:1rem;line-height:1}
#page-tabs{display:flex;gap:.25rem}
#page-tabs button{background:none;border:1px solid transparent;color:var(--muted);
  border-radius:4px;padding:.3rem .7rem;font-size:.82rem;cursor:pointer}
#page-tabs button:hover{color:var(--ink)}
#page-tabs button.on{color:var(--ink);border-color:var(--line);background:var(--panel2)}
#page-error{margin:.625rem 1.25rem 0;padding:.55rem .75rem;
  background:color-mix(in srgb,var(--danger) 12%,transparent);
  border:1px solid var(--danger);border-radius:4px;color:var(--danger);font-size:.8125rem}
#page-body{overflow:auto;flex:1;min-height:0;padding:1rem 1.25rem 1.25rem}
/* MASTER-DETAIL inside a page. A <select> picker exists because a modal has no
   room for a list; a page does, so the catalog is visible and you pick from
   what you can see rather than from a closed dropdown. */
.pg-split{display:flex;gap:1.25rem;align-items:flex-start}
.pg-list{width:19rem;flex:0 0 19rem;max-height:70vh;overflow:auto;
  border:1px solid var(--line);border-radius:6px;background:var(--panel)}
.pg-detail{flex:1;min-width:0}
.pg-group{font-family:Consolas,ui-monospace,monospace;font-size:.62rem;letter-spacing:.12em;
  text-transform:uppercase;color:var(--muted);padding:.5rem .7rem .2rem}
.pg-item{display:flex;gap:.5rem;align-items:baseline;padding:.4rem .7rem;cursor:pointer;
  border-left:2px solid transparent;font-size:.84rem}
.pg-item:hover{background:var(--panel2)}
.pg-item.sel{background:var(--panel2);border-left-color:var(--accent)}
.pg-item .pg-sub{color:var(--muted);font-size:.72rem;margin-left:auto;white-space:nowrap}
@media (max-width: 48rem){
  /* no room for two columns — the list goes above the detail and gets shorter */
  .pg-split{flex-direction:column}
  .pg-list{width:100%;flex:none;max-height:14rem}
}
/* The roster is a real grid here, not a table crammed into a box — give the
   action column room so its buttons sit BESIDE the row instead of stacking
   under it, which is what made the Invite button look like someone else's. */
#page-body .um-table{width:100%}
#page-body .um-table td:last-child{white-space:nowrap;display:flex;gap:.375rem;align-items:center}
@media (max-width: 48rem){
  #page-body{padding:.75rem}
}
#docs-head{display:flex;flex-direction:column;gap:.5rem;margin-bottom:.75rem}
#docs-title-row{display:flex;align-items:baseline;gap:.75rem;flex-wrap:wrap}
#docs-title{font-size:.95rem;font-weight:700;display:flex;flex-wrap:wrap;column-gap:.35rem;align-items:baseline}
.doc-crumb{color:var(--muted);text-decoration:none;font-weight:600}
.doc-crumb:hover{color:var(--accent)}
.crumb-sep{color:var(--line2);font-weight:400;user-select:none}
#docs-actions{display:flex;gap:.5rem;flex-wrap:wrap;align-items:center;
  padding-bottom:.5rem;border-bottom:1px solid var(--line2)}
#docs-actions .btn{white-space:nowrap}
#docs-selmove{width:auto}
/* grouping levels in the gear */
.sh-group-row{display:flex;gap:.375rem;align-items:center;margin-top:.375rem}
.sh-group-row select{flex:1}
.sh-group-row .btn{padding:.3rem .55rem;min-height:0;line-height:1}
/* nested group bands: deeper levels sit lighter and smaller */
tr.grid-group[data-depth="1"] td{background:var(--panel);font-size:.8rem}
tr.grid-group[data-depth="2"] td{background:transparent;font-size:.78rem;opacity:.85}
tr.grid-group[data-depth="3"] td{background:transparent;font-size:.76rem;opacity:.72}
tr.grid-group td .mono-label{margin-right:.375rem}
tr.grid-group td{cursor:default}
.grp-fold{margin-right:.45rem;vertical-align:middle}
/* upload progress: a live row in the folder listing */
.up-cell{display:flex;align-items:center;gap:.625rem}
.up-track{flex:1;max-width:22rem;height:.5rem;background:var(--panel2);
  border-radius:999px;overflow:hidden;display:inline-block}
.up-fill{display:block;height:100%;width:0;background:var(--accent);
  border-radius:999px;transition:width .15s linear}
.up-stat{white-space:nowrap}
.up-row.err .up-fill{background:var(--danger)}
.up-row.done .up-fill{opacity:.5}
.up-line{display:flex;align-items:center;gap:.625rem;padding:.3rem .25rem}
.up-line > span:first-child{flex:0 0 16rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.up-line .up-cell{flex:1}
#docs-tree .tree-row.sel { background: var(--sel); border-radius: 6px; }

/* ── ask(): the app's own confirm ─────────────────────────────────────────
   Destructive confirmation is the ONE case where blocking is correct, so
   this stays modal. z-index 90/91 puts it above #panel (61) and above a
   #toast (70), because several of these are raised from inside an open
   dialog and one of them follows a warning. */
#ask-back{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:90}
#ask{position:fixed;z-index:91;top:50%;left:50%;transform:translate(-50%,-50%);
  width:min(92vw,26rem);max-height:85dvh;background:var(--panel);
  border:1px solid var(--line);border-radius:10px;
  box-shadow:0 20px 60px rgba(0,0,0,.35);display:flex;flex-direction:column}
/* pre-line because half these questions list what is about to go */
#ask .ask-q{padding:1rem;font-size:.875rem;color:var(--ink);
  white-space:pre-line;overflow-y:auto;line-height:1.45}
#ask footer{padding:.75rem 1rem;border-top:1px solid var(--line);
  display:flex;gap:.5rem;justify-content:flex-end}
/* A phone gets a sheet at the BOTTOM rather than a centred box: it is within
   thumb reach, and it does not jump when the keyboard is up behind it. */
@media (max-width: 48rem){
  #ask{top:auto;bottom:0;left:0;transform:none;width:100vw;max-width:100vw;
    border-radius:12px 12px 0 0;border-bottom:0}
  #ask footer .btn{flex:1;padding:.6rem 1rem}
}

/* ── file viewer: full overlay; content fills, header floats ── */
#viewer{position:fixed;inset:1.25rem;z-index:73;background:var(--panel);
  border:1px solid var(--line);border-radius:8px;display:flex;flex-direction:column;
  box-shadow:0 12px 48px rgba(0,0,0,.35)}
#viewer[hidden]{display:none}
#viewer-head{display:flex;align-items:center;gap:.75rem;padding:.6rem .9rem;
  border-bottom:1px solid var(--line2)}
#viewer-title{font-weight:700}
#viewer-body{flex:1;min-height:0;overflow:auto;display:flex;
  align-items:center;justify-content:center;background:var(--panel2)}
#viewer-body img{max-width:100%;max-height:100%;object-fit:contain}
#viewer-body iframe,#viewer-body .viewer-fill{width:100%;height:100%;border:0}
#viewer-body video{max-width:100%;max-height:100%}
#viewer-body pre{align-self:stretch;width:100%;margin:0;padding:1rem;overflow:auto;
  font-family:Consolas,ui-monospace,monospace;font-size:.8rem;white-space:pre-wrap}
.viewer-msg{color:var(--muted);text-align:center;padding:2rem}

/* ── docs selection bar ── */
#docs-selbar{display:flex;align-items:center;gap:.5rem;padding:.4rem .9rem;
  border-bottom:1px solid var(--line2);background:var(--panel2)}
#docs-selbar[hidden]{display:none}
.sel-td{width:1.6rem;text-align:center}
.sel-td input{width:auto;cursor:pointer}

/* ── ✏ parameter panel (CAPS loop) docked right inside the viewer ── */
#param-panel{position:absolute;top:3.2rem;right:.75rem;bottom:.75rem;width:20rem;
  background:var(--panel);border:1px solid var(--line);border-radius:8px;
  display:flex;flex-direction:column;box-shadow:0 8px 32px rgba(0,0,0,.3);z-index:5}
#param-panel input{font-size:.8rem;padding:.25rem .4rem}
.pp-group{border-bottom:1px solid var(--line2);padding:.25rem 0 .375rem;margin-bottom:.25rem}
.pp-group summary{cursor:pointer;padding:.25rem 0;user-select:none;font-weight:700}
#grid-selbar{display:flex;gap:.5rem;align-items:center;padding:.3rem .9rem;border-bottom:1px solid var(--line2)}
#grid-selbar[hidden]{display:none}

/* ── SHEET view: spreadsheet-style rapid entry ── */
.sh-wrap{overflow:auto;border:1px solid var(--line);border-radius:6px}
.sh-table{border-collapse:collapse;width:100%;font-size:.8rem}
.sh-table th{position:sticky;top:0;z-index:1;background:var(--panel2);text-align:left;
  padding:.35rem .5rem;border-bottom:1px solid var(--line);white-space:nowrap;font-weight:600}
.sh-table td{padding:0;border-bottom:1px solid var(--line2);border-right:1px solid var(--line2)}
.sh-table td:last-child,.sh-table th:last-child{border-right:0}
.sh-table input,.sh-table select{border:0;border-radius:0;background:transparent;padding:.3rem .5rem;
  width:100%;min-width:7rem}
.sh-table input[type=checkbox]{width:auto;min-width:0;margin:.35rem .5rem}
.sh-table input:focus,.sh-table select:focus{outline:2px solid var(--accent);outline-offset:-2px;
  background:var(--panel)}
.sh-ro{padding:.3rem .5rem;color:var(--computed);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:16rem}
.sh-state{width:1.4rem;text-align:center;color:var(--muted);font-size:.7rem}
.sh-row.dirty .sh-state{color:var(--accent)}
.sh-open{width:1.8rem;text-align:center}
.sh-panel{border:0;background:none;cursor:pointer;color:var(--muted);padding:.2rem .3rem}
.sh-panel:hover{color:var(--ink)}

/* ── PAGE LAYOUT view: a real sheet of paper, measured in mm ── */
.pl-bar{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin-bottom:.5rem}
.pl-tools{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin-bottom:.5rem;
  padding:.4rem .5rem;background:var(--panel2);border:1px solid var(--line2);border-radius:6px}
.pl-tools select,.pl-tools input[type=number],.pl-tools input[type=text]{width:auto}
.pl-props{display:inline-flex;gap:.4rem;align-items:center;flex-wrap:wrap;min-width:0;padding-left:.5rem;
  border-left:1px solid var(--line)}
.pl-props[hidden]{display:none}
.pl-stick{position:sticky;top:-1rem;z-index:20;margin:-1rem -1.25rem .5rem;padding:1rem 1.25rem 0;background:var(--ground)}
.pl-stick .pl-tools{margin-bottom:0}
.pl-group{display:inline-flex;gap:.4rem;align-items:center;padding:0 .5rem;border-left:1px solid var(--line);border-right:1px solid var(--line)}
@media print{ body.printing-layout .pl-stick{display:none !important} }
.pl-canvas{overflow:auto;padding:.75rem;background:var(--panel2);border-radius:6px}
.pl-page{position:relative;background:#fff;color:#111;background-size:100% 100%;
  background-repeat:no-repeat;box-shadow:0 2px 14px rgba(0,0,0,.3);margin:0 auto}
.pl-el{position:absolute;overflow:hidden;line-height:1.15;display:flex;align-items:center;gap:.6mm}
.pl-field{border-bottom:0.2mm solid rgba(0,0,0,.25)}
.pl-field.pl-noline{border-bottom:0}
.pl-tools [hidden]{display:none}
.pl-lab{color:#666;font-size:.75em;white-space:nowrap}
/* a label outside its box: above it, or to its left */
.pl-field.pl-lab-out{overflow:visible}
.pl-lab-above{position:absolute;left:0;bottom:100%;margin-bottom:.4mm;line-height:1.1}
.pl-lab-left{position:absolute;right:100%;top:0;bottom:0;display:flex;align-items:center;margin-right:1mm}
.pl-val{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pl-el input,.pl-el select{flex:1;min-width:0;border:0;background:transparent;padding:0 .5mm;
  font:inherit;color:inherit;height:100%}
.pl-el input:focus,.pl-el select:focus{outline:1px solid var(--accent)}
/* a drop-down on a page is drawn by the page, not by the system: the system's
   own sets its text lower than the text of the boxes beside it, and cuts it
   in a row that is tight */
.pl-el select,.pl-lines-tbl td select.pl-line-in,.pl-block-val select.pl-line-in{appearance:none;-webkit-appearance:none;line-height:inherit;padding-right:3.4mm;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23333' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right .7mm center;background-size:2.2mm auto}
@media print{ .pl-el select,.pl-lines-tbl td select.pl-line-in,.pl-block-val select.pl-line-in{background-image:none;padding-right:0} }
/* what is typed is aligned as the element is set */
.pl-el input,.pl-el select,.pl-el textarea{text-align:var(--pl-align,left);text-align-last:var(--pl-align,left)}
.pl-editable{cursor:move;outline:0.2mm dashed rgba(0,0,0,.25)}
.pl-editable.sel{outline:0.4mm solid #d95510}
.pl-grip{position:absolute;right:0;bottom:0;width:4mm;height:4mm;background:#d95510;
  border-top:0.3mm solid #fff;border-left:0.3mm solid #fff;border-radius:1mm 0 0 0;
  cursor:nwse-resize;z-index:6}
.pl-grip::after{content:"";position:absolute;right:0;bottom:0;width:7mm;height:7mm}
.pl-editable:hover .pl-grip{background:#ff7a29}
.pl-actions{position:absolute;right:4mm;bottom:4mm;display:flex;gap:.5rem}
/* several pages: stacked on screen with a label each, one sheet each on paper */
.pl-pagehead{display:flex;align-items:center;gap:.5rem;margin:1rem auto .35rem;font-size:.8rem}
.pl-pagehead:first-child{margin-top:0}
.pl-pagehead .pl-page-del{background:none;border:0;color:var(--muted);cursor:pointer;padding:0 .25rem}
.pl-pagehead .pl-page-del:hover{color:var(--accent)}
.pl-page.cur{box-shadow:0 0 0 .6mm #d95510, 0 2px 14px rgba(0,0,0,.3)}

/* printing a layout: the page alone, at its exact size, background included */
@media print {
  body.printing-layout #topbar, body.printing-layout #form-bar, body.printing-layout .pl-pagehead,
  body.printing-layout #sidebar, body.printing-layout #table-head, body.printing-layout #view-bar,
  body.printing-layout .pl-bar, body.printing-layout .pl-tools,
  body.printing-layout .pl-actions, body.printing-layout #grid-selbar { display:none !important }
  body.printing-layout #app{display:block !important}
  /* every page, not the first alone: nothing is as tall as the screen, and nothing scrolls */
  html.printing-layout,body.printing-layout{height:auto !important;overflow:visible !important;background:#fff !important}
  body.printing-layout #main{display:block !important;height:auto !important;min-height:0 !important;overflow:visible !important}
  body.printing-layout #view-wrap{overflow:visible !important;padding:0 !important;height:auto !important}
  body.printing-layout .pl-canvas{overflow:visible !important;padding:0 !important;background:#fff !important}
  body.printing-layout .pl-page{box-shadow:none !important;margin:0 !important;
    -webkit-print-color-adjust:exact;print-color-adjust:exact}
  body.printing-layout .pl-editable{outline:none !important}
  body.printing-layout .pl-page{page-break-after:always;break-after:page}
  body.printing-layout .pl-page:last-of-type{page-break-after:auto;break-after:auto}
}

/* ── SKETCH field: draw a signature, a markup, a site detail ── */
.sketch-box{display:flex;flex-direction:column;gap:.25rem}
.sketch-cv{width:100%;height:var(--sk-h,40mm);background:#fff;border:1px solid var(--line);
  border-radius:4px;touch-action:none;cursor:crosshair;display:block}
.sketch-tools{display:flex;gap:.5rem;align-items:center}
/* the record's workflow history under its Status field, and on a page */
.wf-hist{margin-top:.4rem}
.wf-hist-tbl{width:100%;border-collapse:collapse;font-size:.8125rem}
.wf-hist-tbl th{text-align:left;font-weight:600;color:var(--muted);font-size:.7rem;letter-spacing:.06em;text-transform:uppercase;padding:.15rem .4rem .15rem 0}
.wf-hist-tbl td{padding:.2rem .4rem .2rem 0;border-top:1px solid var(--line);vertical-align:top}
.pl-hist{width:100%;border-collapse:collapse;font-size:inherit;table-layout:fixed}
.pl-hist th{text-align:left;font-weight:600;border-bottom:1px solid #000;padding:0 .3mm}
.pl-hist td{border-bottom:1px solid #999;padding:0 .3mm;vertical-align:top;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* a period: two dates, one value */
svg.barcode{display:block;height:3.2rem;max-width:100%;margin-top:.3rem;color:var(--ink)}
svg.qrcode{display:block;margin-top:.3rem;color:var(--ink)}
.pl-code{display:flex;align-items:center;justify-content:center;height:100%}
.pl-code svg.barcode,.pl-code svg.qrcode{height:100%;width:auto;max-width:100%;margin:0;color:#000}
.location{display:flex;gap:.375rem;align-items:center;flex-wrap:wrap}
.location input[type=number],.location input[type=text]{flex:1;min-width:6rem}
.location .loc-side{flex:0 0 6rem}
.location .loc-map,td .loc-map{font-size:.8rem;color:var(--accent);text-decoration:none;white-space:nowrap}
.period{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}
.period input[type=date],.period input[type=time]{width:auto;flex:0 1 11rem}
.pl-period{display:flex;align-items:center;gap:.5mm;width:100%;height:100%}
.pl-period .pl-half{flex:1;min-width:0}
.pl-period-to{font-size:.7em;color:#555}
/* photos: thumbnails with when and where */
.photo-grid{display:flex;flex-wrap:wrap;gap:.6rem;margin-bottom:.4rem}
.photo-grid figure{margin:0;position:relative;width:9rem}
.photo-grid img{display:block;width:9rem;height:6.5rem;object-fit:cover;border-radius:4px;border:1px solid var(--line);background:#fff;cursor:zoom-in}
.photo-grid figcaption{font-size:.7rem;color:var(--muted);line-height:1.25;margin-top:.2rem}
.photo-x{position:absolute;top:.25rem;right:.25rem;width:1.25rem;height:1.25rem;border:0;border-radius:50%;background:#111;color:#fff;cursor:pointer;line-height:1.25rem;padding:0;opacity:.8}
.photo-x:hover{opacity:1}
.sketch-tools .btn{padding:.15rem .5rem;font-size:.75rem}
.sk-thumb{height:1.6rem;background:#fff;border-radius:2px}
/* on a page layout the element's own box decides the size — a signature
   strip is small, a sketch panel is large; the field never dictates it */
.pl-sketch{position:absolute;inset:0;gap:0}
.pl-sketch .sketch-cv{height:100%;border:0;border-radius:0;background:transparent}
.pl-sketch .sketch-tools{position:absolute;top:0;right:0;z-index:2;gap:.25rem;
  background:rgba(255,255,255,.82);border-radius:0 0 0 3px;padding:0 .15rem;
  opacity:0;transition:opacity .12s}
.pl-sketch:hover .sketch-tools,.pl-sketch:focus-within .sketch-tools{opacity:1}
.pl-sketch .sketch-tools .btn{padding:0 .3rem;font-size:.65rem;line-height:1.4}
.pl-sketch .sketch-hint{font-size:.6rem}
.pl-sk{width:100%;height:100%;object-fit:contain;object-position:left bottom}
@media print{ .sketch-tools{display:none !important} }

/* ── login ── */
#login{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;
  background:var(--ground)}
#login[hidden]{display:none}
#login-card{width:20rem;padding:1.5rem;border:1px solid var(--line);border-radius:10px;
  background:var(--panel)}
#login-card .field{margin-bottom:.75rem}
#login-err{color:#e66;font-size:.8rem;margin-bottom:.75rem}
#login-err[hidden]{display:none}
.who-chip{font-weight:600;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#who-row .btn{padding:.15rem .45rem}

/* attachment fields: the whole field is a dropzone */
.field[data-kind=file]{border:1px dashed transparent;border-radius:6px;transition:border-color .12s}
.field[data-kind=file].file-over{border-color:var(--accent);background:color-mix(in srgb, var(--accent) 8%, transparent)}
.field[data-kind=file].file-busy{opacity:.6;pointer-events:none}

/* layout elements: wrapped text flows in the box instead of clipping a line */
.pl-el.pl-wrap{white-space:normal}
.pl-el.pl-wrap .pl-val{white-space:pre-wrap;overflow:hidden;text-overflow:clip;align-self:stretch}

/* layout child-lines box: a compact table; file columns render as thumbs */
.pl-lines{overflow:hidden}
.pl-lines-host{width:100%;height:100%;overflow:hidden;align-self:stretch}
.pl-lines-tbl{border-collapse:collapse;width:100%;height:100%;table-layout:fixed;font-size:inherit;color:inherit}
/* a table's lines: its frame and every line in it, as thick as the box says */
.pl-lines-tbl th,.pl-lines-tbl td{border:var(--pl-line,.25mm) solid #222;padding:var(--pl-pad,.4mm) 1mm}
/* rows too small for the line spacing of the page: a line is as tall as the row */
.pl-tight th,.pl-tight td{line-height:var(--pl-row)}
/* what a cell holds keeps to the height of its row: a row is the box's height
   divided by its rows, whatever the size of the text */
.pl-cell{max-height:var(--pl-row,none);min-width:0;overflow:hidden}
.pl-lines:not(.pl-wrap) .pl-cell{white-space:nowrap;text-overflow:ellipsis}
.pl-cell .pl-line-in,.pl-cell select,.pl-cell .lp-btn,.pl-cell .mpick,.pl-cell .mpick-btn{
  max-height:var(--pl-row,none);vertical-align:top}
.pl-short{color:var(--accent)}
/* the titles are always in the middle; the box's alignment moves the records */
.pl-lines-tbl th{text-align:center;vertical-align:middle;font-weight:700}
.pl-lines-tbl td{vertical-align:var(--pl-valign,middle)}
.pl-block-line{align-items:var(--pl-vflex,center)}
.pl-block-line .pl-lab{align-self:center}
/* the frame lies half outside the table: room for it, so it is not cut */
.pl-tab{padding:calc(var(--pl-line,.25mm) / 2)}
.pl-lines:not(.pl-wrap) .pl-lines-tbl td{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pl-lines-tbl.pl-rules-rows th,.pl-lines-tbl.pl-rules-rows td{border-left:0;border-right:0}
.pl-lines-tbl.pl-rules-none th,.pl-lines-tbl.pl-rules-none td{border:0}
.pl-photos.pl-rules-none .pl-photo,.pl-photos.pl-rules-none .pl-photo figcaption{border:0}
/* a check box placed on its own */
.pl-mark{justify-content:center;line-height:1}
.pl-mark.pl-editable{overflow:visible}
.pl-mark .pl-grip{display:none}
.pl-mark .pl-grip::after{display:none}
.pl-mark.sel .pl-grip{display:block;width:1.8mm;height:1.8mm;right:-1.8mm;bottom:-1.8mm}
.pl-el textarea{flex:1;min-width:0;align-self:stretch;border:0;background:transparent;padding:.5mm;
  font:inherit;color:inherit;line-height:inherit;resize:none}
.pl-el textarea:focus{outline:1px solid var(--accent)}
.pl-mark .pl-tick input{margin:0}
.pl-mark-name{display:none;position:absolute;left:0;top:100%;z-index:6;margin-top:.6mm;padding:.4mm 1.2mm;
  background:#111;color:#fff;font-size:2.6mm;font-weight:400;white-space:nowrap;border-radius:.6mm;pointer-events:none}
.pl-mark.sel .pl-mark-name,.pl-mark:hover .pl-mark-name{display:block}
.pl-lines-tbl td .pl-line-in{width:100%;border:0;background:transparent;font:inherit;color:inherit;padding:0}
.pl-lines-tbl td .pl-line-in:focus{outline:1px solid var(--accent)}
.pl-thumb{height:14mm;margin:.4mm .4mm 0 0;object-fit:cover}

/* ── forms (057): a form is opened OVER the views, with a way back ── */
#form-bar{display:flex;align-items:center;gap:.6rem;padding:.45rem .25rem;margin-bottom:.5rem;border-bottom:1px solid var(--line)}
#form-bar[hidden]{display:none}
#new-entry-menu{position:absolute;right:0;top:calc(100% + 4px);z-index:75;min-width:16rem;padding:6px;
  background:var(--panel);border:1px solid var(--line2);border-radius:8px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
#new-entry-menu[hidden]{display:none}
#new-entry-menu button{display:flex;gap:.5rem;width:100%;background:none;border:0;color:var(--ink);
  text-align:left;padding:7px 9px;border-radius:6px;cursor:pointer}
#new-entry-menu button:hover{background:var(--sel)}
#new-entry-wrap #new-entry:not([hidden]) + #new-entry-more:not([hidden]){border-top-left-radius:0;border-bottom-left-radius:0}
#new-entry-wrap #new-entry:has(+ #new-entry-more:not([hidden])){border-top-right-radius:0;border-bottom-right-radius:0}
.forms-row{display:flex;align-items:center;gap:.6rem;padding:.55rem .25rem;border-bottom:1px solid var(--line)}
.forms-row .grow{flex:1;min-width:0}

/* ── CHART view ── */
.ch-bar{display:flex;flex-wrap:wrap;gap:.5rem .9rem;align-items:center;padding:.5rem .6rem;margin-bottom:.6rem;
  border:1px solid var(--line);border-radius:8px;background:var(--panel)}
.ch-bar label{display:flex;align-items:center;gap:.35rem;text-transform:none;letter-spacing:0;font-size:.78rem}
.ch-bar select{width:auto}
.ch-wrap{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:.75rem 1rem}
.ch-title{font-weight:600;margin-bottom:.4rem}
.ch-svg{width:100%;height:auto;display:block}
.ch-svg .ch-lab{fill:var(--muted);font-size:12px}
.ch-svg .ch-big{fill:var(--ink);font-size:28px;font-weight:700}
.ch-svg .ch-grid{stroke:var(--line);stroke-width:1}
.ch-svg .ch-hit{cursor:pointer}
.ch-svg .ch-hit:hover{opacity:.8}
#ch-detail{margin-top:.6rem}
.ch-detail-head{display:flex;gap:.6rem;align-items:baseline;padding:.3rem 0;border-bottom:1px solid var(--line)}
.ch-rec{display:flex;justify-content:space-between;gap:.75rem;padding:.35rem 0;border-bottom:1px solid var(--line);cursor:pointer}
.ch-rec:hover{color:var(--accent)}
@media print{ .ch-bar{display:none !important} }

/* ── the Forms / Charts dropdowns in the view bar ── */
.dd-menu{position:fixed;z-index:90;min-width:17rem;max-width:22rem;max-height:60vh;overflow:auto;padding:6px;
  background:var(--panel);border:1px solid var(--line2);border-radius:8px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
.dd-menu hr{border:0;border-top:1px solid var(--line);margin:6px 0}
.dd-row{display:flex;align-items:center;gap:2px;border-radius:6px}
.dd-row:hover{background:var(--sel)}
.dd-main{flex:1;min-width:0;display:flex;gap:.5rem;background:none;border:0;color:var(--ink);text-align:left;
  padding:7px 8px;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dd-act{background:none;border:0;color:var(--muted);cursor:pointer;padding:4px 6px;border-radius:4px;min-width:1.6rem;text-align:center}
.dd-act:hover{color:var(--accent);background:var(--line2)}
.dd-row.dd-on .dd-main{color:var(--accent);font-weight:600}

/* ── 058: a locked (approved) record ── */
.lock-strip{border:1px solid var(--line2);border-left:3px solid var(--accent);border-radius:6px;
  padding:.5rem .75rem;margin-bottom:.75rem;background:var(--panel)}
.row-lock{font-size:.8rem;opacity:.75;cursor:help}
.lock-strip.void{border-left-color:#ef4444}
/* a frozen field reads as a value, not a box you could type in */
#panel-form .field :is(input,select,textarea):disabled{background:transparent;border-style:dashed;
  border-color:var(--line);color:var(--ink);opacity:.8;cursor:default;appearance:none;-webkit-appearance:none}
tr.row-dead td{opacity:.5}
tr.row-dead td:not(.sel-td){text-decoration:line-through;text-decoration-color:rgba(239,68,68,.5)}

/* ── PHONES, part two (2026-09-18: "take a look at how it shows up in the
   mobile phones, because it is really bad"). What broke at 375px:
   · the top bar's pickers kept their desktop minimum widths, so the account
     button fell off the right edge;
   · every view tab WRAPPED inside itself — icon, name and ▾ on three lines —
     so five tabs stood as a column half the screen tall;
   · the action buttons did the same beside them. ── */
@media (max-width: 48rem){
  #topbar{gap:6px;padding:5px 8px}
  #topbar #space-btn,#items-btn{min-width:0;max-width:none;flex:1 1 0;height:36px;padding:0 10px;font-size:.92rem;gap:6px}
  #topbar #space-wrap,#items-wrap{flex:1 1 0;min-width:0}
  #topbar #space-btn,#items-btn{width:100%}   /* fill the slot, never overrun it */
  #topbar > span[style*="flex:1"]{display:none}
  #who-wrap{flex:none}
  #who-btn{height:36px;padding:0 6px}
  /* THE ONE THAT CLIPPED EVERYTHING. A grid track of `1fr` is minmax(auto,1fr):
     it grows to its widest child's min-content, and the top bar's buttons
     (Tools, the assistant, the avatar - none of them allowed to shrink) made
     that 473px on a 375px phone. Every screen then laid out at 473 and was cut
     at 375: "+ New", the card values, the chart's right edge, the view tabs.
     minmax(0,1fr) lets the track be the viewport, and min-width:0 lets each
     flex row shrink to it instead of pushing it out. */
  #app{grid-template-columns:minmax(0,1fr)}
  #topbar,#main,#table-head,#view-bar,#page-wrap,#page-body{min-width:0}
  #tools-wrap,#assist-btn,#who-wrap{flex:none}
  #tools-btn{height:36px;padding:0 8px;font-size:.92rem}
  #tools-btn .caret{display:none}                 /* the word is the affordance here */
  /* With Tools, the assistant and the avatar all on the bar, the two
     stretching buttons were down to "A." and "S". The carets and the avatar's
     caret cost ~45px between them and say nothing a tap does not; the names
     are what tell you where you are. */
  #space-btn .caret,#items-btn .caret,#who-btn .caret{display:none}
  #topbar #space-btn,#items-btn{gap:5px;padding:0 8px}
  #who-btn{padding:0 4px}
  #assist-btn{padding:4px 6px}
  /* search takes its own full line under the title, not a 26rem stub */
  #grid-search{flex:1 1 100%;max-width:none;min-width:0;margin-left:0;order:3}
  #table-head>*{min-width:0}
  /* the print-page warning is about a Letter sheet; the phone canvas is a
     flow grid with no page, so the warning is only noise here */
  .dash-warn{display:none}
  #topbar .caret{font-size:.7rem}
  /* the drawer and its scrim start BELOW the top bar, which stays on top and
     keeps ☰ reachable to close it again */
  #sidebar{top:47px}
  #nav-scrim{top:47px}

  #table-head{flex-wrap:wrap;row-gap:.4rem;column-gap:.5rem;padding:.5rem .75rem}
  #table-head h1{font-size:1.02rem;flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  #table-count{flex:none}
  #new-entry-wrap{order:2;margin-left:auto}
  #new-entry,#new-entry-more{min-height:2rem;padding-top:.3rem;padding-bottom:.3rem}
  #grid-search{order:3;flex:1 1 100%;height:2.1rem;min-width:0}
  #table-head #auto-connect{display:none !important}

  /* the tabs: one line that scrolls sideways; the tools: one row under it */
  /* tabs and ⋯ share ONE line; the tools live in ⋯ */
  #view-bar{flex-wrap:nowrap;gap:.25rem;padding-top:0;border-bottom:1px solid var(--line)}
  #view-tabs{flex:1 1 auto;min-width:0;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;
    -webkit-overflow-scrolling:touch}
  #view-tabs::-webkit-scrollbar{display:none}
  .view-tab{flex:none;white-space:nowrap;padding:.35rem .55rem}
  #view-bar > .btn:not(#view-more){display:none !important}
  #view-more{display:inline-flex;flex:none;align-items:center;min-height:1.9rem;padding:0 .7rem;font-size:1.1rem}
  #grid-wrap{padding:0 0 1rem}
  #grid{margin-top:0}
  #grid td{padding:.35rem .55rem}
  #grid th{padding:.4rem .55rem}
  #view-wrap{padding:.75rem}
  #form-bar{padding-left:.75rem;padding-right:.75rem}
}

/* ── dashboard ── */
.dash-bar{display:flex;align-items:center;margin-bottom:.5rem}
.dash-add{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;padding:.6rem;margin-bottom:.75rem;
  border:1px dashed var(--line2);border-radius:8px}
.dash-add select,.dash-add input{width:auto}
/* a tab is a PAGE: the canvas keeps the paper's proportions; the dashed edge
   marks where the printed sheet ends */
.dash-canvas{position:relative;width:100%;max-width:1400px;background:var(--panel2);border:1px solid var(--line);
  border-radius:4px;box-shadow:0 2px 14px rgba(0,0,0,.18)}
.dash-page-edge{position:absolute;left:0;right:0;top:0;border-bottom:1px dashed var(--line);pointer-events:none}
.dash-warn{margin:0 0 .6rem;padding:.45rem .7rem;border:1px solid var(--danger);border-radius:6px;color:var(--danger);font-size:.84rem}
#dtab-size,#dtab-orient{width:auto;margin-left:.35rem;font-size:.8rem;padding:.15rem .3rem}
.dash-canvas .dash-tile{position:absolute;display:flex;flex-direction:column;overflow:hidden}
.dash-canvas.editing .dash-tile{cursor:move;outline:1px dashed var(--line2)}
.dash-canvas.editing .dash-tile.dragging{outline:2px solid var(--accent);z-index:5;opacity:.92}
.dash-canvas .dash-body{flex:1;min-height:0;display:flex;flex-direction:column}
.dash-chart{flex:1;min-height:0;display:flex}
.dash-chart .ch-wrap{flex:1;min-height:0;display:flex;flex-direction:column}
.dash-chart .ch-svg{flex:1;min-height:0;width:100%;height:100%}
.dash-grip{z-index:6}
.dash-tile{position:relative;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:.75rem .9rem;min-width:0}
.dash-ctl{position:absolute;top:.3rem;right:.3rem;display:flex;gap:2px;background:var(--panel);border-radius:6px;z-index:2}
.dash-kpi{display:flex;flex-direction:column;gap:.2rem;width:100%;background:none;border:0;color:var(--ink);text-align:left;cursor:pointer;padding:0}
.dash-kpi-label{font-size:.8rem;color:var(--muted);font-weight:600}
.dash-kpi-value{font-size:1.65rem;font-weight:700;font-variant-numeric:tabular-nums;line-height:1.2}
.dash-kpi:hover .dash-kpi-value{color:var(--accent)}
.dash-head{display:flex;gap:.5rem;align-items:baseline;background:none;border:0;color:var(--ink);font-weight:700;
  font-size:.92rem;padding:0 0 .4rem;cursor:pointer;text-align:left}
.dash-head:hover{color:var(--accent)}
.dash-chart .ch-wrap{padding:0;border:0;background:none}
.dash-chart .ch-title{font-size:.72rem}
.dash-work{display:flex;gap:.5rem;align-items:center;width:100%;background:none;border:0;border-top:1px solid var(--line2);
  color:var(--ink);padding:.45rem 0;text-align:left;cursor:pointer;font-size:.86rem}
.dash-work span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dash-work-n{font-weight:700;min-width:1.6rem;text-align:right;color:var(--accent)}
.dash-work:hover{background:var(--panel2)}
/* phones: the placed layout would be a tenth of its size — stack in reading
   order instead, narrow tiles two to a row. SCREEN only: a printed page keeps
   its placed layout however narrow the print engine lays it out */
@media screen and (max-width: 48rem){
  .dash-canvas{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.5rem;aspect-ratio:auto !important;
    background:none;border:0;box-shadow:none}
  .dash-page-edge{display:none}
  .dash-canvas .dash-tile{position:static;width:auto !important;height:auto !important;grid-column:span 2}
  .dash-canvas .dash-tile.narrow{grid-column:span 1}
  .dash-canvas .dash-tile.chart{min-height:260px}
  .dash-grip{display:none}
  .dash-tile{padding:.6rem .7rem}
  .dash-kpi-value{font-size:1.3rem}
}
.dash-ctl + .dash-body{margin-top:1.5rem}   /* edit controls get their own line, never over a label */
.dash-tabs{display:flex;align-items:center;gap:.25rem;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;
  border-bottom:1px solid var(--line);margin-bottom:.75rem}
.dash-tabs::-webkit-scrollbar{display:none}
.dash-tabs .view-tab{flex:none;white-space:nowrap}
.dash-tab-ctl{display:inline-flex;align-items:center;gap:2px;margin-left:.5rem;flex:none}

/* 🖨 a dashboard tab prints as one page of its size, in light colours */
@media print {
  body.printing-dashboard #topbar, body.printing-dashboard #sidebar, body.printing-dashboard #table-head,
  body.printing-dashboard #view-bar, body.printing-dashboard #form-bar, body.printing-dashboard .dash-bar,
  body.printing-dashboard .dash-tabs, body.printing-dashboard .dash-add, body.printing-dashboard .dash-warn,
  body.printing-dashboard #nav-toggle { display:none !important }
  body.printing-dashboard #app{display:block !important}
  body.printing-dashboard #view-wrap{padding:0 !important;overflow:visible !important}
  body.printing-dashboard .dash-canvas{--panel:#fff;--panel2:#fff;--ink:#111;--muted:#555;--line:#bbb;--line2:#ddd;--computed:#333;
    max-width:none !important;border:0 !important;box-shadow:none !important;background:#fff !important;
    -webkit-print-color-adjust:exact;print-color-adjust:exact;overflow:hidden}
  body.printing-dashboard .dash-page-edge{display:none}
  body.printing-dashboard .dash-tile{break-inside:avoid;color:#111}
}

/* charts: value labels, the S-curve's today line and its line editor */
.ch-val{font-size:10px;fill:var(--muted)}
.ch-hit{cursor:pointer}
.sc-today{stroke:var(--accent);stroke-width:1.5;stroke-dasharray:4 4}
.sc-end{font-weight:700}
.sc-line{display:flex;flex-wrap:wrap;gap:.35rem;align-items:center;width:100%;padding:.25rem 0;border-top:1px solid var(--line2)}
.sc-line select,.sc-line input{width:auto}
.sc-swatch{width:12px;height:12px;border-radius:3px;flex:none}
#ch-pop{max-width:26rem}
#ch-pop .dd-main{display:flex;gap:.5rem}
.sc-today-lab{fill:var(--accent)}
/* the ruler and the readout - see attachHitTips / the S-curve ruler */
.sc-guide{stroke:var(--muted);stroke-width:1;stroke-dasharray:3 3;pointer-events:none}
.ch-wrap{position:relative}
.ch-tip{position:absolute;z-index:5;pointer-events:none;background:var(--panel2);color:var(--ink);
  border:1px solid var(--line2);border-radius:6px;padding:.4rem .6rem;font-size:.8rem;line-height:1.35;
  box-shadow:0 8px 24px rgba(0,0,0,.35);white-space:nowrap;max-width:min(20rem,80vw)}
.ch-tip[hidden]{display:none}
.ch-tip b{display:block;margin-bottom:.2rem}
.ch-tip div{display:flex;gap:.5rem;align-items:center}
.ch-tip i{width:9px;height:9px;border-radius:2px;display:inline-block;flex:none}
.ch-tip span{margin-left:auto;padding-left:.75rem;font-variant-numeric:tabular-nums;font-weight:600}

/* ── the Forms catalogue: one row per filing type ── */
.fm-list{display:flex;flex-direction:column;gap:.375rem}
.fm-row{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap;
  border:1px solid var(--line2);border-radius:6px;padding:.5rem .75rem;background:var(--panel)}
.fm-def{display:flex;align-items:center;gap:.375rem;margin:0}
.fm-def input{width:auto}
.fm-name{display:flex;align-items:center;gap:.4rem}
@media (max-width:48rem){ .fm-row{gap:.5rem} .fm-hint{display:none} }

/* an item cast from a template carries a quiet ⌂ — the structure lives there */
.from-tpl{font-size:.75rem;opacity:.45;cursor:help}
.module:hover .from-tpl{opacity:.7}

/* ── Searchable link picker ── a long link list is unusable as a dropdown:
   8,398 rows all reading "Basic Wall". The hidden <select> still holds the
   value; this is the face and the popup over it. */
.lp-btn {
  width: 100%; text-align: left; padding: .4rem .55rem; font: inherit;
  background: var(--panel, #1b1f26); color: inherit;
  border: 1px solid var(--line2, #2c323b); border-radius: 6px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lp-btn.empty { opacity: .6; }
/* inside a line row the picker sits among inputs half its padding */
.lp-btn.compact { padding: .2rem .4rem; }
/* on a page layout the picker has no frame of its own: the page draws the box */
.pl-el .lp-btn,.pl-lines-tbl td .lp-btn,.pl-block-val .lp-btn{flex:1;min-width:0;width:100%;height:100%;border:0;border-radius:0;
  background:transparent;color:inherit;font:inherit;padding:0 .5mm;text-align:var(--pl-align,left);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}
.pl-el .lp-btn.empty{color:#8a8a8a;opacity:1}
.pl-el .lp-btn:focus-visible{outline:1px solid var(--accent)}
.pl-computed{display:block;overflow:hidden;text-overflow:ellipsis}
/* what a line's computed fields will hold, under its boxes */
.line-computed{flex:0 0 100%;display:flex;flex-wrap:wrap;gap:.125rem 1rem;font-size:.8125rem;color:var(--muted);padding:0 .25rem .25rem}
.line-computed span:empty{display:none}
.lp-pop {
  position: absolute; z-index: 500; margin-top: 2px; width: min(420px, 92vw);
  background: var(--panel, #1b1f26); border: 1px solid var(--line2, #2c323b);
  border-radius: 8px; box-shadow: 0 14px 40px rgba(0, 0, 0, .45); padding: 6px;
}
.lp-pop { display: flex; flex-direction: column; }
.lp-pop .lp-filter { width: 100%; margin-bottom: 6px; flex: none; }
.lp-pop .lp-rich { flex: 1 1 auto; min-height: 0; }
.lp-pop .lp-rich { max-height: 46vh; overflow: auto; }
.lp-opt {
  display: flex; width: 100%; text-align: left; gap: .5rem; padding: .35rem .45rem;
  background: none; border: 0; color: inherit; cursor: pointer; border-radius: 5px; font: inherit;
}
.lp-opt:hover, .lp-opt.on { background: var(--hover, rgba(255, 255, 255, .07)); }
.lp-opt .lp-txt { display: flex; flex-direction: column; min-width: 0; }
.lp-opt .lp-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-opt .lp-sum { font-size: 11.5px; opacity: .65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── The assistant panel ── one box for questions and orders. A plan is shown
   in full, gaps first, and written only when the person presses Apply. */
#assist-btn { background: none; border: 0; color: inherit; font-size: 16px; cursor: pointer; padding: 4px 8px; opacity: .85; }
#assist-btn:hover { opacity: 1; }
/* [hidden] is only a UA rule of `display: none`, and the id rule below beats it
   on specificity — so ✕ set the flag and the panel stayed on screen. */
#assist-panel[hidden] { display: none; }
#assist-panel {
  position: fixed; right: 12px; bottom: 12px; width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 720px); display: flex; flex-direction: column; z-index: 450;
  background: var(--panel, #1b1f26); border: 1px solid var(--line2, #2c323b);
  border-radius: 12px; box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
}
#assist-panel .as-head { display: flex; gap: .5rem; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line2, #2c323b); }
#assist-panel .as-head button { background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; font-size: 15px; }
#assist-panel .as-log { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
#assist-panel .as-msg { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
#assist-panel .as-me { align-self: flex-end; max-width: 85%; background: var(--hover, rgba(255,255,255,.07)); padding: 6px 10px; border-radius: 10px; }
#assist-panel .as-it { align-self: flex-start; max-width: 100%; }
#assist-panel .as-plan { margin-top: 8px; border: 1px solid var(--line2, #2c323b); border-radius: 8px; padding: 8px 10px; }
#assist-panel .as-plan-head { font-weight: 600; margin-bottom: 6px; }
#assist-panel .as-prop-scroll { max-height: 18rem; overflow: auto; margin-bottom: 8px; border: 1px solid var(--line2, #2c323b); border-radius: 6px; }
#assist-panel .as-prop table { border-collapse: collapse; width: 100%; font-size: 12px; }
#assist-panel .as-prop th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600; padding: 4px 6px; white-space: nowrap; }
#assist-panel .as-prop td { padding: 3px 6px; border-top: 1px solid var(--line2, #2c323b); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
#assist-panel .as-drop { border: none; background: none; color: inherit; cursor: pointer; opacity: .6; }
#assist-panel .as-un { font-size: 12.5px; opacity: .85; margin-bottom: 8px; }
#assist-panel .as-un div { margin-top: 4px; }
#assist-panel .as-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
#assist-panel .as-chip { font-size: 12px; background: var(--hover, rgba(255,255,255,.07)); border-radius: 12px; padding: 2px 6px 2px 10px; }
#assist-panel .as-chip button { background: none; border: 0; color: inherit; cursor: pointer; opacity: .6; }
#assist-panel .as-ask { display: flex; gap: 6px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line2, #2c323b); }
#assist-panel .as-ask textarea { flex: 1; resize: none; font: inherit; }
#assist-panel .as-gap { margin-top: 6px; }
#assist-panel .as-choices { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
#assist-panel .as-choices .btn { font-size: 12px; padding: 2px 8px; }
#assist-panel .as-more { background: none; border: 0; color: var(--accent, #f07a2a); cursor: pointer; font: inherit; padding: 0 2px; }
#assist-panel .as-rest { display: block; margin-top: 4px; }


/* A choice field drawn as a row of boxes, so a form can match the paper one
   it replaces. Wraps inside its box rather than overflowing it. */
.pl-ticks{display:flex;flex-wrap:wrap;align-items:center;gap:.2em .9em;width:100%}
.pl-tick{display:inline-flex;align-items:center;gap:.3em;white-space:nowrap}
.pl-tick input{width:auto;margin:0;flex:none}
/* RADIO by behaviour - one choice only - but a SQUARE BOX by appearance. The
   paper form ticks boxes, and a round dot reads as a different control, so the
   native circle is replaced rather than the semantics. */
.pl-tick input[type="radio"],.pl-tick input[type="checkbox"]{
  appearance:none;-webkit-appearance:none;
  width:.95em;height:.95em;border:1px solid currentColor;border-radius:0;
  position:relative;background:transparent;cursor:pointer}
/* a ticked box holds a CROSS, corner to corner, as the paper form's does */
.pl-tick input[type="radio"]:checked::after,.pl-tick input[type="checkbox"]:checked::after{
  content:"";position:absolute;inset:0;
  background:
    linear-gradient(to top right, transparent calc(50% - .05em), currentColor calc(50% - .05em) calc(50% + .05em), transparent calc(50% + .05em)),
    linear-gradient(to bottom right, transparent calc(50% - .05em), currentColor calc(50% - .05em) calc(50% + .05em), transparent calc(50% + .05em));
  print-color-adjust:exact;-webkit-print-color-adjust:exact}
.pl-tick input[type="radio"]:focus-visible,.pl-tick input[type="checkbox"]:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.pl-tick input[type="radio"]:disabled,.pl-tick input[type="checkbox"]:disabled{cursor:default;opacity:1}
/* the drop-down with check boxes, on a page: no frame of its own */
.pl-el .mpick{flex:1;min-width:0;height:100%}
.pl-el .mpick-btn,.pl-lines-tbl td .mpick-btn,.pl-block-val .mpick-btn{height:100%;border:0;border-radius:0;background:transparent;
  padding:0 .5mm;color:inherit;text-align:var(--pl-align,left)}

/* TOUCH HAS NO HOVER. A control revealed by :hover costs two taps on a phone —
   the first tap only applies the hover state, the second finally activates it
   ("when i am using mobile i have to hit the items almost twice"). On a coarse
   pointer these are simply always there. Scoped to the pointer rather than the
   screen width, because a small window on a mouse still hovers fine. */
@media (hover: none), (pointer: coarse){
  .row-menu,.th-del,.th-edit{visibility:visible}
}

/* ── rescheduling ── */
.sc-bar{display:flex;gap:.75rem;align-items:flex-end;flex-wrap:wrap;margin-bottom:.5rem}
.sc-bar .field{margin:0;min-width:11rem}
.sc-bar .field label,.sc-row b{display:block;font-size:.78rem;color:var(--muted);font-weight:400;margin-bottom:.1875rem}
.sc-opt{opacity:.7;font-size:.7rem;margin-left:.25rem}
.sc-note{margin:.5rem 0;padding:.5rem .7rem;border:1px solid var(--line2);border-left:3px solid var(--muted);
  border-radius:4px;background:var(--panel);font-size:.8125rem}
.sc-note.bad{border-color:var(--danger);border-left-color:var(--danger);color:var(--danger);
  background:color-mix(in srgb,var(--danger) 8%,transparent)}
.sc-note.good{border-left-color:var(--good)}
.sc-tiles{display:flex;gap:.5rem;flex-wrap:wrap;margin:.75rem 0 .25rem}
.sc-tile{border:1px solid var(--line2);border-radius:6px;background:var(--panel);padding:.45rem .75rem;min-width:6.5rem}
.sc-tile b{display:block;font-size:1.15rem;font-variant-numeric:tabular-nums}
.sc-tile span{font-size:.72rem;color:var(--muted)}
.sc-tile.wide{min-width:11rem}
/* ONE scrollbar: the page scrolls, the table only sideways when it must */
.sc-scroll{overflow-x:auto;border:1px solid var(--line2);border-radius:6px;background:var(--panel)}
.sc-hint{font-size:.78rem;color:var(--muted);max-width:52rem}
.sc-item{max-width:24rem;margin-bottom:.75rem}
.sc-item label{display:block;font-size:.78rem;color:var(--muted);margin-bottom:.1875rem}
.sc-item select{width:100%}
.sc-table{border-collapse:collapse;width:100%;font-size:.8125rem}
.sc-table th{background:var(--panel2);text-align:left;font-weight:600;font-size:.72rem;
  color:var(--muted);padding:.4rem .6rem;border-bottom:1px solid var(--line);white-space:nowrap}
.sc-table td{padding:.35rem .6rem;border-bottom:1px solid var(--line2);vertical-align:top}
.sc-table .num{text-align:right;font-variant-numeric:tabular-nums}
.sc-table .code,.sc-table .date{white-space:nowrap;font-variant-numeric:tabular-nums}
.sc-table .name{max-width:26rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sc-table s{color:var(--muted)}
.sc-table tr.crit td:first-child{box-shadow:inset 3px 0 0 var(--accent)}
.sc-group{font-family:Consolas,ui-monospace,monospace;font-size:.62rem;letter-spacing:.12em;text-transform:uppercase;
  color:var(--muted);margin:1.1rem 0 .35rem;padding-bottom:.2rem;border-bottom:1px solid var(--line2)}
.sc-group .sc-opt{text-transform:none;letter-spacing:0}
.sc-row{display:grid;grid-template-columns:minmax(0,15rem) minmax(0,24rem);gap:.75rem;align-items:center;margin-bottom:.35rem}
.sc-row b{margin:0;color:var(--ink);font-size:.8125rem}
.sc-row span{font-size:.72rem;color:var(--muted)}
.sc-row :is(select,textarea,input[type=date]){width:100%}
.sc-days{display:flex;gap:.6rem;flex-wrap:wrap}
.sc-days label{display:flex;gap:.25rem;align-items:center;font-size:.8125rem}
@media (max-width: 48rem){
  .sc-row{grid-template-columns:minmax(0,1fr);gap:.2rem;margin-bottom:.6rem}
  .sc-bar .field{min-width:0;flex:1 1 9rem}
  .sc-tile{flex:1 1 6rem;min-width:0}
  /* Seven columns do not fit a phone, and scrolling sideways to reach the
     dates hides the one thing the page is for. Each activity becomes a small
     block: what it is, then its dates, each with its own label. */
  .sc-table thead{display:none}
  .sc-table,.sc-table tbody{display:block}
  .sc-table tr{display:flex;flex-wrap:wrap;gap:.1rem .6rem;padding:.5rem .7rem;border-bottom:1px solid var(--line2)}
  .sc-table td{padding:0;border:0}
  .sc-table td:first-child{font-weight:600}
  .sc-table tr.crit{box-shadow:inset 3px 0 0 var(--accent)}
  .sc-table tr.crit td:first-child{box-shadow:none}
  .sc-table .name{flex:1 1 60%;max-width:none;white-space:normal}
  .sc-table .st-open{display:none}
  .sc-table td[data-l]{flex:1 1 100%;text-align:left}
  .sc-table td[data-l]:empty{display:none}
  .sc-table td[data-l]::before{content:attr(data-l);display:inline-block;min-width:4.6rem;color:var(--muted);font-size:.72rem}
  .sc-table td[data-l="Float"],.sc-table td[data-l="Driven by"]{flex:0 1 auto}
  .sc-table td[data-l="Float"]::before,.sc-table td[data-l="Driven by"]::before{min-width:0;margin-right:.35rem}
}

/* ── a title's subtitle, and a count beside a label ─────────────────────── */
.t-sub{display:block;margin-top:.125rem;font-size:.6875rem;font-weight:400;letter-spacing:0;text-transform:none;color:var(--muted)}
.count-pill{display:inline-block;min-width:1.25rem;padding:0 .4rem;border-radius:999px;background:var(--panel2);
  border:1px solid var(--line2);color:var(--muted);font-size:.6875rem;text-align:center}

/* ── help mark: the explanation of a control, on hover or focus ─────────── */
.help{position:relative;display:inline-grid;place-items:center;width:1rem;height:1rem;border-radius:50%;
  border:1px solid currentColor;color:var(--muted);font:700 .625rem/1 system-ui,sans-serif;cursor:help;
  letter-spacing:0;text-transform:none;vertical-align:middle;flex:none}
.help:hover,.help:focus{color:var(--accent);outline:none}
#help-tip{position:fixed;z-index:1000;width:max-content;max-width:min(18rem,calc(100vw - 1rem));background:var(--ink);
  color:var(--panel);border-radius:5px;padding:.5rem .65rem;font:400 .75rem/1.45 system-ui,sans-serif;text-align:left;
  pointer-events:none;box-shadow:0 4px 14px rgba(0,0,0,.3)}
#help-tip[hidden]{display:none}
.sc-row>div:first-child,.sc-group{display:flex;align-items:center;gap:.375rem}

/* ── rules ───────────────────────────────────────────────────────────────── */
.rl-form{max-width:60rem}
.rl-form .field{margin:0 0 .75rem}
.rl-form .field>label{display:flex;gap:.375rem;align-items:center}
.rl-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 1rem}
.rl-grid.three{grid-template-columns:repeat(3,1fr)}
.rl-grid[hidden],.rl-check[hidden],.rl-line [hidden]{display:none}
.rl-check{display:flex;gap:.5rem;align-items:center;margin:0 0 .75rem;font-size:.8125rem}
.rl-check input,.rl-days input{width:auto}
.rl-days{display:flex;flex-wrap:wrap;gap:.25rem .75rem;font-size:.8125rem}
.rl-days label{display:flex;gap:.3rem;align-items:center}
.rl-h{margin:1.25rem 0 .5rem;padding-top:.75rem;border-top:1px solid var(--line2);font-size:.8125rem;
  text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
.rl-narrow{width:auto;min-width:14rem}
.rl-block{border:1px solid var(--line2);border-radius:6px;padding:.625rem .75rem;margin:.5rem 0;background:var(--panel2)}
.rl-line{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}
.draft-row{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin-top:.25rem}
.draft-row .mono-label{white-space:normal}
.rl-line>select,.rl-line>input,.rl-line .rl-set-val>*{flex:1 1 9rem;min-width:0}
.rl-line .rl-set-val{display:flex;gap:.5rem;flex:2 1 14rem;flex-wrap:wrap}
.rl-line .rl-rm{flex:none}
.rl-c-body,.rl-a-body{margin-top:.5rem}
.rl-bar{display:flex;gap:.5rem;margin:1.25rem 0 .75rem}
.rl-bad{color:var(--danger)}
.rl-pv ul{margin:.5rem 0 0;padding-left:1.1rem}
.rl-figs{display:flex;gap:1.5rem;margin:.375rem 0}
.rl-chips{display:flex;flex-wrap:wrap;gap:.3rem;margin:.375rem 0}
.rl-chips span{border:1px solid var(--line);border-radius:999px;padding:.05rem .55rem;font-size:.75rem;background:var(--panel)}
.rl-chips .more{border-style:dashed;color:var(--muted)}
.rl-logt{width:100%;border-collapse:collapse;font-size:.8125rem}
.rl-logt th{text-align:left;color:var(--muted);font-weight:600;border-bottom:1px solid var(--line);padding:.3rem .5rem}
.rl-logt td{border-bottom:1px solid var(--line2);padding:.3rem .5rem;vertical-align:top}
.rl-logt td:first-child{white-space:nowrap;color:var(--muted)}
.rl-logt tr.rl-error td:nth-child(2),.rl-logt tr.rl-not-set td:nth-child(2){color:var(--danger)}
.rl-logt tr.rl-not-notified td:nth-child(2){color:var(--muted)}
@media (max-width:760px){
  .rl-grid,.rl-grid.three{grid-template-columns:1fr}
}

/* ── page layout: line items over several sheets, photos, columns ───────── */
.pl-lineprops{display:inline-flex;gap:.4rem;align-items:center;flex-wrap:wrap;min-width:0}
.pl-lineprops[hidden],.pl-lineprops [hidden]{display:none}
.pl-note{margin:0 0 .5rem;padding:.4rem .7rem;border:1px solid var(--danger);border-left-width:3px;border-radius:4px;
  color:var(--danger);font-size:.8125rem}
.pl-photos{display:grid;gap:2mm;width:100%;height:100%}
.pl-photo{margin:0;display:flex;flex-direction:column;min-width:0;min-height:0;border:.15mm solid rgba(0,0,0,.3)}
.pl-photo img,.pl-photo-none{flex:1;min-height:0;width:100%;object-fit:contain}
.pl-photo-none{background:repeating-linear-gradient(45deg,rgba(0,0,0,.04) 0 2mm,transparent 2mm 4mm)}
.pl-photo figcaption{flex:none;padding:.6mm 1mm;border-top:.15mm solid rgba(0,0,0,.2);overflow:hidden;
  white-space:nowrap;text-overflow:ellipsis}
.pl-cap-line{display:block;overflow:hidden;text-overflow:ellipsis}
.pl-blocks,.pl-tabs{display:grid;gap:2mm;width:100%;height:100%}
.pl-tab{position:relative;min-width:0;min-height:0}
.pl-block{position:relative;min-width:0;min-height:0;overflow:hidden;display:grid;border:var(--pl-line,.25mm) solid #222}
.pl-block-line{display:flex;align-items:center;gap:1.5mm;min-width:0;min-height:0;overflow:hidden;padding:.4mm 1mm;
  border-bottom:var(--pl-line,.25mm) solid #222}
.pl-block-line:last-of-type{border-bottom:0}
.pl-block-line .pl-lab{flex:0 0 28%;overflow:hidden;text-overflow:ellipsis;text-align:left}
.pl-block-val{flex:1;min-width:0;max-height:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pl-lines.pl-wrap .pl-block-val{white-space:normal}
.pl-block-line[data-kind=file]{padding:0}
.pl-block-line[data-kind=file] .pl-block-val{height:100%;display:flex;align-items:center;justify-content:center}
.pl-block-val .pl-pic{width:100%;height:100%;object-fit:contain;display:block}
.pl-lines-tbl td .pl-pic{max-width:100%;max-height:var(--pl-row,12mm);object-fit:contain;display:block;margin:0 auto}
.pl-block-val .pl-line-in{width:100%;border:0;background:transparent;font:inherit;color:inherit;padding:0}
.pl-block-val .pl-line-in:focus{outline:1px solid var(--accent)}
.pl-cell-name{color:#8a8a8a;font-weight:400}
/* a file kept as a document: the one in force, its versions, the viewer */
#panel-zip a,.doc-view-bar a{text-decoration:none}
.doc-cur{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.doc-open{background:none;border:0;padding:0;color:var(--accent);cursor:pointer;font:inherit;text-align:left}
.doc-open:hover{text-decoration:underline}
/* a reference shown by name on a line or a page keeps to one line */
.line-doc-open{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom}
.doc-cur .btn,.doc-box > .btn{padding:.2rem .6rem;font-size:.8125rem}
.doc-older{margin-top:.4rem;font-size:.875rem}
.doc-older summary{cursor:pointer;color:var(--muted)}
.doc-row{display:flex;gap:.5rem;align-items:center;padding:.15rem 0 .15rem .9rem}
.doc-zip-list{margin:.4rem 0;padding:.4rem .6rem;border:1px solid var(--line);border-radius:6px;max-height:12rem;overflow:auto;
  font-size:.8125rem;font-family:var(--mono, ui-monospace, monospace)}
#doc-pick{position:fixed;inset:0;z-index:4100;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center}
.doc-pick-box{width:min(94vw,40rem);max-height:80dvh;background:var(--panel);border:1px solid var(--line);border-radius:10px;display:flex;flex-direction:column;overflow:hidden}
.doc-pick-box input[type=search]{margin:.6rem .8rem}
.doc-pick-list{overflow-y:auto;padding:0 .8rem .8rem;display:flex;flex-direction:column;gap:.15rem}
.doc-pick-list .mono-label{margin-top:.6rem}
.doc-pick-row{display:flex;gap:.5rem;align-items:center;justify-content:space-between;text-align:left;border:none;background:none;color:inherit;font:inherit;padding:.35rem .5rem;border-radius:6px;cursor:pointer}
.doc-pick-row:hover{background:color-mix(in srgb,var(--accent) 14%,transparent)}
.page-box{display:flex;gap:.4rem;align-items:center}
.page-box input{flex:1;min-width:0}
.page-link{border:none;background:none;color:var(--accent);font:inherit;cursor:pointer;padding:0;text-decoration:underline}
#doc-view{position:fixed;inset:0;z-index:4000;background:var(--ground);display:flex;flex-direction:column}
.doc-view-bar{display:flex;align-items:center;gap:.5rem;padding:.6rem 1rem;border-bottom:1px solid var(--line)}
.doc-view-body{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}
.doc-view-body iframe{width:100%;height:100%;border:0;background:#fff}
.doc-view-body.pages{display:block;padding:1rem;text-align:center}
.doc-page{display:block;margin:0 auto 1rem;background:#fff;box-shadow:0 2px 14px rgba(0,0,0,.35);max-width:none}
.doc-view-body img{max-width:100%;max-height:100%;object-fit:contain}
/* the Markup tool: a layer over the page or picture, the tools in a second bar */
.mk-tools{flex-wrap:wrap;padding:.4rem 1rem}
.mk-tools .btn{padding:.2rem .6rem;font-size:.8125rem}
.mk-tools .mk-tool.on{background:var(--accent);color:#fff;border-color:var(--accent)}
.mk-colours{display:inline-flex;gap:.3rem;margin:0 .3rem}
.mk-page{display:inline-flex;align-items:center;gap:.3rem;font-size:.75rem;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.mk-page input{width:4rem;padding:.15rem .3rem;font-size:.8125rem}
.mk-colour{width:1.25rem;height:1.25rem;border-radius:50%;border:2px solid transparent;cursor:pointer;padding:0}
.mk-colour.on{border-color:var(--fg);box-shadow:0 0 0 2px var(--panel)}
.mk-here{display:flex;flex-wrap:wrap;gap:.4rem;align-items:center;padding:.4rem 1rem;border-bottom:1px solid var(--line)}
.mk-chip{border:2px solid var(--accent);border-radius:1rem;background:transparent;color:var(--fg);font:inherit;font-size:.8125rem;padding:.1rem .6rem;cursor:pointer}
.mk-chip:hover{background:var(--chip)}
.mk-wrap{position:relative;display:inline-block;margin:0 auto 1rem;line-height:0}
.mk-wrap .doc-page{margin:0}
.doc-view-body.pages .mk-wrap{display:block;width:max-content;max-width:100%}
.mk-layer{position:absolute;left:0;top:0;pointer-events:none}
.mk-layer.mk-live{pointer-events:auto;cursor:crosshair;touch-action:none}
.mk-text{position:absolute;z-index:2;font:bold .95rem system-ui,sans-serif;background:rgba(255,255,255,.92);border:1px solid var(--accent);border-radius:4px;padding:.1rem .3rem;min-width:8rem}
#mk-add{position:absolute;inset:0;z-index:5;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.35)}
.mk-add-box{display:flex;flex-direction:column;gap:.6rem;width:min(92vw,24rem);background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:1rem}
.mk-add-box label{display:flex;flex-direction:column;gap:.2rem;font-size:.8125rem}
.mk-add-btns{display:flex;gap:.5rem;justify-content:flex-end}
/* a Markup field in the record panel */
.mk-box{display:flex;flex-direction:column;gap:.3rem}
.mk-box > .btn{align-self:flex-start;padding:.2rem .6rem;font-size:.8125rem}
.mk-cur{display:flex;gap:.6rem;align-items:flex-start}
.mk-thumb{max-width:14rem;max-height:9rem;border:1px solid var(--line);border-radius:4px;background:#fff}
.mk-cur-txt{display:flex;flex-direction:column;gap:.3rem}
.mk-cur-txt .btn{padding:.2rem .6rem;font-size:.8125rem}
.doc-none{color:var(--muted)}
/* a value another record already holds, in a field marked unique */
.uniq-dup{outline:1px solid var(--danger) !important;outline-offset:-1px}
.uniq-note{display:block;color:var(--danger);font-size:.8125rem;margin-top:.2rem}
/* a picture read on a page opens when clicked; the link takes no room of its own */
.pl-pic-a{display:contents;cursor:zoom-in}
.pl-pic-a .pl-pic{cursor:zoom-in}
/* a page that can be added: said over it while designing, offered while filling in */
.pl-can-add{color:var(--accent)}
.pl-pagehead .pl-sheet-add,.pl-pagehead .pl-sheet-del{padding:.15rem .6rem;font-size:.8125rem}
/* a picture on a page: the box is the button */
.pl-up{position:relative;display:flex;align-items:center;justify-content:center;flex:1;min-width:0;min-height:0;
  width:100%;height:100%;cursor:pointer;overflow:hidden}
.pl-up .pl-file-add{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
.pl-up-face{display:flex;align-items:center;justify-content:center;min-width:0;min-height:0;width:100%;height:100%}
.pl-up-face .pl-pic{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;margin:0}
.pl-lines-tbl td .pl-up{height:var(--pl-row,12mm)}
.pl-up-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pl-up:hover,.pl-up:focus-within{outline:1px solid var(--accent);outline-offset:-1px}
.pl-up-x{display:none;position:absolute;top:.4mm;right:.4mm;z-index:2;width:4mm;height:4mm;padding:0;border:0;border-radius:50%;
  background:#111;color:#fff;font-size:3mm;line-height:4mm;cursor:pointer}
.pl-up-has:hover .pl-up-x,.pl-up-has:focus-within .pl-up-x{display:block}
.pl-up-busy{opacity:.5;pointer-events:none}
@media print{ .pl-up-x{display:none !important} .pl-up{outline:0 !important} }
/* the handle a field is dragged by, to change the order of the fields */
.pl-lines-tbl th,.pl-lines-tbl td,.pl-block-line{position:relative}
.pl-fdrag{display:none;position:absolute;left:.4mm;top:.4mm;z-index:5;font-size:2.8mm;line-height:1;font-weight:400;
  padding:.2mm .6mm;border-radius:.5mm;color:#fff;background:#d95510;cursor:grab}
.pl-lines.sel .pl-fdrag,.pl-lines:hover .pl-fdrag{display:block}
.pl-fmove{opacity:.45}
.pl-fdrop{box-shadow:inset 0 0 0 .6mm #d95510}
/* the line between two fields, dragged to resize them */
.pl-div{position:absolute;z-index:4}
.pl-div-h{left:0;right:0;height:2.4mm;margin-top:-1.2mm;cursor:row-resize}
.pl-div-v{top:0;bottom:0;width:2.4mm;margin-left:-1.2mm;cursor:col-resize}
.pl-div:hover,.pl-div.on{background:rgba(217,85,16,.5)}
.pl-blocks.pl-rules-rows .pl-block{border-left:0;border-right:0}
.pl-blocks.pl-rules-none .pl-block,.pl-blocks.pl-rules-none .pl-block-line{border:0}
.lc-title{display:flex;align-items:center;gap:.375rem}
.li-form{display:flex;flex-direction:column;gap:.6rem;padding:0 1rem 1rem}
.li-row{display:flex;align-items:center;justify-content:space-between;gap:.75rem}
.li-row label{margin:0;display:flex;align-items:center;gap:.375rem}
.li-row input,.li-row select{width:13rem;flex:none}
.li-grid{display:flex;align-items:center;gap:.5rem;width:13rem;flex:none}
.li-grid input{width:auto;flex:1;min-width:0}
.lc-list{display:flex;flex-direction:column;gap:.3rem;max-height:50vh;overflow:auto;margin:.5rem 0}
.lc-row{display:flex;gap:.5rem;align-items:center}
.lc-row label{flex:1;display:flex;gap:.4rem;align-items:center;margin:0}
.lc-row input[type=checkbox]{width:auto}
.lc-row .lc-w{width:4.5rem}
@media print{ body.printing-layout .pl-note{display:none !important} }

/* ── permissions: which records a role sees ─────────────────────────────── */
.rg-records{white-space:nowrap}
.rg-records select{padding:.15rem .4rem;font-size:.8125rem}
.rg-records .mono-label{margin-left:.375rem}
.rg-records .rl-bad{margin-left:.375rem;font-size:.8125rem}

/* the pages of a PDF become records: the page, the areas marked on it, the rows read */
.pg-tools{display:flex;align-items:center;gap:.5rem;margin:.5rem 0;flex-wrap:wrap}
.pg-wrap{position:relative;display:inline-block;max-width:100%;line-height:0;border:1px solid var(--line);background:#fff;user-select:none}
.pg-wrap.marking{cursor:crosshair}
.pg-wrap canvas{display:block;max-width:100%}
#pg-areas{position:absolute;inset:0;pointer-events:none}
.pg-area{position:absolute;border:2px solid var(--accent,#3b82f6);background:rgba(59,130,246,.12);box-sizing:border-box;pointer-events:none}
.pg-area span{position:absolute;left:-2px;top:-1.4rem;line-height:1.1rem;font-size:.7rem;background:var(--accent,#3b82f6);color:#fff;padding:0 .35rem;border-radius:3px 3px 0 0;white-space:nowrap;pointer-events:auto}
.pg-area span button{all:unset;cursor:pointer;margin-left:.35rem;font-weight:700}
.pg-area.ghost{border-style:dashed;background:rgba(59,130,246,.06)}
.pg-table td input[type=text]{width:100%;min-width:6rem;box-sizing:border-box;padding:.15rem .3rem;font:inherit}
.pg-table tr.off td{opacity:.45}
.pg-table td:last-child{display:table-cell}

/* two pages compared: red over blue */
.cmp-name{display:inline-flex;align-items:center;gap:.3rem;padding:.1rem .5rem;border-radius:6px;border:1px solid var(--line)}
.cmp-name.red{border-color:#e53935}.cmp-name.blue{border-color:#1e88e5}
.cmp-name input{width:3.8rem}
.cmp-body #cmp-canvas{cursor:grab;outline:none}
.cmp-hint{margin:.25rem 0 0}

/* a folder is chosen from a tree, opened by a button that says where */
.folder-pick-wrap{display:block}
.folder-pick{display:inline-flex;align-items:center;gap:.4rem;max-width:100%;text-align:left}
.folder-pick-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#folder-pick{position:fixed;inset:0;z-index:4200;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center}
#folder-pick .doc-pick-box{width:min(94vw,34rem);height:min(80dvh,36rem)}
.folder-pick-list{flex:1;gap:0}
.folder-row{display:flex;align-items:center;gap:.25rem;padding:.28rem .4rem;border-radius:6px;cursor:pointer;user-select:none}
.folder-row:hover{background:color-mix(in srgb,var(--accent) 12%,transparent)}
.folder-row.sel{background:color-mix(in srgb,var(--accent) 26%,transparent)}
.folder-tw{all:unset;width:1.1rem;text-align:center;cursor:pointer;opacity:.75}
.folder-tw:disabled{cursor:default}
.folder-pick-foot{border-top:1px solid var(--line);border-bottom:none}
#folder-pick input[type=search]{width:auto;align-self:stretch;box-sizing:border-box}
#folder-pick-at{font-size:.8rem;opacity:.8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pg-table td input.need{outline:2px solid var(--warn,#e0a030);outline-offset:-2px}
.pg-need-note{margin-top:.35rem;color:var(--warn,#e0a030);font-size:.85rem}
.folder-row.adding{flex-wrap:wrap;cursor:default;background:color-mix(in srgb,var(--accent) 8%,transparent)}
.folder-row.adding input{flex:1;min-width:8rem;padding:.2rem .4rem;font:inherit}
.folder-row.adding .btn{padding:.2rem .6rem}
.folder-pick-err{flex-basis:100%;margin:.2rem 0 0 2.6rem;color:var(--warn,#e0a030);font-size:.82rem}

/* no connection: one line at the foot for as long as it lasts */
#offline-bar{position:fixed;left:50%;bottom:.75rem;transform:translateX(-50%);z-index:5000;max-width:calc(100vw - 1.5rem);
  padding:.45rem .9rem;border-radius:999px;background:var(--panel);border:1px solid var(--warn,#e0a030);color:var(--ink);
  font-size:.85rem;box-shadow:0 4px 18px rgba(0,0,0,.35);text-align:center}

/* the Documents page's search: a box in the title row, results by document */
#docs-q{width:min(22rem,100%);padding:.3rem .6rem;font:inherit}
.ds-doc{padding:.6rem 0;border-bottom:1px solid var(--line2)}
.ds-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:.25rem .75rem}
.ds-open{font-weight:600;color:var(--ink);text-decoration:none}
.ds-open:hover{color:var(--accent)}
.ds-folder{text-decoration:none;color:var(--muted);font-size:.8rem}
.ds-folder:hover{color:var(--accent)}
.ds-hits{display:flex;flex-direction:column;gap:.1rem;margin-top:.25rem}
.ds-hit{display:flex;gap:.6rem;align-items:baseline;padding:.2rem .4rem;border-radius:6px;color:inherit;text-decoration:none;font-size:.9rem}
.ds-hit:hover{background:color-mix(in srgb,var(--accent) 12%,transparent)}
.ds-page{flex:0 0 4.2rem;color:var(--muted);font-size:.8rem;white-space:nowrap}
.ds-snip mark{background:color-mix(in srgb,var(--accent) 35%,transparent);color:inherit;border-radius:3px;padding:0 .1rem}
.ds-all{display:inline-block;margin:.2rem 0 0 .4rem;font-size:.85rem;color:var(--accent)}
.ds-notes{margin-top:.75rem;color:var(--muted);font-size:.82rem}
#docs-actions[hidden]{display:none}

/* scatter, histogram, gauge */
.ch-svg .ch-axis{font-size:12px;font-weight:600}
.ch-svg .ch-median{stroke:var(--ink);stroke-width:1.4;stroke-dasharray:5 4;opacity:.75}
.ch-svg .ch-gauge-track{fill:none;stroke:var(--line2)}
.ch-svg .ch-gauge-target{stroke:var(--ink);stroke-width:3}
.ch-svg .ch-gauge-val{fill:var(--ink);font-size:46px;font-weight:700}
