/* Newer admin screens: permissions, activity, connectors, Mayfair apps, company knowledge, tools. Same restrained skin as warm.css:
   neutral surfaces, hairlines, amber only as a tiny indicator, Liquid Glass segmented controls and switches. */

/* ---------- navigation groups ---------- */
.nav-group + .nav-group { margin-top: 6px; }
.nav-group .section-label { padding: 12px 12px 4px; }
.nav-group-top { margin-bottom: 2px; }

/* ---------- layout ---------- */
.x-screen { max-width: 62rem; display: flex; flex-direction: column; gap: 14px; }
.x-lead { margin: 0; color: var(--muted); font-size: var(--fs-md); line-height: 1.6; max-width: 46rem; }
.x-stack { display: flex; flex-direction: column; gap: 14px; }
.x-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 14px; }
.x-card { background: var(--card); border-radius: var(--card-radius); padding: 20px 22px; min-width: 0; }
.x-card-head, .x-conn-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.x-conn-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.x-h { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.screen .x-h { margin-top: 0; }
.x-sub { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-md); line-height: 1.55; overflow-wrap: anywhere; }
.x-note { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; max-width: 46rem; }
.x-summary { margin: 0; color: var(--muted); font-size: var(--fs-md); }
.x-empty { margin: 0; padding: 16px 4px; color: var(--muted); }
.x-error { margin: 8px 0 0; color: var(--danger); font-size: var(--fs-md); line-height: 1.45; }
.x-error:empty { display: none; }
.x-code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-soft2); border-radius: var(--r-chip); padding: 0.08em 0.4em; }
.x-break { overflow-wrap: anywhere; word-break: break-all; }
.x-wrap-any { overflow-wrap: anywhere; }
.x-nowrap { white-space: nowrap; }
.x-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); opacity: 0.6; flex: none; }
.chip-warn { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Liquid Glass controls ---------- */
.x-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg-soft2) 72%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.5); backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--hair), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.x-seg::-webkit-scrollbar { display: none; }
.x-seg button { font: inherit; font-size: var(--fs-sm); font-weight: 500; height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; position: relative; transition: background 0.12s, color 0.12s; }
.x-seg button:hover { color: var(--text); }
.x-seg button[aria-checked=true] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), inset 0 0 0 1px var(--hair), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.x-seg button[aria-checked=true]:not([data-value=none])::before { content: ""; position: absolute; left: 6px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--accent); }
.x-seg button { min-width: 54px; }
.x-seg button[data-value=none] { min-width: 66px; }
.x-seg.is-busy { opacity: 0.6; pointer-events: none; }
@media (prefers-color-scheme: dark) {
  .x-seg { box-shadow: inset 0 0 0 1px var(--hair), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
  .x-seg button[aria-checked=true] { background: var(--bg-soft2); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--hair), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
}
.switch[role=switch]:disabled { opacity: 0.6; cursor: progress; }

/* ---------- permissions ---------- */
.x-levels { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 10px 0 0; }
.x-levels dt { font-weight: 600; }
.x-levels dd { margin: 0; color: var(--muted); }
.x-limits { display: flex; flex-direction: column; margin-top: 10px; }
.x-limit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--hair); }
.x-limit-main { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.x-limit-name { font-weight: 500; overflow-wrap: anywhere; }
.x-meta { color: var(--muted); font-size: var(--fs-sm); }
.x-meta:empty { display: none; }
.x-limit > .x-error { grid-column: 1 / -1; margin: 0; }
.x-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 12px; border-top: 1px solid var(--hair); }
.x-add-input { flex: 1 1 14rem; min-width: 0; }
.x-add > .x-error { flex-basis: 100%; margin: 0; }

/* ---------- activity ---------- */
.x-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.x-filters select, .x-filters input { height: var(--h-m); font-size: var(--fs-md); border-radius: 999px; padding: 0 14px; background: var(--card); border-color: var(--hair); }
.x-filters input { min-width: 12rem; flex: 1 1 12rem; }
.x-tiles { margin: 0; }
.x-tbl code { font-size: 0.88em; }
.x-more { display: flex; justify-content: center; padding-top: 4px; }

