/* Alpha7X brand alignment (restyled to match the trustworksos.ai/studio neutral/zinc theme) */
:root {
  --a7x-bg: #ffffff;
  --a7x-primary: #0b0b12;
  --a7x-primary-dark: #000000;
  --a7x-primary-soft: #f1f1f3;
  --a7x-primary-contrast: #ffffff;
  --a7x-ink: #0b0b12;
  --a7x-muted: #6b6f76;
  --a7x-faint: #9a9ea5;
  --a7x-surface: #f6f6f8;
  --a7x-border: #e4e4e8;
  --a7x-radius: 10px;
  --a7x-radius-lg: 14px;
  --a7x-success: #1a7f4e;
  --a7x-danger: #c62f3b;
  --a7x-shadow-color: 11, 11, 18;
  --a7x-link-evidence: #7c3aed;
  --a7x-amber: #b8860b;
  color-scheme: light;
}

/* Theme is driven by the embedding parent app (ui.alpha7x.ai), not the OS preference — see
   wwwroot/js/theme-bridge.js. Explicit data-theme attribute on <html>, set before first paint.

   Dark values are taken directly from the parent app's own design system (Alpha7xUI's
   apps/Alpha7xUiWeb/src/styles.css :root/.dark oklch tokens), not approximated, so the embedded
   iframe actually matches the shell it sits in: --a7x-bg = their --background, --a7x-surface =
   their --card (a real step lighter than the page, for visible card elevation — the previous
   --a7x-surface was too close to --a7x-bg to read as a card at all), --a7x-border = their
   --border (translucent white, not a flat gray), --a7x-primary = their --primary (inverted to
   near-white in dark mode, same as theirs). */
:root[data-theme="dark"] {
  --a7x-bg: oklch(0.129 0.042 264.695);
  --a7x-primary: oklch(0.929 0.013 255.508);
  --a7x-primary-dark: oklch(1 0 0);
  --a7x-primary-soft: oklch(0.929 0.013 255.508 / 16%);
  --a7x-primary-contrast: oklch(0.208 0.042 265.755);
  --a7x-ink: oklch(0.984 0.003 247.858);
  --a7x-muted: oklch(0.704 0.04 256.788);
  --a7x-faint: oklch(0.551 0.027 264.364);
  --a7x-surface: oklch(0.208 0.042 265.755);
  --a7x-border: oklch(1 0 0 / 10%);
  --a7x-success: oklch(0.72 0.17 150);
  --a7x-danger: oklch(0.704 0.191 22.216);
  --a7x-shadow-color: 0, 0, 0;
  --a7x-link-evidence: oklch(0.75 0.15 300);
  --a7x-amber: oklch(0.78 0.14 80);
  color-scheme: dark;
}

/* Dark-only structural overrides — matching the parent app's own card/field relationship rather
   than just swapping color values. Their --card sits a real step lighter than --background, so
   panels/modals here are explicitly lifted to --a7x-surface instead of staying flush with the
   page (plain var() substitution alone left them flat with no visible edge). Form fields then go
   the other way, to --a7x-bg, so they read as recessed wells against the now-lighter card instead
   of disappearing into it (in light mode the relationship is reversed — surface is already a step
   below the white page/card, so fields don't need their own override there). */
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .token-gate {
  background: var(--a7x-surface);
}

:root[data-theme="dark"] .modal-field input[type="text"],
:root[data-theme="dark"] .modal-field textarea,
:root[data-theme="dark"] .modal-field select,
:root[data-theme="dark"] .modal-field .readonly-value,
:root[data-theme="dark"] .json-preview pre {
  background: var(--a7x-bg);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--a7x-ink);
  background: var(--a7x-bg);
  font-size: 15px;
}

code {
  color: var(--a7x-primary-dark);
  background-color: var(--a7x-surface);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  font-size: 0.9em;
}

/* --- Shell: sidebar + content --- */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--a7x-border);
  background: var(--a7x-bg);
}

.sidebar-brand {
  display: block;
  padding: 16px 18px;
  border-bottom: 1px solid var(--a7x-border);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--a7x-ink);
  text-decoration: none;
}

.sidebar-brand span {
  display: block;
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--a7x-muted);
  margin-top: 1px;
}

