/* Prototype-inspired admin shell + extract page styles */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --palette-cyan: #65c9d4;
  --palette-blue: #348adc;
  --palette-navy: #072741;
  --palette-white: #fbfcfc;
  --palette-border: #dadfe4;
  --palette-gray: #bcc4c9;

  --bg: var(--palette-white);
  --surface: #ffffff;
  --accent-primary: var(--palette-blue);
  --border: var(--palette-border);
  --border-light: var(--palette-border);
  --text: var(--palette-navy);
  --text-muted: #4a6270;
  --text-light: var(--palette-gray);
  --highlight: rgba(52, 138, 220, 0.1);
  --tag-bg: #eef1f3;
  --row-hover: #f6f8f9;
  --header-bg: oklch(0.2082 0.0711 286.97);
  --header-fg: #ffffff;
  --header-height: 48px;
  --header-avatar: #54c1fb;
  --second-background: #eef9ff;
  --midnight-4: oklch(0.5263 0.1154 252.21 / 4%);
  --midnight-7: oklch(0.5163 0.134 253.05 / 7%);
  --midnight-10: oklch(0.409 0.1031 253.19 / 10%);
  --midnight-50: oklch(0.1772 0.0893 281.43 / 50%);
  --midnight-75: oklch(0.194 0.0795 284.75 / 75%);
  --font-sans:
    "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --destructive-text: #c62828;
  --success-text: #1b5e20;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

#app-root {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--header-bg);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-decoration-color: var(--header-bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.app-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  height: var(--header-height);
  padding: 0 24px;
  background: var(--header-bg);
  color: var(--header-fg);
  position: relative;
  z-index: 40;
}

.app-header-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  justify-self: start;
}

.app-header-logo {
  display: inline-flex;
  align-items: center;
  color: var(--header-fg);
  text-decoration: none;
  line-height: 0;
  min-width: 0;
}

.app-header-logo:hover {
  text-decoration: none;
  color: var(--header-fg);
}

.app-header-logo-img {
  display: block;
  height: 28px;
  width: auto;
  max-width: min(204px, 100%);
}

.app-header-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-header-nav::-webkit-scrollbar {
  display: none;
}

.app-header-link {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  line-height: normal;
  color: var(--header-fg);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 120ms ease;
}

.app-header-link:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
  color: var(--header-fg);
}

.app-header-link.active,
.app-header-link.active:hover {
  background: var(--header-avatar);
  color: var(--header-fg);
  text-decoration: none;
}

.app-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  justify-self: end;
}

.app-header-user-wrap {
  position: relative;
}

.app-header-user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.app-header-user:focus-visible {
  outline: 2px solid var(--header-fg);
  outline-offset: 2px;
}

.app-header-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--header-avatar);
  color: var(--header-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.app-header-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 18rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(7, 39, 65, 0.12);
  padding: 6px;
  z-index: 100;
  color: var(--text);
}

.app-header-menu[data-open="true"] {
  display: block;
}

.app-header-menu-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
}

.app-header-menu-label-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.app-header-menu-label-email {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-menu-sep {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

.app-header-menu-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.app-header-menu-emulate {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 8px;
}

.app-header-menu-emulate-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.app-header-menu-emulate-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.app-header-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
}

a.app-header-menu-item {
  color: var(--text);
}

.app-header-menu-item:hover {
  background: var(--row-hover);
  text-decoration: none;
}

.app-header-menu-item.active {
  background: var(--highlight);
  font-weight: 600;
}

.app-header-menu-item.active .app-header-menu-item-icon {
  color: var(--accent-primary);
}

.app-header-menu-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.app-header-menu-item-icon .nav-icon {
  width: 16px;
  height: 16px;
}

.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

#page-content {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.app-page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.app-page-title__crumb {
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
}

.app-page-title__crumb:hover {
  color: var(--text);
  text-decoration: none;
}

.app-page-title__sep {
  color: var(--text-light);
  font-weight: 400;
}

.app-page-title__current {
  min-width: 0;
}

.app-page-title__meta {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-muted);
  white-space: nowrap;
}

.task-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border-light);
  background: var(--second-background);
  position: sticky;
  top: 0;
  z-index: 15;
  overflow: visible;
}

.task-page-back {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: color-mix(in oklab, var(--header-bg) 70%, transparent);
  cursor: pointer;
}

.task-page-back:hover {
  background: color-mix(in oklab, var(--header-bg) 8%, transparent);
  color: var(--header-bg);
}

.task-page-back svg {
  width: 20px;
  height: 20px;
  display: block;
}

.task-page-header .app-page-title {
  flex-shrink: 0;
  margin: 0;
}

.task-page-header-start {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  min-width: 0;
  flex-shrink: 0;
  align-self: stretch;
  margin-top: -14px;
  margin-bottom: -14px;
}

.task-page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.task-page-header-row:has(> .task-page-back) {
  justify-content: flex-start;
}

.task-page-header-row:has(> .task-page-back) > .app-page-title {
  flex: 1;
  min-width: 0;
}

.task-page-header-row:has(> .task-page-back) > .task-page-actions,
.task-page-header-row:has(> .task-page-back) > .page-header-actions {
  margin-left: auto;
}

.task-page-header--stacked {
  flex-direction: column;
  align-items: stretch;
  padding-bottom: 0;
}

.task-page-header--stacked .task-page-header-start {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  margin: 0;
  flex-shrink: 1;
}

.task-page-header--stacked .app-page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.4em;
  min-width: 0;
  flex-shrink: 1;
}

.task-page-header--stacked .app-page-title__line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.task-page-header--stacked .task-page-header-row .app-page-title {
  flex: 1;
}

.task-page-header--stacked .task-page-header-row .task-page-actions {
  flex: 0 0 auto;
  width: auto;
}

.task-page-header--stacked .app-segments {
  align-self: stretch;
}

.task-page-header--stacked .app-segment {
  min-height: 40px;
}

.task-page-header--stacked .app-segment:first-child {
  padding-left: 0;
}

.task-page-header--stacked .app-segment.active:first-child::after {
  left: 0;
}

.app-segments {
  display: flex;
  gap: 0;
  align-self: stretch;
}

.app-segment {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.app-segment[hidden],
.app-segments[hidden] {
  display: none !important;
}

.app-segment:hover {
  color: var(--text);
}

.app-segment.active {
  color: var(--text);
  font-weight: 600;
}

.app-segment.active::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 2px;
  background: var(--header-bg);
}

.page-header-actions,
.task-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.table-toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.page-table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 10px 32px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  min-width: 0;
}

.page-table-toolbar.task-page-actions {
  flex: 0 0 auto;
  justify-content: flex-start;
  width: auto;
}

.page-table-toolbar .table-toolbar-controls {
  justify-content: flex-start;
}

.page-table-toolbar .crm-table__cols {
  margin-left: auto;
}

