.portal-policies {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem;
  max-width: 84rem;
  margin: 0 auto;
}

/* Header */
.portal-policies__head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.portal-policies__title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 650;
  color: var(--color-text-1);
}

.portal-policies__sub {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text-3);
  max-width: 46rem;
}

/* Category grid */
.portal-policies__grid {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* Category card — horizontal table row */
.portal-policies__card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.portal-policies__card--locked {
  opacity: 0.7;
}

.portal-policies__card-identity {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
  min-width: 0;
}

.portal-policies__card-enforces {
  font-size: 0.75rem;
  color: var(--color-text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-policies__card-meta {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-shrink: 0;
}

.portal-policies__card-statpair {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.0625rem;
}

.portal-policies__card-statval {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-1);
  line-height: 1.2;
}

.portal-policies__card-statlbl {
  font-size: 0.6875rem;
  color: var(--color-text-4);
  line-height: 1.2;
}

.portal-policies__cat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  font-size: 1.125rem;
  color: var(--color-text-2);
}

.portal-policies__card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-1);
}

/* Wizard + detail shared chrome */
.portal-policies__wizard-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-policies__wizard-foot,
.portal-policies__detail-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.portal-policies__wizard-banner {
  margin-top: 0.75rem;
}

.portal-policies__wizard-section {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 1rem;
}

.portal-policies__wizard-desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text-3);
}

.portal-policies__wizard-heading {
  margin: 0.75rem 0 0;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-5);
  font-weight: 600;
}

.portal-policies__wizard-subheading {
  margin: 0.875rem 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-3);
}

.portal-policies__fields {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.portal-policies__toggle-row {
  padding: 0.25rem 0;
}

.portal-policies__field-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* Workflow step — tool rows */
.portal-policies__tool-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.portal-policies__tool-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-1);
}

/* Sources picker */
.portal-policies__sources {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

@media (max-width: 40rem) {
  .portal-policies__sources {
    grid-template-columns: 1fr;
  }
}

.portal-policies__source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem;
  text-align: left;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    border-color var(--motion-fast),
    background var(--motion-fast);
}

.portal-policies__source::after {
  content: "";
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  width: 1rem;
  height: 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border-strong);
  transition:
    border-color var(--motion-fast),
    background var(--motion-fast);
}

.portal-policies__source:hover {
  background: var(--color-bg-hover);
}

.portal-policies__source--on {
  border-color: var(--color-blue);
  background: var(--color-blue-light);
}

.portal-policies__source--on::after {
  content: "✓";
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
  border-color: var(--color-blue);
  background: var(--color-blue);
}

.portal-policies__source-icon {
  font-size: 1rem;
  line-height: 1.2;
  flex-shrink: 0;
  color: var(--color-text-3);
}

.portal-policies__source--on .portal-policies__source-icon {
  color: var(--color-blue);
}

.portal-policies__source-text {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  min-width: 0;
}

.portal-policies__source-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-1);
}

.portal-policies__source-desc {
  font-size: 0.6875rem;
  color: var(--color-text-4);
  line-height: 1.4;
}

/* Doc-type scope */
.portal-policies__doctypes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--color-text-2);
}

.portal-policies__doctypes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.625rem;
}

.portal-policies__link {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-blue);
  cursor: pointer;
}

/* Output filename row */
.portal-policies__name-row {
  display: flex;
  gap: 0.5rem;
}

.portal-policies__name-row .sui-input {
  flex: 1;
}

/* Detail panel */
.portal-policies__detail-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.portal-policies__detail-sep {
  color: var(--color-text-5);
  font-size: 0.75rem;
}

.portal-policies__detail-meta {
  font-size: 0.75rem;
  color: var(--color-text-4);
}

.portal-policies__enforce-arrow {
  color: var(--color-text-5);
  font-size: 0.75rem;
}

.portal-policies__detail-inline {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}

.portal-policies__detail-inline-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  width: 4.5rem;
}

.portal-policies__detail-inline-value {
  font-size: 0.8125rem;
  color: var(--color-text-2);
  line-height: 1.5;
}

/* Activity feed */
.portal-policies__activity-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
}

.portal-policies__activity-row + .portal-policies__activity-row {
  border-top: 1px solid var(--color-border-light);
}

.portal-policies__activity-icon {
  flex-shrink: 0;
  margin-top: 0.125rem;
  display: flex;
  align-items: flex-start;
  padding-top: 0.125rem;
}

.portal-policies__activity-icon--success {
  color: var(--color-green);
}
.portal-policies__activity-icon--warning {
  color: var(--color-amber);
}
.portal-policies__activity-icon--info {
  color: var(--color-blue);
}

@keyframes portal-policies-spin {
  to {
    transform: rotate(360deg);
  }
}

.portal-policies__activity-spin {
  animation: portal-policies-spin 1s linear infinite;
}

.portal-policies__activity-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
  min-width: 0;
}

.portal-policies__activity-doc {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-1);
}

.portal-policies__activity-action {
  font-size: 0.75rem;
  color: var(--color-text-3);
}

.portal-policies__activity-time {
  font-size: 0.6875rem;
  color: var(--color-text-5);
  white-space: nowrap;
}

.portal-policies__activity-retry {
  flex-shrink: 0;
  font-size: 0.75rem;
}

/* Error expand/collapse for long activity messages */
.portal-policies__activity-error {
  display: block;
}

.portal-policies__activity-error-text--clamped {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.portal-policies__activity-error-toggle {
  display: block;
  margin-top: 0.125rem;
  font-size: 0.6875rem;
}

/* Detail stats footer */
.portal-policies__detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 1rem;
}

.portal-policies__detail-stats .sui-stat {
  padding: 0.875rem 1rem;
}

.portal-policies__detail-stats .sui-stat + .sui-stat {
  border-left: 1px solid var(--color-border-light);
}
