/* Saved views: the open-view bar (under the filter bar on every lens),
   visibility badges, the Saved Views tab and its dialogs. Built from the
   same tokens and pieces as the lenses (cards, tables, seg, buttons). */

/* ── the open-view bar ── */
.vbar { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--brand) 5%, transparent); }
.vbar-inner { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; max-width: var(--maxw-wide); margin: 0 auto; padding: 8px var(--gutter); min-height: 52px; }
.vbar-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-xs); background: var(--brand-tint); color: var(--brand); flex-shrink: 0; }
.vbar-what { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.vbar-kicker { font-size: 11.5px; font-weight: 600; color: var(--fg-faint); }
.vbar-title { font-family: var(--display); font-size: 15px; font-weight: 650; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42ch; }
.vbar-by { font-size: 12.5px; color: var(--fg-muted); }
.vbar-msg { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--fg-muted); }
.vbar-state { font-size: 12.5px; color: var(--fg-muted); flex: 1 1 180px; min-width: 0; }  /* a long note wraps in its own space, never pushing the close button to a line of its own */
.vbar-state.is-dirty { display: inline-flex; align-items: center; gap: 7px; color: var(--warn); font-weight: 600; }
.vbar-state.is-dirty i { width: 7px; height: 7px; border-radius: 99px; background: var(--warn); }
.is-warn { color: var(--warn); }
.vbar-act { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.vbar-act:empty { display: none; }
.vbar-x { margin-left: 2px; }
.vbar-act:empty + .vbar-x { margin-left: auto; }

/* ── badges: private / global / fork ── */
.vbadge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--fg-muted); white-space: nowrap; }
.vbadge.global { color: var(--brand-hi); border-color: var(--brand-deep); background: var(--brand-tint); }
:root[data-theme='light'] .vbadge.global { color: var(--brand-deep); }
.vbadge.fork { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); background: var(--info-tint); }

/* ── filter bar: save the current filters ── */
.fsave { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 11px; border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--brand-hi); border: 1px dashed var(--brand-deep); }
.fsave:hover { background: var(--brand-tint); }
:root[data-theme='light'] .fsave { color: var(--brand-deep); }

/* ── Saved Views tab ── */
.sv-list .c-view { min-width: 220px; max-width: 420px; }
.sv-name { display: flex; flex-direction: column; gap: 3px; text-align: left; }
.sv-name b { font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.sv-name small { color: var(--fg-muted); font-size: 12px; overflow-wrap: anywhere; }
.sv-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.sv-crit { display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; }
.sv-crit span { font-size: 11.5px; color: var(--fg-muted); padding: 2px 7px; border-radius: 6px; background: var(--raised); border: 1px solid var(--line); white-space: nowrap; }
.sv-acts { display: flex; justify-content: flex-end; gap: 4px; white-space: nowrap; }
.sv-acts .icon-btn { width: 32px; height: 32px; }
.sv-acts .icon-btn.danger:hover { color: var(--crit); }
.sv-list tbody tr { cursor: pointer; }
.tbl tbody tr.is-open { background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
.sv-more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--line); }
.lens-bar .search.sv-search { flex: 0 1 300px; }

