/* OpenCRM-inspired admin shell + extract page styles */

: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;
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 56px;
  --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: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

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

.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;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  height: 100%;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  transition: width 0.2s ease, flex-basis 0.2s ease;
  overflow: visible;
  position: relative;
  z-index: 40;
}

.app-shell--collapsed .sidebar {
  flex-basis: var(--sidebar-width-collapsed);
  width: var(--sidebar-width-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-light);
  min-height: 56px;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
}

.sidebar-logo:hover {
  text-decoration: none;
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-logo-text span {
  color: var(--accent-primary);
}

.app-shell--collapsed .sidebar-logo {
  display: none;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-collapse-btn:hover {
  background: var(--row-hover);
  color: var(--text-muted);
}

.app-shell--collapsed .sidebar-header {
  flex-direction: column;
  padding: 12px 8px;
  gap: 10px;
}

.app-shell--collapsed .sidebar-collapse-btn {
  width: 100%;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  min-height: 36px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}

.sidebar-link:hover {
  background: var(--row-hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--highlight);
  color: var(--text);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent-primary);
}

.sidebar-link-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.sidebar-link:hover .sidebar-link-icon {
  color: var(--text);
}

.sidebar-link.active .sidebar-link-icon {
  color: var(--accent-primary);
}

.sidebar-link-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.app-shell--collapsed .sidebar-link {
  justify-content: center;
  padding: 9px 8px;
}

.app-shell--collapsed .sidebar-link-label,
.app-shell--collapsed .sidebar-user-name {
  display: none;
}

.sidebar-footer {
  position: relative;
  padding: 8px 8px 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-emulate {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 8px 8px;
}

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

.sidebar-emulate-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.app-shell--collapsed .sidebar-emulate-label {
  display: none;
}

.sidebar-user--emulating {
  color: #9a5b00;
  background: rgba(245, 166, 35, 0.16);
}

.sidebar-user--emulating .sidebar-user-avatar {
  background: #f5a623;
  color: #072741;
}

.sidebar-user--emulating:hover {
  background: rgba(245, 166, 35, 0.28);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  margin-top: 0;
  min-height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sidebar-user:hover {
  background: var(--highlight);
}

.sidebar-user:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

.sidebar-user[data-state="open"] {
  background: var(--highlight);
}

.app-shell--collapsed .sidebar-user {
  justify-content: center;
  padding: 9px 8px;
}

.sidebar-user-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  width: 14.5rem;
  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;
}

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

.app-shell--collapsed .sidebar-user-menu {
  left: calc(100% + 6px);
  bottom: 8px;
}

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

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

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

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

.sidebar-user-menu-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-user-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.sidebar-user-menu-item {
  color: var(--text);
}

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

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

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

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

.sidebar-user-menu-item-icon .nav-icon {
  width: 16px;
  height: 16px;
}

.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(--surface);
  position: sticky;
  top: 0;
  z-index: 15;
  overflow: visible;
}

.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--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 .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: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(--accent-primary);
}

.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;
}

.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(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.btn-primary:hover {
  background: #2a74c4;
}

.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 {
  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;
}

.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);
}

/* 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;
  }
  .sidebar {
    display: none;
  }
}

.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);
}

.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__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__list {
  overflow-y: auto;
  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;
}

.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;
  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: flex-end;
}

.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;
  padding-right: 14px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

.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;
}

.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);
}

#panel-results.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%;
}

.results-facts {
  flex: 0 0 var(--results-left);
  width: var(--results-left);
  min-width: 280px;
  overflow: auto;
  padding: 24px 28px 40px;
}

.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-export-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

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

.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: hidden;
  background: var(--tag-bg);
}

.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-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: flex;
  align-items: flex-start;
  gap: 16px;
  max-width: 800px;
  margin-bottom: 12px;
}

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

.fact-row-name {
  width: 200px;
  flex-shrink: 0;
  padding-top: 6px;
  font-size: 14px;
  font-weight: 500;
  word-break: break-word;
}

.fact-row-main {
  flex: 1;
  min-width: 0;
}

.fact-row-value {
  background: var(--tag-bg);
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 34px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

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

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

.fact-row-ref button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font: inherit;
}

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

.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;
}
