/* =============================================================
   trova.css — Operator design system
   ============================================================= */

/* ── §01 DESIGN TOKENS ──────────────────────────────────────── */
/* Values come from the Trova Insights design system
   (design_handoffs/trova_ui_2026-10-07). The short names below (--accent,
   --text-2, --surface-2 ...) are the ones the existing rules already use, so
   they are re-pointed at the new palette rather than renamed. Note the
   design system's own --accent means orange; here --accent stays the action
   blue, and orange is --insight, reserved for one insight moment per view. */
:root {
  /* Design system palette */
  --navy:          #0A2140;
  --blue-50:       #F1F6FB;
  --blue-100:      #E1ECF6;
  --blue-200:      #C3DAEC;
  --blue-300:      #A0C4E1;
  --blue-400:      #7AADD3;
  --blue-500:      #3F7DB8;
  --blue-600:      #164F90;
  --blue-700:      #113F74;
  --grey-25:       #F8FAFC;
  --grey-50:       #F2F5F8;
  --grey-100:      #E6EBF0;
  --grey-200:      #D3DBE3;
  --grey-300:      #B5C1CD;
  --grey-400:      #8D9BAA;
  --grey-500:      #6A7988;
  --grey-700:      #36424F;
  --grey-900:      #141B23;
  --insight:       #F7941D;
  --insight-50:    #FEF4E7;
  --insight-100:   #FDE4C3;
  --insight-700:   #A85D06;

  /* Semantic aliases used throughout this file */
  --bg:            var(--grey-25);
  --surface:       #ffffff;
  --surface-2:     var(--grey-50);
  --surface-3:     var(--grey-100);
  --border:        var(--grey-100);
  --border-strong: var(--grey-200);
  --text:          var(--grey-900);
  --text-2:        var(--grey-700);
  --text-3:        var(--grey-500);
  --text-4:        var(--grey-400);

  --accent:        var(--blue-600);
  --accent-2:      var(--blue-700);
  --accent-tint:   var(--blue-50);
  --accent-tint-2: var(--blue-100);

  /* Each level's colour is its badge label on its own tint, at 12px, so it
     must clear 4.5:1 against that tint (and so against white too). These are
     the lightest of their hue that do. Keep TRUST_COLOURS in
     email_composer.py identical. */
  --verified:      #287A5D;
  --verified-tint: #E8F4EF;
  --informed:      #8C6912;
  --informed-tint: #FBF4E2;
  --general:       #62707E;
  --general-tint:  var(--grey-50);
  --danger:        #C2413A;
  --danger-tint:   #FBECEB;

  --radius:        6px;
  --radius-md:     8px;
  --radius-lg:     10px;
  --radius-xl:     14px;

  --font-body: 'Sweet Sans Pro', 'Avenir Next', system-ui, sans-serif;
  --font-num:  'Sweet Sans Pro', 'Avenir Next', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --shadow-xs:    0 1px 2px rgba(13,47,87,.06);
  --shadow-sm:    0 1px 3px rgba(13,47,87,.08), 0 1px 2px rgba(13,47,87,.04);
  --shadow-md:    0 4px 12px rgba(13,47,87,.08), 0 1px 3px rgba(13,47,87,.06);
  --shadow-lg:    0 12px 32px rgba(13,47,87,.12), 0 2px 6px rgba(13,47,87,.06);
  --shadow-focus: 0 0 0 3px rgba(122,173,211,.45);

  --ease:          cubic-bezier(.2,0,0,1);
  --dur-fast:      120ms;
  --dur-base:      180ms;

  --sidebar-w:     240px;
  --topbar-h:      56px;
  --inspector-w:   340px;
  --inspector-w-expanded: 660px;
}

/* ── §02 RESET / BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button  { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── §03 APP SIDEBAR ────────────────────────────────────────── */
/* The main menu on navy. Values are the design handoff's (2a), not rounded. */
.app-sidebar {
  width: var(--sidebar-w); flex: none; position: relative;
  background: var(--navy); color: var(--blue-200);
  display: flex; flex-direction: column; min-height: 0;
}
.sb-logo { display: block; padding: 22px 22px 20px; }
.sb-logo img { height: 30px; width: auto; display: block; }

.sb-menu {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 14px; display: flex; flex-direction: column; gap: 2px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 6px; background: transparent;
  font: 500 14px/1 var(--font-body); color: var(--blue-200);
  text-decoration: none; text-align: left; user-select: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sb-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.sb-item.is-active { background: rgba(122,173,211,.16); color: #fff; }
.sb-item:focus-visible, .sb-child:focus-visible, .sb-avatar:focus-visible {
  outline: none; box-shadow: var(--shadow-focus);
}
.sb-label { flex: 1; }
.sb-chevron { color: var(--grey-400); transition: transform var(--dur-fast) var(--ease); }
.sb-group-head[aria-expanded="false"] .sb-chevron { transform: rotate(-90deg); }

.sb-group { display: flex; flex-direction: column; gap: 2px; }
.sb-children { display: flex; flex-direction: column; gap: 1px; padding: 0 0 6px 36px; }
.sb-children[hidden] { display: none; }
.sb-child {
  display: block; padding: 7px 10px; border-radius: 6px;
  font: 400 13px/1.2 var(--font-body); color: var(--blue-200); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-child:hover { color: #fff; }
.sb-child.is-current { background: rgba(255,255,255,.07); color: #fff; }
.sb-empty, .sb-empty:hover { color: var(--grey-400); cursor: default; }

.sb-foot {
  border-top: 1px solid rgba(255,255,255,.08); padding: 14px 22px;
  display: flex; align-items: center; gap: 10px;
}
.sb-avatar {
  width: 32px; height: 32px; flex: none; border: 0; border-radius: 50%;
  background: var(--blue-600); color: #fff; font: 700 11px/32px var(--font-body);
  text-align: center; padding: 0;
  transition: background var(--dur-fast) var(--ease);
}
.sb-avatar:hover { background: var(--blue-500); }
.sb-avatar.is-open { box-shadow: var(--shadow-focus); }
.sb-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sb-who-name { font: 500 13px/1 var(--font-body); color: #fff; }
.sb-who-org {
  font: 400 12px/1 var(--font-body); color: var(--blue-300);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* The user menu opens upward from the footer. */
.sb-user-menu {
  position: absolute; left: 14px; bottom: 66px; width: 212px; z-index: 70;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.sb-user-menu[hidden] { display: none; }
.sb-user-menu-head {
  padding: 10px 10px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.sb-user-menu-name { font: 500 13px/1 var(--font-body); color: var(--text); }
.sb-user-menu-email { font: 400 12px/1 var(--font-body); color: var(--text-3); }
.sb-user-menu form { margin: 0; }
.sb-user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 6px; background: transparent;
  font: 400 13px/1 var(--font-body); color: var(--text-2); text-decoration: none; text-align: left;
}
.sb-user-menu-item .i { color: var(--text-3); }
.sb-user-menu-item:hover { background: var(--surface-2); color: var(--text-2); text-decoration: none; }
.sb-user-menu-rule { height: 1px; background: var(--border); margin: 4px 0; }

/* The help menu, opened from the user menu, anchors at the same spot. */
.app-sidebar .support-menu-host { top: auto; right: auto; left: 14px; bottom: 66px; }

/* Signed-out pages (sign-in, MFA, password reset, FAQs) carry only the logo. */
.public-bar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center;
  padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.public-bar-logo img { height: 26px; width: auto; display: block; }

/* Icons from the vendored Lucide sprite ({% icon %} in core_tags). */
.i { flex: none; display: inline-block; vertical-align: middle; }

/* ── §04 APP / WORKSPACE LAYOUT ─────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; }
.app.has-sidebar { flex-direction: row; }
.app-main {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
}

/* The report editor: canvas, then the Build / Ask Trova inspector. The
   inspector's column is always the narrow width; expanded, the inspector
   floats over the canvas rather than taking width from it (§20). */
.workspace {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0,1fr) var(--inspector-w);
  min-width: 860px;
  min-height: 0;
  overflow: hidden;
}

/* ── §06 PANEL BASE ─────────────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  min-width: 0;
}
.p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  height: 48px;
}
.p-head-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.p-head-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  border-radius: 4px;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 13px;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── §07 FIELDS (Build inspector, lower zone) ───────────────── */
.insp-fields {
  flex: 1 1 0; min-height: 180px; display: flex; flex-direction: column;
  background: var(--grey-25);
}
.insp-fields-head {
  padding: 14px 18px 8px; display: flex; align-items: center; gap: 10px; flex: none;
}
.insp-fields-view { font: 500 12px/1 var(--font-mono); color: var(--text-2); min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insp-fields-trusted { color: var(--verified); display: inline-flex; }
.insp-search {
  margin: 0 18px 6px; height: 32px; flex: none;
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  color: var(--text-3);
}
.insp-search:focus-within { border-color: var(--blue-400); box-shadow: var(--shadow-focus); }
.insp-search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: 400 13px/1 var(--font-body); color: var(--text);
}
.insp-search input::placeholder { color: var(--text-3); }

.sv-body { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 10px 14px; }

.sv-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 4px; font: 800 10px/1 var(--font-body);
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-3);
}
.sv-section:first-child .sv-section-head { padding-top: 8px; }

.sv-field {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px;
  border-radius: var(--radius); font: 400 13px/1.2 var(--font-body); color: var(--text-2);
  user-select: none;
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.sv-field[draggable="true"] { cursor: grab; }
.sv-field[draggable="true"]:hover { background: var(--surface); box-shadow: var(--shadow-xs); }
.sv-field.dragging { opacity: .45; cursor: grabbing; }
.sv-field .sv-grip { color: var(--grey-300); }
.sv-field .sv-type { color: var(--text-3); }
.sv-field .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-field .info-icon {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 1px solid currentColor; color: var(--text-4);
  font: 600 9px/12px var(--font-body); text-align: center; font-style: italic;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease); cursor: default;
}
.sv-field:hover .info-icon { opacity: 1; }
.sv-field-empty { font-size: 12px; color: var(--text-3); padding: 8px; }

/* Field tooltip */
#field-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  width: 240px;
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity .12s ease, transform .12s ease;
}
#field-tooltip.show { opacity: 1; transform: translateX(0); }
#field-tooltip::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 14px;
  width: 10px;
  height: 10px;
  background: var(--text);
  transform: rotate(45deg);
  border-radius: 1px;
}
#field-tooltip .ft-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
#field-tooltip .ft-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  color: var(--surface);
}
#field-tooltip .ft-kind {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
#field-tooltip .ft-kind.dim  { background: rgba(255,255,255,.12); color: #d4d6dc; }
#field-tooltip .ft-kind.met  { background: rgba(99,144,246,.25); color: #a8c1f5; }
#field-tooltip .ft-kind.fact { background: rgba(255,255,255,.1); color: #b0b3bc; }
#field-tooltip .ft-desc { color: rgba(255,255,255,.85); margin-bottom: 6px; font-size: 11px; }
#field-tooltip .ft-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 10.5px;
  padding-top: 5px;
  border-top: 1px solid rgba(255,255,255,.1);
}
#field-tooltip .ft-key {
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 9.5px;
  font-weight: 600;
}
#field-tooltip .ft-val {
  color: rgba(255,255,255,.9);
  font-family: var(--font-mono);
  text-align: right;
  font-size: 10px;
}