.page-table-toolbar .crm-table__cols-menu {
  right: 0;
  left: auto;
}

.table-status {
  margin: 0;
  padding: 8px 32px;
  font-size: 12px;
  color: var(--destructive-text);
  background: transparent;
}

.table-status[hidden] {
  display: none;
}

.app-page-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px 32px;
}

.app-page-body--flush {
  padding: 0;
}

@media (max-width: 900px) {
  .task-page-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .task-page-header-start {
    width: 100%;
    margin-top: 0;
    margin-bottom: 0;
    align-self: auto;
  }

  .app-segments {
    align-self: auto;
  }

  .task-page-actions,
  .page-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.btn:hover {
  background: var(--highlight);
  text-decoration: none;
}

.btn-primary {
  background: var(--header-bg);
  color: white;
  border-color: var(--header-bg);
}

.btn-primary:hover {
  background: color-mix(in oklab, var(--header-bg) 85%, white);
  border-color: color-mix(in oklab, var(--header-bg) 85%, white);
}

.btn-sm,
.task-page-actions .btn,
.page-header-actions .btn {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
}

.btn-danger {
  color: var(--destructive-text);
  border-color: #f5c2c2;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.data-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.data-table thead th {
  background: #f4f7f9;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
  background: var(--row-hover);
}

.task-search-box {
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 420px;
}

.task-search-box__field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 2px 8px 2px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--tag-bg);
  transition:
    border-color 0.12s ease,
    background-color 0.12s ease,
    box-shadow 0.12s ease;
}

.task-search-box__field:hover {
  border-color: var(--palette-gray);
}

.task-search-box__field:focus-within {
  border-color: var(--accent-primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--highlight);
}

.task-search-box--active .task-search-box__field {
  border-color: var(--accent-primary);
}

.task-search-box__icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.task-search-box__input,
.task-search-box input[type="search"] {
  flex: 1 1 80px;
  width: auto;
  min-width: 60px;
  border: none;
  background: transparent;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text);
  outline: none;
  box-shadow: none;
}

.task-search-box__input:hover,
.task-search-box__input:focus,
.task-search-box input[type="search"]:hover,
.task-search-box input[type="search"]:focus {
  border: none;
  box-shadow: none;
}

.task-search-box__input::placeholder {
  color: var(--text-muted);
}

.task-search-box__input::-webkit-search-cancel-button {
  display: none;
}

.task-search-box__clear {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 2px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
}

.task-search-box__clear:hover {
  color: var(--text);
  background: var(--tag-bg);
}

.filter-menu {
  position: relative;
}

.filter-menu-trigger {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  position: relative;
  transition:
    border-color 0.12s ease,
    color 0.12s ease,
    box-shadow 0.12s ease;
}

.filter-menu-trigger:hover {
  border-color: var(--palette-gray);
  color: var(--text);
}

.filter-menu-trigger.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.filter-menu-trigger:focus-visible {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--highlight);
}

.filter-menu-trigger__chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.filter-menu-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 13rem;
  max-height: min(24rem, 70vh);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(7, 39, 65, 0.06),
    0 10px 30px rgba(7, 39, 65, 0.12);
}

.filter-menu-panel[data-open="true"] {
  display: block;
}

.filter-menu-option {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 6px 8px 6px 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  justify-content: flex-start;
}

.filter-menu-option:hover {
  background: var(--row-hover);
}

.filter-menu-option__check {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.filter-menu-option__check .nav-icon {
  width: 16px;
  height: 16px;
}

.filter-menu-divider {
  height: 1px;
  margin: 4px -2px;
  background: var(--border-light);
}

.crm-table-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.crm-table-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
}

.crm-table--fixed {
  table-layout: fixed;
}

.crm-table th,
.crm-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  font-weight: 400;
  font-family: inherit;
  color: var(--text);
  vertical-align: middle;
}

.crm-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-table td code,
.crm-table td .mono {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  white-space: inherit;
  word-break: normal;
}

.crm-table th:first-child,
.crm-table td:first-child {
  padding-left: 32px;
}

.crm-table th:last-child,
.crm-table td:last-child {
  padding-right: 32px;
}

.crm-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: var(--surface);
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
}

.crm-table__head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.crm-table__sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  max-width: 100%;
  min-width: 0;
  text-align: left;
  justify-content: flex-start;
}

.crm-table__sort--icon-only {
  flex-shrink: 0;
  max-width: none;
}

.crm-table__header-link {
  min-width: 0;
  color: inherit;
  text-decoration: none;
  font: inherit;
}

.crm-table__header-link:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.crm-table__sort-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.crm-table__sort-icon--idle {
  opacity: 0.35;
}

.crm-table th:hover .crm-table__sort-icon--idle {
  opacity: 0.6;
}

