/* Neutral content atoms shared by registry, single, builder and operations. */

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

.tw-meta {
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-micro);
  line-height: var(--tw-line-micro);
}

.tw-eyebrow {
  margin: 0;
  color: var(--tw-color-primary);
  font-size: var(--tw-font-micro);
  font-weight: var(--tw-weight-bold);
  line-height: var(--tw-line-micro);
  text-transform: uppercase;
}

.tw-cell-stack {
  display: grid;
  min-width: 0;
  gap: var(--tw-space-0-5);
}

.tw-cell-lines {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tw-cell-stack > strong,
.tw-cell-stack > a,
.tw-cell-stack > span,
.tw-cell-stack > small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tw-cell-stack > small {
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-meta);
  line-height: var(--tw-line-meta);
}

/* Desktop registry identity is exactly two visual lines: title + metadata. */
.tw-registry-table td[data-primary] .tw-cell-stack {
  max-width: 100%;
}

.tw-registry-table td[data-primary] .tw-cell-stack > strong,
.tw-registry-table td[data-primary] .tw-cell-stack > a,
.tw-registry-table td[data-primary] .tw-cell-stack > span,
.tw-registry-table td[data-primary] .tw-cell-stack > small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tw-person-compact,
.tw-entity-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--tw-space-2);
}

.tw-person-compact .tw-cell-stack,
.tw-entity-cell .tw-cell-stack {
  flex: 1;
}

button.tw-entity-cell {
  width: 100%;
  padding: 0;
  color: var(--tw-color-text);
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
}

.tw-record-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--tw-space-2);
}

.tw-record-identity > .tw-cell-stack {
  flex: 1;
}

.tw-record-identity > .tw-button-group {
  flex: 0 0 auto;
}

.tw-source-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--tw-space-1);
  color: var(--tw-color-text-muted);
}

.tw-sla,
.tw-due {
  display: grid;
  gap: var(--tw-space-0-5);
}

.tw-sla strong {
  font-size: var(--tw-font-micro);
  line-height: var(--tw-line-micro);
}

.tw-sla.tw-is-hot strong,
.tw-due.tw-is-hot {
  color: var(--tw-color-danger);
}

.tw-metric-pair {
  display: flex;
  gap: var(--tw-space-3);
}

.tw-metric-pair span {
  display: grid;
}

.tw-metric-pair strong {
  font-size: var(--tw-font-ui);
  line-height: var(--tw-line-ui);
}

.tw-metric-pair small {
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-micro);
  line-height: var(--tw-line-micro);
}

/* Compact, chart-free KPI summary shared by singles and analytics surfaces. */
.tw-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.tw-metric {
  min-width: 0;
  padding: var(--tw-space-3);
  border-right: 1px solid var(--tw-color-border);
}

.tw-metric:last-child {
  border-right: 0;
}

.tw-metric span,
.tw-metric small {
  display: block;
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-micro);
  line-height: var(--tw-line-micro);
}

.tw-metric strong {
  display: block;
  margin: var(--tw-space-1) 0;
  font-size: var(--tw-font-heading);
  line-height: var(--tw-line-heading);
}

/*
 * Compact task completion projection.
 *
 * The same two-line atom is used in registries, relation rows and contextual
 * sidebars: one line for the subtask count and percentage, one for the bar.
 */
.tw-task-progress {
  display: grid;
  width: min(132px, 100%);
  min-width: 92px;
  gap: var(--tw-space-1);
}

.tw-task-progress__meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--tw-space-2);
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-micro);
  line-height: var(--tw-line-micro);
  white-space: nowrap;
}

.tw-task-progress__meta strong {
  color: var(--tw-color-text);
  font-size: inherit;
}

.tw-task-progress__track {
  height: 3px;
  overflow: hidden;
  background: var(--tw-color-muted);
  border-radius: 999px;
}

.tw-task-progress__track > span {
  display: block;
  width: var(--tw-progress, 0%);
  height: 100%;
  background: var(--tw-color-primary);
  border-radius: inherit;
}

.tw-task-progress.is-complete .tw-task-progress__track > span {
  background: var(--tw-color-success);
}

/*
 * WorkCard: compact summary -> spatially stable expanded task.
 *
 * The title surface is the disclosure control. Stable elements keep their
 * identity while demo.js performs FLIP interpolation; there is no decorative
 * hover lift and no detached chevron row.
 */
.tw-work-card {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  padding: var(--tw-space-3);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "summary";
  align-items: center;
  gap: var(--tw-space-2) var(--tw-space-3);
  overflow: hidden;
  color: var(--tw-color-text);
  background: var(--tw-color-surface);
  border: 1px solid var(--tw-color-border);
  border-radius: var(--tw-frame-radius);
  box-shadow: none;
  transition:
    background-color var(--tw-motion-fast) var(--tw-ease-standard),
    border-color var(--tw-motion-fast) var(--tw-ease-standard);
}

