
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.error { color: var(--error); }
.warn { color: var(--warn); }
.pad { padding: 8px 2px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }

/* controls */
.btn {
  background: var(--raise); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 11px; cursor: pointer;
}
.btn:hover { background: #30302d; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, white); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.icon-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 6px;
  width: 30px; height: 30px; display: grid; place-items: center; font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: var(--raise); color: var(--text); }
.icon-btn.sm { width: 22px; height: 22px; font-size: 15px; }
input[type=text], input[type=search], input[type=number], input[type=date], select {
  width: 100%; background: var(--page); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); margin: 0; }

/* header */
body > header {
  height: var(--header); display: flex; align-items: center; gap: 16px; padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.tabs { display: flex; gap: 2px; background: var(--page); padding: 3px; border-radius: 8px; }
.tabs button { background: none; border: 0; padding: 5px 16px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--raise); color: var(--text); }
.count { flex: 1; color: var(--text-2); font-variant-numeric: tabular-nums; }

#layout { display: grid; grid-template-columns: var(--sidebar) 1fr; height: calc(100vh - var(--header)); }
main { position: relative; min-width: 0; }

/* sidebar / filters */
#sidebar { border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
/* folded: a strip to open it again, with the count of filters that apply */
#layout.side-closed { grid-template-columns: 36px 1fr; }
#layout.side-closed #sidebar { display: flex; overflow: hidden; }
#layout.side-closed #sidebar > :not(.side-strip), #layout:not(.side-closed) .side-strip { display: none; }
.side-strip .pill:empty { display: none; }
#sidebar-collapse { margin: -2px -6px -2px -4px; font-size: 18px; color: var(--muted); }
.sidebar-head {
  position: sticky; top: 0; z-index: 2; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.head-row { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.find-row { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.find-row .icon-btn { flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; max-height: 78px; overflow-y: auto; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; max-width: 100%; background: var(--accent-wash); border-radius: 5px; font-size: 11.5px; }
.chip button { background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 2px 0 2px 7px; }
.chip .chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-label b { color: var(--accent); font-weight: 600; }
.chip .chip-x { padding: 2px 6px 2px 5px; color: var(--muted); }
.chip .chip-x:hover { color: var(--text); }
.chip.off { background: none; outline: 1px dashed var(--line); outline-offset: -1px; opacity: .6; }
.chip.off .chip-label { cursor: help; }
.head-actions { display: flex; gap: 12px; font-weight: 400; font-size: 12px; white-space: nowrap; }
/* the Recent menu: filter sets used before, or starred to keep (js/filterhistory.js). It hangs below the sidebar's
   head row, across the sidebar, since the sidebar scrolls and can't let it stick out */
.dropdown.fh-menu { top: 36px; left: 8px; right: 8px; width: auto; white-space: normal; font-size: 12px; font-weight: 400; }
#filter-history-btn { margin: -2px 0; color: var(--muted); }
#filter-history-btn:hover, #filter-history-btn[aria-expanded="true"] { color: var(--text); }
.fh-apply:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.fh-item { position: relative; display: flex; align-items: flex-start; border-radius: 5px; }
.fh-item:hover, .fh-item:focus-within { background: var(--raise); }
.fh-item.on { box-shadow: inset 2px 0 0 var(--accent); }
.fh-apply {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; text-align: left;
  background: none; border: 0; border-radius: 5px; color: var(--text); cursor: pointer;
}
.fh-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fh-text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text-2); }
.fh-text b { color: var(--accent); font-weight: 600; }
.fh-text .fh-off { opacity: .5; }
.fh-meta { color: var(--muted); font-size: 11px; }
.fh-acts { position: absolute; right: 4px; bottom: 3px; display: none; gap: 1px; padding-left: 6px; background: var(--raise); }
.fh-item:hover .fh-acts, .fh-item:focus-within .fh-acts { display: flex; }
.fh-act { color: var(--muted); }
.fh-act.on { color: var(--accent); }
.fh-name-input { flex: 1; min-width: 0; margin: 4px 6px; }
.fh-empty { padding: 4px 8px 8px; }
.fh-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; padding: 6px 8px 2px; border-top: 1px solid var(--border); }
.scope-title { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill { background: var(--accent-wash); color: var(--accent); border-radius: 9px; padding: 0 7px; font-size: 11px; line-height: 18px; font-weight: 600; }
.pill:empty { display: none; }
/* data categories (above the filters, shared by both tabs) */
.categories-box { padding: 10px 14px 10px; border-bottom: 1px solid var(--border); }
.categories-head {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 4px; padding: 0;
  background: none; border: 0; color: inherit; font: inherit; font-weight: 600; cursor: pointer;
}
.categories-head::before {
  content: ''; width: 5px; height: 5px; flex: none; align-self: center; border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform .12s;
}
.categories-name { flex: 1; text-align: left; }
.categories-box.closed .categories-head { margin-bottom: 0; }
.categories-box.closed .categories-head::before { transform: rotate(-45deg); }
.categories-box.closed #categories { display: none; }
.cat-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; color: var(--text-2); }
.cat-row.on { color: var(--text); }
.cat-row input:disabled { cursor: not-allowed; }
.cat-name { flex: 1; }
.cat-n { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.cat-status { margin: 0 0 2px 21px; font-size: 11.5px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.cat-status .coverage { color: var(--warn); cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
.progress .indeterminate { width: 30% !important; animation: slide 1.1s ease-in-out infinite alternate; }
@keyframes slide { from { margin-left: 0; } to { margin-left: 70%; } }

/* filter groups: one per category (Pinned first), with section subheadings */
.fgroup-head {
  position: sticky; top: var(--fhead, 0px); z-index: 1; width: 100%; display: flex; align-items: center; gap: 6px;
  padding: 7px 10px 7px 14px; background: var(--surface); border: 0; border-bottom: 1px solid var(--border); cursor: pointer;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
}
.fgroup-head::before {
  content: ''; width: 5px; height: 5px; flex: none; margin-right: 2px; border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform .12s;
}
.fgroup.closed .fgroup-head::before { transform: rotate(-45deg); }
.fgroup-head:hover { color: var(--text); background: var(--surface-2); }
.fgroup-name { flex: 1; text-align: left; }
.fgroup-n { color: var(--muted); font-weight: 400; letter-spacing: 0; font-variant-numeric: tabular-nums; }
#filter-list:not(.finding) .fgroup.closed .fsection { display: none; }
.fsection-name { padding: 9px 14px 3px; color: var(--muted); font-size: 11.5px; border-bottom: 1px solid var(--border); }

.filter { border-bottom: 1px solid var(--border); scroll-margin-top: calc(var(--fhead, 0px) + 32px); }
.filter summary {
  list-style: none; display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 14px; cursor: pointer;
  user-select: none;
}
.filter.flash > summary { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-wash); } }
.filter summary::-webkit-details-marker { display: none; }
.filter summary::before {
  content: ''; width: 5px; height: 5px; flex: none; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .12s;
}
.filter[open] summary::before { transform: rotate(45deg); }
.filter summary:hover { background: var(--surface-2); }
.filter .name { flex: none; color: var(--text-2); }
.filter.active .name { color: var(--text); font-weight: 600; }
.filter .badge {
  flex: 1; min-width: 0; text-align: right; color: var(--accent); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filter .hint { flex: none; color: var(--muted); font-size: 11.5px; }
.filter .clear, .filter .pin { visibility: hidden; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 15px; }
.filter .pin { display: grid; place-items: center; }
.filter .pin.on svg { fill: currentColor; }
.filter.active .clear, .filter summary:hover .pin, .filter[open] .pin { visibility: visible; }
.filter .clear:hover, .filter .pin:hover { color: var(--text); }
.filter-body { padding: 2px 14px 12px; display: flex; flex-direction: column; gap: 7px; }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
/* yes/no filters (js/flags.js): a name and an Any / Yes / No switch per row */
.yn-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 14px; border-bottom: 1px solid var(--border); }
.yn-row .name { flex: 1; min-width: 0; color: var(--text-2); }
.yn-row.active .name { color: var(--text); font-weight: 600; }
.yn-row.active .seg.on { color: var(--accent); }

.opt-list { max-height: 260px; overflow-y: auto; margin: 0 -6px; }
.opt {
  display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 4px; cursor: pointer;
}
.opt:hover { background: var(--surface-2); }
.opt .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .n { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; background: var(--page); border-radius: 6px; padding: 2px; }
.seg { background: none; border: 0; padding: 2px 9px; border-radius: 4px; cursor: pointer; color: var(--muted); font-size: 12px; }
.seg.on { background: var(--raise); color: var(--text); }

/* explore tab */
.tab { position: absolute; inset: 0; display: none; }
.tab.active { display: flex; flex-direction: column; }
.menu { position: relative; }
.dropdown {
  display: none; position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: 260px; max-height: 60vh; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.dropdown.right { left: auto; right: 0; }
.dropdown.open { display: block; }
.menu-head { padding: 8px 6px 2px; color: var(--muted); font-size: 11px; }
.menu-head:first-child { padding-top: 2px; }
/* the Statistics rail's Charts menu: a saved-profile picker above the fields */
.charts-menu { width: 300px; }
.profile-bar { margin: 0 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.profile-row { display: flex; align-items: center; gap: 4px; padding: 2px 6px 0; }
.profile-pick, .profile-name { flex: 1; min-width: 0; }
.profile-row .btn { padding: 3px 7px; }

.explore-body { flex: 1; min-height: 0; display: flex; }
.table-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#grid { flex: 1; min-height: 0; }
/* search and the Columns menu, above the table; as tall as the statistics rail's head beside it */
.toolbar {
  display: flex; align-items: center; gap: 8px; height: 45px; flex: none; padding-right: 8px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.searchbar { flex: 1; min-width: 0; align-self: stretch; display: flex; align-items: center; gap: 10px; padding-left: 12px; color: var(--muted); cursor: text; }
.searchbar:focus-within { color: var(--accent); }
.searchbar input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; font-size: 14px; color: var(--text); }
.searchbar input:focus { border: 0; }
.searchbar input::placeholder { color: var(--muted); }
.searchbar kbd {
  font: 11px var(--font); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px;
}
.searchbar:focus-within kbd { display: none; }
#columns-btn { white-space: nowrap; }
.columns-menu { width: 300px; max-height: min(70vh, 640px); padding-top: 0; }
.col-top {
  position: sticky; top: 0; z-index: 1; display: flex; flex-direction: column; gap: 6px;
  margin: 0 -6px 2px; padding: 6px 6px 7px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.col-actions { display: flex; gap: 12px; padding: 0 2px; font-size: 12px; white-space: nowrap; }
.col-actions .muted { flex: 1; }
.col-section + .col-section { margin-top: 4px; }
.opt.col-head { color: var(--text-2); font-size: 11.5px; font-weight: 600; }

/* statistics rail */
#rail-resize { flex: none; width: 6px; margin: 0 -3px; z-index: 3; cursor: col-resize; position: relative; }
#rail-resize::after { content: ''; position: absolute; inset: 0 2px; transition: background .15s; }
#rail-resize:hover::after, .resizing #rail-resize::after { background: var(--accent); }
.resizing { cursor: col-resize; user-select: none; }
#rail {
  --rail-w: clamp(320px, 32vw, 460px);
  flex: none; width: var(--rail-w); display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--border);
}
#rail.collapsed { width: 36px; }
#rail.collapsed > :not(.rail-strip), #rail:not(.collapsed) > .rail-strip { display: none; }
.rail-strip {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0;
  background: none; border: 0; color: var(--muted); cursor: pointer;
}
.rail-strip:hover { color: var(--text); background: var(--surface-2); }
.rail-strip .vlabel { writing-mode: vertical-rl; letter-spacing: .04em; }
.rail-strip .chev { font-size: 18px; line-height: 1; }
.rail-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); min-height: 45px; }
.rail-title { font-weight: 600; }
.stats-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.pc-note { margin-top: 4px; font-size: 12px; color: var(--text-2); }
.bl.rate .bl-row { grid-template-columns: minmax(0, 1fr) auto 64px; }
.bl.rate .bl-n { color: var(--muted); }
.bl.rate .bl-pct { color: var(--text); }
.rail-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; transition: opacity .15s; }
/* Charts tab: the field list, then a board of graph widgets */
.charts-body { flex: 1; min-height: 0; display: flex; }
.fields-panel {
  flex: none; width: 210px; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--border);
}
.fields-top { display: flex; align-items: center; gap: 2px; margin: 10px 6px 6px 10px; }
.fields-find { flex: 1; min-width: 0; width: auto !important; }
.fields-fold { font-size: 18px; color: var(--muted); }
/* folded: a strip to open it again */
.fields-panel.closed { width: 36px; }
.fields-panel.closed > :not(.fields-strip), .fields-panel:not(.closed) > .fields-strip { display: none; }
.fields-list { flex: 1; overflow-y: auto; padding: 0 6px 8px; }
.fields-group { padding: 10px 6px 2px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.fields-section { padding: 6px 6px 2px; color: var(--muted); font-size: 11px; }
.fl-field { display: flex; align-items: center; gap: 7px; padding: 3px 6px; border-radius: 4px; cursor: grab; color: var(--text-2); }
.fl-field:hover { background: var(--surface-2); color: var(--text); }
.fl-field .v { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fchip .v { min-width: 0; overflow-wrap: break-word; line-height: 1.25; padding-block: 2px; }
.fields-hint { padding: 8px 12px 10px; border-top: 1px solid var(--border); }
.glyph { flex: none; width: 18px; text-align: center; font-size: 10px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.glyph.num { color: #199e70; }
.glyph.date { color: #c98500; }

.wboard { position: relative; flex: 1; min-width: 0; overflow-y: auto; padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 18px; }
.wboard.over { background: var(--accent-wash); }
/* groups: a head (fold, name, count, its buttons) over a grid of its charts; one group alone shows no head */
.wgroup { display: flex; flex-direction: column; gap: 10px; }
.wgroup.ghost { opacity: .35; }
.wg-head { display: flex; align-items: center; gap: 6px; min-height: 30px; padding-bottom: 6px; border-bottom: 1px solid var(--line); cursor: grab; }
.wg-fold {
  width: 20px; height: 20px; flex: none; display: grid; place-items: center; padding: 0; background: none; border: 0;
  border-radius: 4px; color: var(--muted); cursor: pointer;
}
.wg-fold::before {
  content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform .15s;
}
.wgroup.closed .wg-fold::before { transform: rotate(-45deg); }
.wg-fold:hover { color: var(--text); background: var(--surface-2); }
.wg-name { min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-name-edit { width: 220px; padding: 2px 6px; font-weight: 600; }
.wg-count { flex: none; color: var(--muted); font-size: 12px; }
.wg-head .wg-rename { margin-right: auto; opacity: 0; font-size: 12px; color: var(--muted); }
.wg-head:hover .wg-rename { opacity: 1; }
.wg-head .icon-btn:not(.wg-rename) { color: var(--muted); }
.wg-add { flex: none; }
.wgroup.closed .wg-grid { display: none; }
.wboard.solo .wg-head { display: none; }
.wg-grid { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 14px; align-content: start; }
/* free placement (wide boards): each chart sits where it was put; relayout() sets the tops and the section's height */
.wboard.free .wg-grid { display: block; margin-inline: -7px; }
.wboard.free .widget { position: absolute; top: 0; transition: top .2s, left .2s; }
.wboard.free .widget.moving, .wboard.free .widget.resizing { transition: none; z-index: 6; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.wboard.free .widget.moving { cursor: grabbing; opacity: .92; }
.wboard.free .w-new { position: absolute; left: 7px; width: calc(25% - 14px); min-height: 80px; }
.wboard.moving { user-select: none; }
.wg-new {
  align-self: flex-start; padding: 6px 12px; background: none; border: 1px dashed var(--line); border-radius: 8px;
  color: var(--text-2); cursor: pointer;
}
.wg-new:hover { border-color: var(--accent); color: var(--text); }
.widget {
  position: relative; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px 12px; transition: opacity .15s;
}
/* resizing: the corner grip, and the outline that follows the pointer while the widget snaps to whole columns */
.w-grip {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none;
  border-radius: 0 0 10px 0; opacity: .45; transition: opacity .15s;
  background: linear-gradient(135deg, transparent 50%, var(--muted) 50%, var(--muted) 58%, transparent 58%, transparent 70%,
    var(--muted) 70%, var(--muted) 78%, transparent 78%);
}
.widget:hover .w-grip, .widget.resizing .w-grip { opacity: 1; }
/* edges: drag the right one for width, the bottom one for height */
.w-edge { position: absolute; z-index: 2; touch-action: none; }
.w-edge-r { top: 10px; right: 0; bottom: 18px; width: 7px; cursor: ew-resize; }
.w-edge-b { left: 10px; right: 18px; bottom: 0; height: 7px; cursor: ns-resize; }
.w-edge:hover { background: var(--accent-wash); border-radius: 4px; }
/* a chart given a height fills it: bars spread out, number tiles centre their value */
.widget.sized .hb { min-height: 100%; }
.widget.sized .hb-row { flex: 1 1 0; max-height: 64px; }
.widget.sized .hb-line { height: 18px; }
.widget.sized .kpi { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.widget.resizing { border-color: var(--accent); }
.wboard.resizing { cursor: nwse-resize; user-select: none; }
.w-size {
  position: absolute; z-index: 5; pointer-events: none; border: 1.5px dashed var(--accent); border-radius: 10px;
  background: var(--accent-wash);
}
.widget.sized .w-body { overflow: auto; }
.widget.loading .w-body { opacity: .45; }
.widget.ghost { opacity: .35; }
.widget.sortable-fallback { box-shadow: 0 12px 30px rgba(0,0,0,.5); }
/* head: the title and the card's icons; under it the counts and the chart's options */
.w-head { display: flex; align-items: center; gap: 2px; min-height: 22px; cursor: grab; }
.w-title {
  flex: 0 1 auto; min-width: 0; font-weight: 600; overflow: hidden;
  /* up to two lines, then … (the full title is in its tooltip) */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere;
}
/* narrow cards: each shelf's name above its fields, and nothing reaches past the card */
.widget { container-type: inline-size; }
.widget > * { min-width: 0; max-width: 100%; }
@container (max-width: 300px) {
  .shelf { flex-wrap: wrap; row-gap: 2px; padding-block: 4px; }
  .shelf-name { width: 100%; }
  .w-head { flex-wrap: wrap; }
  .w-head .w-title { flex: 1 1 100%; }
}
.w-head .w-rename { font-size: 12px; }
.w-name { flex: 1; min-width: 0; margin-right: 4px; padding: 1px 5px; font-weight: 600; }
.w-head .icon-btn { color: var(--muted); }
/* tabs: the same chart with other filters */
.w-tabs { display: flex; align-items: flex-end; gap: 2px; margin: 6px 0 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.w-tab {
  display: flex; align-items: center; gap: 2px; min-width: 0; max-width: 200px; flex: none; padding: 3px 4px 4px 9px;
  margin-bottom: -1px; border: 1px solid transparent; border-radius: 6px 6px 0 0; font-size: 12px; color: var(--text-2); cursor: pointer;
}
.w-tab:hover { color: var(--text); background: var(--surface-2); }
.w-tab.on { color: var(--text); background: var(--surface); border-color: var(--line); border-bottom-color: var(--surface); cursor: default; }
.w-tab-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-tab-x { padding: 0 3px; background: none; border: 0; border-radius: 4px; color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; opacity: 0; }
.w-tab:hover .w-tab-x, .w-tab.on .w-tab-x { opacity: 1; }
.w-tab-x:hover { color: var(--text); background: var(--line); }
.w-tab-add { flex: none; margin: 0 0 3px 2px; padding: 1px 7px; background: none; border: 0; border-radius: 5px; color: var(--muted); cursor: pointer; }
.w-tab-add:hover { color: var(--text); background: var(--surface-2); }
.w-tab-name { width: 130px; margin: 1px 0 3px; padding: 1px 5px; font-size: 12px; }
/* the filters a chart shows the rows of: a row of tags for its own, then Explore's, dimmer */
.w-filters { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 2px; font-size: 11.5px; }
.wf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 4px; min-width: 0; }
.wf-name { flex: none; width: 54px; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.wf-tag {
  display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; min-width: 0; padding: 1px 7px;
  background: var(--accent-wash); border: 1px solid transparent; border-radius: 10px; color: var(--text); font: inherit; line-height: 1.5;
}
button.wf-tag { cursor: pointer; }
button.wf-tag:hover { border-color: var(--accent); }
.wf-row.explore .wf-tag { background: var(--surface-2); color: var(--text-2); }
.wf-field { flex: none; color: var(--muted); }
.wf-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presenting #tab-charts button.wf-tag { cursor: default; }
.presenting #tab-charts button.wf-tag:hover { border-color: transparent; }
.w-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-height: 24px; margin-top: 1px; }
.w-meta { flex: 1 0 80px; min-width: 0; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-sub select {
  width: auto; flex: 0 1 auto; min-width: 0; max-width: 100%; padding: 2px 4px; font-size: 12px; color: var(--text-2);
  background: none; border-color: transparent; cursor: pointer;
}
.w-sub select:hover, .w-sub select:focus { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.w-pc {
  display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 2px 6px; border-radius: 6px;
  color: var(--text-2); font-size: 12px; cursor: pointer; white-space: nowrap;
}
.w-pc:hover { background: var(--surface-2); color: var(--text); }
.w-pc input { margin: 0; }
/* what the chart's type doesn't take or use: grayed (a shelf while a field it can't take is dragged, a chip on a shelf,
   a menu row, per capita) */
.w-pc.unfit, .field-menu .opt.unfit { opacity: .45; cursor: not-allowed; }
.fchip.unfit { opacity: .45; text-decoration: line-through; text-decoration-color: var(--muted); }
#tab-charts.dragging .shelf.unfit { opacity: .35; background: none; outline: 0; cursor: not-allowed; }
/* presenting: the charts alone, roomier, with nothing for editing them; tabs, per capita and clicking a bar still work */
#layout.presenting:has(#tab-charts.active) { grid-template: 1fr / 1fr; }
#layout.presenting:has(#tab-charts.active) #sidebar,
.presenting #tab-charts :is(.fields-panel, #add-chart, .shelves, .w-text-edit, .w-editor, .w-sub select, .w-head .icon-btn, .w-grip, .w-edge, .w-tab-x, .w-tab-add, .w-new,
  .wg-head .icon-btn, .wg-add, .wg-new) {
  display: none;
}
.presenting #tab-charts :is(.w-head, .wg-head) { cursor: default; }
#tab-charts .wboard { padding: 24px 32px 40px; gap: 28px; }
#tab-charts .wg-grid { gap: 20px; }
#tab-charts .wg-name { font-size: 17px; }
#tab-charts .widget { padding: 16px 18px 18px; }
#tab-charts .w-title { font-size: 15px; }
#tab-charts .w-body { margin-top: 10px; }
#present.on { background: var(--accent); border-color: var(--accent); color: #fff; }
/* + Chart's presets: cards of ready-made charts, by the data they're of */
dialog.presets { width: min(760px, calc(100vw - 32px)); }
.pr-head { margin: 16px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.pr-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer;
}
.pr-card:hover, .pr-card:focus-visible { border-color: var(--accent); outline: 0; }
.pr-icon { fill: var(--accent); stroke: var(--accent); margin-bottom: 4px; }
.pr-blank { width: 48px; height: 32px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 4px; color: var(--muted); font-size: 18px; }
.pr-name { font-weight: 600; }
.pr-note { line-height: 1.35; }
.w-new {
  min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; border: 1px dashed var(--line); border-radius: 10px; color: var(--text-2); cursor: pointer;
}
.w-new:hover { border-color: var(--accent); color: var(--text); }

/* shelves: two to a row, quiet until a field is dragged, when each shows as a place to drop it */
.shelves {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 4px;
  margin: 6px 0 10px; padding: 4px; background: var(--page); border-radius: 8px;
}
.shelf {
  position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 28px; padding: 2px 2px 2px 8px;
  border: 1px solid transparent; border-radius: 6px; transition: background .1s, border-color .1s;
}
.shelf:hover { background: var(--surface); }
#tab-charts.dragging .shelf { border-color: var(--line); border-style: dashed; }
.shelf.over, #tab-charts.dragging .shelf.over { border: 1px solid var(--accent); background: var(--accent-wash); }
.shelf[data-swap]::after {
  content: attr(data-swap); position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #fff; font-size: 11px; pointer-events: none;
}
.shelf-name { flex: none; min-width: 40px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.shelf-chips { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.shelf-ph { color: var(--muted); font-size: 12px; }
.shelf-note { color: var(--warn); font-size: 11.5px; }
.shelf select.agg { width: auto; padding: 1px 4px; font-size: 12px; background: none; border-color: transparent; color: var(--text-2); cursor: pointer; }
.shelf select.agg:hover { border-color: var(--line); color: var(--text); }
.shelf .add { flex: none; color: var(--muted); opacity: .6; }
.shelf:hover .add, .shelf .add:focus { opacity: 1; }
.fchip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-height: 22px; padding-left: 3px;
  background: var(--accent-wash); border-radius: 5px; font-size: 12px; cursor: grab;
}
.fchip.bad { background: none; outline: 1px dashed var(--error); outline-offset: -1px; opacity: .7; }
.fchip .chip-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 1px 6px 1px 4px; }
.fchip .chip-x:hover { color: var(--text); }
.field-menu { position: fixed; width: 280px; padding-top: 0; }
.field-menu .opt .glyph { width: 14px; }
.fm-note { padding: 6px 6px 0; }
.fm-sep { border-top: 1px solid var(--border); margin: 6px 0 2px; }
.field-menu .fm-filter {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; padding: 0; background: none; border: 0;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.field-menu .fm-filter .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-menu .fm-filter:hover .v { text-decoration: underline; }
.fchip.filt { cursor: pointer; }
.fchip.filt .v b { font-weight: 600; }
.fchip.filt.unset .v { color: var(--muted); }
.fchip .chip-on { margin: 0 2px 0 3px; width: 12px; height: 12px; cursor: pointer; }
.fchip.filt.off { background: none; outline: 1px dashed var(--line); outline-offset: -1px; }
.fchip.filt.off .v { color: var(--muted); text-decoration: line-through; }
.filter-pop .fp-on { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.filter-pop .fp-on input { margin: 0; }
.filter-pop { width: 300px; padding: 0; }
.filter-pop .fp-head { display: flex; align-items: baseline; gap: 6px; padding: 10px 14px 6px; }
.filter-pop .fp-head .link { margin-left: auto; }
.filter-pop .filter-body { padding-top: 4px; }

.w-body { min-height: 60px; }
.w-body .empty.error { color: var(--error); }
.vchart svg, .heat svg { display: block; cursor: pointer; overflow: visible; }
.vchart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.vchart .base { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.vchart .tick, .heat .tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.vchart .hot-col { fill: rgba(255, 255, 255, .04); }
.vchart .bar:hover { filter: brightness(1.25); }
.vchart.stacked .bar { stroke: var(--surface); stroke-width: 1px; }
.vchart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.heat .cell:hover { stroke: var(--text); stroke-width: 1; }
.heat .cell-v { fill: var(--text-2); font-size: 10px; pointer-events: none; font-variant-numeric: tabular-nums; }
.heat .cell-v.on { fill: #fff; }

.hb { display: flex; flex-direction: column; gap: 1px; }
.hb-row {
  display: grid; grid-template-columns: var(--lw, minmax(80px, 32%)) minmax(0, 1fr) var(--nw, auto); align-items: center; gap: 10px;
  min-height: 24px; padding: 0 4px; border-radius: 5px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.hb-row:hover { background: var(--surface-2); }
.hb.with-pct .hb-row { grid-template-columns: var(--lw, minmax(80px, 32%)) minmax(0, 1fr) var(--nw, auto) var(--pw, auto); }
.hb-n, .hb-pct { text-align: right; white-space: nowrap; }
.hb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-label.blank { color: var(--muted); font-style: italic; }
.hb-track { display: flex; flex-direction: column; justify-content: center; gap: 1px; min-height: 14px; }
.hb-line { display: flex; height: 14px; }
.hb.grouped .hb-line { height: 5px; }
.hb.grouped .hb-row { padding-block: 3px; }
.hb-seg { height: 100%; min-width: 1px; }
.hb-seg:first-child { border-radius: 3px 0 0 3px; }
.hb-seg:last-child { border-radius: 0 3px 3px 0; }
.hb-seg:only-child { border-radius: 3px; }
.hb.stacked .hb-seg:not(:last-child) { box-shadow: inset -1px 0 0 var(--surface); }
.hb-row:hover .hb-seg { filter: brightness(1.15); }
.hb-n { color: var(--text-2); text-align: right; }
.hb-pct { color: var(--muted); text-align: right; }

.w-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 11.5px; color: var(--text-2); }
.w-legend:empty { display: none; }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg.click { cursor: pointer; }
.lg.click:hover { color: var(--text); }
.lg i, #viz-tip .tip-row i { width: 9px; height: 9px; border-radius: 2px; flex: none; display: inline-block; }
#viz-tip .tip-row { display: flex; align-items: center; gap: 5px; }
.stats-view.loading .overview, .stats-view.loading .stats { opacity: .5; transition: opacity .15s; }
/* a slim bar across the top of the page while a slow request runs (js/loading.js) */
.loading-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; overflow: hidden;
  pointer-events: none; opacity: 0; transition: opacity .2s; }
.loading-bar.on { opacity: 1; }
.loading-bar::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 35%; background: var(--accent);
  animation: loading-slide 1.1s ease-in-out infinite; }
@keyframes loading-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .loading-bar::before { animation: none; width: 100%; opacity: .6; } }

.overview { padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-value { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.tile-label { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 16px; font-weight: 600; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: 11px; font-weight: 400; }
.tiles + .tiles { margin-top: 8px; }

.card { padding: 14px 0 6px; border-bottom: 1px solid var(--border); }
.card:last-child { border-bottom: 0; }
.card.ghost { opacity: .35; }
.card.sortable-fallback { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.card-head { display: flex; align-items: center; gap: 8px; height: 22px; margin-bottom: 8px; cursor: grab; }
.card-head .title { font-weight: 600; }
.card-head .meta { flex: 1; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-head .remove { visibility: hidden; }
.card:hover .remove { visibility: visible; }
.empty { color: var(--muted); padding: 10px 0; }

.bl { display: flex; flex-direction: column; gap: 2px; }
.bl-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 50px; align-items: center; gap: 12px;
  height: 26px; border-radius: 5px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.bl-label { position: relative; height: 100%; display: flex; align-items: center; min-width: 0; }
.bl-bar { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 3px; background: color-mix(in srgb, var(--bar) 28%, transparent); transition: background .1s; }
.bl-label span { position: relative; padding-left: 8px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-label span.blank { color: var(--muted); font-style: italic; }
.bl-n { color: var(--text-2); text-align: right; }
.bl-pct { color: var(--muted); text-align: right; padding-right: 4px; }
.bl-row:hover { background: var(--surface-2); }
.bl-row:hover .bl-bar { background: color-mix(in srgb, var(--bar) 45%, transparent); }
.bl-row:hover .bl-n { color: var(--text); }
.bl-foot { display: flex; justify-content: space-between; gap: 12px; padding: 6px 4px 0 8px; font-size: 12px; }

.hist { height: 128px; }
.hist svg { display: block; cursor: pointer; overflow: visible; }
.hist .bar { fill: var(--bar); }
.hist .bar.hot { fill: color-mix(in srgb, var(--bar) 70%, white); }
.hist .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.hist .base { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.hist .tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }

#viz-tip {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; max-width: 280px;
  background: var(--raise); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px;
  box-shadow: 0 6px 20px rgba(0,0,0,.45); font-size: 12px; font-variant-numeric: tabular-nums;
}
#viz-tip .tip-title { color: var(--text-2); margin-bottom: 2px; word-break: break-word; }
#grid.ag-theme-quartz-dark {
  --ag-font-family: var(--font);
  --ag-font-size: 12.5px;
  --ag-background-color: var(--page);
  --ag-odd-row-background-color: #111110;
  --ag-header-background-color: var(--surface);
  --ag-foreground-color: var(--text-2);
  --ag-header-foreground-color: var(--text);
  --ag-border-color: var(--border);
  --ag-row-border-color: transparent;
  --ag-row-hover-color: var(--accent-wash);
  --ag-wrapper-border-radius: 0;
  --ag-cell-horizontal-padding: 10px;
}
#grid .ag-root-wrapper { border: 0; }
#grid .ag-row { cursor: pointer; }

/* map tab: its search, over the map and its panel */
.map-body { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; }
.panel {
  position: absolute; top: 12px; left: 12px; width: 300px; z-index: 5;
  background: rgba(22, 22, 21, 0.94); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100% - 24px); overflow-y: auto;
}
.panel .big { font-size: 20px; font-weight: 600; }
#map-info, #map-located, #geo-job { display: flex; flex-direction: column; gap: 4px; }
#geo-job:empty, #map-approx:empty { display: none; }
.panel-tabs { display: flex; }
.panel-tabs .seg { flex: 1; padding: 4px 9px; }
.job-running .seg[data-pane="geocoding"]::after {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%;
  background: var(--accent); vertical-align: middle;
}
.pane { display: none; flex-direction: column; gap: 6px; }
.pane.active { display: flex; }
#geo-job { border-top: 1px solid var(--border); padding-top: 8px; }
#map-located:empty + #geo-job { border-top: 0; padding-top: 0; }
.job-running .geo-start { display: none; }
.stat-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.progress { height: 4px; background: var(--raise); border-radius: 2px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); transition: width .3s; }
.panel label.row { white-space: nowrap; }
.panel label.row select { width: auto; flex: 1; min-width: 0; }
#legend-note:empty, #map-sample:empty { display: none; }
#legend { display: flex; flex-direction: column; gap: 1px; margin: 0 -6px; }
.legend-item {
  display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 5px; cursor: pointer;
  color: var(--text); user-select: none; font-variant-numeric: tabular-nums;
}
.legend-item:hover { background: var(--raise); }
.legend-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-n { color: var(--muted); font-size: 12px; }
.legend-item .only { visibility: hidden; font-size: 12px; }
.legend-item:hover .only { visibility: visible; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c); border: 2px solid var(--c); }
.legend-item.off { color: var(--muted); }
.legend-item.off .swatch { background: transparent; }
.legend-item.off .legend-label { text-decoration: line-through; text-decoration-color: var(--line); }
.legend-foot { display: flex; gap: 14px; padding: 4px 6px 0; font-size: 12px; }
.map-tip { background: var(--surface-2) !important; color: var(--text) !important; border: 1px solid var(--border); border-radius: 6px; font: 12px var(--font) !important; padding: 5px 8px !important; }
.map-tip-wrap .maplibregl-popup-content { background: none; padding: 0; box-shadow: none; }
.map-tip-wrap .maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-group { background: var(--surface-2) !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--border) !important; }
.maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { background: rgba(13,13,13,.7) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }

/* dialogs */
dialog {
  padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 64px); box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0; font-size: 16px; }
.modal-head { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
/* a record's name heads its detail, with short facts about it as tags beside it */
#modal-title.record-name { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.name-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 10px; vertical-align: 3px; }
.name-tag { padding: 1px 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
  color: var(--text-2); font-size: 11.5px; font-weight: 500; letter-spacing: 0; }
.modal-body { overflow-y: auto; padding: 14px 16px; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* a detail's tabs (js/detailtabs.js): underlined, sticky at the top of the modal body as it scrolls */
.dtabs { position: sticky; top: -14px; z-index: 1; display: flex; flex-wrap: wrap; gap: 2px; margin: 0 -16px 14px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.dtab { padding: 8px 12px; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); cursor: pointer; }
.dtab:hover { color: var(--text); }
.dtab.on { color: var(--text); border-bottom-color: var(--accent); }
.record .dtabs { position: static; margin: 0 12px; padding: 0; }

.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px 24px; }
.group h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.group dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.group dt { color: var(--muted); }
.group dd { margin: 0; word-break: break-word; }
.group dd.blank { color: var(--line); }
.group dd .was { color: var(--muted); font-size: 11.5px; }  /* a previous value, shown beside the current one */
.ext-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.ext-link:hover { text-decoration: underline; }
.group > .ext-link { display: inline-block; margin-top: 4px; }
.group .thumb { float: right; width: 96px; margin: 0 0 8px 12px; border-radius: 6px; border: 1px solid var(--border); }

.breakdown .bl-row { height: 22px; cursor: default; }
.breakdown .bl-row:hover { background: none; }
.breakdown .bl-row:hover .bl-bar { background: color-mix(in srgb, var(--bar) 28%, transparent); }
.breakdown p { margin: 8px 0 10px; }
.breakdown-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--grid); margin: 2px 0 6px; }
.breakdown-bar span { background: var(--bar); }
.breakdown-bar span + span { opacity: .6; border-left: 1px solid var(--surface); }
.breakdown-bar span + span + span { opacity: .35; }
.breakdown-lead { color: var(--text); }
.breakdown-more { margin-top: 6px; }
.breakdown-more summary { cursor: pointer; width: fit-content; }
.breakdown-more summary:hover { color: var(--text); }
.breakdown-more[open] summary { margin-bottom: 6px; }
.breakdown dd { display: flex; flex-direction: column; gap: 1px; }
.share { display: flex; flex-direction: column; gap: 4px; }

.record-list { display: flex; flex-direction: column; gap: 6px; }
.record { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.record summary { cursor: pointer; padding: 8px 12px; display: flex; gap: 10px; align-items: baseline; }
.record .who { font-size: 15px; font-weight: 700; color: var(--text); }
.record[open] summary { border-bottom: 1px solid var(--border); }
.record .groups { padding: 12px; }
.record .subtables { padding: 0 12px 12px; }
.subtables { margin-top: 18px; }
.subtables h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.subtable-wrap { overflow-x: auto; }
.subtable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.subtable th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; padding: 4px 10px 4px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.subtable td { padding: 4px 10px 4px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.subtable td:nth-child(-n+5) { white-space: nowrap; }
.subtable td.blank { color: var(--line); }
.record .matches { padding: 0 12px; }
.matches { margin-top: 18px; }
.match + .match { margin-top: 10px; }
.match-head { margin-bottom: 4px; }
.match-row { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.match-row .match-p { font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
.match-row.chosen .match-p { color: var(--text); font-weight: 600; }

/* settings: a sidebar of the user's own panes (the admin page, admin.css, reuses it) */
#settings { width: min(1040px, calc(100vw - 32px)); height: min(720px, calc(100vh - 64px)); }
#settings[open] { flex-direction: row; }
.settings-nav {
  flex: none; width: 200px; overflow-y: auto; padding: 12px 8px; background: var(--page); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 14px;
}
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-head {
  padding: 0 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.settings-nav button {
  display: flex; align-items: center; gap: 8px; text-align: left; background: none; border: 0; border-radius: 6px;
  padding: 6px 10px; cursor: pointer; color: var(--text-2);
}
.settings-nav button:hover { background: var(--surface-2); color: var(--text); }
.settings-nav button.active { background: var(--raise); color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; margin-left: auto; }
.settings-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#settings .modal-head { align-items: flex-start; }
#settings-note:empty { display: none; }
#settings-note { margin-top: 3px; }
.settings-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 18px 16px; }
.settings-body .colors-pane { overflow: visible; padding: 0; }
.field-list { padding: 8px 0; }
.field-list .opt { padding: 5px 8px; }
.order-group h3, .pane-section h3 {
  margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600;
}
.pane-section { padding: 4px 0 14px; border-bottom: 1px solid var(--border); }
.pane-section:last-child { border-bottom: 0; }
.pane-section p { margin: 0 0 8px; }
.pane-section > .btn { margin-top: 8px; }
.pane-actions { margin: 12px 0 8px; }
.pane-actions input[type=search] { flex: 1; }
.notice { margin: 14px 0 4px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.notice.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.form-grid { display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }
input[type=password] {
  width: 100%; background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; outline: none;
}
input.num { width: 110px; }
.add-user { display: grid; grid-template-columns: 1fr 1fr 110px auto; gap: 8px; margin-bottom: 6px; }
.account-who { display: flex; align-items: center; gap: 12px; padding-top: 12px; }
.who-name { font-size: 15px; font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .link + .link { margin-left: 12px; }
.table tr.off td { color: var(--muted); }
.table tr.bad td { color: var(--error); }
.table tr.sub-row td, .table tr.edit-row td { border-top: 0; padding-top: 0; }
.table tr:has(+ .sub-row) td, .table tr:has(+ .edit-row) td { border-bottom: 0; }
.table .edit-row .row input { flex: 1; }
.table select.compact { width: auto; padding: 2px 6px; }
.table + .btn { margin-top: 10px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--text-2); }
.nowrap { white-space: nowrap; }
.tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px; background: var(--raise); color: var(--text-2);
  font-size: 10.5px; line-height: 17px; vertical-align: 1px;
}
.tag.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.link.danger { color: var(--error); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 18px; }
.kv > span:nth-child(odd) { color: var(--muted); }
/* the app's dropdown (js/picker.js), in place of native selects */
.pick { display: inline-block; vertical-align: middle; max-width: 100%; }
.pick-btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 150px; max-width: 100%; text-align: left; }
.pick-btn[aria-expanded="true"] { border-color: var(--accent); }
.pick-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-caret { color: var(--muted); font-size: 10px; flex: none; }
.dropdown.pick-drop { position: fixed; z-index: 1000; width: max-content; max-width: min(520px, calc(100vw - 16px)); padding: 0; display: none; flex-direction: column; overflow: hidden; overscroll-behavior: contain; }
.dropdown.pick-drop.open { display: flex; }
.pick-filter { margin: 6px 6px 2px; width: auto !important; }
.pick-list { overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 6px; min-height: 0; flex: 1; }
.pick-list .menu-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; white-space: nowrap; }
.pick-list .menu-item.on { color: var(--accent); font-weight: 600; }
.pick-list .menu-item.on .pick-text::after { content: ' ✓'; }
.pick-list .menu-item.disabled { opacity: .45; cursor: not-allowed; }
.pick-list .menu-item:focus { outline: none; background: var(--raise); }
.pick-text { overflow: hidden; text-overflow: ellipsis; }
.pick-hint { color: var(--muted); font-size: 11px; font-weight: 400; flex: none; }
/* Settings › General › Switch version */
.version-pick, .version-pick .pick-btn { width: 100%; }
.version-notes { margin-top: 10px; max-height: 150px; overflow: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.version-notes .markdown ul { margin: 0; padding-left: 18px; }
.btn.star.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

/* the account menu */
.user-btn {
  display: flex; align-items: center; gap: 8px; background: none; border: 0; border-radius: 6px; padding: 3px 8px 3px 3px;
  cursor: pointer; color: var(--text-2);
}
.user-btn:hover { background: var(--raise); color: var(--text); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-wash); color: var(--accent); font-weight: 600; font-size: 12px;
}
.avatar.lg { width: 40px; height: 40px; font-size: 17px; }
.user-btn.flag .avatar { box-shadow: 0 0 0 2px var(--warn); }
.user-menu { width: 220px; }
.menu-item {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 5px; padding: 6px 8px; cursor: pointer;
}
.menu-item:hover { background: var(--raise); }
.menu-item.warn { color: var(--warn); }
a.menu-item { color: inherit; text-decoration: none; box-sizing: border-box; }
.user-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* the sign-in page */
body.signin-page { display: grid; place-items: center; overflow: auto; padding: 16px; }
.signin {
  width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.signin h1 { margin: 0 0 4px; font-size: 18px; }
.signin label { display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }
.signin .btn { padding: 7px 11px; margin-top: 4px; }
.order-list { list-style: none; margin: 0; padding: 0; counter-reset: n; }
.order-list li {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; cursor: grab;
  counter-increment: n; user-select: none;
}
.order-list li::before { content: counter(n); width: 20px; text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.order-list li:hover { background: var(--surface-2); }
.order-list .handle { color: var(--muted); }
.order-list .name { flex: 1; }
.order-list .type { color: var(--muted); font-size: 11px; }
.order-list .ghost { background: var(--accent-wash); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2f2f2d; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 760px) {
  :root { --sidebar: 100%; }
  #layout { grid-template-columns: 1fr; grid-template-rows: 40vh 1fr; }
  #sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  #layout.side-closed { grid-template-columns: 1fr; grid-template-rows: 40px 1fr; }
  #layout.side-closed .side-strip { flex-direction: row; justify-content: center; padding: 0; }
  #layout.side-closed .side-strip .vlabel { writing-mode: horizontal-tb; }
  .panel { width: calc(100% - 24px); }
  .explore-body { flex-direction: column; }
  .table-col { flex: 1 1 45%; }
  #rail-resize { display: none; }
  #rail { width: auto; flex: 1 1 55%; border-left: 0; border-top: 1px solid var(--border); }
  #rail.collapsed { width: auto; flex: none; height: 40px; }
  #rail.collapsed .rail-strip { flex-direction: row; justify-content: center; padding: 0; }
  #rail.collapsed .rail-strip .vlabel { writing-mode: horizontal-tb; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .charts-body { flex-direction: column; }
  .fields-panel { width: auto; max-height: 30%; border-right: 0; border-bottom: 1px solid var(--border); }
  .fields-hint { display: none; } /* fields are dragged with a mouse; on a phone the + menus place them */
  .fields-panel.closed { width: auto; height: 40px; }
  .fields-panel.closed .fields-strip { flex-direction: row; justify-content: center; padding: 0; }
  .fields-panel.closed .fields-strip .vlabel { writing-mode: horizontal-tb; }
  .wboard { padding: 12px 16px 24px; }
  #settings[open] { flex-direction: column; }
  .settings-nav { width: auto; flex-direction: row; gap: 8px; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav-group { flex-direction: row; }
  .nav-head { display: none; }
  .settings-nav button { white-space: nowrap; }
  .add-user { grid-template-columns: 1fr 1fr; }
  .settings-body .table { min-width: 560px; }
  #user-name { display: none; }
}
.check { gap: 6px; cursor: pointer; color: var(--text-2); }
.swatch-pick { position: relative; display: flex; cursor: pointer; padding: 3px; margin: -3px; border-radius: 50%; }
.swatch-pick:hover { background: var(--line); }
.swatch-pick input { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; }
.colors-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 12px; }
.colors-pane h3 { margin: 16px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.colors-pane .row { margin: 8px 0 4px; }
.colors-pane .row select { width: 45%; flex: none; }
.color-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; cursor: pointer; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-in { width: 30px; height: 22px; padding: 0; flex: none; border: 1px solid var(--line); border-radius: 5px; background: none; cursor: pointer; }
.color-in::-webkit-color-swatch-wrapper { padding: 2px; }
.color-in::-webkit-color-swatch { border: 0; border-radius: 3px; }
.color-in.auto { border-style: dashed; opacity: .7; }
.palette { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.palette-derived { display: inline-grid; grid-template-columns: repeat(8, 10px); gap: 2px; margin-left: 6px; }
.swatch-sm { width: 10px; height: 10px; border-radius: 2px; }
.value-list { display: flex; flex-direction: column; }

/* text box: the writing (editing), and how it reads */
.w-text-edit { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 4px; }
.w-text-src { width: 100%; min-height: 72px; resize: vertical; font: inherit; font-size: 12.5px; padding: 6px 8px; }
.w-text-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.w-text-insert { width: auto; max-width: 100%; font-size: 12px; padding: 2px 4px; }
.textbox { line-height: 1.5; overflow-wrap: break-word; }
.textbox p { margin: 0 0 4px; }
.textbox .tb-h { font-size: 15px; font-weight: 600; margin: 2px 0 6px; }
.textbox .tb-gap { height: 8px; }
.textbox .tv { font-variant-numeric: tabular-nums; color: var(--text); }

/* custom fields: a chart's typed-in numbers, text and formulas */
.calc-edit { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.calc-head { display: flex; align-items: center; gap: 8px; }
.calc-head .shelf-name { min-width: 0; }
.calc-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.calc-row { display: flex; align-items: center; gap: 6px; font-size: 12.5px; min-width: 0; }
.calc-row .calc-expr { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.calc-row .calc-err, .calc-msg.bad { color: var(--error); }
.calc-row .calc-err { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.calc-form { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.calc-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.calc-name { flex: 1 1 110px; min-width: 0; }
.calc-formula { flex: 3 1 180px; min-width: 0; font-size: 12.5px; }
.calc-insert { width: auto; max-width: 100%; font-size: 12px; padding: 2px 4px; }
.calc-msg { color: var(--muted); }
.calc-help { line-height: 1.4; }

/* snapping: the line a chart's edge has caught on while it's moved or resized */
.snap-guide { position: absolute; z-index: 7; pointer-events: none; background: var(--accent); opacity: .7; }
.snap-guide.v { top: 0; bottom: 0; width: 1px; }
.snap-guide.hz { left: 0; right: 0; height: 1px; }

/* the chart editor: a panel under the card's head, over the chart, opened with ⚙ */
.w-editor {
  display: none; position: absolute; left: -1px; right: -1px; z-index: 8; padding: 8px 10px 10px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,.5);
}
.widget.ed-open { z-index: 9; }
.widget.ed-open .w-editor { display: block; }
.w-editor .shelves { margin: 6px 0 0; }
.w-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.w-opts select {
  width: auto; flex: 0 1 auto; min-width: 0; max-width: 100%; padding: 2px 4px; font-size: 12px; color: var(--text-2);
  background: none; border-color: transparent; cursor: pointer;
}
.w-opts select:hover, .w-opts select:focus { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.w-edit-btn.on { color: var(--accent) !important; }
.presenting #tab-charts .w-editor { display: none !important; }

.w-tools {
  position: absolute; top: 6px; right: 6px; z-index: 3; display: flex; gap: 1px; padding: 2px;
  background: var(--surface); border-radius: 7px; opacity: .35; transition: opacity .15s;
}
.widget:hover .w-tools, .widget.ed-open .w-tools { opacity: 1; box-shadow: 0 0 0 1px var(--border); }
.presenting #tab-charts .w-tools { display: none; }