.crm-table__resize {
  position: absolute;
  top: 0;
  right: -3px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.crm-table__resize-line {
  width: 1px;
  height: 50%;
  background: var(--border);
  transition: background 0.12s ease, width 0.12s ease;
}

.crm-table th:hover .crm-table__resize-line,
.crm-table__resize:hover .crm-table__resize-line {
  width: 2px;
  background: var(--accent-primary);
  opacity: 0.45;
}

.crm-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.crm-table tbody tr.crm-table__row--static {
  cursor: default;
}

.crm-table tfoot td {
  font-weight: 600;
  border-bottom: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.crm-table tbody tr.is-expanded {
  background: var(--highlight);
}

.crm-table tbody tr.crm-table__expand-row {
  cursor: default;
  background: #f4f7f9;
}

.crm-table tbody tr.crm-table__expand-row:hover {
  background: #f4f7f9;
}

.crm-table tbody tr.crm-table__expand-row > td {
  padding: 0;
  overflow: visible;
  white-space: normal;
  border-bottom: 1px solid var(--border-light);
}

.crm-table__expand-panel {
  padding: 4px 32px 16px 48px;
}

.crm-table__expand-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.crm-table__expand-cell-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-table__expand-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.12s ease;
}

.crm-table tbody tr.is-expanded .crm-table__expand-chevron {
  transform: rotate(90deg);
}

.crm-table--nested {
  width: 100%;
  table-layout: auto;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
}

.crm-table--nested th {
  position: static;
  background: #eef2f4;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.crm-table--nested th,
.crm-table--nested td {
  padding: 8px 12px;
}

.crm-table--nested th:first-child,
.crm-table--nested td:first-child {
  padding-left: 12px;
}

.crm-table--nested th:last-child,
.crm-table--nested td:last-child {
  padding-right: 12px;
}

.crm-table--nested tbody tr {
  cursor: pointer;
}

.document-runs .crm-table__muted {
  padding: 8px 0 4px;
}

.document-summary-meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.document-empty {
  display: grid;
  gap: 16px;
  justify-items: start;
  max-width: 40rem;
}

.document-empty p {
  margin: 0;
}

.compare-grid-options {
  position: relative;
  flex-shrink: 0;
}

.compare-grid-options__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 12rem;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(7, 39, 65, 0.06),
    0 10px 30px rgba(7, 39, 65, 0.12);
}

.compare-grid-options__menu--end {
  left: auto;
  right: 0;
}

.compare-grid-options__menu[hidden] {
  display: none;
}

.compare-grid-options__item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.compare-grid-options__item:hover {
  background: var(--tag-bg);
}

.compare-grid-columns {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
  max-height: min(20rem, 50vh);
  overflow-y: auto;
}

.compare-grid-columns[hidden] {
  display: none;
}

.compare-grid-columns__title {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.compare-grid-columns__item,
.compare-grid-columns__reset {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 7px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.compare-grid-columns__item:hover,
.compare-grid-columns__reset:hover {
  background: var(--row-hover);
}

.compare-grid-columns__reset {
  margin-top: 4px;
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 6px 6px;
  color: var(--text-muted);
}

.compare-grid-columns__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.compare-grid-columns__check.is-on {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
  color: #fff;
}

.compare-grid-columns__check-icon {
  width: 12px;
  height: 12px;
}

.compare-grid-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}

.compare-cell-btn {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-cell-btn.is-muted {
  color: var(--text-muted);
}

.compare-cell-btn.is-active {
  color: var(--accent-primary);
  font-weight: 500;
}

.compare-cell-btn:hover {
  color: var(--accent-primary);
}

.compare-viewer-tip {
  position: fixed;
  z-index: 90;
  max-width: min(28rem, calc(100vw - 16px));
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(7, 39, 65, 0.1);
  pointer-events: none;
}

.compare-viewer-tip[hidden] {
  display: none;
}

.compare-viewer-chrome {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 10px 0 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}

.compare-viewer-tabs {
  display: flex;
  align-items: stretch;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  gap: 0;
}

.compare-viewer-tabs--measure {
  position: absolute;
  left: -9999px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  width: auto;
  overflow: visible;
}

.compare-viewer-tabs--measure .compare-viewer-tab {
  max-width: none;
  flex: 0 0 auto;
}

.compare-viewer-tabs[data-count="1"] .compare-viewer-tab,
.compare-viewer-tabs[data-count="2"] .compare-viewer-tab {
  flex: 0 1 auto;
  max-width: calc(50% - 8px);
}

.compare-viewer-tab-sep {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 6px;
  color: var(--border);
  font-size: 14px;
  line-height: 1;
  user-select: none;
}

.compare-viewer-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  max-width: 220px;
  padding: 0 12px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.compare-viewer-tab__label {
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-bottom: 12px;
  margin-bottom: -12px;
}

.compare-viewer-tab:hover {
  color: var(--text);
}

.compare-viewer-tab.active {
  color: var(--text);
  font-weight: 600;
}

.compare-viewer-tab.active .compare-viewer-tab__label::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent-primary);
}

.compare-viewer-more {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.compare-viewer-more[hidden] {
  display: none;
}

.compare-viewer-more__trigger {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.compare-viewer-more__trigger:hover,
.compare-viewer-more.is-open .compare-viewer-more__trigger {
  background: var(--highlight);
}

.compare-viewer-more__menu {
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 280px;
  max-width: min(480px, 85vw);
  max-height: min(360px, 55vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(7, 39, 65, 0.12);
}

.compare-viewer-more__menu[hidden] {
  display: none;
}

.compare-viewer-more__item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.compare-viewer-more__item:hover,
.compare-viewer-more__item.is-active {
  background: var(--highlight);
}

.compare-viewer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.compare-viewer-actions .pdf-viewer-icon-btn.is-active {
  background: var(--highlight);
  border-color: var(--palette-gray);
  color: var(--text);
}

.compare-viewer-search {
  flex-shrink: 0;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
}

.compare-viewer-search[hidden] {
  display: none;
}

.compare-viewer-search .task-search-box {
  width: 100%;
  max-width: none;
}

.crm-table tbody tr:hover {
  background: var(--row-hover);
}

.crm-table tbody tr.selected-row {
  background: var(--highlight);
}

.crm-table__muted {
  color: var(--text-muted);
  font-size: 13px;
}

.crm-table__empty-row td {
  white-space: normal;
  padding: 24px 32px;
}

.crm-table__cols {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}

.crm-table__cols-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.crm-table__cols-btn:hover,
.crm-table__cols-btn.is-open {
  background: var(--row-hover);
  color: var(--text);
}

.crm-table__cols-icon {
  width: 14px;
  height: 14px;
}

.crm-table__cols-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  width: 14.5rem;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(7, 39, 65, 0.12);
}

.crm-table__cols-menu[data-open="true"] {
  display: block;
}

.crm-table__cols-title {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.crm-table__cols-item,
.crm-table__cols-reset {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  justify-content: flex-start;
}

.crm-table__cols-item:hover,
.crm-table__cols-reset:hover {
  background: var(--row-hover);
}

.crm-table__cols-reset {
  margin-top: 4px;
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 6px 6px;
  color: var(--text-muted);
}

.crm-table__cols-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
}

.crm-table__cols-check.is-on {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.crm-table__cols-check-icon {
  width: 12px;
  height: 12px;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-detail {
  flex-shrink: 0;
  max-height: 45%;
  min-height: 0;
  overflow: auto;
  padding: 24px 32px 40px;
  border-top: 1px solid var(--border-light);
}

.history-detail h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.history-detail h3,
.run-detail h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 20px 0 8px;
}

.audit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 16px;
  margin-bottom: 8px;
}

.audit-summary .k {
  display: inline-block;
  min-width: 72px;
  margin-right: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.transcript {
  margin: 0;
  padding-left: 18px;
}

.history-detail .crm-table th,
.history-detail .crm-table td,
.run-detail .crm-table th,
.run-detail .crm-table td {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.crm-table td .tag-pill {
  vertical-align: middle;
}

.table-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.crm-table td[data-col="actions"] {
  overflow: visible;
  white-space: nowrap;
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--tag-bg);
  color: var(--text-muted);
}

.tag-pill--success {
  background: #e8f5e9;
  color: var(--success-text);
}

.tag-pill--error {
  background: #ffebee;
  color: var(--destructive-text);
}

.tag-pill--partial {
  background: color-mix(in srgb, #b45309 14%, transparent);
  color: #b45309;
}

.tag-pill--running {
  background: color-mix(in srgb, #2563eb 14%, transparent);
  color: #2563eb;
}

.tag-pill--awaiting {
  background: color-mix(in srgb, #7c3aed 14%, transparent);
  color: #7c3aed;
}

/* Login */
.login-page {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
  background: linear-gradient(160deg, #e8f4f8 0%, #fbfcfc 45%, #eef3f8 100%);
}

.login-card {
  width: min(100%, 24rem);
  padding: 2rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(15, 40, 70, 0.08);
}

.login-card h1 {
  margin: 0 0 1.25rem;
  font-size: 1.5rem;
  color: var(--palette-navy);
}

.login-hint {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.login-field {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.login-error {
  color: var(--destructive-text);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 1.2em;
}

.login-brand {
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.login-brand span {
  color: var(--accent-primary);
}

.login-brand--logo {
  font-weight: inherit;
  letter-spacing: normal;
}

.login-brand-logo {
  display: block;
  height: 28px;
  width: auto;
  max-width: min(220px, 100%);
}

/* Extract / forms */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.login-field {
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-row > label,
.modal label {
  text-transform: none;
  letter-spacing: normal;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="file"],
input:not([type]),
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input:not([type]):hover,
select:hover,
textarea:hover {
  border-color: var(--palette-gray);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--highlight);
}

.upload {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.tenant-bar,
.api-key-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-top: 0;
}

.tenant-bar label {
  min-width: 180px;
}

.tenant-bar select {
  min-width: 200px;
  height: 32px;
  padding: 0 12px;
}

.status {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--highlight);
  color: var(--text);
  font-size: 13px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 960px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 0 16px;
  }

  .app-header-nav {
    justify-content: flex-start;
    gap: 8px;
  }
}

.fact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.fact-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-weight: 400;
  color: var(--text);
}

.fact-item input {
  margin-top: 3px;
}

.fact-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.fact-picker-actions {
  display: flex;
  gap: 8px;
}

.linkish {
  background: none;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
}

.model-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-option {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 400;
  color: var(--text);
}

.hidden {
  display: none !important;
}

.hop {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
}

.fact-card {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
}

.fact-card:hover,
.fact-card.active {
  border-color: var(--accent-primary);
  background: var(--highlight);
}

.outline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 39, 65, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: min(100%, 480px);
  border: 1px solid var(--border);
}

.modal h3 {
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.form-dialog {
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 48px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(7, 39, 65, 0.18);
}

.form-dialog--wide {
  width: min(760px, calc(100vw - 48px));
}

.agent-type-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.agent-type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.agent-type-card:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border));
}

.agent-type-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.agent-type-card__title {
  font-weight: 600;
  font-size: 14px;
}

.agent-type-card__soon {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.document-file-pill {
  margin-left: 8px;
  align-self: center;
  max-width: min(28ch, 100%);
  padding: 2px 8px;
  overflow: hidden;
  border: 0;
  background: var(--midnight-7);
  color: var(--midnight-50);
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.document-file-pill:hover,
.document-file-pill:focus-visible {
  background: var(--midnight-10);
  color: var(--midnight-75);
}

.document-file-pill--static {
  cursor: default;
}

.document-file-pill--static:hover,
.document-file-pill--static:focus-visible {
  background: var(--midnight-7);
  color: var(--midnight-50);
}

.app-tooltip {
  position: fixed;
  z-index: 90;
  max-width: min(22rem, calc(100vw - 16px));
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--palette-navy);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: 0 8px 20px rgba(7, 39, 65, 0.2);
  pointer-events: none;
}

.app-tooltip__arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--palette-navy);
  transform: rotate(45deg);
}

.app-tooltip[data-side="right"] .app-tooltip__arrow {
  left: -3px;
  top: 50%;
  margin-top: -5px;
}

.app-tooltip[data-side="left"] .app-tooltip__arrow {
  right: -3px;
  top: 50%;
  margin-top: -5px;
}

.app-tooltip[data-side="bottom"] .app-tooltip__arrow {
  top: -3px;
  left: 50%;
  margin-left: -5px;
}

.app-tooltip[data-side="top"] .app-tooltip__arrow {
  bottom: -3px;
  left: 50%;
  margin-left: -5px;
}

.app-tooltip[hidden] {
  display: none;
}

.agent-picker-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.agent-picker-search {
  flex: 1 1 160px;
  min-width: 140px;
}

.agent-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.agent-picker-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 4px;
  align-items: stretch;
  width: 100%;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.agent-picker-row:hover {
  border-color: color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border));
}

.agent-picker-row.is-disabled {
  opacity: 0.55;
}

.agent-picker-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 100%;
  min-height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
}

.agent-picker-star:hover,
.agent-picker-star.is-starred {
  color: #c9a227;
}

.agent-picker-star__icon {
  width: 16px;
  height: 16px;
}

.agent-picker-row__main {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  padding: 8px 6px 8px 4px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.agent-picker-row__main:disabled {
  cursor: not-allowed;
}

.agent-picker-row__name {
  font-weight: 600;
  font-size: 14px;
}

.agent-picker-row__desc {
  font-size: 13px;
}

.authoring-cluster {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
}

.authoring-cluster h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.authoring-fact {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 0;
}

.authoring-question {
  margin: 12px 0;
}

.authoring-summary {
  margin-bottom: 12px;
}

.authoring-counts {
  margin: 8px 0 0;
  font-size: 13px;
}

.authoring-holdout {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0 16px;
}

.authoring-holdout th,
.authoring-holdout td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.authoring-answers {
  margin: 16px 0;
}

.authoring-answers summary {
  cursor: pointer;
  font-weight: 600;
}

.form-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 20px 24px 16px;
}

.form-dialog__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.form-dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.form-dialog__close svg {
  width: 16px;
  height: 16px;
}

.form-dialog__close:hover {
  background: var(--highlight);
  color: var(--text);
}

.form-dialog__fields {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 16px;
  padding: 0 24px 8px;
  overscroll-behavior: contain;
}

.form-dialog__field {
  display: grid;
  gap: 6px;
}

.form-dialog__field[hidden] {
  display: none;
}

.form-dialog label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

.form-dialog__hint {
  margin: 0;
  font-size: 12px;
}

.form-dialog__choices {
  display: grid;
  gap: 8px;
}

.form-dialog__choice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
}