/* ── §08 WIDGET BUILDER (Build inspector, upper zone) ───────── */
.insp-builder {
  flex: 0 1 auto; max-height: 62%; min-height: 0;
  display: flex; flex-direction: column;
  border-bottom: 1px solid var(--border); background: var(--surface);
}

.builder-tabs {
  display: flex;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  height: 40px;
  box-sizing: border-box;
}
.builder-tab {
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.builder-tab:hover { color: var(--text); }
.builder-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.builder-tab .badge {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  background: var(--accent-tint);
  color: var(--accent);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
}

.builder-tab-content { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.builder-tab-content.active { display: flex; }

/* Chart type SVG buttons: four across, and eight when the inspector is
   widened, so they stay about the same size rather than doubling with it.
   A fixed count rather than auto-fill, which tipped to three across in the
   narrow pane once its padding and scrollbar were taken out. */
.chart-types {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 12px 12px 0;
}
.chart-type {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  transition: all .12s;
  padding: 6px 2px;
}
.chart-type:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.chart-type.active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.chart-type svg {
  width: 20px;
  height: 20px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-type .ct-fill { fill: currentColor; stroke: none; opacity: 0.85; }
.chart-type.active svg { stroke: var(--accent); }
.chart-type.active .ct-fill { fill: var(--accent); }
.chart-type .ct-label { color: inherit; }
body.inspector-expanded .chart-types { grid-template-columns: repeat(8, 1fr); }

/* Chart picker (picker area wrapper) */
.chart-picker-section { padding: 12px 12px 14px; border-bottom: 1px solid var(--border); }
.chart-picker-hint { font-size: 11px; color: var(--text-3); margin-bottom: 10px; }

/* Builder sections (inside form state) */
.builder-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.builder-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.builder-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}
.field-stack { display: flex; flex-direction: column; gap: 10px; }
.field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field-label .req  { color: var(--danger); margin-left: 2px; }
.field-label .hint { color: var(--text-3); font-weight: 400; font-size: 10px; }

.input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}
.input:hover  { border-color: var(--border-strong); }
.input:focus  { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%238b8f99' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* Drop slots */
.drop-slot {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 12px;
  color: var(--text-3);
  transition: all .12s;
}
.drop-slot.drag-over { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }
.drop-slot.invalid   { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }
.drop-slot.slot-eligible { border-color: var(--accent); border-style: dashed; }
.drop-slot.slot-eligible:not(.drag-over) { background: var(--accent-tint); opacity: 0.7; }
.drop-slot.has-value { border-style: solid; border-color: var(--border); background: var(--surface); color: var(--text); }
.slot-placeholder { color: var(--text-4); font-style: italic; font-size: 11px; }
.slot-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.slot-pill .kind-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  flex-shrink: 0;
}
.slot-pill .kind-tag.dim  { background: var(--general-tint); color: var(--general); }
.slot-pill .kind-tag.met  { background: var(--accent-tint);  color: var(--accent); }
.slot-pill .field-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.slot-pill .x {
  width: 18px;
  height: 18px;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 11px;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
}
.slot-pill .x:hover { background: var(--surface-3); color: var(--danger); }

/* Builder actions */
.builder-actions {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  line-height: 1;
  transition: all .12s;
  white-space: nowrap;
}
.btn-primary   { background: var(--accent);  color: var(--surface); border-color: var(--accent);        flex: 1; }
.btn-primary:hover  { background: var(--accent-2); border-color: var(--accent-2); }
.btn-secondary { background: var(--surface); color: var(--text);    border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost     { background: transparent;    color: var(--text-2); }
.btn-ghost:hover    { background: var(--surface-2); color: var(--text); }
.btn-sm  { padding: 5px 9px; font-size: 11px; }
.btn-icon { padding: 5px; }

/* Legacy builder form styles (combo, waterfall, table, data_grid) */
.builder-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: block;
}
.builder-required { color: var(--danger); }
.builder-hint { font-size: 10px; color: var(--text-3); font-weight: 400; text-transform: none; letter-spacing: 0; }
.builder-hint-block { font-size: 11px; color: var(--text-3); padding: 6px 14px; }
.builder-errors { padding: 8px 14px; background: var(--danger-tint); border-bottom: 1px solid #f8c4b8; }
.builder-error  { font-size: 12px; color: var(--danger); margin-bottom: 2px; }
.builder-select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
}
.builder-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.cb-checkbox-row { display: flex; flex-direction: column; gap: 2px; }
.cb-checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); cursor: pointer; }
.check-list { display: flex; flex-direction: column; gap: 3px; max-height: 160px; overflow-y: auto; }
.check-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); cursor: pointer; padding: 2px 0; }
.check-item input[type="checkbox"] { margin: 0; flex-shrink: 0; }
.col-type-badge { font-size: 9px; color: var(--text-3); border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; }
.col-type-badge.metric { color: var(--accent); border-color: var(--accent-tint-2); }
.table-col-note { font-size: 10px; color: var(--text-3); margin-bottom: 6px; }
.btn-add-filter {
  margin-top: 5px;
  font-size: 11px;
  color: var(--accent);
  background: none;
  border: 1px dashed var(--accent-tint-2);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  width: 100%;
}
.btn-add-filter:hover { background: var(--accent-tint); }
.size-opts { display: flex; flex-direction: column; gap: 4px; }
.size-opt { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); cursor: pointer; }
.gauge-range-row { display: flex; gap: 10px; }
.gauge-range-row > div { flex: 1; }
.gauge-range-input { width: 100%; padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 12px; background: var(--surface); }

/* Number format controls, below a widget's metric slot */
.nf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
/* The select turns red while a red negative is chosen, and its options would
   inherit that, so each option sets its own colour. */
.builder-select:has(option.nf-negative-red:checked) { color: var(--danger); }
.builder-select option { color: var(--text); }
.builder-select option.nf-negative-red { color: var(--danger); }
.kpi-value.is-negative { color: var(--danger); }

/* Text widget fields */
.text-content-input { resize: vertical; font-family: inherit; box-sizing: border-box; }
.text-style-row { display: flex; gap: 10px; align-items: flex-end; }
.text-style-row > div:first-child { flex: 1; }
.text-font-size-input { width: 100%; padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 12px; background: var(--surface); }
.text-color-input { width: 36px; height: 30px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.chart-type-tabs { display: flex; flex-wrap: wrap; gap: 3px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.chart-tab { padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); font-size: 11px; color: var(--text-2); cursor: pointer; }
.chart-tab:hover  { background: var(--accent-tint); color: var(--accent); border-color: var(--accent-tint-2); }
.chart-tab.active { background: var(--accent-tint); color: var(--accent-2); border-color: var(--accent-tint-2); font-weight: 600; }
#widget-title-input { width: 100%; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 12px; font-family: inherit; color: var(--text); background: var(--surface); }
#widget-title-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.combo-series-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; margin-bottom: 6px; background: var(--surface); }
.combo-row-fields { display: flex; gap: 4px; margin-bottom: 4px; }
.combo-metric { flex: 2; min-width: 0; }
.combo-render, .combo-axis { flex: 1; min-width: 0; }
.combo-row-secondary { display: flex; gap: 4px; align-items: center; }
.combo-label-input, .combo-stack-input { flex: 1; font-size: 11px; padding: 4px 6px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); min-width: 0; }
.combo-remove-btn { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 12px; padding: 2px 4px; flex-shrink: 0; }
.combo-remove-btn:hover { color: var(--danger); }

/* ── §09 CANVAS ─────────────────────────────────────────────── */
.panel-canvas { background: var(--bg); }

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  height: var(--topbar-h);
  flex-shrink: 0;
}
.canvas-title {
  font: 500 17px/1.2 var(--font-body);
  color: var(--text);
  border-radius: 4px;
  padding: 2px 4px;
  margin-left: -4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.canvas-title[onclick] { cursor: pointer; }
.canvas-title[onclick]:hover { background: var(--surface-2); }
.canvas-title-input {
  font: 500 17px/1.2 var(--font-body);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--blue-400);
  box-shadow: var(--shadow-focus);
  border-radius: 4px;
  padding: 1px 4px;
  outline: none;
  width: 280px;
}
.canvas-meta {
  font: 400 12px/1 var(--font-mono);
  color: var(--text-3);
  white-space: nowrap;
}
.canvas-spacer { flex: 1; }

/* Save button pill — hidden until unsaved changes exist */
.save-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  background: transparent;
  color: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: default;
  visibility: hidden;
}
.save-btn.unsaved {
  visibility: visible;
  background: #cc5500;
  color: #fff;
  border-color: #cc5500;
  cursor: pointer;
}
.save-btn.saving {
  visibility: visible;
  background: var(--surface-3);
  color: var(--text-2);
  border-color: var(--border);
  cursor: default;
}
.save-btn .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.save-btn.unsaved .dot { background: rgba(255, 255, 255, 0.6); }
.save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── §10b FILTER HEADER BAR — interactive controls ─────────── */
.filter-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px 28px 0;
  flex-shrink: 0;
}
.filter-bar-hidden { display: none !important; }

/* One section per filter dimension */
.fv-section {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  position: relative;
}
.fv-section-date { padding: 0 4px 0 0; border: 0; background: transparent; }
/* "+ Filter": opens the Filters tab of the Build inspector. */
.fv-add {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px dashed var(--border-strong); border-radius: 999px; background: transparent;
  font: 500 12px/1 var(--font-body); color: var(--text-3);
}
.fv-add:hover { border-color: var(--blue-400); color: var(--blue-600); background: var(--blue-50); }
.fv-section:last-child { border-right: none; margin-right: 0; }

.fv-dim-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  white-space: nowrap;
}