.db-label-badge {
  position: fixed;
  right: 6px;
  bottom: 4px;
  z-index: 50;
  font-weight: 400;
  font-size: 0.6rem;
  line-height: 1.3;
  color: var(--a7x-muted);
  opacity: 0.55;
  font-family: ui-monospace, monospace;
  pointer-events: none;
  user-select: text;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--a7x-faint);
  padding: 4px 8px 8px;
  margin-top: 16px;
}

.nav-section-label:first-child {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--a7x-ink);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.nav-icon {
  display: flex;
  flex: none;
  color: var(--a7x-muted);
}

.nav-icon svg {
  width: 16px;
  height: 16px;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  color: var(--a7x-ink);
}

.nav-label {
  min-width: 0;
}

.nav-item:hover {
  background: var(--a7x-surface);
}

.nav-item.active {
  background: var(--a7x-surface);
  color: var(--a7x-ink);
}

.nav-item.wip {
  color: var(--a7x-muted);
  font-weight: 500;
}

.wip-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--a7x-muted);
  background: var(--a7x-surface);
  border: 1px solid var(--a7x-border);
  border-radius: 999px;
  padding: 1px 7px;
  vertical-align: middle;
}

.sidebar-token {
  border-top: 1px solid var(--a7x-border);
  padding: 12px 14px;
}

.token-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.dot-green {
  background: var(--a7x-success);
  box-shadow: 0 0 0 3px rgba(26, 127, 78, 0.15);
}

.dot-red {
  background: var(--a7x-danger);
  box-shadow: 0 0 0 3px rgba(198, 47, 59, 0.15);
}

.dot-amber {
  background: var(--a7x-amber);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

.token-form textarea {
  width: 100%;
  min-height: 64px;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  padding: 7px;
  border: 1px solid var(--a7x-border);
  border-radius: 8px;
  resize: vertical;
  margin-bottom: 6px;
}

.token-form input[type="email"],
.token-form input[type="password"] {
  width: 100%;
  font-size: 0.78rem;
  padding: 7px;
  border: 1px solid var(--a7x-border);
  border-radius: 8px;
  margin-bottom: 6px;
}

.token-error {
  color: var(--a7x-danger);
  font-size: 0.74rem;
  margin: 6px 0 0;
}

.token-paste-fallback {
  margin-top: 10px;
}

.token-paste-fallback summary {
  font-size: 0.74rem;
  color: var(--a7x-muted, inherit);
  cursor: pointer;
}

.token-paste-fallback .token-form {
  margin-top: 8px;
}

.btn-sm, .btn-link-sm {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
}

.btn-sm {
  width: 100%;
  background: var(--a7x-primary);
  border: 1px solid var(--a7x-primary);
  color: var(--a7x-primary-contrast);
  padding: 6px 10px;
}

.btn-sm:hover {
  background: var(--a7x-primary-dark);
}

.btn-link-sm {
  background: none;
  border: none;
  color: var(--a7x-muted);
  text-decoration: underline;
  padding: 0;
}

.content {
  flex: 1;
  min-width: 0;
}

main {
  padding: 20px 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 14px;
}

/* --- Landing / WIP pages --- */
.landing {
  max-width: 640px;
}

.landing h1 {
  font-size: 1.4rem;
  margin: 0 0 8px;
}

.landing p {
  color: var(--a7x-muted);
  font-size: 0.92rem;
}

.dev-login-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 16px 0;
}

.dev-login-links a {
  color: var(--a7x-accent, #4f7cff);
  font-size: 0.92rem;
  text-decoration: none;
}

.dev-login-links a:hover {
  text-decoration: underline;
}

/* --- Token gate (inline, within content) --- */
.token-gate {
  border: 1px solid var(--a7x-border);
  border-radius: var(--a7x-radius-lg);
  padding: 20px;
  max-width: 520px;
}

.token-gate p {
  color: var(--a7x-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* --- Toolbar --- */
.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 10px;
}

.toolbar .field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--a7x-muted);
  margin-bottom: 5px;
}

.toolbar input[type="search"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--a7x-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
}

.toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--a7x-primary);
  box-shadow: 0 0 0 3px var(--a7x-primary-soft);
}

.format-row {
  margin-bottom: 16px;
}