/* ---------- connectors and apps ---------- */
.x-conn.is-off, .x-app.is-off { opacity: 0.8; }
.x-conn-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: var(--fs-md); }
.x-conn-meta strong { color: var(--text); }
.x-conn-url { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.x-setup { margin-top: 14px; padding: 14px 16px; border-radius: 16px; background: var(--warn-bg); }
.x-setup-h { margin: 0 0 4px; font-weight: 600; }
.x-setup-t { margin: 8px 0 0; color: var(--muted); font-size: var(--fs-md); line-height: 1.55; }
.x-envs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.x-envs li, .x-envs-one { display: flex; align-items: center; gap: 6px; margin: 0; min-width: 0; }
.x-envs-one { margin-top: 6px; }
.x-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 12px 0 0; }
.x-kv dt { color: var(--muted); font-size: var(--fs-sm); padding-top: 2px; }
.x-kv dd { margin: 0; min-width: 0; }
.x-tools { margin-top: 12px; border-top: 1px solid var(--hair); padding-top: 10px; }
.x-tools summary { cursor: pointer; font-weight: 500; }
.x-toollist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; }
.x-toollist li { padding: 10px 0; border-top: 1px solid var(--hair); }
.x-toollist li:first-child { border-top: 0; }
.x-toollist li > div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.x-toollist .x-sub { margin-top: 2px; }
.x-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.x-reg-row { display: flex; gap: 8px; }
.x-reg-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: var(--fs-md); }
.x-reg .field-label { margin-top: 0; }
.x-secret { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-soft); border-radius: 14px; padding: 14px; margin: 12px 0; }
.x-secret code { background: none; padding: 0; font-size: 13px; font-weight: 600; user-select: all; min-width: 0; }

/* ---------- company knowledge ---------- */
.x-org-list { padding: 8px 22px; }
.x-org { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; padding: 16px 0; border-top: 1px solid var(--hair); }
.x-org:first-child { border-top: 0; }
.x-org.is-off .x-org-text { color: var(--muted); }
.x-org-main { min-width: 0; flex: 1; }
.x-org-text { margin: 0; line-height: 1.55; overflow-wrap: anywhere; font-size: var(--fs-lg); }
.x-org-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.x-org-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.x-org-dlg textarea { min-height: 8rem; resize: vertical; }

/* ---------- toasts ---------- */
.x-toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; pointer-events: none; max-width: calc(100vw - 28px); }
.x-toast { background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: 999px; font-size: var(--fs-md); box-shadow: var(--shadow); }

