.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--ds-radius-md);
  font-family: var(--ds-font-family);
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-medium);
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.ui-button:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

.ui-button:disabled,
.ui-button[aria-busy="true"],
button[aria-busy="true"] {
  cursor: not-allowed;
  opacity: 0.62;
  pointer-events: none;
}

.ui-button--primary {
  background: var(--ds-color-primary);
  color: #ffffff;
}

.ui-button--primary:hover {
  background: var(--ds-color-primary-hover);
}

.ui-button--secondary {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-line);
  color: var(--ds-color-text);
}

.ui-button--secondary:hover {
  background: var(--ds-color-surface-soft);
}

.ui-button--danger {
  background: var(--ds-color-danger);
  color: #ffffff;
}

.ui-button--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ds-color-muted);
}

.ui-context-header {
  display: flex;
  justify-content: space-between;
  gap: var(--ds-space-4);
  align-items: flex-start;
  margin-bottom: var(--ds-space-5);
}

.ui-context-header__copy {
  display: grid;
  gap: var(--ds-space-1);
  min-width: 0;
}

.ui-context-header__eyebrow {
  margin: 0;
  color: var(--ds-color-muted);
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-strong);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ui-context-header__title {
  margin: 0;
  color: var(--ds-color-text);
  font-size: var(--ds-font-size-xl);
  font-weight: var(--ds-font-weight-strong);
  line-height: 1.2;
}

.ui-context-header__description {
  margin: 0;
  color: var(--ds-color-secondary-text);
  font-size: var(--ds-font-size-sm);
  line-height: 1.5;
}

.ui-context-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-2);
  justify-content: flex-end;
}

.ui-metric-card {
  display: grid;
  gap: var(--ds-space-2);
  min-width: 0;
  padding: var(--ds-space-5);
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-surface);
  box-shadow: var(--ds-shadow-sm);
}

.ui-metric-card__label {
  color: var(--ds-color-muted);
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ui-metric-card__value {
  color: var(--ds-color-text);
  font-size: var(--ds-font-size-lg);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.ui-empty-state,
.ui-error-state {
  display: grid;
  gap: var(--ds-space-2);
  padding: var(--ds-space-6);
  border: 1px dashed var(--ds-color-line);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-surface-soft);
  color: var(--ds-color-muted);
}

.ui-empty-state strong,
.ui-error-state strong {
  color: var(--ds-color-text);
}

.ui-error-state {
  border-color: rgba(185, 28, 28, 0.28);
  background: rgba(254, 242, 242, 0.72);
}

.ui-filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-3);
  align-items: end;
  padding: var(--ds-space-4);
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-surface-soft);
}

.ui-filter-toolbar label {
  min-width: 180px;
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-1);
  width: fit-content;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid var(--ds-color-line-soft);
  border-radius: 999px;
  background: var(--ds-color-surface-soft);
  color: var(--ds-color-secondary-text);
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-medium);
}

.ui-badge--success {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #14532d;
}

.ui-badge--warning {
  border-color: #fde68a;
  background: #fef3c7;
  color: #78350f;
}

.ui-badge--danger {
  border-color: #fecaca;
  background: #fee2e2;
  color: var(--ds-color-danger);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 24px;
  padding: 4px 11px;
  border: 1px solid var(--ds-color-line-soft);
  border-radius: 999px;
  background: var(--ds-color-surface-soft);
  color: #374151;
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-semibold);
  line-height: 1.15;
  white-space: nowrap;
}

.status-badge-success {
  border-color: #86efac;
  background: #dcfce7;
  color: #166534;
}

.status-badge-danger {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #991b1b;
}

.status-badge-warning {
  border-color: #fcd34d;
  background: #fef3c7;
  color: #92400e;
}

.status-badge-info {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge-neutral,
.status-badge-inactive {
  border-color: #d1d5db;
  background: #f3f4f6;
  color: #374151;
}

.ui-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--ds-z-drawer);
  display: grid;
  justify-content: end;
  background: rgba(15, 23, 42, 0.36);
}

.ui-drawer {
  width: min(520px, 100vw);
  height: 100vh;
  overflow: auto;
  background: var(--ds-color-surface);
  box-shadow: var(--ds-shadow-md);
}

.ui-drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-4);
  padding: var(--ds-space-5);
  border-bottom: 1px solid var(--ds-color-line-soft);
}

.ui-drawer__body {
  padding: var(--ds-space-5);
}

.pcmso-exam-group-list {
  display: grid;
  gap: var(--ds-space-4);
}

.pcmso-exam-group-card {
  display: grid;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  border: 1px solid var(--ds-color-line-soft);
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-surface);
}

.pcmso-exam-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-4);
}

.pcmso-exam-group-header h4 {
  margin: 0;
  color: var(--ds-color-text);
  font-size: var(--ds-font-size-lg);
}

.pcmso-exam-group-header p {
  margin: var(--ds-space-1) 0 0;
  color: var(--ds-color-text-muted);
}

.pcmso-exam-group-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--ds-space-2);
}

.pcmso-exam-technical-note {
  padding: var(--ds-space-3);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-color-surface-soft);
  color: var(--ds-color-text-muted);
  font-size: var(--ds-font-size-sm);
  line-height: 1.45;
}

.pcmso-exam-area-table td strong,
.pcmso-exam-area-table td small {
  display: block;
}

.pcmso-exam-area-table td small {
  margin-top: 2px;
  color: var(--ds-color-text-muted);
}

.pcmso-exam-area-check {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-weight: var(--ds-font-weight-semibold);
  white-space: nowrap;
}

.pcmso-exam-area-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--ds-color-primary);
}

@media (max-width: 720px) {
  .ui-context-header {
    display: grid;
  }

  .pcmso-exam-group-header {
    display: grid;
  }

  .pcmso-exam-group-meta {
    justify-content: flex-start;
  }

  .ui-context-header__actions,
  .ui-filter-toolbar {
    display: grid;
    justify-content: stretch;
  }

  .ui-button,
  .ui-context-header__actions > * {
    width: 100%;
  }
}