.format-row label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--a7x-muted);
  margin-bottom: 6px;
}

.pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--a7x-border);
  background: var(--a7x-bg);
  color: var(--a7x-ink);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.pill:hover {
  border-color: var(--a7x-primary);
}

.pill.active {
  background: var(--a7x-ink);
  border-color: var(--a7x-ink);
  color: var(--a7x-primary-contrast);
}

/* --- Panel grid --- */
.panels {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 1.1fr;
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--a7x-border);
  border-radius: var(--a7x-radius-lg);
  box-shadow: 0 1px 2px rgba(var(--a7x-shadow-color), 0.04);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 12px;
  background: var(--a7x-surface);
  border-bottom: 1px solid var(--a7x-border);
  border-top-left-radius: var(--a7x-radius-lg);
  border-top-right-radius: var(--a7x-radius-lg);
}

.panel-header h2 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 0;
}

.panel-header .count {
  font-size: 0.78rem;
  color: var(--a7x-muted);
  font-variant-numeric: tabular-nums;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-clear {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--a7x-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.btn-clear:hover {
  color: var(--a7x-ink);
}

.panel-body {
  height: auto;
  min-height: 120px;
  max-height: 480px;
  overflow-y: auto;
  padding: 6px;
}

/* Refreshing a panel dims its current rows instead of blanking them to a bare "Loading…" state. */
.panel-body.is-loading {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--a7x-border);
  font-size: 0.78rem;
  color: var(--a7x-muted);
}

.panel-footer select {
  font-size: 0.78rem;
  border: 1px solid var(--a7x-border);
  border-radius: 6px;
  padding: 2px 4px;
}

.panel-footer .pager {
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel-footer button {
  border: 1px solid var(--a7x-border);
  background: var(--a7x-bg);
  border-radius: 6px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  line-height: 1;
}

.panel-footer button:disabled {
  opacity: 0.35;
  cursor: default;
}

.row-item {
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.row-item:hover {
  background: var(--a7x-surface);
}

.row-item.selected {
  background: var(--a7x-surface);
  border-color: var(--a7x-ink);
}

.row-item .title {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.3;
}

.row-item .subtitle {
  font-size: 0.78rem;
  color: var(--a7x-muted);
  margin-top: 1px;
}

.row-item .meta {
  font-size: 0.76rem;
  color: var(--a7x-faint);
  margin-top: 2px;
}

.row-item .derived {
  font-size: 0.8rem;
  color: var(--a7x-muted);
  margin-top: 2px;
}

.format-badges {
  display: flex;
  gap: 4px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.format-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--a7x-surface);
  color: var(--a7x-muted);
  border: 1px solid var(--a7x-border);
}

/* --- Table-mode panel body (Panel's tableColumns option) --- */
#panel-policies .panel-body,
#panel-agents .panel-body,
#panel-assignments .panel-body,
#panel-tasks .panel-body,
#panel-mappings .panel-body {
  padding: 0;
}

.data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.86rem;
}

/* Policy Library: Policy ID | Display Name | Rule | Output Fact Data Type */
#panel-policies .data-table th:nth-child(1), #panel-policies .data-table td:nth-child(1) { width: 18%; }
#panel-policies .data-table th:nth-child(2), #panel-policies .data-table td:nth-child(2) { width: 20%; }
#panel-policies .data-table th:nth-child(3), #panel-policies .data-table td:nth-child(3) { width: 48%; }
#panel-policies .data-table th:nth-child(4), #panel-policies .data-table td:nth-child(4) { width: 14%; }

/* Agent Library: Agent ID | Agent Name | Role | Domain | Lifecycle Stage | Description */
#panel-agents .data-table th:nth-child(1), #panel-agents .data-table td:nth-child(1) { width: 14%; }
#panel-agents .data-table th:nth-child(2), #panel-agents .data-table td:nth-child(2) { width: 16%; }
#panel-agents .data-table th:nth-child(3), #panel-agents .data-table td:nth-child(3) { width: 18%; }
#panel-agents .data-table th:nth-child(4), #panel-agents .data-table td:nth-child(4) { width: 10%; }
#panel-agents .data-table th:nth-child(5), #panel-agents .data-table td:nth-child(5) { width: 12%; }
#panel-agents .data-table th:nth-child(6), #panel-agents .data-table td:nth-child(6) { width: 30%; }