/* Remove button (×) for each filter section */
.fv-remove {
  width: 16px; height: 16px;
  border: none; background: none;
  color: var(--text-4); font-size: 10px;
  border-radius: 3px; line-height: 1;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.fv-remove:hover { background: var(--surface-3); color: var(--danger); }

/* Categorical chip form wrapper */
.fv-chip-form { display: flex; align-items: center; gap: 3px; }

/* Individual value chips (selected = on, deselected = off) */
.fv-chip {
  padding: 2px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  line-height: 1.5;
}
.fv-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.fv-chip:hover:not(.on) { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.fv-sel-inputs { display: none; }   /* hidden inputs, not rendered */

/* ────────── Date filter trigger (collapsed, in filter bar) ────────── */
.fv-section-date {
  position: relative;
  gap: 8px;
}

.fv-date-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
}
.fv-date-trigger:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.fv-date-trigger.open {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}

.fv-trigger-active {
  font-size: 12px;
  font-weight: 600;
  color: inherit;
}
.fv-trigger-active.custom {
  font-style: italic;
  font-weight: 500;
}

.fv-trigger-sep {
  color: var(--text-4);
  font-size: 11px;
}
.fv-date-trigger.open .fv-trigger-sep {
  color: var(--accent);
  opacity: 0.5;
}

.fv-trigger-range {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.fv-date-trigger.open .fv-trigger-range {
  color: var(--accent-2);
}
.fv-trigger-range .arr {
  color: var(--text-4);
  margin: 0 3px;
}
.fv-date-trigger.open .fv-trigger-range .arr {
  color: var(--accent);
  opacity: 0.6;
}
.fv-trigger-range.empty {
  font-family: inherit;
  font-style: italic;
  color: var(--text-4);
  font-size: 11px;
}

.fv-trigger-duration {
  font-size: 10px;
  color: var(--text-3);
  font-style: italic;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.fv-date-trigger.open .fv-trigger-duration {
  color: var(--accent);
  border-left-color: var(--accent-tint-2);
}

.fv-trigger-caret {
  color: var(--text-3);
  margin-left: 2px;
}
.fv-date-trigger.open .fv-trigger-caret {
  color: var(--accent);
}

/* ────────── Popover ────────── */
.fv-date-popover-wrap {
  position: relative;
  display: inline-flex;
}
.fv-date-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 8px rgba(15,17,23,0.08), 0 12px 32px rgba(15,17,23,0.06);
  z-index: 200;
  overflow: hidden;
}
.fv-date-popover::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 26px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.fv-date-popover[hidden] { display: none; }

/* ────────── Date filter component (shared bar/panel) ────────── */
.df-component {
  display: flex;
  flex-direction: column;
}
.df-component-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.df-component-section:last-child {
  border-bottom: none;
}

/* Resolved date readback header */
.df-resolved-header {
  background: var(--surface-2);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.df-resolved-header .label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 4px;
}
.df-resolved-header .value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.df-resolved-header .value .arr { color: var(--text-4); }
.df-resolved-header .value .duration {
  font-family: inherit;
  font-style: italic;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 400;
}

/* Mode tabs — segmented control */
.df-mode-tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.df-tab {
  flex: 1;
  padding: 5px 8px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  line-height: 1.4;
  transition: color 0.12s, background 0.12s;
}
.df-tab:hover { color: var(--text); }
.df-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15,17,23,0.04);
  font-weight: 600;
}