.tw-work-card:hover,
.tw-work-card:focus-within {
  background: var(--tw-color-surface);
  border-color: var(--tw-color-border-strong);
  box-shadow: none;
  transform: none;
}

.tw-work-card__head {
  display: grid;
  min-width: 0;
  min-height: var(--tw-control-compact);
  padding: 0 72px 0 0;
  grid-area: head;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: var(--tw-space-2);
}

.tw-work-card__title {
  display: grid;
  min-width: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.tw-work-card__title strong,
.tw-work-card__title small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tw-work-card__title small {
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-micro);
}

.tw-work-card__menu {
  position: absolute;
  top: var(--tw-space-3);
  right: var(--tw-space-3);
  z-index: 1;
  display: inline-grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  color: var(--tw-color-text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--tw-radius);
}

.tw-work-card__menu:hover,
.tw-work-card__menu:focus-visible {
  color: var(--tw-color-text);
  background: var(--tw-color-surface-subtle);
}

.tw-work-card__progress {
  position: absolute;
  top: calc(var(--tw-space-3) + 5px);
  right: calc(var(--tw-space-3) + 36px);
  display: block;
  width: 18px;
  height: 18px;
  min-width: 0;
  padding: 0;
  grid-area: progress;
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-micro);
}

.tw-work-card__progress > span:first-child,
.tw-work-card__progress > strong {
  display: none;
}

.tw-work-card__progress-track {
  display: block;
  width: 18px;
  height: 18px;
  overflow: hidden;
  background: transparent;
  border-radius: 50%;
}

.tw-work-card__progress-track > span {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  background: conic-gradient(
    var(--tw-color-success) var(--tw-progress, 0%),
    var(--tw-color-muted) 0
  );
  border-radius: 50%;
}

.tw-work-card__progress-track > span::after {
  position: absolute;
  inset: 3px;
  content: "";
  background: var(--tw-color-surface);
  border-radius: 50%;
}

.tw-work-card__summary {
  display: grid;
  min-width: 0;
  padding: 0;
  grid-area: summary;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--tw-space-2);
}

.tw-work-card__choices {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--tw-space-1);
}

.tw-work-card__choice-field {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--tw-space-2);
}

.tw-work-card__choice-field > .tw-meta {
  display: none;
}

.tw-work-card__details {
  display: none;
  max-height: 0;
  min-width: 0;
  padding: 0;
  grid-area: details;
  gap: var(--tw-space-2);
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.tw-work-card__checklist {
  position: relative;
  display: grid;
  margin: 0;
  padding: var(--tw-space-1) 0 var(--tw-space-1) 32px;
  gap: var(--tw-space-2);
  list-style: none;
}

.tw-work-card__checklist::before {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 8px;
  width: 1px;
  content: "";
  background: var(--tw-color-border);
}

.tw-work-card__checklist li {
  position: relative;
  min-height: 18px;
  padding: 0;
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-meta);
  line-height: 18px;
  cursor: pointer;
}

.tw-work-card__checklist li::before {
  position: absolute;
  top: 2px;
  left: -30px;
  z-index: 1;
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  content: "";
  color: var(--tw-color-on-primary);
  background: var(--tw-color-surface);
  border: 1px solid var(--tw-color-border-strong);
  border-radius: 50%;
  font-size: 9px;
  line-height: 1;
}

.tw-work-card__checklist li[data-done="true"]::before {
  content: "✓";
  background: var(--tw-color-text-muted);
  border-color: var(--tw-color-text-muted);
}

.tw-work-card__checklist li:focus-visible {
  color: var(--tw-color-text);
  outline: 2px solid var(--tw-color-focus);
  outline-offset: 2px;
}

.tw-work-card__checklist li[data-done="true"] {
  text-decoration: line-through;
  text-decoration-color: var(--tw-color-border-strong);
}

.tw-work-card__details-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tw-space-2);
}

.tw-work-card[data-expanded="true"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "progress"
    "details"
    "summary";
  align-items: stretch;
  gap: var(--tw-space-3);
}

.tw-work-card[data-expanded="true"] .tw-work-card__head {
  grid-template-columns: minmax(0, 1fr);
}

.tw-work-card[data-expanded="true"] .tw-work-card__progress {
  position: static;
  display: grid;
  width: auto;
  height: auto;
  grid-template-columns: auto minmax(56px, 1fr) auto;
  align-items: center;
  gap: var(--tw-space-2);
}

.tw-work-card[data-expanded="true"] .tw-work-card__progress > span:first-child,
.tw-work-card[data-expanded="true"] .tw-work-card__progress > strong {
  display: inline;
}

