/* Center every app dialog; the body scrolls while actions remain visible. */
#overlay-root .overlay, #overlay-root .overlay.center { align-items: center; justify-content: center; padding: 24px; animation-name: workspace-fade; }
#overlay-root .overlay.redraw { animation: none; }
#overlay-root .drawer, #overlay-root .modal { width: min(860px,100%); height: auto; max-height: calc(100dvh - 48px); border: 1px solid var(--line); border-radius: 0; overflow: hidden; }
#overlay-root .search-modal { width: min(680px,100%); }
#overlay-root .drawer-header, #overlay-root .drawer-footer { flex-shrink: 0; }
#overlay-root .drawer-body { min-height: 0; overscroll-behavior: contain; }
#overlay-root .drawer-footer { flex-wrap: wrap; }
.collection-view { min-width: 0; width: 100%; }
.record-window { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; font-size: 12px; color: var(--sub); }
.record-window > span { flex: 1 1 250px; }
.collection-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.collection-search { flex: 1 1 190px; min-width: 0; }
.collection-search .field { width: 100%; min-height: 36px; }
.collection-options { display: flex; flex: 2 1 auto; flex-wrap: wrap; gap: 8px; align-items: end; }
.collection-field { display: flex; flex: 1 1 110px; flex-direction: column; gap: 5px; min-width: 0; max-width: 230px; font-size: 11px; color: var(--muted); }
.collection-field .select { width: 100%; min-width: 0; height: 36px; padding: 4px 8px; line-height: 1.5; }
.collection-options .button { height: 36px; }
.collection-display-panel { flex-basis: 100%; min-width: 0; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.collection-density { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12px; color: var(--sub); }
.collection-density .select { min-width: 150px; padding: 4px 8px; height: 36px; line-height: 1.5; }
.collection-columns { border: 0; padding: 0; min-width: 0; margin: 16px 0; }
.collection-columns legend { padding: 0; margin-bottom: 10px; font-size: 12px; font-weight: 600; }
.collection-column-choices { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 8px 16px; }
.collection-column-option { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
.collection-column-option input { width: 16px; height: 16px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.collection-display-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.collection-display-foot p { flex: 1 1 240px; font-size: 12px; color: var(--muted); }
.collection-view[data-density=compact] table > tbody > tr > td { padding-block: 8px; }
.collection-view[data-density=compact] table > thead > tr > th { padding-block: 8px; }
.collection-filter-chips { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.collection-filter-chip { max-width: 100%; padding: 7px 10px; border: 1px solid var(--line); background: var(--accent-bg); color: var(--text); border-radius: 0; font: inherit; font-size: 12px; cursor: pointer; overflow-wrap: anywhere; text-align: start; }
.collection-scroll-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--sub); }
.collection-scroll-controls[hidden] { display: none; }
.collection-scroll-controls > span { flex: 1 1 220px; }
.collection-scroll-buttons { display: flex; gap: 8px; }
.collection-view .table-wrap { overscroll-behavior-x: contain; }
.collection-view .table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.collection-scroll-controls button:focus-visible, .collection-filter-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.collection-pagination { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--sub); }
.collection-pages { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.collection-size { display: flex; gap: 8px; align-items: center; }
.collection-size select { min-width: 65px; }
.collection-page { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; }
.collection-page input { width: 64px; min-width: 0; padding: 8px; }
.collection-count, .collection-filter-chip { unicode-bidi: plaintext; }
.collection-sort { background: none; border: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; text-align: inherit; padding: 0; cursor: pointer; }
th[aria-sort=ascending] .collection-sort::after { content: ' ↑'; color: var(--accent); }
th[aria-sort=descending] .collection-sort::after { content: ' ↓'; color: var(--accent); }
.collection-empty { padding: 24px 20px; color: var(--muted); }
.collection-view [hidden] { display: none !important; }
.collection-view > .timeline, .collection-view > .model-grid, .collection-view > .intel-catalogue { margin-top: 16px; }
.collection-view .collection-toolbar button:focus-visible, .collection-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media(max-width:720px){
 #overlay-root .overlay, #overlay-root .overlay.center { padding: 10px; }
 #overlay-root .drawer, #overlay-root .modal { max-height: calc(100dvh - 20px); }
 .collection-toolbar,.collection-pagination,.collection-scroll-controls { padding: 12px; }
 .collection-search { flex-basis: 100%; }
 .collection-field { max-width: none; }
 .collection-pagination { align-items: start; }
 .collection-pages { gap: 8px; }
 .collection-scroll-controls > span { flex-basis: 100%; }
}

/* Separate datasets share a page, but only the selected table occupies space. */
[data-record-tabs] { min-width: 0; }
[data-record-panel][hidden] { display: none !important; }
[data-record-tabs] > [data-record-panel].section-gap,
[data-record-panel] > .section-gap:first-child { margin-top: 0; }
.record-tabs { max-width: 100%; overscroll-behavior-x: contain; }
.record-tabs button { flex-shrink: 0; }
.record-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Long labels, identifiers and notes must not dictate the width of the register. */
.table-wrap { min-width: 0; max-width: 100%; }
.table-wrap > table { white-space: normal; }
.table-wrap > table > tbody > tr > td { overflow-wrap: anywhere; }
/* Cells that hold one figure, date or name keep it on one line; long
   explanations wrap but keep a readable column. */
.table-wrap td.cell-num { white-space: nowrap; overflow-wrap: normal; text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap th.cell-num { text-align: right; }
.table-wrap td.cell-date, .table-wrap td.cell-key { white-space: nowrap; overflow-wrap: normal; }
.table-wrap td.cell-key > details, .table-wrap td.cell-key > .note { white-space: normal; }
.table-wrap td.cell-text { min-width: 16rem; }
.table-wrap td > select.field { min-width: 7.5rem; }
/* While a panel is open, a toast sits under the top bar instead of over the
   panel's footer buttons. */
#overlay-root:has([role="dialog"]) + .toast { bottom: auto; top: 12px; transform: translate(-50%, -20px); }
#overlay-root:has([role="dialog"]) + .toast.visible { transform: translate(-50%, 0); }
@media (max-width: 720px) {
  /* The phone panel reaches the top of the screen, so the toast sits above
     the footer's two rows of buttons instead. */
  #overlay-root:has([role="dialog"]) + .toast { top: auto; bottom: 132px; }
}
/* A row of checkboxes: each box stays with its own label. */
.choice-list { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 12px; }
.choice-list label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; margin: 0; }
/* On a phone a panel's table scrolls sideways inside its wrap rather than
   squeezing every word down to letters. */
@media (max-width: 720px) {
  #overlay-root .table-wrap > table { min-width: 36rem; }
}
.table-wrap .table-person > div { min-width: 0; }
.table-wrap .person-name, .table-wrap .person-meta { white-space: normal; overflow-wrap: anywhere; }
.collection-view .collection-status-column { width: 1%; white-space: nowrap; }
.collection-status-column .person-meta { max-inline-size: 12rem; }
.collection-view .collection-actions-column { width: 1%; white-space: nowrap; overflow-wrap: normal; }
.collection-actions-column .button { white-space: nowrap; }
