/* Admin screen (full-viewport overlay) */
.admin-screen {
  position: fixed; inset: 0; background: #f5f5f5; z-index: 50;
  display: flex; flex-direction: column;
}
.admin-header {
  padding: 14px 24px; background: #1e1e2e; color: #cdd6f4;
  display: flex; align-items: center; gap: 16px;
}
.admin-header h2 { font-size: 17px; font-weight: 600; }
/* Breadcrumb trail: Chat / Context packs / <slug>. Every level but the
   current one is a link back up, so there is one consistent way out. */
.admin-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-crumb {
  background: none; border: none; color: #a6adc8; cursor: pointer;
  font-size: 17px; font-family: inherit; padding: 2px 4px; border-radius: 4px;
}
.admin-crumb:hover { color: #cdd6f4; background: #313244; }
.admin-crumb-sep { color: #6c7086; font-size: 17px; }
.admin-crumb-current { font-size: 17px; font-weight: 600; color: #cdd6f4; }
.admin-content { flex: 1; overflow-y: auto; padding: 24px; }
.admin-intro { color: #6b7280; font-size: 13px; margin-bottom: 16px; }
.admin-table {
  width: 100%; border-collapse: collapse; background: #fff; font-size: 13px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.06), 0 0 0 1px rgba(16,24,40,0.05);
  border-radius: 8px; overflow: hidden;
}
.admin-table th, .admin-table td {
  padding: 11px 16px; text-align: left; vertical-align: middle;
}
/* Small caps on a tinted band: reads as a header at a glance without
   competing with the row content for attention. */
.admin-table th {
  background: #eef1f5; color: #64748b; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid #dde3ea;
}
.admin-table td {
  color: #475569; border-bottom: 1px solid #eef1f5;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: #f8fafc; }
/* First column is the identity of the row, so let it carry the weight. */
.admin-table tbody td:first-child { color: #1e293b; font-weight: 500; }
.role-label {
  display: inline-flex; align-items: center; gap: 4px; margin-right: 14px;
  font-size: 13px; color: #374151; cursor: pointer;
}
.role-label input[disabled] { cursor: not-allowed; }
.verified-yes { color: #16a34a; }
.verified-no { color: #9ca3af; }

/* Pack admin (reuses the .admin-* shell above) */
.pack-row-link { color: #4f46e5; cursor: pointer; text-decoration: none; }
.pack-row-link:hover { text-decoration: underline; }
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600; text-transform: capitalize;
}
.status-draft { background: #e5e7eb; color: #4b5563; }
.status-in_review { background: #fef3c7; color: #92400e; }
.status-approved { background: #dcfce7; color: #166534; }
/* Publication state: whether the agent is serving this pack, separate from
   the workflow status of the working copy above. */
.pub-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600;
}
.pub-live { background: #dcfce7; color: #166534; }
.pub-none { background: #f3f4f6; color: #9ca3af; }
/* Live snapshot is behind the working copy: a newer draft exists unpublished. */
.pub-stale {
  display: block; margin-top: 3px; font-size: 11px;
  font-weight: 600; color: #b45309;
}
.pack-detail { display: flex; flex-direction: column; gap: 18px; }
.pack-card {
  background: #fff; border-radius: 6px; padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.pack-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.pack-field { display: block; margin-bottom: 10px; font-size: 13px; color: #374151; }
.pack-field input, .pack-field textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px; font-size: 13px;
  border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit;
}
.pack-field textarea {
  min-height: 360px; font-family: ui-monospace, monospace; line-height: 1.5;
  resize: vertical;  /* vertical only; horizontal drag breaks the grid */
}
/* A reader (admin, or anyone without editor) gets these fields disabled.
   Without a visible treatment they look editable, so a reader can type into
   a field that will never save. Buttons already carry this; fields need it
   just as much. */
.pack-field input:disabled,
.pack-field textarea:disabled,
.pack-field select:disabled {
  background: #f9fafb; color: #6b7280; cursor: not-allowed;
}
.pack-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pack-btn {
  padding: 7px 14px; font-size: 13px; border-radius: 6px; cursor: pointer;
  border: 1px solid #d1d5db; background: #fff; color: #374151;
}
.pack-btn:hover:not(:disabled) { background: #f3f4f6; }
.pack-btn:disabled { opacity: .5; cursor: not-allowed; }
.pack-btn-primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.pack-btn-primary:hover:not(:disabled) { background: #4338ca; }
.pack-note { color: #6b7280; font-size: 12px; margin-top: 8px; }
.pack-msg { font-size: 13px; margin-left: 4px; }
.pack-msg-ok { color: #166534; }
.pack-msg-err { color: #b91c1c; }
.pack-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 14px;
}
/* Section heading + one line of orientation, used above each table. */
.section-head {
  font-size: 15px; font-weight: 600; color: #111827; margin-bottom: 3px;
}
.section-desc {
  color: #6b7280; font-size: 13px; line-height: 1.5; max-width: 70ch;
}
.section + .section { margin-top: 36px; }
.pack-btn-danger { border-color: #fca5a5; color: #b91c1c; }
.pack-btn-danger:hover:not(:disabled) { background: #fef2f2; }
.pack-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 14px;
}
.pack-field select {
  width: 100%; margin-top: 4px; padding: 8px 10px; font-size: 13px;
  border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit;
  background: #fff;
}
/* Read-only panel showing which entry of a dataset payload a reference
   serves, and the exact slice the agent will receive. */
.pack-slice {
  margin-top: 10px; padding: 10px 12px; border: 1px solid #e5e7eb;
  border-radius: 6px; background: #f9fafb;
}
.pack-slice-preview {
  margin-top: 4px; padding: 8px 10px; background: #fff; border-radius: 4px;
  border: 1px solid #e5e7eb; font-family: ui-monospace, monospace;
  font-size: 12px; line-height: 1.5; overflow-x: auto; max-height: 220px;
}
.pack-field-hint {
  display: block; color: #9ca3af; font-weight: 400; font-size: 12px;
  line-height: 1.45; margin-top: 3px;
}
.pack-field-label { display: block; font-weight: 600; color: #6b7280; font-size: 12px; }
.pack-value { margin-top: 3px; color: #111827; overflow-wrap: anywhere; }
.pack-body {
  margin-top: 4px; padding: 10px 12px; background: #f9fafb; border-radius: 6px;
  border: 1px solid #e5e7eb; font-family: ui-monospace, monospace;
  font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-x: auto;
  max-height: 420px;
}
.field-group-head {
  font-size: 13px; font-weight: 600; color: #374151;
  margin: 18px 0 2px; padding-top: 14px; border-top: 1px solid #e5e7eb;
}
.field-group-note {
  color: #6b7280; font-size: 12px; line-height: 1.5; margin-bottom: 10px;
}
.field-group-note code, .pack-field-hint code {
  background: #f3f4f6; padding: 1px 4px; border-radius: 3px; font-size: 11px;
}
.pack-ref {
  border-top: 1px solid #e5e7eb; padding-top: 14px; margin-top: 14px;
}
.pack-ref-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  flex-wrap: wrap;
}
.pack-ref-title { font-weight: 600; font-size: 14px; }
.pack-ref-spacer { flex: 1; }
.pack-ref-order {
  background: none; border: 1px solid #d1d5db; border-radius: 4px;
  cursor: pointer; color: #6b7280; font-size: 12px; padding: 2px 7px;
}
.pack-ref-order:hover:not(:disabled) { background: #f3f4f6; color: #374151; }
.pack-ref-order:disabled { opacity: .35; cursor: not-allowed; }
.pack-kind-shared { background: #ede9fe; color: #5b21b6; }
.pack-kind-dataset { background: #e0f2fe; color: #075985; }
.pack-kind-file { background: #f3f4f6; color: #4b5563; }
/* Modal for create flows (new pack / new reference) */
.pack-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 40px 16px;
}
.pack-modal-box {
  background: #fff; border-radius: 8px; padding: 24px 26px; width: 100%;
  max-width: 780px; box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.pack-modal-box h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.pack-modal-sub { color: #6b7280; font-size: 13px; margin-bottom: 16px; }

/* What is failing most, as pills rather than a comma-separated sentence: the
   counts are the thing being scanned, so they get to be the shape you scan. */
.failure-counts {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 18px;
}
.failure-counts-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: #64748b; margin-right: 2px;
}
.failure-counts-empty { font-size: 13px; color: #9ca3af; }
.failure-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 3px 3px 10px; border-radius: 999px;
  background: #fef2f2; border: 1px solid #fecaca;
}
.failure-chip-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: #b91c1c;
}
.failure-chip-count {
  min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: #b91c1c; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}

/* A capability that fell back and was routed around. Deliberately quieter than
   a real failure: nobody felt it, and giving it the same weight buries the
   ones that were felt. */
.failure-chip-degraded {
  background: #f3f4f6; border-color: #e5e7eb;
}
.failure-chip-degraded .failure-chip-name { color: #6b7280; }
.failure-chip-degraded .failure-chip-count { background: #9ca3af; }

.failure-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin: 0 0 16px; font-size: 12px; color: #64748b;
}
.failure-filters label {
  display: inline-flex; align-items: center; gap: 6px;
}
.failure-filters select, .failure-filters input {
  font-size: 12px; padding: 4px 6px; border: 1px solid #dde3ea;
  border-radius: 6px; background: #fff; color: #475569;
}
.failure-trace-link { font-size: 11px; color: #2563eb; text-decoration: none; }
.failure-trace-link:hover { text-decoration: underline; }

/* Fixed layout so the declared widths hold: without it a long unbroken error
   string widens its column and squeezes the rest, which is the failure mode
   this table is most prone to. */
#failures-screen .admin-table { table-layout: fixed; }
#failures-screen .admin-table th:nth-child(1),
#failures-screen .admin-table td:nth-child(1) { width: 13%; }
#failures-screen .admin-table th:nth-child(2),
#failures-screen .admin-table td:nth-child(2) { width: 12%; }
/* The two text columns are read against each other — what broke, and what the
   user was told about it — so they get equal room. */
#failures-screen .admin-table th:nth-child(3),
#failures-screen .admin-table td:nth-child(3),
#failures-screen .admin-table th:nth-child(4),
#failures-screen .admin-table td:nth-child(4) { width: 37.5%; }

/* One failed run can carry several errors, joined with newlines. They are set
   with textContent, so the line breaks only show if the cell honours them. */
#failures-tbody td:nth-child(3) {
  white-space: pre-line;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* Cells wrap to several lines, so top-align the row rather than centring
   short cells against tall ones. */
#failures-screen .admin-table td { vertical-align: top; }

.hidden { display: none !important; }

/* --- Agents & tuning ---------------------------------------------------- */
/* Cards rather than a table: an agent has a paragraph of dependency prose and
   six short facts, which a row would either truncate or stretch. */
/* One card per agent, full width, stacked. Side by side rather than tiled:
   the tuning table is the wide half and wants the room, and reading down a
   single column keeps the agents in the order they actually run in. */
.inv-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.inv-card {
  display: grid;
  grid-template-columns: minmax(220px, 25%) minmax(0, 1fr);
  gap: 20px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
}
@media (max-width: 900px) {
  .inv-card { grid-template-columns: 1fr; gap: 12px; }
}
.inv-about { min-width: 0; }
.inv-card-head { display: flex; align-items: baseline; gap: 8px; }
.inv-card-head h4 { margin: 0; font-size: 14px; font-family: ui-monospace, monospace; }
.inv-tag {
  font-size: 11px;
  color: #4b5563;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}
.inv-finds { margin: 8px 0 4px; font-size: 13px; color: #111827; }
.inv-deps { margin: 0 0 10px; font-size: 12px; color: #6b7280; }
.inv-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 12px;
  margin: 0;
  font-size: 12px;
}
.inv-facts dt { color: #6b7280; }
.inv-facts dd { margin: 0; color: #111827; word-break: break-word; }
.inv-warning {
  border-left: 3px solid #b91c1c;
  background: #fef2f2;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
/* The wide half of a card. It scrolls rather than squeezing the reason column,
   which is the one worth reading. */
.inv-knobs { min-width: 0; overflow-x: auto; }
.inv-knobs-table { font-size: 12px; margin: 0; }
.inv-knobs-table th { white-space: nowrap; }
.inv-empty { margin: 0; font-size: 12px; }

/* The reason is the column worth reading, so it gets the room and the rest
   stay narrow enough to scan down. */
.inv-knob { font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; }
.inv-value { font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; }
.inv-default { color: #6b7280; font-size: 11px; }
.inv-why { font-size: 12px; color: #374151; line-height: 1.45; }
.inv-muted { color: #9ca3af; }

/* Openable rows. The card already carries the answer to the first question, so
   the affordance stays quiet: a hover, and a line saying there is more. */
.inv-card-open { cursor: pointer; }
.inv-card-open:hover { border-color: #c7d2fe; background: #fcfcff; }
.inv-card-open:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
.inv-more {
  margin: 10px 0 0;
  font-size: 11px;
  color: #6b7280;
}
.inv-tools-table { font-size: 12px; margin: 0; }
.inv-tools-table th { white-space: nowrap; }
.inv-row-open { cursor: pointer; }
.inv-row-open:hover { background: #f9fafb; }
.inv-row-open:focus-visible { outline: 2px solid #6366f1; outline-offset: -2px; }
.inv-tag-off { background: #fef2f2; color: #b91c1c; }
.inv-tag-sub { background: #ede9fe; color: #5b21b6; }

/* Detail overlay. Shares the packs modal's frame — same overlay, same box —
   and only adds what this screen puts inside it. */
.inv-modal .pack-modal-box h3 {
  margin: 0;
  font-size: 15px;
  font-family: ui-monospace, monospace;
}
.inv-modal-head {
  margin: 18px 0 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
}
.inv-modal-note { margin: 0 0 8px; font-size: 12px; color: #6b7280; line-height: 1.5; }
.inv-modal-desc { margin: 12px 0 0; font-size: 13px; color: #111827; line-height: 1.5; white-space: pre-wrap; }