/* Mode-specific input rows */
.df-mode-panel {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.df-mode-panel[hidden] { display: none; }
.df-rel-label,
.df-mode-label {
  font-size: 12px;
  color: var(--text-2);
}

/* Stepper number input */
.df-stepper {
  display: inline-flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  height: 30px;
}
.df-stepper .step {
  width: 22px;
  border: none;
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.df-stepper .step:hover { background: var(--surface-2); color: var(--text); }
.df-stepper .step:not(:last-child),
.df-stepper .step + input { border-right: 1px solid var(--border); }
.df-stepper input {
  width: 38px;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  -moz-appearance: textfield;
}
.df-stepper input::-webkit-outer-spin-button,
.df-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.df-stepper input:focus { outline: none; }

/* Select (period in Relative mode) */
.df-select {
  height: 30px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%238b8f99' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  font-family: inherit;
}
.df-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Styled date input wrapper (Range / Starting / Ending modes) */
.df-date-input {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  flex: 1;
  min-width: 130px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.df-date-input:hover { border-color: var(--text-3); }
.df-date-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.df-date-input svg {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  flex-shrink: 0;
  pointer-events: none;
}
.df-date-input .display {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.df-date-input input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  z-index: 1;
}

/* Apply button */
.df-apply-row {
  padding-top: 10px;
}
.df-apply-btn {
  width: 100%;
  padding: 7px 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
}
.df-apply-btn:hover { opacity: 0.88; }
.df-apply-btn:active { opacity: 0.75; }

/* Range row layout */
.df-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.df-range-row .arrow {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ────────── Panel layout (chart builder, 280px) ────────── */
.df-layout-panel .df-resolved-header {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 12px;
  padding: 10px 12px;
}
.df-layout-panel .df-resolved-header .value { font-size: 12px; }
.df-layout-panel .df-component-section {
  padding: 0;
  border-bottom: none;
  margin-bottom: 12px;
}
.cb-date-filter-wrap { margin-bottom: 8px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.cb-date-filter-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }

/* Numeric filter */
.fv-num-form { display: flex; align-items: center; gap: 4px; }
.fv-num-input {
  width: 72px; font-size: 11px; padding: 2px 6px;
  border: 1px solid var(--border-strong); border-radius: 3px;
  background: var(--surface); color: var(--text);
}
.fv-num-sep { color: var(--text-3); font-size: 11px; }

/* Boolean filter (three radio chips: All / Yes / No) */
.fv-bool-form { display: flex; gap: 3px; align-items: center; }

/* High-cardinality dropdown */
.fv-hc-wrap { position: relative; }
.fv-hc-toggle {
  padding: 2px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
}
.fv-hc-toggle:hover { background: var(--surface-2); }
.fv-hc-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 8px;
  min-width: 200px;
}
.fv-hc-search {
  width: 100%; box-sizing: border-box;
  padding: 4px 8px; font-size: 11px;
  border: 1px solid var(--border); border-radius: 3px;
  background: var(--surface); color: var(--text);
  margin-bottom: 6px;
}
.fv-hc-list { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.fv-hc-item { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 2px; font-size: 11px; cursor: pointer; }
.fv-hc-item:hover { background: var(--surface-2); }
.fv-hc-item input[type=checkbox] { margin: 0; cursor: pointer; }
.fv-hc-actions { display: flex; gap: 4px; margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
/* "Select all": outside the scrolling list so it stays in view, and not a
   .fv-hc-item so the search never hides it. */
.fv-hc-all { display: flex; align-items: center; gap: 6px; padding: 3px 4px 5px; margin-bottom: 3px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; cursor: pointer; }
.fv-hc-all input[type=checkbox] { margin: 0; cursor: pointer; }
.fv-hc-apply { flex: 1; font-size: 10px; padding: 3px 4px; border: none; border-radius: 3px; background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.fv-hc-apply:hover { background: var(--accent-2); }

/* Canvas scroll area */
.canvas-scroll { padding: 14px 28px 28px; flex: 1; overflow-y: auto; }
.dashboard-canvas { min-height: 100%; }

/* Gridstack */
.grid-stack { background: transparent; }
/* overflow visible so a selected widget's ring and Editing tag are not clipped. */
.grid-stack-item-content { border-radius: 0; background: transparent; overflow: visible !important; }
/* Position SE/SW resize handles at the correct corner (missing from vendor CSS) */
.grid-stack-item > .ui-resizable-se { bottom: 0; right: 0; }
.grid-stack-item > .ui-resizable-sw { bottom: 0; left: 0; }

/* ── §10 WIDGET CHROME ──────────────────────────────────────── */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: box-shadow var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
  position: relative;
}
.widget.is-selectable { cursor: pointer; }
.widget.is-selectable:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.widget > .w-body { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
/* The widget being edited in Build. The tag sits on the border, so the card
   and its gridstack wrapper must not clip it. */
.widget.is-selected,
.widget.is-selected:hover {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(122,173,211,.35);
}
.w-editing-tag {
  display: none; position: absolute; top: -11px; left: 14px; z-index: 6;
  background: var(--blue-600); color: #fff; font: 600 11px/1 var(--font-body);
  padding: 5px 8px; border-radius: 4px; pointer-events: none;
}
.widget.is-selected .w-editing-tag { display: block; }

.w-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px 8px;
  flex-shrink: 0;
  gap: 8px;
}
.w-title-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.w-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.w-title {
  font: 500 15px/1.2 var(--font-body);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.w-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s;
}
.widget:hover .w-actions { opacity: 1; }

.w-body {
  flex: 1;
  padding: 0 14px 14px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.w-body.metric  { justify-content: center; }
.w-body.no-pad  { padding: 0; }
.w-body.text    { padding: 0; }
.widget-text-content {
  width: 100%; height: 100%; box-sizing: border-box;
  padding: 12px 16px; overflow: auto;
  border-radius: var(--radius-lg);
  white-space: pre-wrap; word-break: break-word;
  line-height: 1.4;
}
/* Text widgets have no header bar (content-only, no title) -- the delete icon floats
   over the content instead, revealed on hover like .w-actions does for other widgets.
   A translucent backdrop keeps it visible regardless of the widget's own bg/text color. */
.widget-text-delete {
  position: absolute; top: 6px; right: 6px; z-index: 5;
  opacity: 0; transition: opacity .12s;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(2px);
  box-shadow: var(--shadow-sm);
}
.widget:hover .widget-text-delete { opacity: 1; }

/* Trust badge — tinted pill: solid glyph circle, level name, explanation on hover */
.trust {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 4px;
  border-radius: 999px;
  flex-shrink: 0;
  position: relative;
  cursor: help;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.trust-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: currentColor;
}
.trust-icon svg { width: 10px; height: 10px; display: block; color: #fff; }
.trust-head { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 6px; }
.trust-note { font-size: 11px; line-height: 1.4; color: var(--text-3); }
.trust .tt {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(-2px);
  background: var(--text);
  color: var(--surface);
  font-size: 10px;
  font-weight: 500;
  padding: 4px 7px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s, transform .12s;
  z-index: 50;
}
.trust .tt::before {
  content: '';
  position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%);
  border: 3px solid transparent;
  border-bottom-color: var(--text);
}
.trust:hover .tt { opacity: 1; transform: translateX(-50%) translateY(0); }
.trust--verified { background: var(--verified-tint); color: var(--verified); }
.trust--informed { background: var(--informed-tint); color: var(--informed); }
.trust--general  { background: var(--general-tint);  color: var(--general); }

/* Widget filter indicator */
.widget-filter-badge { font-size: 10px; color: var(--accent); cursor: default; line-height: 1; }
.widget-filter-badge.muted { color: var(--text-4); }

/* Widget error */
.widget-error { font-size: 12px; color: var(--danger); background: var(--danger-tint); padding: 12px; border-radius: 4px; width: 100%; }

/* KPI / Metric card */
.kpi-value {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
}
.kpi-comparison { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; }
.kpi-comparison.good { color: #3ba272; }
.kpi-comparison.bad  { color: #ee6666; }
.kpi-delta { font-weight: 700; }

/* Widget grid (native table) */
.widget-grid-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tgrid-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tgrid-scroll { flex: 1; min-height: 0; overflow: auto; }
.tgrid-foot {
  flex-shrink: 0;
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-4);
  background: var(--surface);
}

table.tgrid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }

/* header */
.tgrid thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  color: var(--text-3); text-align: left; padding: 8px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.tgrid thead th:first-child { padding-left: 16px; }
.tgrid thead th:last-child  { padding-right: 16px; }
.tgrid thead th.num { text-align: right; }
.tgrid thead th:hover { color: var(--text); }
.tgrid thead th.sorted { color: var(--text); }
.sort-ind {
  display: inline-flex; width: 12px; height: 12px; margin-left: 3px; vertical-align: middle;
  opacity: 0; transition: opacity 0.12s, transform 0.12s; color: var(--text-3);
}
.sort-ind svg { width: 12px; height: 12px; }
.tgrid thead th:hover .sort-ind { opacity: 0.45; }
.sort-ind.on { opacity: 1; color: var(--accent); }
.sort-ind.on.asc { transform: rotate(180deg); }

/* cells */
.tgrid tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tgrid tbody td:first-child { padding-left: 16px; }
.tgrid tbody td:last-child  { padding-right: 16px; }
.tgrid td.num { text-align: right; }
.tgrid tbody tr:hover td { background: var(--surface-2); }

/* totals row */
.tgrid tfoot td {
  position: sticky; bottom: 0; z-index: 3;
  background: var(--surface-2); border-top: 1px solid var(--border-strong);
  padding: 8px 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tgrid tfoot td:first-child { padding-left: 16px; }
.tgrid tfoot td:last-child  { padding-right: 16px; }
.tgrid tfoot td.num { text-align: right; }
.tgrid tfoot td.t-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); font-weight: 700; }
.t-tag { font-family: var(--mono, monospace); font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-4); font-weight: 600; margin-right: 5px; }

/* group rows */
.g-row td { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.g-row.collapsed td { border-bottom-color: var(--border-strong); }
.g-head-cell {
  cursor: pointer; display: flex; align-items: center; gap: 7px;
  padding: 7px 12px 7px 16px; white-space: nowrap;
}
.g-caret { display: inline-flex; width: 13px; height: 13px; color: var(--text-3); transition: transform 0.14s; flex-shrink: 0; }
.g-caret svg { width: 13px; height: 13px; }
.g-caret.open { transform: rotate(90deg); }
.g-name { font-weight: 600; color: var(--text); font-size: 12px; }
.g-count {
  font-size: 10px; color: var(--text-3); font-weight: 500;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 6px; line-height: 16px;
}
.g-sub { color: var(--text-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.g-sub.num { text-align: right; }

/* qb_pnl widget */
.qbpnl-meta {
  flex-shrink: 0; padding: 6px 16px; font-size: 11px; color: var(--text-3);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.qbpnl-scroll { flex: 1; min-height: 0; overflow: auto; }
.qbpnl-col-amt { width: 140px; }

.qbpnl-table .pnl-num {
  font-variant-numeric: tabular-nums; text-align: right; width: 140px;
}

.qbpnl-row td { padding: 7px 12px; border-bottom: 1px solid var(--border); }

.qbpnl-row[data-row-type="section_header"][data-depth="0"] td {
  background: var(--surface-2); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-2); font-weight: 500;
}
.qbpnl-row[data-row-type="section_header"]:not([data-depth="0"]) td {
  font-weight: 500; color: var(--text);
}
.qbpnl-row[data-row-type="account"] td { font-weight: 400; color: var(--text); }
.qbpnl-row[data-row-type="subtotal"] td {
  font-weight: 600; color: var(--text); border-top: 0.5px solid var(--border);
}
.qbpnl-row[data-row-type="section_total"] td {
  font-weight: 600; color: var(--text);
  border-top: 0.5px solid var(--border-strong); background: var(--surface-2);
}
.qbpnl-row[data-row-type="computed_total"] td {
  font-weight: 600; font-size: 14px; color: var(--text);
  border-top: 0.5px solid var(--border-strong); border-bottom: 0.5px solid var(--border-strong);
  padding: 10px 12px; background: var(--surface-2);
}
.qbpnl-row[data-row-type="computed_total"][data-final="true"] td {
  border-bottom: 3px double var(--border-strong);
}
.qbpnl-row[data-row-type="spacer"] td { height: 10px; padding: 0; border: none; background: transparent; }

.qbpnl-caret {
  display: inline-block; width: 10px; color: var(--text-3); font-size: 8px;
  margin-right: 6px; transition: transform 0.15s; text-align: center; user-select: none;
}
.qbpnl-row.collapsed .qbpnl-caret { transform: rotate(-90deg); }
.qbpnl-row[data-collapse-target] { cursor: pointer; }

.qbpnl-empty-cell {
  text-align: center; padding: 40px 16px; color: var(--text-3); font-size: 13px; border: none;
}

/* export dropdown (in widget header) */
.export-wrap { position: relative; }
.grid-export-menu {
  position: absolute; top: calc(100% + 6px); right: 0; width: 160px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg, 8px);
  box-shadow: 0 4px 8px rgba(15,17,23,0.08), 0 12px 32px rgba(15,17,23,0.06);
  z-index: 50; padding: 5px; overflow: hidden;
}
.export-menu-lbl {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-4); padding: 5px 8px 4px; font-weight: 600;
}
.grid-export-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: none; cursor: pointer; text-align: left;
  padding: 7px 8px; border-radius: 5px; font-size: 12px; font-weight: 500; color: var(--text);
}
.grid-export-menu button:hover { background: var(--surface-2); }
.grid-export-menu button svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.grid-export-menu .ext { margin-left: auto; font-size: 10px; color: var(--text-4); }

/* Canvas empty state */
.canvas-empty { padding: 60px 24px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ── §11 GLOBAL FILTER MANAGEMENT IN BUILDER ────────────────── */
.cb-filter-section    { border-bottom: 1px solid var(--border); padding-bottom: 2px; }
.cb-filter-section-hd { padding: 8px 14px 4px; }
.cb-section-title     { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; }
.cb-add-btn-wrap { padding: 4px 14px 2px; }
.btn-add-gf {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  font-size: 11px; color: var(--accent); background: none;
  border: 1px dashed var(--accent-tint-2); border-radius: var(--radius);
  padding: 5px 8px; cursor: pointer;
}
.btn-add-gf:hover { background: var(--accent-tint); }
.cb-active-filters { padding: 2px 14px 6px; display: flex; flex-direction: column; gap: 4px; }
.cb-filter-chip {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent-tint); border: 1px solid var(--accent-tint-2);
  border-radius: var(--radius); padding: 4px 8px; font-size: 11px; color: var(--accent-2);
}
.cb-chip-label   { flex: 1; }
.cb-chip-remove  { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 11px; padding: 0 2px; line-height: 1; flex-shrink: 0; }
.cb-chip-remove:hover { color: var(--danger); }
.cb-filter-empty { font-size: 12px; color: var(--text-4); padding: 4px 14px 8px; }
/* Add-filter form (dimension-only picker) */
.gf-add-form-wrap { padding: 6px 14px 8px; border-top: 1px solid var(--border); }
.gf-actions { display: flex; gap: 6px; margin-top: 8px; }
.btn-gf-apply { flex: 1; padding: 5px 8px; background: var(--accent); color: var(--surface); border: none; border-radius: var(--radius); font-size: 11px; font-weight: 600; cursor: pointer; }
.btn-gf-apply:hover { background: var(--accent-2); }
.btn-gf-clear { flex: 1; padding: 5px 8px; background: var(--surface); color: var(--text-2); border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 11px; cursor: pointer; }
.btn-gf-clear:hover { background: var(--surface-2); }
.widget-filter-badge-text { font-size: 10px; color: var(--accent); cursor: default; }

/* Widget Filters section (inline in Chart Builder Chart tab, Apply-gated).
   Compact popover redesign — see design_handoffs/widget_filters/README.md. Each filter
   collapses to a one-line trigger (.ftrig); clicking opens a floating popover (.fpop)
   that gets reparented to <body> with position:fixed while open (see wfTogglePopover in
   dashboard.html) because .panel / #cb-builder-section both clip overflow, which would
   otherwise cut off a plain position:absolute popover. */
.wf-section { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 10px 0; }
.wf-control { position: relative; margin: 0 14px 10px; }
.wf-control:last-of-type { margin-bottom: 4px; }
.wf-hc-wrap { position: static; }
.wf-apply-row { padding: 8px 14px 4px; }
.wf-local-confirm { display: block; font-size: 11px; color: var(--text-3); margin-top: 6px; }

/* Trigger row */
.ftrig {
  display: flex; align-items: center; gap: 6px; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 8px 10px; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.ftrig:hover { border-color: var(--border-strong); }
.ftrig.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.fdim {
  font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); font-weight: 700; flex-shrink: 0;
}
.fsummary { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 5px; overflow: hidden; white-space: nowrap; }
.fsummary .fpreset { font-size: 12px; font-weight: 600; color: var(--text); }
.fsummary .frange { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.fremove {
  width: 18px; height: 18px; border: none; background: none; color: var(--text-4);
  border-radius: 4px; flex-shrink: 0; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; padding: 0;
}
.fremove:hover { background: var(--surface-3); color: var(--danger); }
.fremove svg { width: 11px; height: 11px; }
.fchev { width: 12px; height: 12px; color: var(--text-3); flex-shrink: 0; }
.fchev svg { width: 12px; height: 12px; }

/* Popover editor */
.fpop {
  width: 252px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 12px;
  z-index: 500; display: none;
}
.fpop.show { display: block; }
.fpop-title {
  font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); font-weight: 700; margin-bottom: 8px;
}

.showing { background: var(--surface-2); border-radius: 6px; padding: 6px 9px; margin-bottom: 8px; font-size: 11px; color: var(--text-3); }
.showing b { color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 600; }

/* Select control (date preset picker; reused for numeric unit select) */
.fselect {
  width: 100%; appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 12px; font-weight: 500;
  padding: 7px 26px 7px 9px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f99' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px;
}
.fselect:focus { outline: none; border-color: var(--accent); }

/* Segmented Relative/Range toggle */
.mode-seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px; margin-top: 8px; }
.mode-seg button { flex: 1; border: none; background: none; font-size: 10.5px; font-weight: 500; color: var(--text-3); padding: 4px 4px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.mode-seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

/* Relative stepper row */
.stepper-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.stepper-row .lbl { font-size: 11.5px; color: var(--text-2); flex-shrink: 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex-shrink: 0; }
.stepper button { width: 22px; height: 26px; border: none; background: var(--surface-2); color: var(--text-2); font-size: 13px; cursor: pointer; line-height: 1; }
.stepper button:hover { background: var(--surface-3); }
.stepper input { width: 30px; height: 26px; border: none; text-align: center; font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.stepper input:focus { outline: none; }
.unit-select { flex: 1; min-width: 0; }

/* Range date pickers (date Range mode) and numeric min/max -- shared primitive */
.range-inputs { display: flex; gap: 6px; margin-top: 8px; }
.range-inputs input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; font-size: 11.5px; color: var(--text); }
.range-inputs input:focus { outline: none; border-color: var(--accent); }

/* Chip row -- text (low-cardinality) and boolean -- shared primitive */
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-row button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; font-size: 10.5px; font-weight: 500; color: var(--text-2); padding: 4px 9px; cursor: pointer; white-space: nowrap; }
.chip-row button.on { background: var(--text); border-color: var(--text); color: #fff; font-weight: 600; }

/* ── §12 CHAT PANEL ─────────────────────────────────────────── */
.panel-chat { background: var(--surface); }

.chat-usage { font-size: 10px; font-weight: 500; color: var(--text-3); text-transform: none; letter-spacing: 0; }
.chat-usage--warning { color: var(--informed); }
.chat-usage--limit   { color: var(--danger); }

.panel-chat .message-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel-chat .message-list:empty::before {
  content: 'Talk to your business.';
  display: block;
  text-align: center;
  color: var(--text-4);
  font-size: 13px;
  margin-top: 40px;
}

.panel-chat .message { display: flex; flex-direction: column; gap: 3px; max-width: 100%; }
.panel-chat .message.user      { align-items: flex-end; }
.panel-chat .message.assistant { align-items: flex-start; }
.panel-chat .bubble {
  line-height: 1.45;
  max-width: 100%;
  word-break: break-word;
  font-size: 14px;
}
.panel-chat .message.user .bubble {
  max-width: 250px;
  padding: 10px 14px;
  background: var(--blue-50);
  color: var(--text);
  border-radius: 12px 12px 4px 12px;
  white-space: pre-wrap;
}
.panel-chat .message.assistant .bubble {
  color: var(--text-2);
  line-height: 1.5;
}
.panel-chat .bubble.markdown p                { margin: 0 0 0.5em; }
.panel-chat .bubble.markdown p:last-child     { margin-bottom: 0; }
.panel-chat .bubble.markdown ul,
.panel-chat .bubble.markdown ol               { margin: 0 0 0.5em 1.1em; }
.panel-chat .bubble.markdown strong           { font-weight: 600; }
.panel-chat .bubble.markdown code             { font-family: var(--font-mono); font-size: 10px; background: var(--surface-3); padding: 1px 3px; border-radius: 3px; }

/* Provenance / trust row in chat */
.panel-chat .provenance-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.panel-chat .analysis-summary { font-size: 10px; color: var(--text-3); }

/* Message feedback buttons (thumbs up / down) */
.feedback-buttons { display: inline-flex; align-items: center; gap: 2px; margin-left: 2px; }
.feedback-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0;
  border: none; background: none; border-radius: 3px;
  color: var(--text-4); cursor: pointer;
  transition: color 0.1s, background 0.15s;
}
.feedback-btn:hover { color: var(--text-2); background: var(--surface-2); }
.feedback-btn.selected { color: var(--verified); }
.feedback-btn.negative.selected { color: var(--general); }

/* Thinking indicator */
.thinking-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 7px 11px;
  background: var(--surface-2);
  border-radius: 11px;
  border-bottom-left-radius: 3px;
  width: fit-content;
}
.thinking-bubble span {
  width: 6px;
  height: 6px;
  background: var(--text-3);
  border-radius: 50%;
  display: inline-block;
  animation: thinking-dot 1.2s infinite ease-in-out;
}
.thinking-bubble span:nth-child(2) { animation-delay: .2s; }
.thinking-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes thinking-dot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* Streaming answer (static/js/chat_stream.js). Provisional until the saved
   answer replaces it, so it carries a neutral pill rather than a trust level. */
.trust--pending { background: var(--surface-2); color: var(--text-3); cursor: default; padding-left: 8px; }
.trust--pending .trust-icon { width: 8px; height: 8px; animation: thinking-dot 1.2s infinite ease-in-out; }
.message.streaming .bubble[hidden],
.stream-status[hidden] { display: none; }
.stream-steps:empty { display: none; }
.stream-step { font-size: 11px; line-height: 1.4; color: var(--text-3); font-style: italic; margin-bottom: 4px; }
.stream-status { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.message-error { font-size: 12px; line-height: 1.4; color: var(--danger); padding: 4px 2px; }
/* A report's chat is always on the report's view. The answer's out-of-band
   swap that locks the standalone page's selector replaces this pane's hidden
   copy with one carrying no inline style, so it is hidden here instead. */
.panel-chat #semantic-view-select { display: none; }

/* Chat chart bubbles */
.panel-chat .chart-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px; width: 100%; }
.panel-chat .chart-title  { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.panel-chat .chart-container { width: 100%; height: 160px; }

/* Pin dialog */
.pin-trigger-area  { margin-top: 3px; }
.pin-trigger-btn { font-size: 11px; color: var(--accent); background: none; border: 1px solid var(--accent-tint-2); border-radius: var(--radius); padding: 3px 9px; cursor: pointer; }
.pin-trigger-btn:hover { background: var(--accent-tint); }
.pin-confirmation { font-size: 12px; color: var(--verified); font-weight: 600; padding: 3px 0; }
.pin-confirmation.is-error { color: var(--danger); }
.pin-dialog-hint { display: block; font-size: 10px; color: var(--text-4); margin-top: 3px; }
.pin-dialog { margin-top: 7px; padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.pin-dialog-row   { margin-bottom: 7px; }
.pin-dialog-label { font-size: 10px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }
.pin-dialog input[type="text"] { width: 100%; padding: 5px 7px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 12px; font-family: inherit; color: var(--text); }


/* ── §13 TENANT ADMIN PORTAL ────────────────────────────────── */
/*
   Governance surface: people, data access, usage. Two conventions carry
   meaning here and are worth not undoing.

   1. Mono vs sans is the boundary between what an admin NAMES and what
      Snowflake IS. Display names, people, and prose set in the sans; view names,
      role slugs, token counts, and timestamps set in mono. Reach for .mg-mono
      on identifiers, never for emphasis.

   2. Trust colours (--verified / --informed / --general) mean grounding level
      everywhere else in the product and are deliberately NOT reused here. A
      granted or active state uses --accent; absence uses the greys.
*/

.mg-page { flex: 1; display: flex; overflow: hidden; min-height: 0; background: var(--bg); }

/* Section rail */
.mg-rail {
  width: 208px; flex-shrink: 0; display: flex; flex-direction: column;
  gap: 2px; padding: 20px 12px; background: var(--surface);
  border-right: 1px solid var(--border); overflow-y: auto;
}
.mg-rail-eyebrow {
  font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3); padding: 0 10px 10px;
}
.mg-rail-link {
  display: block; padding: 7px 10px; border-radius: var(--radius);
  font-size: 13px; color: var(--text-2); text-decoration: none;
  border-left: 2px solid transparent;
}
.mg-rail-link:hover { background: var(--surface-2); color: var(--text); }
.mg-rail-link.is-active {
  background: var(--accent-tint); color: var(--accent-2);
  font-weight: 600; border-left-color: var(--accent);
}
.mg-rail-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.mg-rail-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--border); }
.mg-rail-tenant { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.mg-rail-stat { font-size: 11px; color: var(--text-3); line-height: 1.7; }
.mg-rail-back {
  display: inline-block; margin-top: 12px; font-size: 11px;
  color: var(--accent); text-decoration: none;
}
.mg-rail-back:hover { text-decoration: underline; }

/* Content column */
.mg-content { flex: 1; overflow-y: auto; padding: 28px 32px 64px; }
.mg-head { max-width: 940px; margin-bottom: 20px; }
.mg-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.mg-lede { font-size: 13px; color: var(--text-2); margin-top: 5px; }

.mg-messages { max-width: 940px; margin-bottom: 16px; }
.mg-alert {
  font-size: 13px; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); margin-bottom: 8px;
}
.mg-alert-success { background: var(--accent-tint); border-color: var(--accent-tint-2); color: var(--accent-2); }
.mg-alert-error   { background: var(--danger-tint); border-color: var(--danger); color: var(--danger); }

.mg-card {
  max-width: 940px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 20px 22px; margin-bottom: 16px;
}
.mg-card-head { margin-bottom: 16px; }
.mg-card-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.mg-card h2 { font-size: 14px; font-weight: 600; color: var(--text); }
.mg-card h3 { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }

.mg-mono { font-family: var(--font-mono); font-size: .92em; }
.mg-num  { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mg-hint { font-size: 11.5px; color: var(--text-3); line-height: 1.6; margin-top: 4px; }
.mg-hint a { color: var(--accent); }
.mg-nowrap { white-space: nowrap; }
.mg-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mg-empty { font-size: 13px; color: var(--text-3); padding: 20px 0; text-align: center; }
.mg-empty-inline { padding: 6px 0; text-align: left; }
.mg-foot-note {
  font-size: 11.5px; color: var(--text-3); line-height: 1.6;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.mg-foot-note a { color: var(--accent); }

/* Buttons */
.mg-btn {
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 6px 13px;
  border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  white-space: nowrap; text-decoration: none; display: inline-block;
}
.mg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mg-btn-primary { background: var(--accent); color: #fff; }
.mg-btn-primary:hover { background: var(--accent-2); }
.mg-btn-quiet { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.mg-btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.mg-btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-tint); }
.mg-btn-danger:hover { background: var(--danger-tint); }
.mg-btn-block { display: block; width: 100%; text-align: center; padding: 10px; font-size: 13px; }

/* Fields */
.mg-field { margin-bottom: 12px; }
.mg-field label, .mg-field legend {
  display: block; font-size: 11px; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px; letter-spacing: .02em;
}
.mg-field input[type="text"], .mg-field input[type="email"], .mg-field input[type="password"] {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); font-size: 13px; font-family: inherit; color: var(--text);
  background: var(--surface);
}
.mg-field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.mg-field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); font-size: 13px; line-height: 1.55; color: var(--text);
  background: var(--surface); resize: vertical; min-height: 160px;
}
.mg-field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.mg-field textarea[aria-invalid="true"] { border-color: var(--danger); }
.mg-char-count { font-size: 11px; color: var(--text-3); text-align: right; margin-top: 4px; }
.mg-callout {
  font-size: 12.5px; line-height: 1.55; color: var(--text-2);
  background: var(--surface-2); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 10px 12px; margin: 4px 0 0;
}
.mg-field-row { display: flex; gap: 12px; }
.mg-field-row .mg-field { flex: 1; }
.mg-field-error { font-size: 11.5px; color: var(--danger); margin-top: 4px; }
.mg-roleset { border: 0; }