.form-dialog__choice input {
  margin: 0;
}

.form-dialog__check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 2px 0 0;
}

.form-dialog__check input {
  margin: 2px 0 0;
  flex-shrink: 0;
}

.form-dialog .form-dialog__check label {
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.form-dialog__error {
  margin: 0;
  font-size: 13px;
  color: var(--destructive-text);
}

.form-dialog__error[hidden] {
  display: none;
}

.form-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}

.multi-select {
  display: grid;
  gap: 6px;
}

.multi-select[hidden] {
  display: none;
}

.multi-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.multi-select__trigger:hover {
  border-color: var(--palette-gray);
}

.multi-select__trigger:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--highlight);
}

.multi-select__trigger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.multi-select__summary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select__summary.is-placeholder {
  color: var(--text-muted);
}

.multi-select__help {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
}

.multi-select__menu {
  position: fixed;
  z-index: 120;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(7, 39, 65, 0.16);
}

.multi-select__menu[hidden] {
  display: none;
}

.multi-select__actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
}

.multi-select__row {
  display: flex;
  align-items: center;
}

.multi-select__row > .multi-select__option {
  flex: 1;
  min-width: 0;
}

.multi-select__row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-right: 10px;
  font-size: 12px;
}

.multi-select__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 4px;
}

.multi-select__divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border-light);
}