@media (max-width: 800px) {
  .x-tbl td { white-space: nowrap; }
  .nav-group { display: contents; }
  .nav-group ul { display: contents; }
  .nav { display: flex; gap: 4px; align-items: center; }
  .nav li { display: contents; }
  .x-card { padding: 18px 16px; }
  .x-limit { grid-template-columns: 1fr; }
  .x-seg { display: flex; width: 100%; }
  .x-seg button { flex: 1 1 auto; padding: 0 6px; }
  .x-org { flex-direction: column; }
  .x-org-actions { width: 100%; justify-content: space-between; }
  .x-reg-row { flex-direction: column; }
  .x-kv { grid-template-columns: 1fr; gap: 2px; }
  .x-kv dd { margin-bottom: 8px; }
  .x-levels { grid-template-columns: 1fr; gap: 0; }
  .x-levels dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { .x-seg button { transition: none; } }

/* ---------- storage, direct mode, abuse, assistants, audit, quality ---------- */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; --viz-grid: rgba(0, 0, 0, 0.08); --viz-axis: rgba(0, 0, 0, 0.28); }
@media (prefers-color-scheme: dark) { :root { --viz-1: #3987e5; --viz-2: #d95926; --viz-grid: rgba(255, 255, 255, 0.09); --viz-axis: rgba(255, 255, 255, 0.3); } }
.x-h-gap { margin: 8px 0 8px; }
.x-inner { background: var(--bg-soft); margin: 10px 0 0; }
.x-person { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.x-gap { margin-right: 6px; }
.x-region { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; margin-top: 8px; }
.x-region .stat-note { margin: 0; }
.x-inline { display: flex; align-items: center; gap: 12px; }
.x-row-ctl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.x-chips-tight { margin-top: 4px; }
.x-detail { max-width: 26rem; color: var(--muted); font-size: var(--fs-sm); }
.x-steps { margin: 8px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.x-steps li + li { margin-top: 4px; }
.x-toolchips { gap: 6px; margin-top: 10px; }
.x-test { margin: 10px 0 0; font-size: var(--fs-md); color: var(--muted); }
.x-test:empty { display: none; }
.x-test-ok { color: var(--ok); }
.x-test-bad { color: var(--danger); }
.x-sto-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.x-sto-cell .raw { display: inline; }

/* slim bars: storage (amber and red steps at 80 and 95), one-hue magnitude bars */
.x-bar { display: inline-block; width: 84px; height: 6px; border-radius: 999px; background: var(--bg-soft2); vertical-align: middle; overflow: hidden; flex: none; }
.x-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--text); opacity: 0.55; }
.x-bar-warn > span { background: var(--accent); opacity: 1; }
.x-bar-bad > span { background: var(--danger); opacity: 1; }
.x-bar-viz > span { background: var(--viz-1); opacity: 1; }
.x-bar-down > span { background: var(--viz-2); opacity: 1; }
.x-bar-t { margin-left: 8px; font-variant-numeric: tabular-nums; }
.x-bars { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.x-bars li { display: grid; grid-template-columns: minmax(7rem, 12rem) minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.x-bars .x-bar { width: 100%; height: 8px; }
.x-bars-v { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

/* quality chart */
.q-chart { position: relative; margin-top: 14px; min-height: 220px; }
.q-svg { display: block; width: 100%; height: 220px; overflow: visible; }
.q-grid { stroke: var(--viz-grid); stroke-width: 1; }
.q-axis { stroke: var(--viz-axis); stroke-width: 1; }
.q-tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.q-up { fill: var(--viz-1); }
.q-down { fill: var(--viz-2); }
.q-hit { fill: transparent; }
.q-col { outline: none; }
.q-col:hover .q-hit, .q-col:focus .q-hit { fill: var(--bg-soft2); opacity: 0.6; }
.q-col:focus-visible .q-hit { stroke: var(--focus); stroke-width: 2; }
.q-tip { position: absolute; top: 0; z-index: 2; pointer-events: none; background: var(--panel); border-radius: 12px; padding: 8px 12px; font-size: var(--fs-sm); line-height: 1.5; white-space: nowrap; box-shadow: var(--shadow), inset 0 0 0 1px var(--hair); }
.q-tip[hidden] { display: none; }
.q-legend { display: flex; gap: 14px; font-size: var(--fs-sm); color: var(--muted); flex-wrap: wrap; }
.q-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.q-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.q-legend .q-sw { margin: 0; }
.q-sw-up { background: var(--viz-1); }
.q-sw-down { background: var(--viz-2); }

@media (max-width: 800px) {
  .x-bars li { grid-template-columns: minmax(0, 1fr) auto; }
  .x-bars li .x-bar { grid-column: 1 / -1; grid-row: 2; }
  .x-inline { flex-wrap: wrap; }
  .x-card-head { flex-wrap: wrap; }
  .x-detail { max-width: 16rem; }
}

/* tiles in one row where they fit */
.x-tiles { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
/* phone: marked tables become one card per row */
@media (max-width: 800px) {
  .x-cards, .x-cards tbody, .x-cards tr, .x-cards td { display: block; }
  .x-cards thead { display: none; }
  .x-cards tr { padding: 12px 16px; border-bottom: 1px solid var(--hair); }
  .x-cards tbody tr:last-child { border-bottom: 0; }
  .x-cards td, .x-tbl.x-cards td { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; border: 0; white-space: normal; text-align: right; }
  .x-cards td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-sm); text-align: left; flex: none; }
  .x-cards td[data-label=""]::before, .x-cards td:first-child::before { display: none; }
  .x-cards td:first-child { text-align: left; justify-content: flex-start; padding-bottom: 8px; }
  .x-cards td[data-label=""] { justify-content: flex-start; }
  .x-cards td.num { text-align: right; }
  .x-cards tbody tr:hover td { background: transparent; }
  .x-cards .x-error { text-align: left; }
  .x-cards td > .x-seg { width: auto; }
}
#dm-table .x-seg button { min-width: 66px; }
@media (max-width: 800px) { .x-cards td:first-child { flex-direction: column; align-items: flex-start; gap: 2px; } }
@media (max-width: 800px) {
  .x-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .x-tiles .stat { padding: 14px 16px; }
}
@media (max-width: 800px) { .x-cards td.x-stackcell { flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; } }

/* review queue, trust (assistants + connectors) */
.x-queue { margin-bottom: 18px; }
.x-queue-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.x-queue-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--warn-bg); }
.x-queue-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.x-rowact { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.x-facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 14px; }
.x-facts dt { color: var(--muted); font-size: var(--fs-md); }
.x-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.x-h3 { margin: 6px 0 8px; font-size: var(--fs-md); font-weight: 600; }
.x-instr { margin: 0; padding: 14px 16px; max-height: 40vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-soft, rgba(127,127,127,.12)); border-radius: 14px; }
.x-trust { margin-top: 14px; padding: 12px 16px; border-radius: 16px; background: rgba(127,127,127,.1); display: grid; gap: 8px; }
.x-trust-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.x-trust-row strong { font-weight: 600; }
.x-trust-t { margin: 0; color: var(--muted); font-size: var(--fs-md); line-height: 1.55; }
.x-flags { margin: 0 0 18px; padding: 14px 18px; border-radius: 16px; background: rgba(127,127,127,.1); }
.x-flags ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: var(--fs-md); line-height: 1.55; }
@media (max-width: 640px) { .x-queue-item { flex-direction: column; align-items: stretch; } .x-facts { grid-template-columns: 1fr; gap: 2px; } .x-facts dd { margin-bottom: 8px; } .x-trust-row { align-items: flex-start; } }
.x-sticky-actions { position: sticky; bottom: -24px; margin: 14px -24px -24px; padding: 14px 24px 24px; background: var(--panel); }
.x-instr { max-height: 32vh; }