.tw-work-card[data-expanded="true"] .tw-work-card__progress-track {
  width: auto;
  height: 5px;
  background: var(--tw-color-muted);
  border-radius: 999px;
}

.tw-work-card[data-expanded="true"] .tw-work-card__progress-track > span {
  width: var(--tw-progress, 0%);
  height: 100%;
  background: var(--tw-color-success);
  border-radius: inherit;
}

.tw-work-card[data-expanded="true"] .tw-work-card__progress-track > span::after {
  display: none;
}

.tw-work-card[data-expanded="true"] .tw-work-card__details {
  display: grid;
  max-height: 420px;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.tw-work-card[data-expanded="true"] .tw-work-card__summary {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--tw-space-3);
}

.tw-work-card[data-expanded="true"] .tw-work-card__choices {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--tw-space-2);
}

.tw-work-card[data-expanded="true"] .tw-work-card__choice-field {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
}

.tw-work-card[data-expanded="true"] .tw-work-card__choice-field > .tw-meta {
  display: inline;
}

.tw-work-card[data-animating="true"] {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .tw-work-card,
  .tw-work-card * {
    animation-duration: 1ms !important;
  }
}

/* Reusable realtime operations primitives. */
.tw-live-indicator {
  display: inline-flex;
  min-height: 24px;
  padding: 0 var(--tw-space-2);
  align-items: center;
  gap: var(--tw-space-1);
  color: var(--tw-color-success);
  background: color-mix(in srgb, var(--tw-color-success) 10%, var(--tw-color-surface));
  border: 1px solid color-mix(in srgb, var(--tw-color-success) 24%, var(--tw-color-border));
  border-radius: 999px;
  font-size: var(--tw-font-micro);
}

.tw-live-indicator i {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}

.tw-job-monitor {
  display: grid;
  padding: var(--tw-space-3);
  gap: var(--tw-space-2);
  background: var(--tw-color-surface-subtle);
  border-bottom: 1px solid var(--tw-color-border);
}

.tw-job-item {
  display: grid;
  padding: var(--tw-space-3);
  gap: var(--tw-space-2);
}

.tw-job-item > header,
.tw-job-item > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tw-space-2);
}

.tw-job-item > footer {
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-micro);
}

.tw-job-progress {
  height: 6px;
  overflow: hidden;
  background: var(--tw-color-muted);
  border-radius: 999px;
}

.tw-job-progress > span {
  display: block;
  width: var(--tw-progress, 0%);
  height: 100%;
  background: var(--tw-color-primary);
  border-radius: inherit;
  transition: width var(--tw-motion-base) var(--tw-ease-standard);
}

.tw-job-item[data-state="complete"] .tw-job-progress > span {
  background: var(--tw-color-success);
}


.tw-empty-block {
  display: grid;
  width: min(460px, calc(100% - var(--tw-space-6)));
  margin: auto;
  padding: var(--tw-space-6);
  justify-items: center;
  gap: var(--tw-space-2);
  color: var(--tw-color-text-muted);
  text-align: center;
}

.tw-empty-block h2,
.tw-empty-block p {
  margin: 0;
}

.tw-empty-block h2 {
  color: var(--tw-color-text);
  font-size: var(--tw-font-heading);
  line-height: var(--tw-line-heading);
}

.tw-callout {
  display: flex;
  padding: var(--tw-space-2) var(--tw-space-2-5);
  align-items: flex-start;
  gap: var(--tw-space-2);
  color: var(--tw-color-text-muted);
  background: var(--tw-color-surface-subtle);
  border: 1px solid var(--tw-color-border);
  border-radius: var(--tw-radius);
}

.tw-callout--warning {
  color: var(--tw-color-warning);
  background: var(--tw-color-warning-soft);
  border-color: color-mix(
    in srgb,
    var(--tw-color-warning) 34%,
    var(--tw-color-border)
  );
}

.tw-callout--action {
  display: grid;
  padding: var(--tw-space-3);
  grid-template-columns: 18px minmax(0, 1fr) auto;
}

.tw-callout--stack {
  display: grid;
  gap: var(--tw-space-1);
}

.tw-callout--stack span {
  color: var(--tw-color-text-muted);
  font-size: var(--tw-font-meta);
}

.tw-callout p {
  margin: 0;
}

.tw-callout .tw-icon {
  margin-top: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .tw-work-card,
  .tw-work-card__details,
  .tw-job-progress > span {
    transition: none;
  }
}

@media (max-width: 700px) {
  .tw-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tw-metric:nth-child(2n) {
    border-right: 0;
  }

  .tw-metric:nth-child(n + 3) {
    border-top: 1px solid var(--tw-color-border);
  }
}

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

  .tw-metric {
    border-top: 1px solid var(--tw-color-border);
    border-right: 0;
  }

  .tw-metric:first-child {
    border-top: 0;
  }
}