.multi-select__empty {
  margin: 0;
  padding: 8px 10px;
}

.multi-select__option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.multi-select__option:hover {
  background: var(--highlight);
}

.multi-select__option.is-active {
  background: var(--highlight);
}

.multi-select__option.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.multi-select__check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.multi-select__option.is-active .multi-select__check {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
  color: #fff;
}

.multi-select__check svg {
  width: 12px;
  height: 12px;
}

.multi-select__name {
  min-width: 0;
}

.multi-select__option-badge {
  margin-left: auto;
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--highlight);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}

.multi-select__filter {
  flex-shrink: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
}

.multi-select__filter-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
}

.multi-select__filter-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--highlight);
}

.multi-select__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.multi-select__pills[hidden] {
  display: none;
}

.multi-select__pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--highlight);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

.multi-select__pill-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select__pill-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
}

.multi-select__pill-remove:hover {
  opacity: 1;
}

.multi-select__pill-remove svg {
  width: 12px;
  height: 12px;
}

.file-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-transform: none;
  letter-spacing: normal;
}

input.file-field__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.file-field__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-field--multi {
  flex-wrap: wrap;
}

.file-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 180px;
  overflow: auto;
  font-size: 13px;
}

.file-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
}

.file-list__remove {
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
}
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-field__label {
  font-size: 12px;
  font-weight: 600;
}

.login-card.ingest-card {
  width: min(100%, 36rem);
}

.ingest-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 1.25rem;
}

.ingest-card .ingest-heading h1 {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
}

.ingest-card .login-error {
  min-height: 0;
}

.ingest-card .login-error:empty,
.ingest-card #ingest-status:empty {
  display: none;
}

.ingest-card #ingest-status {
  margin: 0;
  flex: 1 1 auto;
  text-align: right;
  font-size: 0.75rem;
  line-height: 1.35;
}

.ingest-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 8.5rem;
  padding: 1.25rem 1rem;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: #f8fafb;
  text-align: center;
}

.ingest-drop.is-dragover {
  border-color: var(--accent-primary);
  background: var(--highlight);
}

.ingest-drop__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--palette-navy);
}

.ingest-drop__actions {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ingest-drop__or {
  margin: 0 0.35rem;
}

.ingest-drop__link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-primary);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.ingest-drop__link:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ingest-files {
  margin: 1rem 0 0;
  min-width: 0;
}

.ingest-files__toolbar {
  display: flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 8px;
}

.ingest-files__selected {
  font-size: 12px;
  color: var(--text-muted);
}

.ingest-bulk {
  position: relative;
}

.ingest-bulk__trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.ingest-bulk__chevron {
  width: 14px;
  height: 14px;
}

.ingest-bulk__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 8;
  min-width: 8.5rem;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 40, 70, 0.12);
}

.ingest-bulk__item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: none;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.ingest-bulk__item:hover {
  background: var(--row-hover);
  color: var(--destructive-text);
}

.ingest-files__head,
.ingest-file {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr) 5.5rem 4.75rem auto;
  column-gap: 12px;
  align-items: center;
  padding-left: 2px;
  padding-right: 0;
}

.ingest-files__head,
.ingest-files__body {
  scrollbar-gutter: stable;
}

.ingest-files__head {
  padding-top: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ingest-files__sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  border: none;
  background: none;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  justify-content: flex-start;
}

.ingest-files__sort[data-sort="size"],
.ingest-files__sort[data-sort="status"] {
  justify-content: center;
}

.ingest-files__sort[data-sort="size"]:not(.is-active) .ingest-files__sort-dir,
.ingest-files__sort[data-sort="status"]:not(.is-active) .ingest-files__sort-dir {
  display: none;
}

.ingest-files__sort.is-active {
  color: var(--palette-navy);
}

.ingest-files__sort-dir {
  width: 10px;
  font-size: 10px;
  line-height: 1;
  text-align: center;
}

.ingest-files__body {
  max-height: 18rem;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #c5cdd3 transparent;
}

.ingest-files__body::-webkit-scrollbar {
  width: 8px;
}

.ingest-files__body::-webkit-scrollbar-track {
  background: transparent;
  border: none;
  box-shadow: none;
}

.ingest-files__body::-webkit-scrollbar-thumb {
  background-color: #c5cdd3;
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.ingest-files__body::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.ingest-files__body::-webkit-scrollbar-corner {
  background: transparent;
}

.ingest-file {
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.ingest-file:last-child {
  border-bottom: none;
}

.ingest-file__check {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.ingest-file__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--palette-navy);
}

.ingest-file__size,
.ingest-file__meta {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: center;
}

.ingest-file__remove {
  justify-self: end;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-primary);
  text-decoration: underline;
  white-space: nowrap;
  cursor: pointer;
}

.ingest-file.is-failed .ingest-file__meta {
  color: var(--destructive-text);
}

.ingest-file__tip {
  position: fixed;
  z-index: 40;
  max-width: min(22rem, calc(100vw - 16px));
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--palette-navy);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: 0 8px 20px rgba(7, 39, 65, 0.2);
  pointer-events: none;
}

.ingest-file__remove-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.ingest-done {
  width: 100%;
  margin-top: 1rem;
}

.ingest-done-list {
  margin: 0.75rem 0 1rem;
  padding: 0;
  max-height: 12rem;
  overflow-x: hidden;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: #c5cdd3 transparent;
}