/* Agent-to-Evidence/Policy/Extra Task: Agent ID | [linked] ID | Created At */
#panel-assignments .data-table th:nth-child(1), #panel-assignments .data-table td:nth-child(1) { width: 20%; }
#panel-assignments .data-table th:nth-child(2), #panel-assignments .data-table td:nth-child(2) { width: 62%; }
#panel-assignments .data-table th:nth-child(3), #panel-assignments .data-table td:nth-child(3) { width: 18%; }

/* Task Library: Task ID | Task Name | Type | Canonical Field / SOT | Evidence Bindings */
#panel-tasks .data-table th:nth-child(1), #panel-tasks .data-table td:nth-child(1) { width: 16%; }
#panel-tasks .data-table th:nth-child(2), #panel-tasks .data-table td:nth-child(2) { width: 20%; }
#panel-tasks .data-table th:nth-child(3), #panel-tasks .data-table td:nth-child(3) { width: 10%; }
#panel-tasks .data-table th:nth-child(4), #panel-tasks .data-table td:nth-child(4) { width: 22%; }
#panel-tasks .data-table th:nth-child(5), #panel-tasks .data-table td:nth-child(5) { width: 32%; }

/* Extraction Mappings: Evidence Type ID | Canonical Field ID | Transform Type ID | Params | Created At */
#panel-mappings .data-table th:nth-child(1), #panel-mappings .data-table td:nth-child(1) { width: 20%; }
#panel-mappings .data-table th:nth-child(2), #panel-mappings .data-table td:nth-child(2) { width: 22%; }
#panel-mappings .data-table th:nth-child(3), #panel-mappings .data-table td:nth-child(3) { width: 16%; }
#panel-mappings .data-table th:nth-child(4), #panel-mappings .data-table td:nth-child(4) { width: 28%; }
#panel-mappings .data-table th:nth-child(5), #panel-mappings .data-table td:nth-child(5) { width: 14%; }

.params-preview {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--a7x-surface);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--a7x-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--a7x-border);
}

.data-table tbody tr.row-item {
  cursor: pointer;
  border-bottom: 1px solid var(--a7x-border);
}

.data-table tbody tr.row-item:last-child {
  border-bottom: none;
}

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

.data-table tbody tr.row-item.selected td {
  background: var(--a7x-surface);
}

.data-table td {
  padding: 8px 10px;
  vertical-align: top;
  color: var(--a7x-ink);
  overflow-wrap: break-word;
  word-break: break-word;
}

.data-table td code {
  font-size: 0.78rem;
}

.empty-state {
  color: var(--a7x-faint);
  font-size: 0.85rem;
  padding: 20px 10px;
  text-align: center;
}

.error-state {
  color: var(--a7x-danger);
  font-size: 0.85rem;
  padding: 12px 10px;
}

/* --- Runtime impact --- */
.impact-section h3 {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--a7x-muted);
  margin: 12px 8px 4px;
}

.impact-section h3:first-child {
  margin-top: 6px;
}

.impact-item {
  padding: 5px 9px;
  font-size: 0.82rem;
  border-radius: 6px;
}

.impact-item:hover {
  background: var(--a7x-surface);
}

.impact-item .title {
  font-weight: 600;
}

.impact-item .subtitle {
  font-size: 0.74rem;
  color: var(--a7x-muted);
}

button.btn {
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--a7x-radius);
  border: 1px solid var(--a7x-primary);
  background: var(--a7x-primary);
  color: var(--a7x-primary-contrast);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.88rem;
}

button.btn:hover {
  background: var(--a7x-primary-dark);
  border-color: var(--a7x-primary-dark);
}