/* ── dialogs (create, edit, fork, delete, sign-in prompt) ── */
.overlay.is-center { justify-content: center; align-items: center; padding: 16px; }
.dialog { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: var(--pad); animation: dlgIn 0.16s var(--ease); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.dialog h2 { font-family: var(--display); font-size: 18px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 6px; }
.dialog p { font-size: 13.5px; color: var(--fg-muted); line-height: 1.55; }
.dlg-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.dlg-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--fg-muted); }
.dlg-field input, .dlg-field textarea { font: inherit; font-size: 14px; font-weight: 400; color: var(--fg); background: var(--canvas); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 9px 11px; }
.dlg-field textarea { min-height: 70px; resize: vertical; }
.dlg-field input:focus, .dlg-field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.dlg-vis { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.dlg-vis legend { font-size: 12.5px; font-weight: 600; color: var(--fg-muted); margin-bottom: 6px; }
.dlg-attr[hidden] { display: none; }
.dlg-opt { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; }
.dlg-opt:has(input:checked) { border-color: var(--brand-deep); background: var(--brand-tint); }
.dlg-opt input { margin-top: 3px; accent-color: var(--brand); }
.dlg-opt b { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.dlg-opt.is-off { cursor: not-allowed; opacity: .6; }
.dlg-opt small { grid-column: 2; font-size: 12.5px; color: var(--fg-muted); line-height: 1.45; }
.dlg-crit { padding: 10px 12px; border-radius: var(--r-sm); background: var(--raised); border: 1px solid var(--line); }
.dlg-crit h3 { font-size: 11.5px; font-weight: 600; color: var(--fg-faint); margin-bottom: 6px; }
.dlg-note { font-size: 12.5px; color: var(--fg-muted); padding: 10px 12px; border-left: 3px solid var(--info); background: var(--info-tint); border-radius: 0 var(--r-xs) var(--r-xs) 0; }
.dlg-err { font-size: 13px; color: var(--crit); }
.dlg-err:empty { display: none; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btn-danger { display: inline-flex; align-items: center; gap: 7px; background: var(--crit); color: #fff; font-weight: 600; font-size: 13.5px; padding: 9px 15px; border-radius: var(--r-sm); }
.btn-danger:hover { filter: brightness(1.08); }
button[disabled] { opacity: 0.6; cursor: progress; }

.nav-signin { white-space: nowrap; flex-shrink: 0; }

@media (max-width: 640px) {
  /* a guest's nav carries Sign in instead of the account initial */
  .is-guest .brand-name { display: none; }
}

@media (max-width: 860px) {
  .vbar-inner { min-height: 0; padding-top: 8px; padding-bottom: 8px; gap: 6px 10px; }
  .vbar-icon { display: none; }
  .vbar-title { max-width: 100%; white-space: normal; }
  .vbar-act { margin-left: 0; width: 100%; }
  .vbar-act .btn-primary, .vbar-act .btn-secondary { flex: 1 1 auto; justify-content: center; min-height: 40px; }
  .vbar-x { position: absolute; right: 8px; }
  .vbar-inner { position: relative; padding-right: 48px; }
  .overlay.is-center { align-items: flex-end; padding: 0; }
  .dialog { width: 100%; border-radius: var(--r) var(--r) 0 0; max-height: 92vh; padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom)); }
  .dlg-field input, .dlg-field textarea { font-size: 16px; } /* no iOS focus zoom */
  .dlg-foot > * { flex: 1 1 auto; justify-content: center; min-height: 44px; }
  .sv-crit { max-width: none; }
}

/* ---------- Complainant (src/components/complainant.js) ---------- */
.cmpbar { background: color-mix(in srgb, var(--brand) 4%, transparent); }
/* one grid, so nothing competes for the name's row:
   desktop  [icon] [who] [counts ......] [ask to be anonymous] [x]
   phone    [who .......................................] [x]
            [counts ...............................................]
            [ask to be anonymous ..................................] */
.cmp-inner { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px 14px; }
.cmp-inner > .vbar-icon { grid-column: 1; }
.cmp-who { grid-column: 2; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; min-width: 0; }
.cmp-counts, .cmp-actions { grid-column: 3; }
.cmp-optout { grid-column: 4; white-space: nowrap; }
.cmp-x { grid-column: 5; }
.cmp-inner.is-pick .cmp-pick { grid-column: 2 / 5; }
.cmp-inner.is-guest .cmp-who { grid-column: 2 / 4; }
.cmp-inner.is-guest .cmp-actions { grid-column: 4; }
.cmp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
/* taller states (search open, guest note): icon and close sit by the first line */
.cmp-inner.is-pick, .cmp-inner.is-guest { align-items: start; }
.cmp-inner.is-pick > .vbar-icon { margin-top: 5px; }
.cmp-inner.is-pick > .cmp-x { margin-top: 1px; }
.cmp-inner.is-guest > .cmp-actions { align-self: center; }
.cmp-guest b { font-size: 14px; }
.cmp-inner.is-guest .cmp-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.cmp-lock { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px dashed var(--brand-deep); border-radius: 999px; background: var(--surface); color: var(--fg); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.cmp-lock:hover, .cmp-lock:focus-visible { background: var(--brand-tint); border-style: solid; }
.cmp-guest span { font-size: 13px; color: var(--fg-muted); }
.cmp-ward { white-space: nowrap; }
.cmp-name { font-family: var(--display); font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.cmp-ward { font-size: 13px; color: var(--fg-muted); }
.cmp-flag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--warn); cursor: help; }
.cmp-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-count { display: inline-flex; align-items: baseline; gap: 5px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--fg-muted); font-size: 13px; text-decoration: none; }
.cmp-count b { color: var(--fg); font-variant-numeric: tabular-nums; }
.cmp-count.crit b { color: var(--crit); }
.cmp-count.warn b { color: var(--warn); }
.cmp-count.pos b { color: var(--pos); }
.cmp-optout { font-size: 12px; color: var(--fg-faint); text-decoration: underline; text-underline-offset: 2px; }
.cmp-optout:hover { color: var(--fg-muted); }
.cmp-count:hover { border-color: var(--brand); }
.cmp-count.is-on { border-color: var(--brand); background: var(--brand-tint); color: var(--fg); }
.cmp-pick { min-width: 0; max-width: 560px; }
.cmp-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--fg-faint); }
.cmp-search:focus-within { border-color: var(--brand); }
.cmp-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 15px; outline: none; }
.cmp-hint { margin: 8px 2px 0; font-size: 13px; color: var(--fg-muted); }
.cmp-hint.is-warn { color: var(--warn); }
.cmp-results { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.cmp-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; width: 100%; text-align: left; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--surface); color: var(--fg-muted); font: inherit; font-size: 13px; cursor: pointer; }
.cmp-result:hover, .cmp-result:focus-visible { border-color: var(--brand); }
.cmp-result b { font-size: 14.5px; color: var(--fg); }
.cmp-result em { display: inline-flex; align-items: center; gap: 4px; font-style: normal; font-size: 12px; color: var(--warn); }
.linkish { padding: 0; border: 0; background: none; color: var(--brand); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
@media (max-width: 860px) {
  /* the saved-view bar's phone rules make room for an absolute close button;
     this bar places its own */
  .cmp-inner { grid-template-columns: minmax(0, 1fr) auto; padding-right: var(--gutter); gap: 10px 10px; }
  .cmp-who, .cmp-inner.is-pick .cmp-pick, .cmp-inner.is-guest .cmp-who { grid-column: 1; grid-row: 1; }
  .cmp-x { grid-column: 2; grid-row: 1; position: static; align-self: start; }
  .cmp-counts, .cmp-actions, .cmp-inner.is-guest .cmp-actions { grid-column: 1 / -1; grid-row: 2; }
  .cmp-optout { grid-column: 1 / -1; grid-row: 3; white-space: normal; }
  .cmp-actions > * { flex: 1 1 auto; justify-content: center; min-height: 40px; }
  .cmp-pick { max-width: none; }
}