.ingest-done-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  font-weight: 500;
  color: var(--palette-navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ingest-done-list li:last-child {
  border-bottom: none;
}

.ingest-done:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ingest-upload__actions {
  margin-top: 16px;
  justify-content: flex-end;
}

.ingest-upload__actions .ingest-done {
  width: auto;
  margin-top: 0;
}

.ingest-card .ingest-upload__actions {
  display: block;
  margin-top: 0;
}

.ingest-card .ingest-upload__actions .ingest-done {
  width: 100%;
  margin-top: 1rem;
}

.ingest-upload__error:empty,
.ingest-upload__status:empty {
  display: none;
}

.ingest-modal .form-dialog__fields {
  overflow: auto;
}

.ingest-modal .ingest-drop {
  margin-top: 0;
}

.toast-host {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 200px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--text, #0f172a);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(7, 39, 65, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.crm-table tbody tr.is-uploading {
  opacity: 0.55;
}

.crm-table tbody tr.is-uploading td {
  color: var(--text-muted, #64748b);
}

.crm-table tbody tr.is-convert-failed td[data-col="source"] {
  overflow: visible;
}

.doc-source-failed {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.doc-convert-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.doc-convert-retry:hover:not(:disabled) {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.doc-convert-retry:disabled,
.doc-convert-retry.is-busy {
  opacity: 0.55;
  cursor: wait;
}

.doc-convert-retry__icon {
  width: 14px;
  height: 14px;
}

.doc-convert-retry.is-busy .doc-convert-retry__icon {
  animation: doc-convert-spin 0.8s linear infinite;
}

@keyframes doc-convert-spin {
  to {
    transform: rotate(360deg);
  }
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row > label {
  flex: 1;
  min-width: 160px;
}

.auth-me-error {
  color: var(--destructive-text);
}

.app-page-body--flush {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.results-split {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  --results-left: 55%;
  /** Collapsed width, and the narrowest the handle can drag the viewer. */
  --results-viewer-min: 300px;
}

.results-left {
  display: flex;
  flex-direction: row;
  flex: 0 0 var(--results-left);
  width: var(--results-left);
  min-width: 280px;
  overflow: hidden;
  background: var(--surface);
}

.results-facts {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  padding: 0;
}

/* Direct split child (compare / legacy): keep width on the facts pane. */
.results-split > .results-facts {
  flex: 0 0 var(--results-left);
  width: var(--results-left);
  min-width: 280px;
}

.tab-side-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.tab-side-nav {
  --tab-side-nav-width: 260px;
  flex: 0 0 var(--tab-side-nav-width);
  width: var(--tab-side-nav-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  overflow: hidden;
}

.tab-side-nav.is-collapsed {
  --tab-side-nav-width: 44px;
}

.tab-side-nav__collapsed {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
}

.tab-side-nav.is-collapsed .tab-side-nav__collapsed {
  display: flex;
}

.tab-side-nav.is-collapsed .tab-side-nav__open {
  display: none;
}

.tab-side-nav__open {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tab-side-nav__header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 6px 0;
  flex-shrink: 0;
}

.tab-side-nav__collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.tab-side-nav__collapse-btn:hover {
  background: var(--row-hover);
  color: var(--header-bg);
}

.tab-side-nav__icon {
  width: 18px;
  height: 18px;
}

/* Don't inherit toolbar `.task-search-box { flex: 1 }` or the rail search grows tall. */
.tab-side-nav__search.task-search-box {
  flex: 0 0 auto;
  min-width: 0;
  max-width: none;
  width: auto;
  margin: 2px 10px 6px;
}

.tab-side-nav__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 0 16px;
}

.tab-side-nav__empty {
  padding: 8px 14px;
  font-size: 13px;
}

.tab-side-nav__group {
  border-bottom: 1px solid var(--border-light);
}

.tab-side-nav__group:last-child {
  border-bottom: none;
}

.tab-side-nav__group-head {
  padding: 8px 14px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tab-side-nav__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 7px 12px 7px 14px;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.tab-side-nav__item:hover {
  background: var(--second-background);
}

.tab-side-nav__item.is-active {
  background: #e3f4fe;
  border-left-color: #54c1fb;
}

.tab-side-nav__item-label {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--header-bg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tab-side-nav__item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.results-left.is-nav-collapsed .tab-side-nav {
  --tab-side-nav-width: 44px;
}

@media (max-width: 1100px) {
  .results-left:not(.is-nav-collapsed) .tab-side-nav {
    --tab-side-nav-width: 220px;
  }
}

.results-facts--compare {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px 0;
  min-width: 320px;
}

.results-facts--compare .results-facts-header {
  margin: 0 0 8px;
  flex-shrink: 0;
  gap: 8px;
}

.results-facts--compare .compare-grid-toolbar.task-page-actions {
  flex: 1;
  width: 100%;
  justify-content: flex-start;
}

.results-facts--compare .compare-grid-toolbar .table-toolbar-controls {
  justify-content: flex-start;
  flex: 1;
  min-width: 0;
}

.results-facts--compare .results-facts-title {
  font-size: 13px;
}

.results-facts--compare .crm-table-page {
  flex: 1;
  min-height: 0;
}

.results-facts--compare .crm-table th,
.results-facts--compare .crm-table td {
  padding: 6px 10px;
}

.results-facts--compare .crm-table th:first-child,
.results-facts--compare .crm-table td:first-child {
  padding-left: 12px;
}

.results-facts--compare .crm-table th:last-child,
.results-facts--compare .crm-table td:last-child {
  padding-right: 12px;
}

.results-facts--compare .crm-table-page.is-freeze-first .crm-table th:first-child,
.results-facts--compare .crm-table-page.is-freeze-first .crm-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border-light);
}

.results-facts--compare .crm-table-page.is-freeze-first .crm-table td:first-child {
  z-index: 1;
}

.results-facts--compare .crm-table-page.is-freeze-first .crm-table th:first-child {
  z-index: 4;
}

.results-facts--compare .crm-table-page.is-freeze-first .crm-table tbody tr:hover td:first-child {
  background: var(--row-hover);
}

.results-facts-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 16px;
}

.results-facts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}

.results-facts-header .results-facts-title {
  margin: 0;
}

.results-facts-toolbar-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  min-height: 44px;
  padding: 6px 10px 6px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.results-facts-toolbar-row .results-facts-title {
  margin: 0;
  flex-shrink: 0;
}

.results-facts-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.results-facts-toolbar .task-search-box {
  flex: 0 1 280px;
  min-width: 160px;
  max-width: 320px;
}

.facts-jump-select {
  flex: 0 1 220px;
  min-width: 160px;
  max-width: 280px;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--tag-bg)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a6270' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  appearance: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.facts-jump-select:hover:not(:disabled) {
  border-color: var(--palette-gray);
}

.facts-jump-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px var(--highlight);
}

.facts-jump-select:disabled {
  opacity: 0.55;
  cursor: default;
}

.results-facts-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.results-facts-toolbar .compare-grid-options {
  margin-left: 0;
}

.results-facts-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 28px 40px;
  container-type: inline-size;
  container-name: facts;
}

.results-facts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 24px 16px;
}

.results-facts-empty p {
  margin: 0;
}

.results-facts-list > .results-facts-title {
  margin-top: 40px;
}

.results-facts-list > .results-facts-title:first-child {
  margin-top: 0;
}

.results-facts-cluster {
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text);
  line-height: 1.5;
}