button.btn-link {
  background: none;
  border: none;
  color: var(--a7x-muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 0;
}

@media (max-width: 1400px) {
  .panels {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Single-panel library pages (Task/Policy/Agent/Evidence/Canonical Field) --- */
.panel-single {
  max-width: none;
}

.panel-single .panel-body {
  height: auto;
  min-height: 140px;
  max-height: 560px;
}

/* --- List + detail, side by side (Evidence Library: Sources | Source Detail; Canonical Field
   Library: Canonical Fields | Canonical Field Detail, AVE-1248) --- */
.list-detail-split {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 14px;
  align-items: start;
}

.list-detail-split .panel-single,
.list-detail-split .detail-panel {
  max-width: none;
  margin-top: 0;
}

.list-detail-split .detail-panel .panel-body {
  max-height: none;
  height: 560px;
}

@media (max-width: 900px) {
  .list-detail-split {
    grid-template-columns: 1fr;
  }
}

.match-mode {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 4px 0 16px;
  font-size: 0.85rem;
}

.match-mode label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-weight: 600;
}

.detail-panel {
  margin-top: 14px;
  max-width: 1100px;
}

.detail-panel .panel-body {
  height: auto;
  min-height: 100px;
  max-height: 360px;
  overflow-y: auto;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid var(--a7x-border);
  font-size: 0.85rem;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row .label {
  color: var(--a7x-muted);
}

.chip-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.chip {
  font-size: 0.72rem;
  background: var(--a7x-surface);
  border: 1px solid var(--a7x-border);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--a7x-muted);
}

/* --- Tag/chip input (AVE-1247: Enum Sets) --- */
.tag-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--a7x-surface);
}

.tag-input:focus-within {
  border-color: var(--a7x-primary);
  box-shadow: 0 0 0 3px var(--a7x-primary-soft);
}

.tag-input-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-input-chips:empty {
  display: none;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  background: var(--a7x-bg);
  border: 1px solid var(--a7x-border);
  border-radius: 5px;
  padding: 2px 4px 2px 8px;
  color: var(--a7x-ink);
}

.tag-chip-remove {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--a7x-muted);
  cursor: pointer;
}

.tag-chip-remove:hover {
  background: var(--a7x-border);
  color: var(--a7x-ink);
}

.tag-input input[type="text"] {
  border: none;
  background: transparent;
  padding: 2px 0;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--a7x-ink);
  outline: none;
}

/* --- Update button (panel footer) --- */
.panel-footer button.btn-update {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 12px;
  width: auto;
  height: auto;
  border: 1px solid var(--a7x-primary);
  background: var(--a7x-primary);
  color: var(--a7x-primary-contrast);
}

.panel-footer button.btn-update:disabled {
  opacity: 0.4;
  cursor: default;
  background: var(--a7x-bg);
  color: var(--a7x-muted);
  border-color: var(--a7x-border);
}

/* --- Delete button (panel footer): always disabled, display-only, no behavior wired up --- */
.panel-footer button.btn-delete:disabled {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  padding: 3px 12px;
  width: auto;
  height: auto;
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--a7x-bg);
  color: var(--a7x-muted);
  border: 1px solid var(--a7x-border);
}

.panel-footer button.btn-new {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 12px;
  width: auto;
  height: auto;
  border: 1px solid var(--a7x-ink);
  background: var(--a7x-bg);
  color: var(--a7x-ink);
}

.panel-footer button.btn-new:hover {
  background: var(--a7x-surface);
}

/* --- Deploy to Production (Validation page): danger-colored, since it writes to production --- */
.panel-footer button.btn-deploy {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 12px;
  width: auto;
  height: auto;
  border: 1px solid var(--a7x-danger);
  background: var(--a7x-bg);
  color: var(--a7x-danger);
}

.panel-footer button.btn-deploy:hover {
  background: var(--a7x-danger);
  color: #ffffff;
}

.panel-footer button.btn-deploy:disabled {
  opacity: 0.4;
  cursor: default;
  background: var(--a7x-bg);
  color: var(--a7x-danger);
}

/* --- Link Evidence Source button: purple border calls out new, not-previously-available functionality --- */
.panel-footer button.btn-link-evidence {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 12px;
  width: auto;
  height: auto;
  border: 2px solid var(--a7x-link-evidence);
  background: var(--a7x-bg);
  color: var(--a7x-link-evidence);
}

.panel-footer button.btn-link-evidence:hover {
  background: var(--a7x-link-evidence);
  color: #ffffff;
}