/* Invite */
.mg-invite summary { list-style: none; }
.mg-invite summary::-webkit-details-marker { display: none; }
.mg-invite-summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--accent-2);
}
.mg-invite-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.mg-invite-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; font-size: 14px;
  background: var(--accent-tint); color: var(--accent);
}
.mg-invite[open] .mg-invite-summary { margin-bottom: 16px; }
.mg-invite-form { max-width: 520px; }
.mg-role-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.mg-role-opt {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border: 1px solid var(--border-strong); border-radius: 20px;
  font-size: 12px; font-weight: 500; color: var(--text-2); cursor: pointer;
}
.mg-role-opt:has(input:checked) {
  background: var(--accent-tint); border-color: var(--accent); color: var(--accent-2);
}
.mg-role-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.mg-form-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: 16px;
}
.mg-hint-inline { margin-top: 0; flex: 1; }

/* Tables */
.mg-table { width: 100%; border-collapse: collapse; }
.mg-table th {
  text-align: left; font-size: 10px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 10px 8px; border-bottom: 1px solid var(--border);
}
.mg-table td { padding: 14px 10px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 13px; }
.mg-table tr:last-child td { border-bottom: 0; }
.mg-table-dense td { padding: 8px 10px; font-size: 12px; }
.mg-col-num { text-align: right; }
/* Wraps rather than scrolls: with the app sidebar beside it, three actions on
   one line no longer fit a 1440px window. */