.fact-row--composed-child {
  margin-left: 12px;
  border-left: 2px solid var(--border-subtle, #e5e7eb);
  padding-left: 10px;
}

.fact-row--composed-parent {
  margin-top: 8px;
}

.fact-compose-lineage {
  margin-top: 4px;
  flex: 1 1 100%;
}

.fact-compose-lineage__pill {
  font-size: 11px;
}

.fact-compose-details__summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.results-export-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.results-export-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.results-facts-title + .results-facts-title {
  margin-top: 40px;
}

.results-split-handle {
  flex: 0 0 1px;
  width: 1px;
  cursor: col-resize;
  background: var(--border-light);
  border: none;
  padding: 0;
  position: relative;
  z-index: 1;
}

.results-split-handle::before {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

.results-split-handle:hover,
.results-split-handle:focus-visible {
  background: var(--accent-primary);
}

.results-viewer {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
  background: var(--tag-bg);
}

.results-viewer .pdf-viewer-scroll {
  flex: 1;
  min-height: 0;
}

.results-viewer .pdf-viewer-scroll.hidden {
  display: none;
}

/* Collapsed document viewer: narrowest width that still fits the toolbar row. */
.results-split.is-viewer-collapsed .results-left,
.results-split.is-viewer-collapsed > .results-facts {
  flex: 1 1 auto;
  width: auto;
}

.results-split.is-viewer-collapsed .results-viewer {
  flex: 0 0 var(--results-viewer-min);
  min-width: var(--results-viewer-min);
}

.pdf-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: 44px;
  padding: 6px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.pdf-viewer-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.pdf-viewer-icon-btn:hover:not(:disabled) {
  background: var(--highlight);
}

.pdf-viewer-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pdf-viewer-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.pdf-viewer-search {
  display: flex;
  align-items: center;
  margin-left: auto;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.pdf-viewer-search[hidden] {
  display: none;
}

.pdf-viewer-toolbar .task-search-box {
  flex: 1 1 180px;
  min-width: 160px;
  max-width: 340px;
}

.pdf-viewer-search-tools {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  padding-left: 6px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
}

.pdf-viewer-search-tools[hidden] {
  display: none;
}

.pdf-viewer-search-count {
  flex-shrink: 0;
  padding: 0 4px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.pdf-viewer-search-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.pdf-viewer-search-nav:hover:not(:disabled) {
  color: var(--text);
  background: var(--highlight);
}

.pdf-viewer-search-nav:disabled {
  opacity: 0.4;
  cursor: default;
}

.pdf-viewer-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  position: relative;
  padding: 12px;
}

.pdf-viewer-empty {
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.pdf-page {
  position: relative;
  margin: 0 auto 12px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(7, 39, 65, 0.12);
}

.pdf-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pdf-page-highlights {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.pdf-highlight {
  position: absolute;
  background: rgba(251, 191, 36, 0.35);
  border-radius: 2px;
}

.pdf-highlight.is-current {
  background: rgba(251, 191, 36, 0.55);
}

.fact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  column-gap: 16px;
  row-gap: 6px;
  align-items: start;
  max-width: none;
  margin-bottom: 10px;
  width: 100%;
}

.fact-row--wide {
  max-width: none;
  margin-top: 24px;
  margin-bottom: 24px;
}

.fact-row.is-active .fact-row-value:not(.fact-row-value--flush),
.fact-row-value.is-active:not(.fact-row-value--flush) {
  outline: 1px solid var(--accent-primary);
}

.fact-row.is-active .fact-row-value--flush > .fact-fields,
.fact-row.is-active .fact-row-value--flush > .fact-value-block,
.fact-row.is-active .fact-row-value--flush > .fact-table-wrap,
.fact-row.is-active .fact-row-value--flush .fact-record {
  outline: 1px solid var(--accent-primary);
  border-radius: 8px;
}

.fact-row-name {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}

.fact-row-name__label {
  min-width: 0;
}

.fact-row-main {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
}

.fact-row-value {
  background: var(--midnight-4);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 34px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  box-sizing: border-box;
}

.fact-value-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fact-value-item:has(> .fact-row-ref) {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.fact-value-item__body {
  flex: 1;
  min-width: 0;
}

.fact-value-primary {
  font-size: 13px;
  line-height: 1.5;
}

.fact-value-stack .fact-value-item + .fact-value-item {
  padding-top: 0;
  border-top: none;
}

.fact-value-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fact-record {
  width: 100%;
  background: var(--midnight-4);
  border-radius: 8px;
  padding: 8px 12px;
  box-sizing: border-box;
}

.fact-record__primary {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.fact-record__rule {
  display: block;
  width: 100%;
  height: 1px;
  margin: 8px 0;
  border: none;
  background: color-mix(in oklab, var(--header-bg) 12%, transparent);
}

.fact-fields {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.fact-fields[data-layout="fields"] {
  background: var(--midnight-4);
  border-radius: 8px;
  padding: 4px 14px;
  box-sizing: border-box;
}

.fact-fields[data-layout="fields"] .fact-fields__value {
  background: transparent;
  border-radius: 0;
  padding: 0;
  min-height: 0;
}

.fact-fields__row {
  display: grid;
  grid-template-columns: minmax(140px, max-content) minmax(0, 1fr);
  column-gap: 16px;
  align-items: start;
  padding: 10px 0;
}

.fact-fields__row + .fact-fields__row {
  border-top: 1px solid color-mix(in oklab, var(--header-bg) 12%, transparent);
}

.fact-fields__label {
  max-width: 280px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  color: color-mix(in oklab, var(--text) 80%, transparent);
}

.fact-fields__value {
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  color: var(--text);
  background: var(--midnight-4);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 34px;
  box-sizing: border-box;
  white-space: pre-wrap;
}

/* Structured nested chrome owns its own surface — don't wrap it in another pill. */
.fact-fields__value:has(> .fact-fields),
.fact-fields__value:has(> .fact-table-wrap),
.fact-fields__value:has(> .fact-record),
.fact-fields__value:has(> .fact-value-block),
.fact-fields__value:has(> .fact-value-stack),
.fact-fields__value:has(> .fact-value-item) {
  background: transparent;
  border-radius: 0;
  padding: 0;
  min-height: 0;
}

.fact-record .fact-fields {
  width: 100%;
  gap: 0;
}

.fact-record .fact-fields__label {
  padding-top: 0;
}

.fact-record .fact-fields__value {
  background: transparent;
  border-radius: 0;
  padding: 0;
  min-height: 0;
}

.fact-record .fact-subtable {
  margin-top: 8px;
}

/* Fields beside a nested table: keyline rows; the table wrap owns the grey. */
.fact-value-block > .fact-fields .fact-fields__value {
  background: transparent;
  border-radius: 0;
  padding: 0;
  min-height: 0;
}

.fact-fields__ref {
  display: inline;
  margin-left: 6px;
  white-space: nowrap;
}

.fact-subtable {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.fact-subtable__label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  color: color-mix(in oklab, var(--text) 80%, transparent);
}

.fact-row-value--flush {
  padding: 0;
  overflow: visible;
  min-height: 0;
  white-space: normal;
  width: 100%;
  max-width: 100%;
  background: transparent;
  display: block;
}

.fact-row-value--flush .fact-table-wrap {
  max-width: 100%;
}

.fact-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background: var(--midnight-4);
  border-radius: 8px;
}

.fact-value-list {
  display: inline;
}

.fact-value-list__sep {
  color: var(--text-muted);
}

.fact-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.fact-table th,
.fact-table td {
  text-align: left;
  vertical-align: top;
  padding: 10px 14px;
  border-bottom: 1px solid color-mix(in oklab, var(--header-bg) 8%, transparent);
  overflow-wrap: anywhere;
}

.fact-table thead th {
  font-weight: 500;
  font-size: 12px;
  color: color-mix(in oklab, var(--text) 65%, transparent);
  background: transparent;
  white-space: nowrap;
}

.fact-table tbody tr:last-child td {
  border-bottom: none;
}

.fact-table__col--tight {
  width: 1%;
  white-space: nowrap;
  overflow-wrap: normal;
}

.fact-table__col--prose {
  max-width: none;
  white-space: normal;
}

.fact-table__text {
  max-width: none;
}

.fact-table__ref {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  overflow-wrap: normal;
}

.fact-table thead th.fact-table__ref {
  /* Keep the column for alignment; no visible "Ref" heading. */
  color: transparent;
  user-select: none;
}

.fact-ref-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--header-bg);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--header-bg) 30%, transparent);
  text-underline-offset: 2px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.fact-ref-link:hover {
  text-decoration-color: var(--header-bg);
}

.fact-row-value.is-muted {
  color: var(--text-muted);
}

.fact-row-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.fact-row-ref {
  width: 52px;
  flex-shrink: 0;
  padding-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.fact-row > .fact-row-ref {
  grid-column: 2;
  grid-row: 1 / -1;
  padding-top: 2px;
}

@container facts (min-width: 640px) {
  .fact-row:not(.fact-row--wide) {
    grid-template-columns: minmax(0, 1fr) minmax(200px, 1fr) 52px;
    align-items: start;
  }

  .fact-row:not(.fact-row--wide) .fact-row-name {
    padding-top: 7px;
  }

  .fact-row:not(.fact-row--wide) .fact-row-main {
    grid-column: 2;
    grid-row: 1;
  }

  .fact-row:not(.fact-row--wide) > .fact-row-ref {
    grid-column: 3;
  }
}

.fact-row-ref button {
  background: none;
  border: none;
  padding: 0;
  color: var(--header-bg);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--header-bg) 30%, transparent);
  text-underline-offset: 2px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.fact-row-ref button:hover {
  text-decoration-color: var(--header-bg);
}

.fact-row-ref-tip {
  position: fixed;
  z-index: 90;
  max-width: min(36rem, calc(100vw - 16px));
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 6px 18px rgba(7, 39, 65, 0.1);
  pointer-events: none;
}

.fact-row-ref-tip[hidden] {
  display: none;
}

.fact-history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.fact-history-btn:hover,
.fact-history-btn:focus-visible {
  background: var(--highlight);
  color: var(--header-bg);
  outline: none;
}

.fact-history-icon {
  width: 14px;
  height: 14px;
  display: block;
}

.fact-history-dialog {
  width: min(640px, calc(100vw - 48px));
}

.fact-history-dialog__body {
  padding-top: 0;
}

.fact-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fact-history-entry {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.fact-history-entry__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  line-height: 1.4;
}

.fact-history-entry__summary::-webkit-details-marker {
  display: none;
}

.fact-history-entry__meta {
  min-width: 0;
  color: var(--text);
}

.fact-history-entry__body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 14px;
  line-height: 1.45;
  overflow-x: auto;
}

.html-viewer-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 480px;
  border: 0;
  background: #fff;
}

.results-viewer .pdf-viewer-scroll:has(.html-viewer-frame) {
  overflow: hidden;
  padding: 0;
}

.text-viewer {
  margin: 0;
  padding: 16px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.text-viewer .kernel-quote-highlight {
  background: rgba(250, 204, 21, 0.55);
  outline: 2px solid #ca8a04;
}

.docx-viewer {
  min-height: 100%;
  background: #fff;
  color: #111;
}

.docx-viewer .docx-preview-wrapper {
  background: #e8e8e8;
  padding: 16px 12px;
}

.docx-viewer .docx-preview {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  margin: 0 auto 16px;
}


.modal--wide {
  max-width: 720px;
  max-height: 90vh;
  overflow: auto;
}

.picker-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 10px 0;
}

.picker-group legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
}