/* --- Update modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(var(--a7x-shadow-color), 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--a7x-bg);
  border-radius: var(--a7x-radius-lg);
  width: 672px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 50px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(var(--a7x-shadow-color), 0.25);
}

/* --- Wide modal: forms with long enumerated values (e.g. Agent to Extra Tasks' TASK.* IDs) --- */
.modal-lg {
  width: 984px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 17px 22px;
  border-bottom: 1px solid var(--a7x-border);
}

.modal-header h2 {
  font-size: 1rem;
  margin: 0;
}

.modal form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.modal-close {
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--a7x-muted);
}

.modal-body {
  padding: 19px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--a7x-border);
  font-size: 0.8rem;
  color: var(--a7x-muted);
}

.modal-nav button {
  border: 1px solid var(--a7x-border);
  background: var(--a7x-bg);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: inherit;
}

.modal-field {
  margin-bottom: 26px;
}

.modal-field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--a7x-ink);
  margin-bottom: 10px;
}

.modal-field input[type="text"],
.modal-field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--a7x-surface);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--a7x-ink);
}

.modal-field textarea {
  resize: vertical;
  min-height: 65px;
}

.modal-field input[type="text"]:focus,
.modal-field textarea:focus {
  outline: none;
  border-color: var(--a7x-primary);
  box-shadow: 0 0 0 3px var(--a7x-primary-soft);
}

.modal-field select {
  width: 100%;
  padding: 12px 36px 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--a7x-ink);
  background-color: var(--a7x-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6f76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.modal-field select:focus {
  outline: none;
  border-color: var(--a7x-primary);
  box-shadow: 0 0 0 3px var(--a7x-primary-soft);
}

.modal-field .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 12px 14px;
  background: var(--a7x-surface);
  border-radius: 10px;
}

.modal-field .checkbox-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--a7x-ink);
  margin-bottom: 0;
  cursor: pointer;
}

.modal-field .checkbox-option input[type="checkbox"] {
  accent-color: var(--a7x-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.modal-field .readonly-value {
  font-size: 0.92rem;
  color: var(--a7x-ink);
  padding: 12px 14px;
  background: var(--a7x-surface);
  border-radius: 10px;
}

.modal-field .hint {
  font-size: 0.78rem;
  color: var(--a7x-muted);
  margin-top: 6px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 17px 22px;
  border-top: 1px solid var(--a7x-border);
}

.modal-error {
  color: var(--a7x-danger);
  font-size: 0.8rem;
  margin-right: auto;
}

.modal-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--a7x-ink);
  margin: 26px 0 4px;
  padding-top: 20px;
  border-top: 1px solid var(--a7x-border);
}

.json-field {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8rem;
  min-height: 110px;
}

/* --- Advanced: review generated JSON (read-only live preview, Policy Create/Update) --- */
.json-preview {
  margin-bottom: 14px;
}

.json-preview summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--a7x-muted);
  padding: 8px 10px;
  border: 1px solid var(--a7x-border);
  border-radius: 8px;
  list-style: none;
}

.json-preview summary::-webkit-details-marker {
  display: none;
}

.json-preview summary::before {
  content: "\203A";
  display: inline-block;
  width: 10px;
  margin-right: 6px;
  transition: transform 0.15s;
}

.json-preview[open] summary {
  border-radius: 8px 8px 0 0;
}

.json-preview[open] summary::before {
  transform: rotate(90deg);
}

.json-preview pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
  background: var(--a7x-surface);
  border: 1px solid var(--a7x-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 10px;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--a7x-ink);
}

/* --- Task Library: simple-case editor row (SOT/supported_evidences/ignore_condition select +
   disabled "Open Applicability builder" placeholder button, AVE-1276/1277/1278) --- */
.simple-case-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.simple-case-row select {
  flex: 1;
}

/* --- Extraction Mappings: read-only params preview (detail panel, AVE-1256) --- */
.params-preview {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
  background: var(--a7x-surface);
  border: 1px solid var(--a7x-border);
  border-radius: 8px;
  padding: 10px;
  margin: 4px 0 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--a7x-ink);
}

/* --- Extraction Mappings: structured per-transform-type params editors (AVE-1258/1260/1261/1262) --- */
.struct-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.struct-grid label,
.struct-sublabel {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.78rem;
  color: var(--a7x-muted);
}

.struct-sublabel {
  margin-top: 10px;
}