.mg-col-actions { text-align: right; }
.mg-col-actions form { display: inline-block; margin: 0 0 6px 6px; }

.mg-person-name { font-size: 13px; font-weight: 600; color: var(--text); }
.mg-person-email { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.mg-person.is-deactivated .mg-person-name { color: var(--text-3); }
.mg-you {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); background: var(--surface-3);
  padding: 1px 5px; border-radius: 3px; margin-left: 5px;
}
.mg-structure { font-size: 11.5px; color: var(--text-2); line-height: 1.7; }

.mg-status {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}
.mg-status-active      { background: var(--accent-tint); color: var(--accent-2); }
.mg-status-pending     { background: var(--surface-3); color: var(--text-2); }
.mg-status-deactivated { background: var(--surface-2); color: var(--text-3); }
/* Something the admin has to act on, e.g. a connection needing reauthorization. */
.mg-status-attention   { background: var(--danger-tint); color: var(--danger); }

/* Role chips in the People table */
.mg-role-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.mg-chip {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 11px; color: var(--text-3); cursor: pointer; background: var(--surface);
}
.mg-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
/* Live checkbox state only. Pairing this with a server-rendered class would
   leave an unchecked chip still styled as granted until the form was saved. */
.mg-chip:has(input:checked) {
  background: var(--accent-tint); border-color: var(--accent-tint-2); color: var(--accent-2); font-weight: 600;
}
.mg-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.mg-role-form { min-width: 230px; }
.mg-dept-chips { margin-top: 6px; }
.mg-role-save { margin-top: 8px; }

/* ── The access matrix ──
   The signature element. Roles across, semantic views down, so the grant that
   connects a person to data is a single visible intersection. */
.mg-matrix-scroll { overflow-x: auto; }
.mg-matrix { border-collapse: collapse; min-width: 100%; }
.mg-matrix th, .mg-matrix td { border-bottom: 1px solid var(--border); }
.mg-matrix-corner { width: 40%; min-width: 200px; border-bottom-color: var(--border-strong) !important; }
.mg-matrix-col {
  padding: 0 4px 10px; text-align: center; vertical-align: bottom;
  border-bottom: 1px solid var(--border-strong) !important; min-width: 74px;
}
.mg-matrix-role { display: block; font-size: 11px; font-weight: 600; color: var(--text-2); }
.mg-matrix-count {
  display: block; font-size: 10px; color: var(--text-3);
  font-family: var(--font-num); font-variant-numeric: tabular-nums; margin-top: 2px;
}
.mg-matrix-col.is-unheld .mg-matrix-role,
.mg-matrix-col.is-unheld .mg-matrix-count { color: var(--text-4); }

.mg-matrix-row-head { text-align: left; padding: 12px 10px 12px 0; font-weight: 400; }
.mg-matrix-row-head .mg-mono { display: block; font-size: 12px; font-weight: 600; color: var(--text); }
.mg-matrix-row-label { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.mg-matrix-cell { text-align: center; padding: 8px 4px; }
.mg-matrix-cell.is-unheld { background: var(--surface-2); }
.mg-matrix-cell form { display: inline; }

/* An outline is "not granted", a filled block is "granted". Deliberately a
   square rather than a checkmark: it reads as a cell in a grid, which is what
   it is, and stays legible at this size. */
.mg-grant {
  width: 22px; height: 22px; padding: 0; cursor: pointer;
  border: 1.5px solid var(--border-strong); border-radius: 4px;
  background: var(--surface);
}
.mg-grant:hover { border-color: var(--accent); background: var(--accent-tint); }
.mg-grant:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mg-grant.is-granted { background: var(--accent); border-color: var(--accent); }
.mg-grant.is-granted:hover { background: var(--accent-2); border-color: var(--accent-2); }

/* Semantic view discovery */
.mg-discovered {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px;
}
.mg-discover-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mg-discover-name { font-size: 12px; font-weight: 600; color: var(--text); min-width: 150px; }
.mg-discover-row input {
  flex: 1; min-width: 130px; padding: 6px 9px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); font-size: 12px; font-family: inherit; color: var(--text);
}
.mg-discover-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

/* Email sharing domains */
.mg-domains { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.mg-domain {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px;
  font-size: 12px; color: var(--text-2);
}
.mg-domain-x {
  background: none; border: 0; cursor: pointer; color: var(--text-3);
  font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 50%;
}
.mg-domain-x:hover { color: var(--danger); background: var(--danger-tint); }
.mg-domain-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mg-domain-add { display: flex; gap: 8px; max-width: 400px; }
.mg-domain-add input {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); font-size: 13px; font-family: inherit; color: var(--text);
}
.mg-domain-add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.mg-confirm {
  background: var(--danger-tint); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
  font-size: 12.5px; color: var(--text); line-height: 1.6;
}
.mg-confirm p { margin-bottom: 10px; }

/* Account deletion: the danger zone and its confirmation */
.mg-card-danger { border-color: var(--danger-tint); }
.mg-card-danger h2 { color: var(--danger); }
.mg-delete-form { max-width: 360px; margin-top: 4px; }
.mg-delete-actions { display: flex; gap: 8px; align-items: center; }
.mg-connect-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }

/* Usage */
.mg-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; }
.mg-stat-value { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -.02em; }
.mg-stat-label { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.mg-allowance { margin-top: 20px; }
.mg-allowance-track { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.mg-allowance-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.mg-allowance-fill.is-high { background: var(--danger); }

/* Daily token bars. Plain CSS rather than ECharts: this is not a semantic-view
   widget, and chart_builder.py is the only place allowed to hold ECharts
   config. A 30-bar column chart does not justify bending that. */
.mg-chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.mg-chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.mg-chart-bar { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.mg-chart-col:hover .mg-chart-bar { background: var(--accent-2); }
.mg-chart-axis {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-3); margin-top: 6px;
}

.mg-kind {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 6px;
  border-radius: 3px; background: var(--surface-3); color: var(--text-2); margin-right: 6px;
}
.mg-kind.is-llm { background: var(--accent-tint); color: var(--accent-2); }
.mg-activity-detail { color: var(--text-2); font-size: 11.5px; }

/* Invite acceptance / expired link */
.mg-gate { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg); overflow-y: auto; }
.mg-gate-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 30px 32px;
}
.mg-gate-eyebrow {
  font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.mg-gate-card h1 { font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.mg-gate-lede { font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 8px 0 22px; }
.mg-gate-form .mg-btn-block { margin-top: 18px; }
.mg-gate-rules { list-style: none; margin-top: 18px; font-size: 11.5px; color: var(--text-3); line-height: 1.8; }

/* Narrow screens: the rail becomes a horizontal strip rather than disappearing,
   since it is the only navigation between sections. */
@media (max-width: 720px) {
  .mg-page { flex-direction: column; overflow-y: auto; }
  .mg-rail {
    width: 100%; flex-direction: row; align-items: center; gap: 4px;
    padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .mg-rail-eyebrow, .mg-rail-foot { display: none; }
  .mg-rail-link { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .mg-rail-link.is-active { border-left: 0; border-bottom-color: var(--accent); }
  .mg-content { padding: 20px 16px 48px; }
  .mg-card { padding: 16px; }
  .mg-field-row { flex-direction: column; gap: 0; }
  .mg-form-actions { flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  .mg-page * { transition: none !important; animation: none !important; }
}


/* ── §14 AUTHENTICATION AND MFA ─────────────────────────────── */
/*
   Sign-in, factor verification, and enrolment share the .mg-gate card from
   §13, so the whole authentication surface reads as one place. The pieces
   below are what those pages add.
*/

.mg-gate-card-wide { max-width: 460px; }
.mg-gate-alert { margin-bottom: 16px; }
.mg-gate-secondary { margin-top: 14px; text-align: center; }
.mg-body-copy { font-size: 13px; line-height: 1.65; color: var(--text-2); margin-bottom: 10px; }

.mg-linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 12.5px; color: var(--accent); text-decoration: underline;
}
.mg-linkbtn:hover { color: var(--accent-2); }
.mg-linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One field takes an app code, an emailed code, or a backup code. Spaced and
   oversized because it is typed under pressure, often from a phone screen. */
.mg-code-input {
  font-family: var(--font-mono) !important;
  font-size: 20px !important;
  letter-spacing: .14em;
  text-align: center;
  padding: 11px 10px !important;
}

.mg-trust-opt {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
  margin: 14px 0 4px; cursor: pointer;
}
.mg-trust-opt input { margin-top: 2px; flex-shrink: 0; }

/* Factor choice at enrolment */
.mg-factor-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.mg-factor-form { display: block; }
.mg-factor {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 14px 16px; text-decoration: none;
  font-family: inherit;
}
.mg-factor:hover { border-color: var(--accent); background: var(--accent-tint); }
.mg-factor:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mg-factor-strong { border-color: var(--accent-tint-2); }
.mg-factor-rank {
  display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-2); background: var(--accent-tint);
  padding: 2px 7px; border-radius: 3px; margin-bottom: 7px;
}
.mg-factor-rank-weak { color: var(--text-2); background: var(--surface-3); }
.mg-factor-name { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.mg-factor-note { display: block; font-size: 12px; line-height: 1.6; color: var(--text-2); margin-top: 4px; }

/* TOTP enrolment */
.mg-qr {
  display: flex; justify-content: center; padding: 16px;
  /* Explicitly white, and load-bearing: the generated SVG is a bare path with
     no background of its own, so a scanner's contrast comes from here. */
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 14px;
}
/* The SVG declares its own size in mm, which this overrides, so the size here
   is what decides whether the code can actually be scanned. A provisioning URI
   with a 32-character secret is a version 7 QR: 45 modules plus a 2-module
   quiet zone each side, 49 across. At the old 190px that was 3.88 pixels per
   module, under the ~4px floor for scanning off a screen, and fractional, so
   every module straddled a pixel boundary and got anti-aliased into grey.
   Codes scanned on some phones and not others.

   245px holds at or above 4px per module through version 10, which covers a
   much longer email than any address here. crispEdges then stops the browser
   softening the edges when a longer address does push the scale fractional
   again. Do not shrink this to fit a layout. */
.mg-qr svg {
  width: 245px; height: 245px; display: block;
  shape-rendering: crispEdges;
}

.mg-manual { margin-bottom: 18px; }
.mg-manual summary {
  cursor: pointer; font-size: 12.5px; color: var(--accent);
  list-style: none; padding: 4px 0;
}
.mg-manual summary::-webkit-details-marker { display: none; }
.mg-manual summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mg-secret {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 11px; margin-top: 6px;
  font-size: 12.5px; word-break: break-all; color: var(--text); user-select: all;
}

/* Backup codes, shown once */
.mg-codes {
  list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 12px;
}
.mg-codes li { font-size: 13px; color: var(--text); letter-spacing: .04em; user-select: all; }

/* Security section in the admin portal */
.mg-stats-compact { margin-bottom: 20px; }
.mg-stats-compact .mg-stat-value { font-size: 18px; }
.mg-mfa-form { border-top: 1px solid var(--border); padding-top: 18px; }

.mg-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 6px; }
.mg-switch-label { font-size: 13px; font-weight: 600; color: var(--text); }

.mg-factor-choice { margin-top: 16px; }
.mg-factor-opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  margin-bottom: 8px; cursor: pointer;
}
.mg-factor-opt:has(input:checked) { border-color: var(--accent-tint-2); background: var(--accent-tint); }
.mg-factor-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.mg-factor-opt input { margin-top: 3px; flex-shrink: 0; }
.mg-factor-opt-body { flex: 1; }
.mg-factor-opt-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.mg-factor-opt-note { display: block; font-size: 11.5px; line-height: 1.6; color: var(--text-2); margin-top: 3px; }

.mg-strength {
  font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 3px;
}
.mg-strength-strong { color: var(--accent-2); background: var(--accent-tint-2); }
.mg-strength-weak { color: var(--text-2); background: var(--surface-3); }

/* Per-person MFA state in the People table.
   --danger, not --informed: the trust colours mean grounding level everywhere
   else in the product (see §13) and must not pick up a second meaning here.
   An unenrolled person under a required policy is an attention state, which is
   what --danger already signals on alerts and destructive actions. */
.mg-mfa-state { font-size: 11px; margin-top: 5px; }
.mg-mfa-state.is-on  { color: var(--text-3); }
.mg-mfa-state.is-off { color: var(--danger); font-weight: 600; }

@media (max-width: 720px) {
  .mg-codes { grid-template-columns: 1fr; }
  .mg-gate { padding: 16px; }
}
.pin-dialog select { width: 100%; padding: 4px 7px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 12px; background: var(--surface); }
.pin-dialog-sizes { display: flex; gap: 8px; }
.pin-dialog-sizes label { font-size: 12px; display: flex; align-items: center; gap: 3px; cursor: pointer; }
.pin-dialog-actions  { display: flex; gap: 5px; margin-top: 8px; }
.pin-btn-primary  { padding: 4px 10px; background: var(--accent); color: white; border: none; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; }
.pin-btn-primary:hover { background: var(--accent-2); }
.pin-btn-cancel   { padding: 4px 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 12px; cursor: pointer; }

/* Chat input area */
.chat-panel-input { padding: 8px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-panel-input form { display: flex; gap: 5px; align-items: flex-end; }
.chat-panel-input textarea {
  flex: 1;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
  resize: none;
  min-height: 36px;
  max-height: 110px;
  line-height: 1.5;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
}
.chat-panel-input textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.chat-panel-input .send-btn {
  padding: 7px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  height: 36px;
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-panel-input .send-btn:hover    { background: var(--accent-2); }
.chat-panel-input .send-btn:disabled { background: var(--text-4); cursor: not-allowed; }

/* Chat metric card (query_for_metric_card inline display) */
.chat-metric-card { padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: inline-flex; flex-direction: column; gap: 2px; min-width: 140px; }
.cmc-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.cmc-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.cmc-comparison { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.cmc-comparison.good .cmc-delta { color: #3ba272; }
.cmc-comparison.bad  .cmc-delta { color: #ee6666; }
.cmc-delta { font-weight: 600; }

/* Chat data grid (query_for_data_grid inline display) */
.chat-data-grid-wrap { max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.chat-data-grid { width: 100%; border-collapse: collapse; font-size: 11px; }
.chat-data-grid th { background: var(--surface-2); padding: 5px 8px; text-align: left; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.chat-data-grid td { padding: 4px 8px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.chat-data-grid tr:last-child td { border-bottom: none; }
.chat-data-grid tr:hover td { background: var(--surface-2); }
.chat-chart-error { padding: 8px 12px; font-size: 12px; color: var(--text-3); background: var(--surface-2); border-radius: var(--radius); }

/* ── Email this answer ─────────────────────────────────────────
   Mirrors the pin dialog's visual language so the two share-style
   affordances on a message read as siblings. */
.email-trigger-area { margin-top: 6px; }
.email-trigger-btn {
  font-size: 11px; color: var(--text-2); background: none;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 3px 9px; cursor: pointer;
}
.email-trigger-btn:hover { background: var(--surface-2); color: var(--text); }

.email-dialog {
  margin-top: 7px; padding: 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.email-dialog-row { margin-bottom: 8px; }
.email-dialog-label {
  display: block; font-size: 10px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px;
}
.email-dialog-optional {
  text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-4);
}
.email-dialog input[type="text"],
.email-dialog textarea {
  width: 100%; padding: 5px 7px; border: 1px solid var(--border-strong);
  border-radius: 4px; font-size: 12px; font-family: inherit; color: var(--text);
  background: var(--surface); box-sizing: border-box;
}
.email-dialog textarea { resize: vertical; line-height: 1.4; }
.email-dialog-hint {
  display: block; font-size: 10px; color: var(--text-4); margin-top: 3px;
}
.email-dialog-actions { display: flex; gap: 5px; margin-top: 10px; }
.email-btn-primary {
  padding: 4px 12px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer;
}
.email-btn-primary:hover { background: var(--accent-2); }
.email-btn-primary[disabled] { opacity: .6; cursor: default; }
.email-btn-cancel {
  padding: 4px 10px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: 12px; cursor: pointer;
}

/* ── Help and support menu ─────────────────────────────────────
   Drops from the topbar's question-mark icon. Same shape as the share panel,
   since both are "a small decision made where you already are". */
.support-trigger-area { position: relative; }
.support-menu-host { position: absolute; top: calc(100% + 8px); right: 0; z-index: 70; }

.support-menu {
  width: 320px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 10px;
}
.support-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 8px;
}
.support-menu-title { font-size: 12px; font-weight: 600; color: var(--text); }
.support-menu-close {
  background: none; border: none; color: var(--text-4); font-size: 12px;
  cursor: pointer; padding: 2px 4px; border-radius: 4px;
}
.support-menu-close:hover { color: var(--text); background: var(--surface-2); }

.support-option {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 9px 8px; border: none; background: none; border-radius: var(--radius);
  text-align: left; text-decoration: none; cursor: pointer; color: inherit;
  font-family: inherit;
}
.support-option:hover { background: var(--surface-2); }
.support-option-icon { color: var(--text-3); flex-shrink: 0; margin-top: 1px; }
.support-option:hover .support-option-icon { color: var(--accent); }
.support-option-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.support-option-label { font-size: 13px; font-weight: 500; color: var(--text); }
.support-option-hint { font-size: 11px; color: var(--text-4); line-height: 1.35; }

.support-pane { border-top: 1px solid var(--border); margin-top: 8px; padding: 10px 8px 4px; }
.support-pane-label {
  display: block; font-size: 10px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px;
}
.support-pane textarea {
  width: 100%; box-sizing: border-box; padding: 7px 8px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-size: 12px; font-family: inherit; line-height: 1.45; color: var(--text);
  background: var(--surface);
}
.support-pane-actions { display: flex; gap: 6px; margin-top: 9px; }

.support-btn-primary {
  padding: 5px 13px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer;
}
.support-btn-primary:hover { background: var(--accent-2); }
.support-btn-primary[disabled] { opacity: .6; cursor: default; }
.support-btn-quiet {
  padding: 5px 11px; background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: 12px; cursor: pointer;
}
.support-btn-quiet:hover { background: var(--surface-2); color: var(--text); }

.support-alert {
  font-size: 11px; line-height: 1.45; border-radius: var(--radius);
  padding: 7px 9px; margin-bottom: 9px;
}
.support-alert.is-error { color: var(--danger); background: var(--danger-tint); }
.support-alert.is-ok { color: var(--verified); background: var(--verified-tint); }

/* ── Share this dashboard ──────────────────────────────────────
   Right-justified in the canvas toolbar, with the panel dropping below it.
   A blocked row is greyed rather than hidden, the same way the access matrix
   greys a role nobody holds: the dead end is shown before the click. */
.share-trigger-area { position: relative; }
.share-owner-tag {
  font-size: 12px; color: var(--text-3); background: var(--surface-2);
  border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}

.share-panel-host {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
}
.share-panel {
  width: 340px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 12px;
}
.share-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.share-panel-title { font-size: 12px; font-weight: 600; color: var(--text); }
.share-panel-close {
  background: none; border: none; color: var(--text-4); font-size: 12px;
  cursor: pointer; padding: 2px 4px; border-radius: 4px;
}
.share-panel-close:hover { color: var(--text); background: var(--surface-2); }

.share-alert {
  font-size: 11px; color: var(--danger); background: var(--danger-tint);
  border-radius: var(--radius); padding: 6px 8px; margin-bottom: 10px;
}

.share-zone { margin-bottom: 12px; }
.share-zone-label {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 5px;
}
.share-search {
  width: 100%; padding: 5px 7px; margin-bottom: 6px; box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-size: 12px; font-family: inherit; color: var(--text);
}
.share-candidates { max-height: 220px; overflow-y: auto; }

.share-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 4px; border-bottom: 1px solid var(--border);
}
.share-row:last-child { border-bottom: none; }
.share-row.is-blocked { opacity: .55; }
.share-row-who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.share-row-name {
  font-size: 12px; color: var(--text); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.share-row-email {
  font-size: 10px; color: var(--text-4); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.share-row-reason { font-size: 10px; color: var(--informed); line-height: 1.3; }
.share-row-tag {
  font-size: 10px; color: var(--text-3); background: var(--surface-2);
  border-radius: 10px; padding: 1px 7px; white-space: nowrap;
}
.share-row-tag.is-muted { color: var(--text-4); }

.share-btn-add {
  padding: 3px 10px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-size: 11px; font-weight: 600; cursor: pointer;
}
.share-btn-add:hover { background: var(--accent-2); }
.share-btn-remove {
  padding: 3px 9px; background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: 11px; cursor: pointer;
}
.share-btn-remove:hover { color: var(--danger); border-color: var(--danger); }

.share-empty, .share-foot-note {
  font-size: 10px; color: var(--text-4); line-height: 1.4;
}
.share-foot-note { border-top: 1px solid var(--border); padding-top: 8px; }

/* Save as template: local checkouts only */
.share-template { border-top: 1px solid var(--border); padding-top: 10px; margin: 10px 0 0; }
.share-template form { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.share-template form .share-search { margin-bottom: 0; }
.share-template-tag {
  font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--informed);
  background: var(--informed-tint); border-radius: 10px; padding: 0 6px; margin-left: 4px;
}
.share-template-label { font-size: 11px; color: var(--text-2); }
.share-template-check { display: flex; gap: 6px; align-items: flex-start; font-size: 11px; color: var(--text-2); line-height: 1.35; }
.share-template-check input { margin: 1px 0 0; }
.share-template-list { margin: 4px 0 0; padding-left: 16px; }
.share-template-ok {
  font-size: 11px; color: var(--text-2); background: var(--surface-2);
  border-radius: var(--radius); padding: 6px 8px; margin-bottom: 8px; line-height: 1.4;
  overflow-wrap: anywhere;
}
.share-template-ok code, .share-template-warn code { font-size: 10px; }
.share-template-warn { color: var(--informed); margin-top: 4px; }

.email-result {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 12px; padding: 5px 0; line-height: 1.45;
}
.email-result-icon { flex-shrink: 0; font-weight: 700; }
.email-result--ok    { color: var(--verified); }
.email-result--error { color: var(--danger); }
/* A refused send reopens the dialog with the reason at its top. */
.email-dialog > .email-result--error { padding-top: 0; margin-bottom: 6px; }

/* ── §20 REPORT EDITOR: INSPECTOR AND SHARED CONTROLS ─────────
   The right-hand column of the report editor (design handoff 2a). Build and
   Ask Trova are two bodies in one aside; data-mode on the aside picks which
   is visible, so switching never discards the chat thread or the builder. */
.inspector { border-left: 1px solid var(--border); background: var(--surface); }
.insp-head {
  height: var(--topbar-h); flex: none; display: flex; align-items: center;
  padding: 0 16px; border-bottom: 1px solid var(--border);
}
.insp-seg {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface-2); border-radius: var(--radius-md); padding: 3px;
}
.insp-seg-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; border: 0; border-radius: var(--radius); background: transparent;
  font: 500 13px/1 var(--font-body); color: var(--text-3);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.insp-seg-btn:hover { color: var(--text-2); }
.insp-seg-btn.is-active { background: var(--surface); box-shadow: var(--shadow-xs); color: var(--blue-600); }
.insp-seg-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.insp-title { display: flex; align-items: center; gap: 8px; font: 500 14px/1 var(--font-body); color: var(--blue-600); }
.insp-title { flex: 1; }
.insp-expand-btn { flex: none; margin-right: 8px; }
.insp-expand-btn .when-expanded,
body.inspector-expanded .insp-expand-btn .when-collapsed { display: none; }
body.inspector-expanded .insp-expand-btn .when-expanded { display: inline-flex; }
.insp-expand-btn .when-collapsed { display: inline-flex; }
/* Expanded: the width the chat panel expanded to before the 2a layout. It
   sits over the right of the canvas instead of narrowing it, so the canvas
   keeps its width and its charts are not squeezed. The grid's second column
   stays at --inspector-w, so nothing on the canvas moves. Above the widgets'
   own layers, below the canvas's menus and popovers (z-index 50 and up). */
body.inspector-expanded .inspector {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: var(--inspector-w-expanded); z-index: 40;
  box-shadow: var(--shadow-lg);
}

.insp-body { flex: 1; min-height: 0; display: none; flex-direction: column; }
.inspector[data-mode="build"] .insp-build { display: flex; }
.inspector[data-mode="ask"] .insp-ask { display: flex; }

/* Ask Trova */
.chat-context {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: 14px 18px 4px; font: 400 12px/1.3 var(--font-body); color: var(--text-3);
}
.chat-context-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Chat history: a full-width row under the context line, and the menu of this
   report's conversations drops from it at the same width. */
.chat-history { position: relative; flex: none; padding: 8px 18px 4px; }
.chat-history-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font: 500 13px/1 var(--font-body); color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 8px 10px; cursor: pointer; text-align: left;
}
.chat-history-btn-label { flex: 1; }
.chat-history-btn:hover { background: var(--surface-2); color: var(--text); }
.chat-history-btn[aria-expanded="true"] { border-color: var(--blue-400); }
.chat-history-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.chat-history-btn:disabled { opacity: 0.5; cursor: default; background: var(--surface); }
.chat-history-menu {
  position: absolute; top: calc(100% + 2px); left: 18px; right: 18px; z-index: 70;
  max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 6px;
}
.chat-history-menu[hidden] { display: none; }
.chat-history-list { display: flex; flex-direction: column; gap: 2px; }
.chat-history-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 6px; background: transparent;
  font: 400 13px/1.3 var(--font-body); color: var(--text-2); text-align: left; cursor: pointer;
}
.chat-history-item:hover { background: var(--surface-2); color: var(--text); }
.chat-history-item.is-current { background: var(--surface-2); color: var(--text); font-weight: 500; }
.chat-history-new .i { color: var(--text-3); }
.chat-history-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-history-when { flex: none; font-size: 11px; color: var(--text-4); }
.chat-history-rule { height: 1px; background: var(--border); margin: 4px 0; }
.chat-history-label {
  padding: 6px 10px 4px; font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.chat-history-empty { padding: 8px 10px; font-size: 12px; color: var(--text-4); }
.inspector .chat-panel-input { padding: 14px 16px; border-top: 1px solid var(--border); }
.inspector .chat-composer {
  display: flex; align-items: flex-end; gap: 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md); padding: 8px 8px 8px 14px; background: var(--surface);
}
.inspector .chat-composer:focus-within { border-color: var(--blue-400); }
.inspector .chat-panel-input textarea {
  border: 0; padding: 4px 0; min-height: 26px; font: 400 14px/1.4 var(--font-body);
  background: transparent; box-shadow: none;
}
.inspector .chat-panel-input textarea:focus { box-shadow: none; }
.inspector .chat-panel-input textarea::placeholder { color: var(--text-3); }
.inspector .chat-panel-input .send-btn {
  width: 26px; height: 26px; padding: 0; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue-600);
}
.inspector .chat-panel-input .send-btn:hover { background: var(--blue-700); }

/* Small shared pieces from the design system */
.eyebrow {
  font: 800 11px/1 var(--font-body); letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3);
}
.mono { font-family: var(--font-mono); }
.btn-outline {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: 500 13px/1 var(--font-body); padding: 0 12px; height: 32px;
  transition: background var(--dur-fast) var(--ease);
}
.btn-outline:hover { background: var(--surface-2); color: var(--text); }
.btn-outline:active { transform: translateY(1px); }
.btn-outline:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
/* Scoped to .btn-outline: the builder already has its own .btn-sm. */
.btn-outline.btn-sm { height: 30px; font-size: 12px; padding: 0 10px; }

/* A Viewer's canvas: no resize handles. */
.workspace.is-readonly .ui-resizable-handle { display: none !important; }
/* Removing a filter control changes the report; a Viewer only chooses values. */
.workspace.is-readonly .fv-remove { display: none; }

/* ── Build pane: New / Edit widget, Advanced, Chat build ─────── */
/* A head naming the widget, then two sections of which at most one is open,
   then the chat box, which stays at the bottom whatever is open. */
.cbuild-head {
  flex: none; display: flex; align-items: flex-start; gap: 8px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
}
.cbuild-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cbuild-head-title { font: 500 15px/1.25 var(--font-body); color: var(--text); overflow-wrap: anywhere; }
.cbuild-head-hint { font: 400 12px/1.4 var(--font-body); color: var(--text-3); }

.cbuild-sec { flex: none; display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); }
.cbuild-sec.is-open { flex: 1 1 0; }
.cbuild-sec-head {
  display: flex; align-items: center; gap: 8px; width: 100%; flex: none;
  padding: 11px 16px; background: none; border: 0; cursor: pointer; text-align: left;
  font: 500 13px/1 var(--font-body); color: var(--text-2);
}
.cbuild-sec-head:hover { background: var(--grey-25); }
.cbuild-sec-head:focus-visible { outline: 2px solid var(--blue-400); outline-offset: -2px; }
.cbuild-sec-title { color: var(--text); }
.cbuild-sec-meta {
  flex: 1; min-width: 0; font-weight: 400; font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cbuild-chev { display: inline-flex; color: var(--text-4); transition: transform .12s cubic-bezier(.2,0,0,1); }
.cbuild-sec.is-open .cbuild-chev { transform: rotate(180deg); }
.cbuild-sec-body { display: none; }
.cbuild-sec.is-open .cbuild-sec-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cbuild-advanced .cbuild-sec-body { overflow: hidden; border-top: 1px solid var(--border); }
.cbuild-chat .cbuild-sec-body { overflow-y: auto; padding: 4px 16px 14px; gap: 10px; }

.cbuild-composer { flex: none; margin-top: auto; }
.cbuild-status { font: 400 12px/1.3 var(--font-body); color: var(--text-3); padding: 0 4px 8px; }
.cbuild-status[hidden] { display: none; }
.cbuild-error {
  font: 400 12px/1.4 var(--font-body); color: var(--danger);
  background: var(--danger-tint); border-radius: var(--radius-md); padding: 8px 10px; margin-top: 8px;
}

.cbuild-topics-head { display: flex; align-items: baseline; gap: 8px; padding-top: 8px; }
.cbuild-topics-view { font-size: 11px; color: var(--text-3); }
.cbuild-topics { display: flex; flex-direction: column; gap: 8px; }
.cbuild-topic {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  padding: 10px 12px; background: var(--surface); cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  transition: border-color .12s, box-shadow .12s;
}
.cbuild-topic:hover { border-color: var(--blue-400); box-shadow: var(--shadow-md); }
.cbuild-topic:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.cbuild-topic-icon {
  flex: none; width: 28px; height: 28px; border-radius: var(--radius);
  background: var(--accent-tint); color: var(--blue-600);
  display: inline-flex; align-items: center; justify-content: center;
}
.cbuild-topic-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cbuild-topic-title { font: 500 13px/1.3 var(--font-body); color: var(--text); }
.cbuild-topic-desc { font: 400 12px/1.4 var(--font-body); color: var(--text-2); }
.cbuild-topic-example { font: 400 12px/1.4 var(--font-body); color: var(--blue-600); }
.cbuild-empty { font: 400 12px/1.4 var(--font-body); color: var(--text-3); margin: 10px 0 0; }

.cbuild-thread { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.cbuild-turn.is-user {
  align-self: flex-end; max-width: 85%; padding: 8px 12px;
  background: var(--blue-50); border-radius: 12px 12px 4px 12px;
  font: 400 13px/1.45 var(--font-body); color: var(--text);
}
.cbuild-turn.is-trova { display: flex; flex-direction: column; gap: 6px; font: 400 13px/1.45 var(--font-body); color: var(--text-2); }
.cbuild-trova { color: var(--blue-600); }
.cbuild-changes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.cbuild-changes li {
  font: 500 11px/1.2 var(--font-body); color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 8px;
}

/* Once-per-person notice that Ask Trova moved off a retired model. */
.model-notice {
  position: relative; margin: 16px 24px 0; padding: 10px 40px 10px 14px;
  font-size: 13px; line-height: 1.55; color: var(--text-2);
  background: var(--accent-tint); border: 1px solid var(--accent-tint-2);
  border-radius: var(--radius);
}
.model-notice strong { color: var(--text); font-weight: 600; }
.model-notice-close {
  position: absolute; top: 6px; right: 8px; border: 0; background: none;
  font-size: 18px; line-height: 1; color: var(--text-3); cursor: pointer; padding: 4px;
}
.model-notice-close:hover { color: var(--text); }