.picker-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

.analysis-page {
  max-width: none;
  padding: 0 0 48px;
}

.results-facts[data-analysis-report],
.tab-side-main[data-analysis-report] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.analysis-split {
  flex: 1;
  min-height: 0;
}

.analysis-report {
  max-width: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 0 48px;
}

.analysis-report__empty {
  padding: 0 28px;
}

.analysis-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  min-height: 44px;
  margin: 0;
  padding: 6px 10px 6px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.analysis-toolbar .task-search-box {
  flex: 0 1 180px;
  min-width: 140px;
  max-width: 200px;
}

.analysis-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.analysis-q__evidence {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 4px 0 8px;
}

.analysis-q__evidence .fact-row:last-child,
.analysis-q__table .fact-row:last-child {
  margin-bottom: 0;
}

/* Keep evidence labels a step below the question heading. */
.analysis-q__evidence .fact-row-name,
.analysis-q__table .fact-row-name {
  font-size: 14px;
}

.analysis-q__table {
  margin: 10px 0 14px;
}

.analysis-persona {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 0 56px;
}

.analysis-persona:last-child {
  margin-bottom: 0;
}

.analysis-persona__header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}

.analysis-persona__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
}

.analysis-persona__title {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--header-bg);
}

.analysis-persona__rule {
  display: block;
  width: 100%;
  height: 1px;
  margin: 0;
  border: none;
  background: oklch(0.409 0.1031 253.19 / 20%);
}

.analysis-persona__subtitle {
  margin: 0;
  padding: 0 28px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.analysis-persona__body {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 0 28px;
}

.analysis-q {
  margin: 0;
  padding: 0 0 0 30px;
  border: none;
  scroll-margin-top: 56px;
}

.analysis-q.is-active .analysis-q__q {
  outline: none;
}

.analysis-q.is-active {
  border-radius: 8px;
  box-shadow: inset 3px 0 0 #54c1fb;
  padding-left: 42px;
  margin-left: -12px;
}

.analysis-q__q {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--header-bg);
}

.analysis-q__a {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  max-width: 760px;
}

/* Step the answer and evidence in under the question, as facts do under their name. */
.analysis-q__a,
.analysis-q__details,
.analysis-q__warn,
.analysis-q__evidence,
.analysis-q__table {
  padding-left: 30px;
}

.analysis-q__details,
.analysis-q__warn {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Document overview (identity) */
.overview-split {
  flex: 1;
  min-height: 0;
}

.document-overview {
  max-width: 52rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.document-overview__section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.document-overview__heading {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.document-overview__description {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}
.documents-file-secondary {
  margin-top: 0.15rem;
  font-size: 0.85rem;
}