.struct-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.struct-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 6px;
}

.struct-row-remove {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--a7x-muted);
  cursor: pointer;
}

.struct-row-remove:hover {
  background: var(--a7x-border);
  color: var(--a7x-ink);
}

.struct-add {
  align-self: flex-start;
  margin-top: 8px;
}

/* multi_checkbox_to_choice: one choice heading with a stack of searchable extraction-key inputs (AVE-1560) */
.struct-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--a7x-border);
  border-radius: 6px;
}

.struct-option-head,
.struct-key {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
}

.struct-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.struct-add-key {
  align-self: flex-start;
}

/* --- Validation report: one accordion per Studio check (Validation page) --- */
.validation-summary {
  padding: 10px 12px;
  color: var(--a7x-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.validation-report {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px;
}

.validation-check {
  border: 1px solid var(--a7x-border);
  border-radius: 8px;
  overflow: hidden;
}

.validation-check summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
}

.validation-check summary::-webkit-details-marker {
  display: none;
}

.validation-check summary::before {
  content: "\203A";
  display: inline-block;
  width: 10px;
  margin-right: 6px;
  color: var(--a7x-muted);
  transition: transform 0.15s;
}

.validation-check[open] summary::before {
  transform: rotate(90deg);
}

.validation-check-static {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.validation-check-desc {
  flex: 1;
  min-width: 0;
}

.validation-check-counts {
  display: flex;
  gap: 6px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.validation-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.validation-count.count-passed {
  color: var(--a7x-success);
  background: color-mix(in srgb, var(--a7x-success) 16%, transparent);
}

.validation-count.count-failed {
  color: var(--a7x-danger);
  background: color-mix(in srgb, var(--a7x-danger) 16%, transparent);
}

.validation-count.count-skipped {
  color: var(--a7x-muted);
  background: var(--a7x-surface);
}

.validation-check-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--a7x-border);
  background: var(--a7x-surface);
  font-size: 0.82rem;
}

.validation-skipped-note {
  color: var(--a7x-muted);
  font-size: 0.78rem;
  margin-top: 10px;
}

.validation-failures-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 8px;
  table-layout: fixed;
}

.validation-failures-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--a7x-border);
  color: var(--a7x-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.03em;
}

.validation-failures-table th:nth-child(1) { width: 20%; }
.validation-failures-table th:nth-child(2) { width: 42%; }
.validation-failures-table th:nth-child(3) { width: 38%; }

.validation-failures-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--a7x-border);
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: break-word;
}

.validation-failures-table tr:last-child td {
  border-bottom: none;
}

.validation-kv div {
  overflow-wrap: break-word;
  word-break: break-word;
}

.validation-kv div + div {
  margin-top: 2px;
}

/* --- QA Checklist (/testing20261022): progress bar + nested parent/subtask accordions --- */
.qa-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 18px;
  padding: 10px 14px;
  background: var(--a7x-surface);
  border: 1px solid var(--a7x-border);
  border-radius: var(--a7x-radius);
}

.qa-summary-bar {
  flex: 1;
  height: 8px;
  background: var(--a7x-border);
  border-radius: 999px;
  overflow: hidden;
  min-width: 120px;
}

.qa-summary-fill {
  height: 100%;
  width: 0%;
  background: var(--a7x-success);
  border-radius: 999px;
  transition: width 0.2s ease;
}

#qaSummaryText {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--a7x-ink);
  white-space: nowrap;
}

.qa-tickets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qa-parent {
  border: 1px solid var(--a7x-border);
  border-radius: var(--a7x-radius-lg);
  background: var(--a7x-bg);
  overflow: hidden;
}

.qa-parent-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  background: var(--a7x-surface);
}

.qa-parent-summary::-webkit-details-marker {
  display: none;
}

.qa-parent-summary::before {
  content: "\203A";
  display: inline-block;
  width: 10px;
  color: var(--a7x-muted);
  transition: transform 0.15s;
}

.qa-parent[open] > .qa-parent-summary::before {
  transform: rotate(90deg);
}

.qa-parent-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--a7x-ink);
}

.qa-parent-title code {
  font-weight: 700;
}

.qa-jira-link {
  font-size: 0.78rem;
  color: var(--a7x-muted);
  text-decoration: none;
}