/* ---------- workspaces, plans and overrides, model improvement ---------- */
.is-suspended td:first-child strong { opacity: 0.85; }
.is-expired { opacity: 0.7; }
.x-audit-items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; }
.x-audit-items li { padding: 10px 0; border-top: 1px solid var(--hair); display: flex; flex-direction: column; gap: 2px; }
.x-audit-items li:first-child { border-top: 0; }
.x-audit-line { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.x-auditlist .x-more { padding-top: 10px; }
.x-inner-tiles { margin-top: 12px; }
.x-card .x-tiles .stat { background: var(--bg-soft); }
.ws-detail-dlg .tbl-wrap, .ws-audit-dlg .x-auditlist { margin-top: 4px; }

.pl-limits { display: flex; flex-direction: column; }
.pl-limit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(10rem, 14rem); gap: 6px 16px; align-items: center; padding: 10px 0; border-top: 1px solid var(--hair); }
.pl-limit:first-child { border-top: 0; }
.pl-limit-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pl-limit-name { font-weight: 500; }
.pl-limit .x-seg { justify-self: end; }
.pl-dlg textarea { min-height: 4.5rem; resize: vertical; }
.pl-dlg #pl-date { max-width: 12rem; }
.pl-dlg #pl-date[hidden] { display: none; }

.im-modes { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.im-mode { padding: 12px 16px; border-radius: 16px; background: var(--bg-soft); }
.im-mode.is-current { box-shadow: inset 0 0 0 2px var(--accent); }
.im-mode-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.im-mode .x-sub { margin-top: 2px; }
.im-facts { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; max-width: 46rem; }
.im-facts li + li { margin-top: 6px; }
.im-facts strong { color: var(--text); font-weight: 600; }
.im-export-ctl { margin-top: 14px; }
.im-export-ctl select { height: var(--h-m); border-radius: 999px; padding: 0 14px; }
#im-status { margin-top: 12px; }
#im-export .banner { margin-top: 12px; }

@media (max-width: 800px) {
  .pl-limit { grid-template-columns: 1fr; }
  .pl-limit .x-seg { justify-self: stretch; }
}
.x-meter { display: inline-flex; flex-direction: column; gap: 5px; align-items: flex-start; }
#ws-table td:nth-child(1) { min-width: 10rem; }
#ws-table td:nth-child(2) { min-width: 9rem; }
@media (max-width: 800px) { .x-cards .x-meter { align-items: flex-end; } #ws-table td:nth-child(1), #ws-table td:nth-child(2) { min-width: 0; } }

.pl-limit input[type=number] { width: 100%; height: var(--h-field); font: inherit; font-size: var(--fs-lg); padding: 0 0.7rem; border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--panel); color: var(--text); font-variant-numeric: tabular-nums; }
.pl-limit input[type=number]:focus-visible { border-color: var(--accent-ring); outline: none; }
.pl-dlg input[type=text], .pl-dlg #pl-date { width: 100%; }
#pl-grant .x-add input, #pl-grant .x-add select { flex: 1 1 16rem; min-width: 0; max-width: 100%; }
#pl-grant .x-add select { text-overflow: ellipsis; }
#im-people-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#im-excluded li { grid-template-columns: minmax(11rem, 17rem) minmax(0, 1fr) 2.5rem; }
@media (max-width: 800px) { #im-people-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } #im-excluded li { grid-template-columns: minmax(0, 1fr) auto; } }