.qa-jira-link:hover {
  color: var(--a7x-primary);
  text-decoration: underline;
}

.qa-parent-stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.qa-parent-progress {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--a7x-muted);
  min-width: 36px;
  text-align: right;
}

.qa-subtasks {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--a7x-border);
}

.qa-subtask {
  border-bottom: 1px solid var(--a7x-border);
}

.qa-subtask:last-child {
  border-bottom: none;
}

.qa-subtask-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 32px;
  cursor: pointer;
  list-style: none;
}

.qa-subtask-summary::-webkit-details-marker {
  display: none;
}

.qa-subtask-checked .qa-subtask-summary {
  background: color-mix(in oklab, var(--a7x-success) 8%, transparent);
}

.qa-check {
  width: 16px;
  height: 16px;
  accent-color: var(--a7x-success);
  flex-shrink: 0;
}

.qa-subtask-id {
  flex-shrink: 0;
}

.qa-subtask-id code {
  font-size: 0.78rem;
}

.qa-subtask-title {
  font-size: 0.85rem;
  color: var(--a7x-ink);
  flex: 1;
}

.qa-subtask-checked .qa-subtask-title {
  color: var(--a7x-muted);
  text-decoration: line-through;
}

.qa-status-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.qa-status-done {
  background: color-mix(in oklab, var(--a7x-success) 18%, transparent);
  color: var(--a7x-success);
}

.qa-status-blocked {
  background: color-mix(in oklab, var(--a7x-danger) 18%, transparent);
  color: var(--a7x-danger);
}

.qa-subtask-body {
  padding: 4px 16px 16px 32px;
}

.qa-subtask-jira {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  padding: 8px 10px;
  background: var(--a7x-surface);
  border: 1px solid var(--a7x-border);
  border-radius: 8px;
  margin-bottom: 10px;
}

.qa-subtask-jira a {
  color: var(--a7x-primary);
  text-decoration: none;
  font-weight: 600;
}

.qa-subtask-jira a:hover {
  text-decoration: underline;
}

.qa-subtask-jira-desc {
  color: var(--a7x-muted);
  flex: 1;
  min-width: 200px;
}

.qa-subtask-jira-cta {
  white-space: nowrap;
}

/* The QA side of each row (tick box + QA ticket link) sits apart from the original-subtask header,
   so the tester's eye lands on it rather than on the finished subtask */
.qa-subtask-summary {
  flex-wrap: wrap;
}

.qa-subtask-title {
  min-width: 220px;
}

.qa-action {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
  padding-left: 14px;
  border-left: 1px solid var(--a7x-border);
  flex-shrink: 0;
}

.qa-subtask-jira .qa-original-link {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--a7x-faint);
}

.qa-subtask-jira .qa-original-link:hover {
  color: var(--a7x-muted);
}

/* QA ticket link: chip on the collapsed row, main button in the expanded detail header */
.qa-qa-chip {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--a7x-link-evidence);
  border: 1px solid var(--a7x-link-evidence);
  border-radius: 999px;
  padding: 3px 11px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.qa-qa-chip:hover {
  background: var(--a7x-link-evidence);
  color: #ffffff;
}

.qa-qa-chip-muted,
.qa-qa-cta-muted {
  color: var(--a7x-faint);
  border-color: var(--a7x-border);
  background: transparent;
}

.qa-qa-chip-muted:hover {
  background: transparent;
  color: var(--a7x-muted);
}

.qa-qa-cta {
  white-space: nowrap;
  font-weight: 600;
  color: #ffffff !important;
  background: var(--a7x-link-evidence);
  border-radius: 6px;
  padding: 3px 10px;
}

.qa-qa-cta:hover {
  text-decoration: none !important;
  filter: brightness(1.1);
}

.qa-qa-cta-muted {
  color: var(--a7x-muted) !important;
  background: transparent;
  border: 1px solid var(--a7x-border);
  font-weight: 400;
}

.qa-subtask-untestable .qa-subtask-title {
  color: var(--a7x-faint);
}

.qa-check:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.qa-steps-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--a7x-muted);
  margin-bottom: 4px;
}

.qa-steps ol {
  margin: 0;
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--a7x-ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
